babylon.module.d.ts 6.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699157700157701157702157703157704157705157706157707157708157709157710157711157712157713157714157715157716157717157718157719157720157721157722157723157724157725157726157727157728157729157730157731157732157733157734157735157736157737157738157739157740157741157742157743157744157745157746157747157748157749157750157751157752157753157754157755157756157757157758157759157760157761157762157763157764157765157766157767157768157769157770157771157772157773157774157775157776157777157778157779157780157781157782157783157784157785157786157787157788157789157790157791157792157793157794157795157796157797157798157799157800157801157802157803157804157805157806157807157808157809157810157811157812157813157814157815157816157817157818157819157820157821157822157823157824157825157826157827157828157829157830157831157832157833157834157835157836157837157838157839157840157841157842157843157844157845157846157847157848157849157850157851157852157853157854157855157856157857157858157859157860157861157862157863157864157865157866157867157868157869157870157871157872157873157874157875157876157877157878157879157880157881157882157883157884157885157886157887157888157889157890157891157892157893157894157895157896157897157898157899157900157901157902157903157904157905157906157907157908157909157910157911157912157913157914157915157916157917157918157919157920157921157922157923157924157925157926157927157928157929157930157931157932157933157934157935157936157937157938157939157940157941157942157943157944157945157946157947157948157949157950157951157952157953157954157955157956157957157958157959157960157961157962157963157964157965157966157967157968157969157970157971157972157973157974157975157976157977157978157979157980157981157982157983157984157985157986157987157988157989157990157991157992157993157994157995157996157997157998157999158000158001158002158003158004158005158006158007158008158009158010158011158012158013158014158015158016158017158018158019158020158021158022158023158024158025158026158027158028158029158030158031158032158033158034158035158036158037158038158039158040158041158042158043158044158045158046158047158048158049158050158051158052158053158054158055158056158057158058158059158060158061158062158063158064158065158066158067158068158069158070158071158072158073158074158075158076158077158078158079158080158081158082158083158084158085158086158087158088158089158090158091158092158093158094158095158096158097158098158099158100158101158102158103158104158105158106158107158108158109158110158111158112158113158114158115158116158117158118158119158120158121158122158123158124158125158126158127158128158129158130158131158132158133158134158135158136158137158138158139158140158141158142158143158144158145158146158147158148158149158150158151158152158153158154158155158156158157158158158159158160158161158162158163158164158165158166158167158168158169158170158171158172158173158174158175158176158177158178158179158180158181158182158183158184158185158186158187158188158189158190158191158192158193158194158195158196158197158198158199158200158201158202158203158204158205158206158207158208158209158210158211158212158213158214158215158216158217158218158219158220158221158222158223158224158225158226158227158228158229158230158231158232158233158234158235158236158237158238158239158240158241158242158243158244158245158246158247158248158249158250158251158252158253158254158255158256158257158258158259158260158261158262158263158264158265158266158267158268158269158270158271158272158273158274158275158276158277158278158279158280158281158282158283158284158285158286158287158288158289158290158291158292158293158294158295158296158297158298158299158300158301158302158303158304158305158306158307158308158309158310158311158312158313158314158315158316158317158318158319158320158321158322158323158324158325158326158327158328158329158330158331158332158333158334158335158336158337158338158339158340158341158342158343158344158345158346158347158348158349158350158351158352158353158354158355158356158357158358158359158360158361158362158363158364158365158366158367158368158369158370158371158372158373158374158375158376158377158378158379158380158381158382158383158384158385158386158387158388158389158390158391158392158393158394158395158396158397158398158399158400158401158402158403158404158405158406158407158408158409158410158411158412158413158414158415158416158417158418158419158420158421158422158423158424158425158426158427158428158429158430158431158432158433158434158435158436158437158438158439158440158441158442158443158444158445158446158447158448158449158450158451158452158453158454158455158456158457158458158459158460158461158462158463158464158465158466158467158468158469158470158471158472158473158474158475158476158477158478158479158480158481158482158483158484158485158486158487158488158489158490158491158492158493158494158495158496158497158498158499158500158501158502158503158504158505158506158507158508158509158510158511158512158513158514158515158516158517158518158519158520158521158522158523158524158525158526158527158528158529158530158531158532158533158534158535158536158537158538158539158540158541158542158543158544158545158546158547158548158549158550158551158552158553158554158555158556158557158558158559158560158561158562158563158564158565158566158567158568158569158570158571158572158573158574158575158576158577158578158579158580158581158582158583158584158585158586158587158588158589158590158591158592158593158594158595158596158597158598158599158600158601158602158603158604158605158606158607158608158609158610158611158612158613158614158615158616158617158618158619158620158621158622158623158624158625158626158627158628158629158630158631158632158633158634158635158636158637158638158639158640158641158642158643158644158645158646158647158648158649158650158651158652158653158654158655158656158657158658158659158660158661158662158663158664158665158666158667158668158669158670158671158672158673158674158675158676158677158678158679158680158681158682158683158684158685158686158687158688158689158690158691158692158693158694158695158696158697158698158699158700158701158702158703158704158705158706158707158708158709158710158711158712158713158714158715158716158717158718158719158720158721158722158723158724158725158726158727158728158729158730158731158732158733158734158735158736158737158738158739158740158741158742158743158744158745158746158747158748158749158750158751158752158753158754158755158756158757158758158759158760158761158762158763158764158765158766158767158768158769158770158771158772158773158774158775158776158777158778158779158780158781158782158783158784158785158786158787158788158789158790158791158792158793158794158795158796158797158798158799158800158801158802158803158804158805158806158807158808158809158810158811158812158813158814158815158816158817158818158819158820158821158822158823158824158825158826158827158828158829158830158831158832158833158834158835158836158837158838158839158840158841158842158843158844158845158846158847158848158849158850158851158852158853158854158855158856158857158858158859158860158861158862158863158864158865158866158867158868158869158870158871158872158873158874158875158876158877158878158879158880158881158882158883158884158885158886158887158888158889158890158891158892158893158894158895158896158897158898158899158900158901158902158903158904158905158906158907158908158909158910158911158912158913158914158915158916158917158918158919158920158921158922158923158924158925158926158927158928158929158930158931158932158933158934158935158936158937158938158939158940158941158942158943158944158945158946158947158948158949158950158951158952158953158954158955158956158957158958158959158960158961158962158963158964158965158966158967158968158969158970158971158972158973158974158975158976158977158978158979158980158981158982158983158984158985158986158987158988158989158990158991158992158993158994158995158996158997158998158999159000159001159002159003159004159005159006159007159008159009159010159011159012159013159014159015159016159017159018159019159020159021159022159023159024159025159026159027159028159029159030159031159032159033159034159035159036159037159038159039159040159041159042159043159044159045159046159047159048159049159050159051159052159053159054159055159056159057159058159059159060159061159062159063159064159065159066159067159068159069159070159071159072159073159074159075159076159077159078159079159080159081159082159083159084159085159086159087159088159089159090159091159092159093159094159095159096159097159098159099159100159101159102159103159104159105159106159107159108159109159110159111159112159113159114159115159116159117159118159119159120159121159122159123159124159125159126159127159128159129159130159131159132159133159134159135159136159137159138159139159140159141159142159143159144159145159146159147159148159149159150159151159152159153159154159155159156159157159158159159159160159161159162159163159164159165159166159167159168159169159170159171159172159173159174159175159176159177159178159179159180159181159182159183159184159185159186159187159188159189159190159191159192159193159194159195159196159197159198159199159200159201159202159203159204159205159206159207159208159209159210159211159212159213159214159215159216159217159218159219159220159221159222159223159224159225159226159227159228159229159230159231159232159233159234159235159236159237159238159239159240159241159242159243159244159245159246159247159248159249159250159251159252159253159254159255159256159257159258159259159260159261159262159263159264159265159266159267159268159269159270159271159272159273159274159275159276159277159278159279159280159281159282159283159284159285159286159287159288159289159290159291159292159293159294159295159296159297159298159299159300159301159302159303159304159305159306159307159308
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. /**
  95. * User defined information that will be sent to observers
  96. */
  97. userInfo?: any;
  98. }
  99. /**
  100. * Represent an Observer registered to a given Observable object.
  101. */
  102. export class Observer<T> {
  103. /**
  104. * Defines the callback to call when the observer is notified
  105. */
  106. callback: (eventData: T, eventState: EventState) => void;
  107. /**
  108. * Defines the mask of the observer (used to filter notifications)
  109. */
  110. mask: number;
  111. /**
  112. * Defines the current scope used to restore the JS context
  113. */
  114. scope: any;
  115. /** @hidden */
  116. _willBeUnregistered: boolean;
  117. /**
  118. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  119. */
  120. unregisterOnNextCall: boolean;
  121. /**
  122. * Creates a new observer
  123. * @param callback defines the callback to call when the observer is notified
  124. * @param mask defines the mask of the observer (used to filter notifications)
  125. * @param scope defines the current scope used to restore the JS context
  126. */
  127. constructor(
  128. /**
  129. * Defines the callback to call when the observer is notified
  130. */
  131. callback: (eventData: T, eventState: EventState) => void,
  132. /**
  133. * Defines the mask of the observer (used to filter notifications)
  134. */
  135. mask: number,
  136. /**
  137. * Defines the current scope used to restore the JS context
  138. */
  139. scope?: any);
  140. }
  141. /**
  142. * Represent a list of observers registered to multiple Observables object.
  143. */
  144. export class MultiObserver<T> {
  145. private _observers;
  146. private _observables;
  147. /**
  148. * Release associated resources
  149. */
  150. dispose(): void;
  151. /**
  152. * Raise a callback when one of the observable will notify
  153. * @param observables defines a list of observables to watch
  154. * @param callback defines the callback to call on notification
  155. * @param mask defines the mask used to filter notifications
  156. * @param scope defines the current scope used to restore the JS context
  157. * @returns the new MultiObserver
  158. */
  159. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  160. }
  161. /**
  162. * The Observable class is a simple implementation of the Observable pattern.
  163. *
  164. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  165. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  166. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  167. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  168. */
  169. export class Observable<T> {
  170. private _observers;
  171. private _eventState;
  172. private _onObserverAdded;
  173. /**
  174. * Gets the list of observers
  175. */
  176. get observers(): Array<Observer<T>>;
  177. /**
  178. * Creates a new observable
  179. * @param onObserverAdded defines a callback to call when a new observer is added
  180. */
  181. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  182. /**
  183. * Create a new Observer with the specified callback
  184. * @param callback the callback that will be executed for that Observer
  185. * @param mask the mask used to filter observers
  186. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  187. * @param scope optional scope for the callback to be called from
  188. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  189. * @returns the new observer created for the callback
  190. */
  191. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  192. /**
  193. * Create a new Observer with the specified callback and unregisters after the next notification
  194. * @param callback the callback that will be executed for that Observer
  195. * @returns the new observer created for the callback
  196. */
  197. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  198. /**
  199. * Remove an Observer from the Observable object
  200. * @param observer the instance of the Observer to remove
  201. * @returns false if it doesn't belong to this Observable
  202. */
  203. remove(observer: Nullable<Observer<T>>): boolean;
  204. /**
  205. * Remove a callback from the Observable object
  206. * @param callback the callback to remove
  207. * @param scope optional scope. If used only the callbacks with this scope will be removed
  208. * @returns false if it doesn't belong to this Observable
  209. */
  210. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  211. private _deferUnregister;
  212. private _remove;
  213. /**
  214. * Moves the observable to the top of the observer list making it get called first when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverTopPriority(observer: Observer<T>): void;
  218. /**
  219. * Moves the observable to the bottom of the observer list making it get called last when notified
  220. * @param observer the observer to move
  221. */
  222. makeObserverBottomPriority(observer: Observer<T>): void;
  223. /**
  224. * Notify all Observers by calling their respective callback with the given data
  225. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  226. * @param eventData defines the data to send to all observers
  227. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  228. * @param target defines the original target of the state
  229. * @param currentTarget defines the current target of the state
  230. * @param userInfo defines any user info to send to observers
  231. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  232. */
  233. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  234. /**
  235. * Calling this will execute each callback, expecting it to be a promise or return a value.
  236. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  237. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  238. * and it is crucial that all callbacks will be executed.
  239. * The order of the callbacks is kept, callbacks are not executed parallel.
  240. *
  241. * @param eventData The data to be sent to each callback
  242. * @param mask is used to filter observers defaults to -1
  243. * @param target defines the callback target (see EventState)
  244. * @param currentTarget defines he current object in the bubbling phase
  245. * @param userInfo defines any user info to send to observers
  246. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  247. */
  248. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  249. /**
  250. * Notify a specific observer
  251. * @param observer defines the observer to notify
  252. * @param eventData defines the data to be sent to each callback
  253. * @param mask is used to filter observers defaults to -1
  254. */
  255. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  256. /**
  257. * Gets a boolean indicating if the observable has at least one observer
  258. * @returns true is the Observable has at least one Observer registered
  259. */
  260. hasObservers(): boolean;
  261. /**
  262. * Clear the list of observers
  263. */
  264. clear(): void;
  265. /**
  266. * Clone the current observable
  267. * @returns a new observable
  268. */
  269. clone(): Observable<T>;
  270. /**
  271. * Does this observable handles observer registered with a given mask
  272. * @param mask defines the mask to be tested
  273. * @return whether or not one observer registered with the given mask is handeled
  274. **/
  275. hasSpecificMask(mask?: number): boolean;
  276. }
  277. }
  278. declare module "babylonjs/Misc/domManagement" {
  279. /**
  280. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  281. * Babylon.js
  282. */
  283. export class DomManagement {
  284. /**
  285. * Checks if the window object exists
  286. * @returns true if the window object exists
  287. */
  288. static IsWindowObjectExist(): boolean;
  289. /**
  290. * Checks if the navigator object exists
  291. * @returns true if the navigator object exists
  292. */
  293. static IsNavigatorAvailable(): boolean;
  294. /**
  295. * Check if the document object exists
  296. * @returns true if the document object exists
  297. */
  298. static IsDocumentAvailable(): boolean;
  299. /**
  300. * Extracts text content from a DOM element hierarchy
  301. * @param element defines the root element
  302. * @returns a string
  303. */
  304. static GetDOMTextContent(element: HTMLElement): string;
  305. }
  306. }
  307. declare module "babylonjs/Misc/logger" {
  308. /**
  309. * Logger used througouht the application to allow configuration of
  310. * the log level required for the messages.
  311. */
  312. export class Logger {
  313. /**
  314. * No log
  315. */
  316. static readonly NoneLogLevel: number;
  317. /**
  318. * Only message logs
  319. */
  320. static readonly MessageLogLevel: number;
  321. /**
  322. * Only warning logs
  323. */
  324. static readonly WarningLogLevel: number;
  325. /**
  326. * Only error logs
  327. */
  328. static readonly ErrorLogLevel: number;
  329. /**
  330. * All logs
  331. */
  332. static readonly AllLogLevel: number;
  333. private static _LogCache;
  334. /**
  335. * Gets a value indicating the number of loading errors
  336. * @ignorenaming
  337. */
  338. static errorsCount: number;
  339. /**
  340. * Callback called when a new log is added
  341. */
  342. static OnNewCacheEntry: (entry: string) => void;
  343. private static _AddLogEntry;
  344. private static _FormatMessage;
  345. private static _LogDisabled;
  346. private static _LogEnabled;
  347. private static _WarnDisabled;
  348. private static _WarnEnabled;
  349. private static _ErrorDisabled;
  350. private static _ErrorEnabled;
  351. /**
  352. * Log a message to the console
  353. */
  354. static Log: (message: string) => void;
  355. /**
  356. * Write a warning message to the console
  357. */
  358. static Warn: (message: string) => void;
  359. /**
  360. * Write an error message to the console
  361. */
  362. static Error: (message: string) => void;
  363. /**
  364. * Gets current log cache (list of logs)
  365. */
  366. static get LogCache(): string;
  367. /**
  368. * Clears the log cache
  369. */
  370. static ClearLogCache(): void;
  371. /**
  372. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  373. */
  374. static set LogLevels(level: number);
  375. }
  376. }
  377. declare module "babylonjs/Misc/typeStore" {
  378. /** @hidden */
  379. export class _TypeStore {
  380. /** @hidden */
  381. static RegisteredTypes: {
  382. [key: string]: Object;
  383. };
  384. /** @hidden */
  385. static GetClass(fqdn: string): any;
  386. }
  387. }
  388. declare module "babylonjs/Misc/stringTools" {
  389. /**
  390. * Helper to manipulate strings
  391. */
  392. export class StringTools {
  393. /**
  394. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static EndsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  402. * @param str Source string
  403. * @param suffix Suffix to search for in the source string
  404. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  405. */
  406. static StartsWith(str: string, suffix: string): boolean;
  407. /**
  408. * Decodes a buffer into a string
  409. * @param buffer The buffer to decode
  410. * @returns The decoded string
  411. */
  412. static Decode(buffer: Uint8Array | Uint16Array): string;
  413. /**
  414. * Encode a buffer to a base64 string
  415. * @param buffer defines the buffer to encode
  416. * @returns the encoded string
  417. */
  418. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  419. /**
  420. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  421. * @param num the number to convert and pad
  422. * @param length the expected length of the string
  423. * @returns the padded string
  424. */
  425. static PadNumber(num: number, length: number): string;
  426. }
  427. }
  428. declare module "babylonjs/Misc/deepCopier" {
  429. /**
  430. * Class containing a set of static utilities functions for deep copy.
  431. */
  432. export class DeepCopier {
  433. /**
  434. * Tries to copy an object by duplicating every property
  435. * @param source defines the source object
  436. * @param destination defines the target object
  437. * @param doNotCopyList defines a list of properties to avoid
  438. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  439. */
  440. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  441. }
  442. }
  443. declare module "babylonjs/Misc/precisionDate" {
  444. /**
  445. * Class containing a set of static utilities functions for precision date
  446. */
  447. export class PrecisionDate {
  448. /**
  449. * Gets either window.performance.now() if supported or Date.now() else
  450. */
  451. static get Now(): number;
  452. }
  453. }
  454. declare module "babylonjs/Misc/devTools" {
  455. /** @hidden */
  456. export class _DevTools {
  457. static WarnImport(name: string): string;
  458. }
  459. }
  460. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  461. /**
  462. * Interface used to define the mechanism to get data from the network
  463. */
  464. export interface IWebRequest {
  465. /**
  466. * Returns client's response url
  467. */
  468. responseURL: string;
  469. /**
  470. * Returns client's status
  471. */
  472. status: number;
  473. /**
  474. * Returns client's status as a text
  475. */
  476. statusText: string;
  477. }
  478. }
  479. declare module "babylonjs/Misc/webRequest" {
  480. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  481. import { Nullable } from "babylonjs/types";
  482. /**
  483. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  484. */
  485. export class WebRequest implements IWebRequest {
  486. private readonly _xhr;
  487. /**
  488. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  489. * i.e. when loading files, where the server/service expects an Authorization header
  490. */
  491. static CustomRequestHeaders: {
  492. [key: string]: string;
  493. };
  494. /**
  495. * Add callback functions in this array to update all the requests before they get sent to the network
  496. */
  497. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  498. private _injectCustomRequestHeaders;
  499. /**
  500. * Gets or sets a function to be called when loading progress changes
  501. */
  502. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  503. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  504. /**
  505. * Returns client's state
  506. */
  507. get readyState(): number;
  508. /**
  509. * Returns client's status
  510. */
  511. get status(): number;
  512. /**
  513. * Returns client's status as a text
  514. */
  515. get statusText(): string;
  516. /**
  517. * Returns client's response
  518. */
  519. get response(): any;
  520. /**
  521. * Returns client's response url
  522. */
  523. get responseURL(): string;
  524. /**
  525. * Returns client's response as text
  526. */
  527. get responseText(): string;
  528. /**
  529. * Gets or sets the expected response type
  530. */
  531. get responseType(): XMLHttpRequestResponseType;
  532. set responseType(value: XMLHttpRequestResponseType);
  533. /** @hidden */
  534. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  535. /** @hidden */
  536. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  537. /**
  538. * Cancels any network activity
  539. */
  540. abort(): void;
  541. /**
  542. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  543. * @param body defines an optional request body
  544. */
  545. send(body?: Document | BodyInit | null): void;
  546. /**
  547. * Sets the request method, request URL
  548. * @param method defines the method to use (GET, POST, etc..)
  549. * @param url defines the url to connect with
  550. */
  551. open(method: string, url: string): void;
  552. /**
  553. * Sets the value of a request header.
  554. * @param name The name of the header whose value is to be set
  555. * @param value The value to set as the body of the header
  556. */
  557. setRequestHeader(name: string, value: string): void;
  558. /**
  559. * Get the string containing the text of a particular header's value.
  560. * @param name The name of the header
  561. * @returns The string containing the text of the given header name
  562. */
  563. getResponseHeader(name: string): Nullable<string>;
  564. }
  565. }
  566. declare module "babylonjs/Misc/fileRequest" {
  567. import { Observable } from "babylonjs/Misc/observable";
  568. /**
  569. * File request interface
  570. */
  571. export interface IFileRequest {
  572. /**
  573. * Raised when the request is complete (success or error).
  574. */
  575. onCompleteObservable: Observable<IFileRequest>;
  576. /**
  577. * Aborts the request for a file.
  578. */
  579. abort: () => void;
  580. }
  581. }
  582. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  583. /**
  584. * Define options used to create a render target texture
  585. */
  586. export class RenderTargetCreationOptions {
  587. /**
  588. * Specifies is mipmaps must be generated
  589. */
  590. generateMipMaps?: boolean;
  591. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  592. generateDepthBuffer?: boolean;
  593. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  594. generateStencilBuffer?: boolean;
  595. /** Defines texture type (int by default) */
  596. type?: number;
  597. /** Defines sampling mode (trilinear by default) */
  598. samplingMode?: number;
  599. /** Defines format (RGBA by default) */
  600. format?: number;
  601. }
  602. }
  603. declare module "babylonjs/Engines/constants" {
  604. /** Defines the cross module used constants to avoid circular dependncies */
  605. export class Constants {
  606. /** Defines that alpha blending is disabled */
  607. static readonly ALPHA_DISABLE: number;
  608. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  609. static readonly ALPHA_ADD: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_COMBINE: number;
  612. /** Defines that alpha blending is DEST - SRC * DEST */
  613. static readonly ALPHA_SUBTRACT: number;
  614. /** Defines that alpha blending is SRC * DEST */
  615. static readonly ALPHA_MULTIPLY: number;
  616. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  617. static readonly ALPHA_MAXIMIZED: number;
  618. /** Defines that alpha blending is SRC + DEST */
  619. static readonly ALPHA_ONEONE: number;
  620. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  621. static readonly ALPHA_PREMULTIPLIED: number;
  622. /**
  623. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  624. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  625. */
  626. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  627. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  628. static readonly ALPHA_INTERPOLATE: number;
  629. /**
  630. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  631. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  632. */
  633. static readonly ALPHA_SCREENMODE: number;
  634. /**
  635. * Defines that alpha blending is SRC + DST
  636. * Alpha will be set to SRC ALPHA + DST ALPHA
  637. */
  638. static readonly ALPHA_ONEONE_ONEONE: number;
  639. /**
  640. * Defines that alpha blending is SRC * DST ALPHA + DST
  641. * Alpha will be set to 0
  642. */
  643. static readonly ALPHA_ALPHATOCOLOR: number;
  644. /**
  645. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  646. */
  647. static readonly ALPHA_REVERSEONEMINUS: number;
  648. /**
  649. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  650. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  651. */
  652. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  653. /**
  654. * Defines that alpha blending is SRC + DST
  655. * Alpha will be set to SRC ALPHA
  656. */
  657. static readonly ALPHA_ONEONE_ONEZERO: number;
  658. /**
  659. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  660. * Alpha will be set to DST ALPHA
  661. */
  662. static readonly ALPHA_EXCLUSION: number;
  663. /** Defines that alpha blending equation a SUM */
  664. static readonly ALPHA_EQUATION_ADD: number;
  665. /** Defines that alpha blending equation a SUBSTRACTION */
  666. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  667. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  668. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  669. /** Defines that alpha blending equation a MAX operation */
  670. static readonly ALPHA_EQUATION_MAX: number;
  671. /** Defines that alpha blending equation a MIN operation */
  672. static readonly ALPHA_EQUATION_MIN: number;
  673. /**
  674. * Defines that alpha blending equation a DARKEN operation:
  675. * It takes the min of the src and sums the alpha channels.
  676. */
  677. static readonly ALPHA_EQUATION_DARKEN: number;
  678. /** Defines that the ressource is not delayed*/
  679. static readonly DELAYLOADSTATE_NONE: number;
  680. /** Defines that the ressource was successfully delay loaded */
  681. static readonly DELAYLOADSTATE_LOADED: number;
  682. /** Defines that the ressource is currently delay loading */
  683. static readonly DELAYLOADSTATE_LOADING: number;
  684. /** Defines that the ressource is delayed and has not started loading */
  685. static readonly DELAYLOADSTATE_NOTLOADED: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  687. static readonly NEVER: number;
  688. /** 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 */
  689. static readonly ALWAYS: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  691. static readonly LESS: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  693. static readonly EQUAL: number;
  694. /** 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 */
  695. static readonly LEQUAL: number;
  696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  697. static readonly GREATER: number;
  698. /** 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 */
  699. static readonly GEQUAL: number;
  700. /** 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 */
  701. static readonly NOTEQUAL: number;
  702. /** Passed to stencilOperation to specify that stencil value must be kept */
  703. static readonly KEEP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be replaced */
  705. static readonly REPLACE: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented */
  707. static readonly INCR: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented */
  709. static readonly DECR: number;
  710. /** Passed to stencilOperation to specify that stencil value must be inverted */
  711. static readonly INVERT: number;
  712. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  713. static readonly INCR_WRAP: number;
  714. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  715. static readonly DECR_WRAP: number;
  716. /** Texture is not repeating outside of 0..1 UVs */
  717. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  718. /** Texture is repeating outside of 0..1 UVs */
  719. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  720. /** Texture is repeating and mirrored */
  721. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  722. /** ALPHA */
  723. static readonly TEXTUREFORMAT_ALPHA: number;
  724. /** LUMINANCE */
  725. static readonly TEXTUREFORMAT_LUMINANCE: number;
  726. /** LUMINANCE_ALPHA */
  727. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  728. /** RGB */
  729. static readonly TEXTUREFORMAT_RGB: number;
  730. /** RGBA */
  731. static readonly TEXTUREFORMAT_RGBA: number;
  732. /** RED */
  733. static readonly TEXTUREFORMAT_RED: number;
  734. /** RED (2nd reference) */
  735. static readonly TEXTUREFORMAT_R: number;
  736. /** RG */
  737. static readonly TEXTUREFORMAT_RG: number;
  738. /** RED_INTEGER */
  739. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  740. /** RED_INTEGER (2nd reference) */
  741. static readonly TEXTUREFORMAT_R_INTEGER: number;
  742. /** RG_INTEGER */
  743. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  744. /** RGB_INTEGER */
  745. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  746. /** RGBA_INTEGER */
  747. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  748. /** UNSIGNED_BYTE */
  749. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  750. /** UNSIGNED_BYTE (2nd reference) */
  751. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  752. /** FLOAT */
  753. static readonly TEXTURETYPE_FLOAT: number;
  754. /** HALF_FLOAT */
  755. static readonly TEXTURETYPE_HALF_FLOAT: number;
  756. /** BYTE */
  757. static readonly TEXTURETYPE_BYTE: number;
  758. /** SHORT */
  759. static readonly TEXTURETYPE_SHORT: number;
  760. /** UNSIGNED_SHORT */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  762. /** INT */
  763. static readonly TEXTURETYPE_INT: number;
  764. /** UNSIGNED_INT */
  765. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  766. /** UNSIGNED_SHORT_4_4_4_4 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  768. /** UNSIGNED_SHORT_5_5_5_1 */
  769. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  770. /** UNSIGNED_SHORT_5_6_5 */
  771. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  772. /** UNSIGNED_INT_2_10_10_10_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  774. /** UNSIGNED_INT_24_8 */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  776. /** UNSIGNED_INT_10F_11F_11F_REV */
  777. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  778. /** UNSIGNED_INT_5_9_9_9_REV */
  779. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  780. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  781. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  782. /** nearest is mag = nearest and min = nearest and no mip */
  783. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  784. /** mag = nearest and min = nearest and mip = none */
  785. static readonly TEXTURE_NEAREST_NEAREST: number;
  786. /** Bilinear is mag = linear and min = linear and no mip */
  787. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  788. /** mag = linear and min = linear and mip = none */
  789. static readonly TEXTURE_LINEAR_LINEAR: number;
  790. /** Trilinear is mag = linear and min = linear and mip = linear */
  791. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  792. /** Trilinear is mag = linear and min = linear and mip = linear */
  793. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = nearest and mip = nearest */
  795. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  796. /** mag = nearest and min = linear and mip = nearest */
  797. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  798. /** mag = nearest and min = linear and mip = linear */
  799. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  800. /** mag = nearest and min = linear and mip = none */
  801. static readonly TEXTURE_NEAREST_LINEAR: number;
  802. /** nearest is mag = nearest and min = nearest and mip = linear */
  803. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  804. /** mag = linear and min = nearest and mip = nearest */
  805. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = linear */
  807. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  808. /** Bilinear is mag = linear and min = linear and mip = nearest */
  809. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  810. /** mag = linear and min = nearest and mip = none */
  811. static readonly TEXTURE_LINEAR_NEAREST: number;
  812. /** Explicit coordinates mode */
  813. static readonly TEXTURE_EXPLICIT_MODE: number;
  814. /** Spherical coordinates mode */
  815. static readonly TEXTURE_SPHERICAL_MODE: number;
  816. /** Planar coordinates mode */
  817. static readonly TEXTURE_PLANAR_MODE: number;
  818. /** Cubic coordinates mode */
  819. static readonly TEXTURE_CUBIC_MODE: number;
  820. /** Projection coordinates mode */
  821. static readonly TEXTURE_PROJECTION_MODE: number;
  822. /** Skybox coordinates mode */
  823. static readonly TEXTURE_SKYBOX_MODE: number;
  824. /** Inverse Cubic coordinates mode */
  825. static readonly TEXTURE_INVCUBIC_MODE: number;
  826. /** Equirectangular coordinates mode */
  827. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  828. /** Equirectangular Fixed coordinates mode */
  829. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  830. /** Equirectangular Fixed Mirrored coordinates mode */
  831. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  832. /** Offline (baking) quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  834. /** High quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  836. /** Medium quality for texture filtering */
  837. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  838. /** Low quality for texture filtering */
  839. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  840. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  841. static readonly SCALEMODE_FLOOR: number;
  842. /** Defines that texture rescaling will look for the nearest power of 2 size */
  843. static readonly SCALEMODE_NEAREST: number;
  844. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  845. static readonly SCALEMODE_CEILING: number;
  846. /**
  847. * The dirty texture flag value
  848. */
  849. static readonly MATERIAL_TextureDirtyFlag: number;
  850. /**
  851. * The dirty light flag value
  852. */
  853. static readonly MATERIAL_LightDirtyFlag: number;
  854. /**
  855. * The dirty fresnel flag value
  856. */
  857. static readonly MATERIAL_FresnelDirtyFlag: number;
  858. /**
  859. * The dirty attribute flag value
  860. */
  861. static readonly MATERIAL_AttributesDirtyFlag: number;
  862. /**
  863. * The dirty misc flag value
  864. */
  865. static readonly MATERIAL_MiscDirtyFlag: number;
  866. /**
  867. * The dirty prepass flag value
  868. */
  869. static readonly MATERIAL_PrePassDirtyFlag: number;
  870. /**
  871. * The all dirty flag value
  872. */
  873. static readonly MATERIAL_AllDirtyFlag: number;
  874. /**
  875. * Returns the triangle fill mode
  876. */
  877. static readonly MATERIAL_TriangleFillMode: number;
  878. /**
  879. * Returns the wireframe mode
  880. */
  881. static readonly MATERIAL_WireFrameFillMode: number;
  882. /**
  883. * Returns the point fill mode
  884. */
  885. static readonly MATERIAL_PointFillMode: number;
  886. /**
  887. * Returns the point list draw mode
  888. */
  889. static readonly MATERIAL_PointListDrawMode: number;
  890. /**
  891. * Returns the line list draw mode
  892. */
  893. static readonly MATERIAL_LineListDrawMode: number;
  894. /**
  895. * Returns the line loop draw mode
  896. */
  897. static readonly MATERIAL_LineLoopDrawMode: number;
  898. /**
  899. * Returns the line strip draw mode
  900. */
  901. static readonly MATERIAL_LineStripDrawMode: number;
  902. /**
  903. * Returns the triangle strip draw mode
  904. */
  905. static readonly MATERIAL_TriangleStripDrawMode: number;
  906. /**
  907. * Returns the triangle fan draw mode
  908. */
  909. static readonly MATERIAL_TriangleFanDrawMode: number;
  910. /**
  911. * Stores the clock-wise side orientation
  912. */
  913. static readonly MATERIAL_ClockWiseSideOrientation: number;
  914. /**
  915. * Stores the counter clock-wise side orientation
  916. */
  917. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  918. /**
  919. * Nothing
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_NothingTrigger: number;
  923. /**
  924. * On pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickTrigger: number;
  928. /**
  929. * On left pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnLeftPickTrigger: number;
  933. /**
  934. * On right pick
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnRightPickTrigger: number;
  938. /**
  939. * On center pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnCenterPickTrigger: number;
  943. /**
  944. * On pick down
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickDownTrigger: number;
  948. /**
  949. * On double pick
  950. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  951. */
  952. static readonly ACTION_OnDoublePickTrigger: number;
  953. /**
  954. * On pick up
  955. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  956. */
  957. static readonly ACTION_OnPickUpTrigger: number;
  958. /**
  959. * On pick out.
  960. * This trigger will only be raised if you also declared a OnPickDown
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPickOutTrigger: number;
  964. /**
  965. * On long press
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnLongPressTrigger: number;
  969. /**
  970. * On pointer over
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnPointerOverTrigger: number;
  974. /**
  975. * On pointer out
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnPointerOutTrigger: number;
  979. /**
  980. * On every frame
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnEveryFrameTrigger: number;
  984. /**
  985. * On intersection enter
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnIntersectionEnterTrigger: number;
  989. /**
  990. * On intersection exit
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnIntersectionExitTrigger: number;
  994. /**
  995. * On key down
  996. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  997. */
  998. static readonly ACTION_OnKeyDownTrigger: number;
  999. /**
  1000. * On key up
  1001. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1002. */
  1003. static readonly ACTION_OnKeyUpTrigger: number;
  1004. /**
  1005. * Billboard mode will only apply to Y axis
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1008. /**
  1009. * Billboard mode will apply to all axes
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1012. /**
  1013. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1014. */
  1015. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1016. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1017. * Test order :
  1018. * Is the bounding sphere outside the frustum ?
  1019. * If not, are the bounding box vertices outside the frustum ?
  1020. * It not, then the cullable object is in the frustum.
  1021. */
  1022. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1023. /** Culling strategy : Bounding Sphere Only.
  1024. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1025. * It's also less accurate than the standard because some not visible objects can still be selected.
  1026. * Test : is the bounding sphere outside the frustum ?
  1027. * If not, then the cullable object is in the frustum.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1030. /** Culling strategy : Optimistic Inclusion.
  1031. * This in an inclusion test first, then the standard exclusion test.
  1032. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1033. * 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.
  1034. * Anyway, it's as accurate as the standard strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the default culling strategy.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1040. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1041. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1042. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1043. * 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.
  1044. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1045. * Test :
  1046. * Is the cullable object bounding sphere center in the frustum ?
  1047. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1048. */
  1049. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1050. /**
  1051. * No logging while loading
  1052. */
  1053. static readonly SCENELOADER_NO_LOGGING: number;
  1054. /**
  1055. * Minimal logging while loading
  1056. */
  1057. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1058. /**
  1059. * Summary logging while loading
  1060. */
  1061. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1062. /**
  1063. * Detailled logging while loading
  1064. */
  1065. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1066. /**
  1067. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1068. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1069. */
  1070. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1071. /**
  1072. * Constant used to retrieve the position texture index in the textures array in the prepass
  1073. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1074. */
  1075. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1076. /**
  1077. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1078. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1079. */
  1080. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1081. /**
  1082. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1083. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1084. */
  1085. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1086. /**
  1087. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1088. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1089. */
  1090. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1091. /**
  1092. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1093. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1094. */
  1095. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1096. /**
  1097. * Constant used to retrieve albedo index in the textures array in the prepass
  1098. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1099. */
  1100. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1101. }
  1102. }
  1103. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1104. import { Nullable } from "babylonjs/types";
  1105. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1106. /**
  1107. * This represents the required contract to create a new type of texture loader.
  1108. */
  1109. export interface IInternalTextureLoader {
  1110. /**
  1111. * Defines wether the loader supports cascade loading the different faces.
  1112. */
  1113. supportCascades: boolean;
  1114. /**
  1115. * This returns if the loader support the current file information.
  1116. * @param extension defines the file extension of the file being loaded
  1117. * @param mimeType defines the optional mime type of the file being loaded
  1118. * @returns true if the loader can load the specified file
  1119. */
  1120. canLoad(extension: string, mimeType?: string): boolean;
  1121. /**
  1122. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1123. * @param data contains the texture data
  1124. * @param texture defines the BabylonJS internal texture
  1125. * @param createPolynomials will be true if polynomials have been requested
  1126. * @param onLoad defines the callback to trigger once the texture is ready
  1127. * @param onError defines the callback to trigger in case of error
  1128. * @param options options to be passed to the loader
  1129. */
  1130. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1131. /**
  1132. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1133. * @param data contains the texture data
  1134. * @param texture defines the BabylonJS internal texture
  1135. * @param callback defines the method to call once ready to upload
  1136. * @param options options to be passed to the loader
  1137. */
  1138. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1139. }
  1140. }
  1141. declare module "babylonjs/Engines/IPipelineContext" {
  1142. /**
  1143. * Class used to store and describe the pipeline context associated with an effect
  1144. */
  1145. export interface IPipelineContext {
  1146. /**
  1147. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1148. */
  1149. isAsync: boolean;
  1150. /**
  1151. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1152. */
  1153. isReady: boolean;
  1154. /** @hidden */
  1155. _getVertexShaderCode(): string | null;
  1156. /** @hidden */
  1157. _getFragmentShaderCode(): string | null;
  1158. /** @hidden */
  1159. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1160. }
  1161. }
  1162. declare module "babylonjs/Meshes/dataBuffer" {
  1163. /**
  1164. * Class used to store gfx data (like WebGLBuffer)
  1165. */
  1166. export class DataBuffer {
  1167. /**
  1168. * Gets or sets the number of objects referencing this buffer
  1169. */
  1170. references: number;
  1171. /** Gets or sets the size of the underlying buffer */
  1172. capacity: number;
  1173. /**
  1174. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1175. */
  1176. is32Bits: boolean;
  1177. /**
  1178. * Gets the underlying buffer
  1179. */
  1180. get underlyingResource(): any;
  1181. }
  1182. }
  1183. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1184. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  1185. /** @hidden */
  1186. export interface IShaderProcessor {
  1187. attributeProcessor?: (attribute: string) => string;
  1188. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1189. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1190. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1191. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1192. lineProcessor?: (line: string, isFragment: boolean) => string;
  1193. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1194. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  1195. }
  1196. }
  1197. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1198. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1199. /** @hidden */
  1200. export interface ProcessingOptions {
  1201. defines: string[];
  1202. indexParameters: any;
  1203. isFragment: boolean;
  1204. shouldUseHighPrecisionShader: boolean;
  1205. supportsUniformBuffers: boolean;
  1206. shadersRepository: string;
  1207. includesShadersStore: {
  1208. [key: string]: string;
  1209. };
  1210. processor?: IShaderProcessor;
  1211. version: string;
  1212. platformName: string;
  1213. lookForClosingBracketForUniformBuffer?: boolean;
  1214. }
  1215. }
  1216. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1217. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1218. /** @hidden */
  1219. export class ShaderCodeNode {
  1220. line: string;
  1221. children: ShaderCodeNode[];
  1222. additionalDefineKey?: string;
  1223. additionalDefineValue?: string;
  1224. isValid(preprocessors: {
  1225. [key: string]: string;
  1226. }): boolean;
  1227. process(preprocessors: {
  1228. [key: string]: string;
  1229. }, options: ProcessingOptions): string;
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1233. /** @hidden */
  1234. export class ShaderCodeCursor {
  1235. private _lines;
  1236. lineIndex: number;
  1237. get currentLine(): string;
  1238. get canRead(): boolean;
  1239. set lines(value: string[]);
  1240. }
  1241. }
  1242. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1243. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1244. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1245. /** @hidden */
  1246. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1247. process(preprocessors: {
  1248. [key: string]: string;
  1249. }, options: ProcessingOptions): string;
  1250. }
  1251. }
  1252. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1253. /** @hidden */
  1254. export class ShaderDefineExpression {
  1255. isTrue(preprocessors: {
  1256. [key: string]: string;
  1257. }): boolean;
  1258. private static _OperatorPriority;
  1259. private static _Stack;
  1260. static postfixToInfix(postfix: string[]): string;
  1261. static infixToPostfix(infix: string): string[];
  1262. }
  1263. }
  1264. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1265. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1266. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1267. /** @hidden */
  1268. export class ShaderCodeTestNode extends ShaderCodeNode {
  1269. testExpression: ShaderDefineExpression;
  1270. isValid(preprocessors: {
  1271. [key: string]: string;
  1272. }): boolean;
  1273. }
  1274. }
  1275. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1276. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1277. /** @hidden */
  1278. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1279. define: string;
  1280. not: boolean;
  1281. constructor(define: string, not?: boolean);
  1282. isTrue(preprocessors: {
  1283. [key: string]: string;
  1284. }): boolean;
  1285. }
  1286. }
  1287. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1288. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1289. /** @hidden */
  1290. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1291. leftOperand: ShaderDefineExpression;
  1292. rightOperand: ShaderDefineExpression;
  1293. isTrue(preprocessors: {
  1294. [key: string]: string;
  1295. }): boolean;
  1296. }
  1297. }
  1298. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1299. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1300. /** @hidden */
  1301. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1302. leftOperand: ShaderDefineExpression;
  1303. rightOperand: ShaderDefineExpression;
  1304. isTrue(preprocessors: {
  1305. [key: string]: string;
  1306. }): boolean;
  1307. }
  1308. }
  1309. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1310. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1311. /** @hidden */
  1312. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1313. define: string;
  1314. operand: string;
  1315. testValue: string;
  1316. constructor(define: string, operand: string, testValue: string);
  1317. isTrue(preprocessors: {
  1318. [key: string]: string;
  1319. }): boolean;
  1320. }
  1321. }
  1322. declare module "babylonjs/Offline/IOfflineProvider" {
  1323. /**
  1324. * Class used to enable access to offline support
  1325. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1326. */
  1327. export interface IOfflineProvider {
  1328. /**
  1329. * Gets a boolean indicating if scene must be saved in the database
  1330. */
  1331. enableSceneOffline: boolean;
  1332. /**
  1333. * Gets a boolean indicating if textures must be saved in the database
  1334. */
  1335. enableTexturesOffline: boolean;
  1336. /**
  1337. * Open the offline support and make it available
  1338. * @param successCallback defines the callback to call on success
  1339. * @param errorCallback defines the callback to call on error
  1340. */
  1341. open(successCallback: () => void, errorCallback: () => void): void;
  1342. /**
  1343. * Loads an image from the offline support
  1344. * @param url defines the url to load from
  1345. * @param image defines the target DOM image
  1346. */
  1347. loadImage(url: string, image: HTMLImageElement): void;
  1348. /**
  1349. * Loads a file from offline support
  1350. * @param url defines the URL to load from
  1351. * @param sceneLoaded defines a callback to call on success
  1352. * @param progressCallBack defines a callback to call when progress changed
  1353. * @param errorCallback defines a callback to call on error
  1354. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1355. */
  1356. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1357. }
  1358. }
  1359. declare module "babylonjs/Misc/filesInputStore" {
  1360. /**
  1361. * Class used to help managing file picking and drag'n'drop
  1362. * File Storage
  1363. */
  1364. export class FilesInputStore {
  1365. /**
  1366. * List of files ready to be loaded
  1367. */
  1368. static FilesToLoad: {
  1369. [key: string]: File;
  1370. };
  1371. }
  1372. }
  1373. declare module "babylonjs/Misc/retryStrategy" {
  1374. import { WebRequest } from "babylonjs/Misc/webRequest";
  1375. /**
  1376. * Class used to define a retry strategy when error happens while loading assets
  1377. */
  1378. export class RetryStrategy {
  1379. /**
  1380. * Function used to defines an exponential back off strategy
  1381. * @param maxRetries defines the maximum number of retries (3 by default)
  1382. * @param baseInterval defines the interval between retries
  1383. * @returns the strategy function to use
  1384. */
  1385. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1386. }
  1387. }
  1388. declare module "babylonjs/Misc/baseError" {
  1389. /**
  1390. * @ignore
  1391. * Application error to support additional information when loading a file
  1392. */
  1393. export abstract class BaseError extends Error {
  1394. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1395. }
  1396. }
  1397. declare module "babylonjs/Misc/fileTools" {
  1398. import { WebRequest } from "babylonjs/Misc/webRequest";
  1399. import { Nullable } from "babylonjs/types";
  1400. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1401. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1402. import { BaseError } from "babylonjs/Misc/baseError";
  1403. /** @ignore */
  1404. export class LoadFileError extends BaseError {
  1405. request?: WebRequest;
  1406. file?: File;
  1407. /**
  1408. * Creates a new LoadFileError
  1409. * @param message defines the message of the error
  1410. * @param request defines the optional web request
  1411. * @param file defines the optional file
  1412. */
  1413. constructor(message: string, object?: WebRequest | File);
  1414. }
  1415. /** @ignore */
  1416. export class RequestFileError extends BaseError {
  1417. request: WebRequest;
  1418. /**
  1419. * Creates a new LoadFileError
  1420. * @param message defines the message of the error
  1421. * @param request defines the optional web request
  1422. */
  1423. constructor(message: string, request: WebRequest);
  1424. }
  1425. /** @ignore */
  1426. export class ReadFileError extends BaseError {
  1427. file: File;
  1428. /**
  1429. * Creates a new ReadFileError
  1430. * @param message defines the message of the error
  1431. * @param file defines the optional file
  1432. */
  1433. constructor(message: string, file: File);
  1434. }
  1435. /**
  1436. * @hidden
  1437. */
  1438. export class FileTools {
  1439. /**
  1440. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1441. */
  1442. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1443. /**
  1444. * Gets or sets the base URL to use to load assets
  1445. */
  1446. static BaseUrl: string;
  1447. /**
  1448. * Default behaviour for cors in the application.
  1449. * It can be a string if the expected behavior is identical in the entire app.
  1450. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1451. */
  1452. static CorsBehavior: string | ((url: string | string[]) => string);
  1453. /**
  1454. * Gets or sets a function used to pre-process url before using them to load assets
  1455. */
  1456. static PreprocessUrl: (url: string) => string;
  1457. /**
  1458. * Removes unwanted characters from an url
  1459. * @param url defines the url to clean
  1460. * @returns the cleaned url
  1461. */
  1462. private static _CleanUrl;
  1463. /**
  1464. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1465. * @param url define the url we are trying
  1466. * @param element define the dom element where to configure the cors policy
  1467. */
  1468. static SetCorsBehavior(url: string | string[], element: {
  1469. crossOrigin: string | null;
  1470. }): void;
  1471. /**
  1472. * Loads an image as an HTMLImageElement.
  1473. * @param input url string, ArrayBuffer, or Blob to load
  1474. * @param onLoad callback called when the image successfully loads
  1475. * @param onError callback called when the image fails to load
  1476. * @param offlineProvider offline provider for caching
  1477. * @param mimeType optional mime type
  1478. * @returns the HTMLImageElement of the loaded image
  1479. */
  1480. 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>;
  1481. /**
  1482. * Reads a file from a File object
  1483. * @param file defines the file to load
  1484. * @param onSuccess defines the callback to call when data is loaded
  1485. * @param onProgress defines the callback to call during loading process
  1486. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1487. * @param onError defines the callback to call when an error occurs
  1488. * @returns a file request object
  1489. */
  1490. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1491. /**
  1492. * Loads a file from a url
  1493. * @param url url to load
  1494. * @param onSuccess callback called when the file successfully loads
  1495. * @param onProgress callback called while file is loading (if the server supports this mode)
  1496. * @param offlineProvider defines the offline provider for caching
  1497. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1498. * @param onError callback called when the file fails to load
  1499. * @returns a file request object
  1500. */
  1501. 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;
  1502. /**
  1503. * Loads a file
  1504. * @param url url to load
  1505. * @param onSuccess callback called when the file successfully loads
  1506. * @param onProgress callback called while file is loading (if the server supports this mode)
  1507. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1508. * @param onError callback called when the file fails to load
  1509. * @param onOpened callback called when the web request is opened
  1510. * @returns a file request object
  1511. */
  1512. 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;
  1513. /**
  1514. * Checks if the loaded document was accessed via `file:`-Protocol.
  1515. * @returns boolean
  1516. */
  1517. static IsFileURL(): boolean;
  1518. }
  1519. }
  1520. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1521. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1522. import { WebRequest } from "babylonjs/Misc/webRequest";
  1523. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1524. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1525. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1526. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  1527. /** @hidden */
  1528. export class ShaderProcessor {
  1529. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1530. private static _ProcessPrecision;
  1531. private static _ExtractOperation;
  1532. private static _BuildSubExpression;
  1533. private static _BuildExpression;
  1534. private static _MoveCursorWithinIf;
  1535. private static _MoveCursor;
  1536. private static _EvaluatePreProcessors;
  1537. private static _PreparePreProcessors;
  1538. private static _ProcessShaderConversion;
  1539. private static _ProcessIncludes;
  1540. /**
  1541. * Loads a file from a url
  1542. * @param url url to load
  1543. * @param onSuccess callback called when the file successfully loads
  1544. * @param onProgress callback called while file is loading (if the server supports this mode)
  1545. * @param offlineProvider defines the offline provider for caching
  1546. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1547. * @param onError callback called when the file fails to load
  1548. * @returns a file request object
  1549. * @hidden
  1550. */
  1551. 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;
  1552. }
  1553. }
  1554. declare module "babylonjs/Maths/math.like" {
  1555. import { float, int, DeepImmutable } from "babylonjs/types";
  1556. /**
  1557. * @hidden
  1558. */
  1559. export interface IColor4Like {
  1560. r: float;
  1561. g: float;
  1562. b: float;
  1563. a: float;
  1564. }
  1565. /**
  1566. * @hidden
  1567. */
  1568. export interface IColor3Like {
  1569. r: float;
  1570. g: float;
  1571. b: float;
  1572. }
  1573. /**
  1574. * @hidden
  1575. */
  1576. export interface IVector4Like {
  1577. x: float;
  1578. y: float;
  1579. z: float;
  1580. w: float;
  1581. }
  1582. /**
  1583. * @hidden
  1584. */
  1585. export interface IVector3Like {
  1586. x: float;
  1587. y: float;
  1588. z: float;
  1589. }
  1590. /**
  1591. * @hidden
  1592. */
  1593. export interface IVector2Like {
  1594. x: float;
  1595. y: float;
  1596. }
  1597. /**
  1598. * @hidden
  1599. */
  1600. export interface IMatrixLike {
  1601. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1602. updateFlag: int;
  1603. }
  1604. /**
  1605. * @hidden
  1606. */
  1607. export interface IViewportLike {
  1608. x: float;
  1609. y: float;
  1610. width: float;
  1611. height: float;
  1612. }
  1613. /**
  1614. * @hidden
  1615. */
  1616. export interface IPlaneLike {
  1617. normal: IVector3Like;
  1618. d: float;
  1619. normalize(): void;
  1620. }
  1621. }
  1622. declare module "babylonjs/Materials/iEffectFallbacks" {
  1623. import { Effect } from "babylonjs/Materials/effect";
  1624. /**
  1625. * Interface used to define common properties for effect fallbacks
  1626. */
  1627. export interface IEffectFallbacks {
  1628. /**
  1629. * Removes the defines that should be removed when falling back.
  1630. * @param currentDefines defines the current define statements for the shader.
  1631. * @param effect defines the current effect we try to compile
  1632. * @returns The resulting defines with defines of the current rank removed.
  1633. */
  1634. reduce(currentDefines: string, effect: Effect): string;
  1635. /**
  1636. * Removes the fallback from the bound mesh.
  1637. */
  1638. unBindMesh(): void;
  1639. /**
  1640. * Checks to see if more fallbacks are still availible.
  1641. */
  1642. hasMoreFallbacks: boolean;
  1643. }
  1644. }
  1645. declare module "babylonjs/Maths/math.size" {
  1646. /**
  1647. * Interface for the size containing width and height
  1648. */
  1649. export interface ISize {
  1650. /**
  1651. * Width
  1652. */
  1653. width: number;
  1654. /**
  1655. * Heighht
  1656. */
  1657. height: number;
  1658. }
  1659. /**
  1660. * Size containing widht and height
  1661. */
  1662. export class Size implements ISize {
  1663. /**
  1664. * Width
  1665. */
  1666. width: number;
  1667. /**
  1668. * Height
  1669. */
  1670. height: number;
  1671. /**
  1672. * Creates a Size object from the given width and height (floats).
  1673. * @param width width of the new size
  1674. * @param height height of the new size
  1675. */
  1676. constructor(width: number, height: number);
  1677. /**
  1678. * Returns a string with the Size width and height
  1679. * @returns a string with the Size width and height
  1680. */
  1681. toString(): string;
  1682. /**
  1683. * "Size"
  1684. * @returns the string "Size"
  1685. */
  1686. getClassName(): string;
  1687. /**
  1688. * Returns the Size hash code.
  1689. * @returns a hash code for a unique width and height
  1690. */
  1691. getHashCode(): number;
  1692. /**
  1693. * Updates the current size from the given one.
  1694. * @param src the given size
  1695. */
  1696. copyFrom(src: Size): void;
  1697. /**
  1698. * Updates in place the current Size from the given floats.
  1699. * @param width width of the new size
  1700. * @param height height of the new size
  1701. * @returns the updated Size.
  1702. */
  1703. copyFromFloats(width: number, height: number): Size;
  1704. /**
  1705. * Updates in place the current Size from the given floats.
  1706. * @param width width to set
  1707. * @param height height to set
  1708. * @returns the updated Size.
  1709. */
  1710. set(width: number, height: number): Size;
  1711. /**
  1712. * Multiplies the width and height by numbers
  1713. * @param w factor to multiple the width by
  1714. * @param h factor to multiple the height by
  1715. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1716. */
  1717. multiplyByFloats(w: number, h: number): Size;
  1718. /**
  1719. * Clones the size
  1720. * @returns a new Size copied from the given one.
  1721. */
  1722. clone(): Size;
  1723. /**
  1724. * True if the current Size and the given one width and height are strictly equal.
  1725. * @param other the other size to compare against
  1726. * @returns True if the current Size and the given one width and height are strictly equal.
  1727. */
  1728. equals(other: Size): boolean;
  1729. /**
  1730. * The surface of the Size : width * height (float).
  1731. */
  1732. get surface(): number;
  1733. /**
  1734. * Create a new size of zero
  1735. * @returns a new Size set to (0.0, 0.0)
  1736. */
  1737. static Zero(): Size;
  1738. /**
  1739. * Sums the width and height of two sizes
  1740. * @param otherSize size to add to this size
  1741. * @returns a new Size set as the addition result of the current Size and the given one.
  1742. */
  1743. add(otherSize: Size): Size;
  1744. /**
  1745. * Subtracts the width and height of two
  1746. * @param otherSize size to subtract to this size
  1747. * @returns a new Size set as the subtraction result of the given one from the current Size.
  1748. */
  1749. subtract(otherSize: Size): Size;
  1750. /**
  1751. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  1752. * @param start starting size to lerp between
  1753. * @param end end size to lerp between
  1754. * @param amount amount to lerp between the start and end values
  1755. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  1756. */
  1757. static Lerp(start: Size, end: Size, amount: number): Size;
  1758. }
  1759. }
  1760. declare module "babylonjs/Materials/Textures/thinTexture" {
  1761. import { Nullable } from "babylonjs/types";
  1762. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1763. import { ISize } from "babylonjs/Maths/math.size";
  1764. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  1765. /**
  1766. * Base class of all the textures in babylon.
  1767. * It groups all the common properties required to work with Thin Engine.
  1768. */
  1769. export class ThinTexture {
  1770. protected _wrapU: number;
  1771. /**
  1772. * | Value | Type | Description |
  1773. * | ----- | ------------------ | ----------- |
  1774. * | 0 | CLAMP_ADDRESSMODE | |
  1775. * | 1 | WRAP_ADDRESSMODE | |
  1776. * | 2 | MIRROR_ADDRESSMODE | |
  1777. */
  1778. get wrapU(): number;
  1779. set wrapU(value: number);
  1780. protected _wrapV: number;
  1781. /**
  1782. * | Value | Type | Description |
  1783. * | ----- | ------------------ | ----------- |
  1784. * | 0 | CLAMP_ADDRESSMODE | |
  1785. * | 1 | WRAP_ADDRESSMODE | |
  1786. * | 2 | MIRROR_ADDRESSMODE | |
  1787. */
  1788. get wrapV(): number;
  1789. set wrapV(value: number);
  1790. /**
  1791. * | Value | Type | Description |
  1792. * | ----- | ------------------ | ----------- |
  1793. * | 0 | CLAMP_ADDRESSMODE | |
  1794. * | 1 | WRAP_ADDRESSMODE | |
  1795. * | 2 | MIRROR_ADDRESSMODE | |
  1796. */
  1797. wrapR: number;
  1798. /**
  1799. * With compliant hardware and browser (supporting anisotropic filtering)
  1800. * this defines the level of anisotropic filtering in the texture.
  1801. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  1802. */
  1803. anisotropicFilteringLevel: number;
  1804. /**
  1805. * Define the current state of the loading sequence when in delayed load mode.
  1806. */
  1807. delayLoadState: number;
  1808. /**
  1809. * How a texture is mapped.
  1810. * Unused in thin texture mode.
  1811. */
  1812. get coordinatesMode(): number;
  1813. /**
  1814. * Define if the texture is a cube texture or if false a 2d texture.
  1815. */
  1816. get isCube(): boolean;
  1817. set isCube(value: boolean);
  1818. /**
  1819. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  1820. */
  1821. get is3D(): boolean;
  1822. set is3D(value: boolean);
  1823. /**
  1824. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  1825. */
  1826. get is2DArray(): boolean;
  1827. set is2DArray(value: boolean);
  1828. /**
  1829. * Get the class name of the texture.
  1830. * @returns "ThinTexture"
  1831. */
  1832. getClassName(): string;
  1833. /** @hidden */
  1834. _texture: Nullable<InternalTexture>;
  1835. protected _engine: Nullable<ThinEngine>;
  1836. private _cachedSize;
  1837. private _cachedBaseSize;
  1838. /**
  1839. * Instantiates a new ThinTexture.
  1840. * Base class of all the textures in babylon.
  1841. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  1842. * @param internalTexture Define the internalTexture to wrap
  1843. */
  1844. constructor(internalTexture: Nullable<InternalTexture>);
  1845. /**
  1846. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  1847. * @returns true if fully ready
  1848. */
  1849. isReady(): boolean;
  1850. /**
  1851. * Triggers the load sequence in delayed load mode.
  1852. */
  1853. delayLoad(): void;
  1854. /**
  1855. * Get the underlying lower level texture from Babylon.
  1856. * @returns the insternal texture
  1857. */
  1858. getInternalTexture(): Nullable<InternalTexture>;
  1859. /**
  1860. * Get the size of the texture.
  1861. * @returns the texture size.
  1862. */
  1863. getSize(): ISize;
  1864. /**
  1865. * Get the base size of the texture.
  1866. * It can be different from the size if the texture has been resized for POT for instance
  1867. * @returns the base size
  1868. */
  1869. getBaseSize(): ISize;
  1870. /**
  1871. * Update the sampling mode of the texture.
  1872. * Default is Trilinear mode.
  1873. *
  1874. * | Value | Type | Description |
  1875. * | ----- | ------------------ | ----------- |
  1876. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  1877. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  1878. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  1879. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  1880. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  1881. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  1882. * | 7 | NEAREST_LINEAR | |
  1883. * | 8 | NEAREST_NEAREST | |
  1884. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  1885. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  1886. * | 11 | LINEAR_LINEAR | |
  1887. * | 12 | LINEAR_NEAREST | |
  1888. *
  1889. * > _mag_: magnification filter (close to the viewer)
  1890. * > _min_: minification filter (far from the viewer)
  1891. * > _mip_: filter used between mip map levels
  1892. *@param samplingMode Define the new sampling mode of the texture
  1893. */
  1894. updateSamplingMode(samplingMode: number): void;
  1895. /**
  1896. * Release and destroy the underlying lower level texture aka internalTexture.
  1897. */
  1898. releaseInternalTexture(): void;
  1899. /**
  1900. * Dispose the texture and release its associated resources.
  1901. */
  1902. dispose(): void;
  1903. }
  1904. }
  1905. declare module "babylonjs/Misc/smartArray" {
  1906. /**
  1907. * Defines an array and its length.
  1908. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  1909. */
  1910. export interface ISmartArrayLike<T> {
  1911. /**
  1912. * The data of the array.
  1913. */
  1914. data: Array<T>;
  1915. /**
  1916. * The active length of the array.
  1917. */
  1918. length: number;
  1919. }
  1920. /**
  1921. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  1922. */
  1923. export class SmartArray<T> implements ISmartArrayLike<T> {
  1924. /**
  1925. * The full set of data from the array.
  1926. */
  1927. data: Array<T>;
  1928. /**
  1929. * The active length of the array.
  1930. */
  1931. length: number;
  1932. protected _id: number;
  1933. /**
  1934. * Instantiates a Smart Array.
  1935. * @param capacity defines the default capacity of the array.
  1936. */
  1937. constructor(capacity: number);
  1938. /**
  1939. * Pushes a value at the end of the active data.
  1940. * @param value defines the object to push in the array.
  1941. */
  1942. push(value: T): void;
  1943. /**
  1944. * Iterates over the active data and apply the lambda to them.
  1945. * @param func defines the action to apply on each value.
  1946. */
  1947. forEach(func: (content: T) => void): void;
  1948. /**
  1949. * Sorts the full sets of data.
  1950. * @param compareFn defines the comparison function to apply.
  1951. */
  1952. sort(compareFn: (a: T, b: T) => number): void;
  1953. /**
  1954. * Resets the active data to an empty array.
  1955. */
  1956. reset(): void;
  1957. /**
  1958. * Releases all the data from the array as well as the array.
  1959. */
  1960. dispose(): void;
  1961. /**
  1962. * Concats the active data with a given array.
  1963. * @param array defines the data to concatenate with.
  1964. */
  1965. concat(array: any): void;
  1966. /**
  1967. * Returns the position of a value in the active data.
  1968. * @param value defines the value to find the index for
  1969. * @returns the index if found in the active data otherwise -1
  1970. */
  1971. indexOf(value: T): number;
  1972. /**
  1973. * Returns whether an element is part of the active data.
  1974. * @param value defines the value to look for
  1975. * @returns true if found in the active data otherwise false
  1976. */
  1977. contains(value: T): boolean;
  1978. private static _GlobalId;
  1979. }
  1980. /**
  1981. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  1982. * The data in this array can only be present once
  1983. */
  1984. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  1985. private _duplicateId;
  1986. /**
  1987. * Pushes a value at the end of the active data.
  1988. * THIS DOES NOT PREVENT DUPPLICATE DATA
  1989. * @param value defines the object to push in the array.
  1990. */
  1991. push(value: T): void;
  1992. /**
  1993. * Pushes a value at the end of the active data.
  1994. * If the data is already present, it won t be added again
  1995. * @param value defines the object to push in the array.
  1996. * @returns true if added false if it was already present
  1997. */
  1998. pushNoDuplicate(value: T): boolean;
  1999. /**
  2000. * Resets the active data to an empty array.
  2001. */
  2002. reset(): void;
  2003. /**
  2004. * Concats the active data with a given array.
  2005. * This ensures no dupplicate will be present in the result.
  2006. * @param array defines the data to concatenate with.
  2007. */
  2008. concatWithNoDuplicate(array: any): void;
  2009. }
  2010. }
  2011. declare module "babylonjs/Misc/andOrNotEvaluator" {
  2012. /**
  2013. * Class used to evalaute queries containing `and` and `or` operators
  2014. */
  2015. export class AndOrNotEvaluator {
  2016. /**
  2017. * Evaluate a query
  2018. * @param query defines the query to evaluate
  2019. * @param evaluateCallback defines the callback used to filter result
  2020. * @returns true if the query matches
  2021. */
  2022. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  2023. private static _HandleParenthesisContent;
  2024. private static _SimplifyNegation;
  2025. }
  2026. }
  2027. declare module "babylonjs/Misc/tags" {
  2028. /**
  2029. * Class used to store custom tags
  2030. */
  2031. export class Tags {
  2032. /**
  2033. * Adds support for tags on the given object
  2034. * @param obj defines the object to use
  2035. */
  2036. static EnableFor(obj: any): void;
  2037. /**
  2038. * Removes tags support
  2039. * @param obj defines the object to use
  2040. */
  2041. static DisableFor(obj: any): void;
  2042. /**
  2043. * Gets a boolean indicating if the given object has tags
  2044. * @param obj defines the object to use
  2045. * @returns a boolean
  2046. */
  2047. static HasTags(obj: any): boolean;
  2048. /**
  2049. * Gets the tags available on a given object
  2050. * @param obj defines the object to use
  2051. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2052. * @returns the tags
  2053. */
  2054. static GetTags(obj: any, asString?: boolean): any;
  2055. /**
  2056. * Adds tags to an object
  2057. * @param obj defines the object to use
  2058. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2059. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2060. */
  2061. static AddTagsTo(obj: any, tagsString: string): void;
  2062. /**
  2063. * @hidden
  2064. */
  2065. static _AddTagTo(obj: any, tag: string): void;
  2066. /**
  2067. * Removes specific tags from a specific object
  2068. * @param obj defines the object to use
  2069. * @param tagsString defines the tags to remove
  2070. */
  2071. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2072. /**
  2073. * @hidden
  2074. */
  2075. static _RemoveTagFrom(obj: any, tag: string): void;
  2076. /**
  2077. * Defines if tags hosted on an object match a given query
  2078. * @param obj defines the object to use
  2079. * @param tagsQuery defines the tag query
  2080. * @returns a boolean
  2081. */
  2082. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2083. }
  2084. }
  2085. declare module "babylonjs/Maths/math.scalar" {
  2086. /**
  2087. * Scalar computation library
  2088. */
  2089. export class Scalar {
  2090. /**
  2091. * Two pi constants convenient for computation.
  2092. */
  2093. static TwoPi: number;
  2094. /**
  2095. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2096. * @param a number
  2097. * @param b number
  2098. * @param epsilon (default = 1.401298E-45)
  2099. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2100. */
  2101. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2102. /**
  2103. * Returns a string : the upper case translation of the number i to hexadecimal.
  2104. * @param i number
  2105. * @returns the upper case translation of the number i to hexadecimal.
  2106. */
  2107. static ToHex(i: number): string;
  2108. /**
  2109. * Returns -1 if value is negative and +1 is value is positive.
  2110. * @param value the value
  2111. * @returns the value itself if it's equal to zero.
  2112. */
  2113. static Sign(value: number): number;
  2114. /**
  2115. * Returns the value itself if it's between min and max.
  2116. * Returns min if the value is lower than min.
  2117. * Returns max if the value is greater than max.
  2118. * @param value the value to clmap
  2119. * @param min the min value to clamp to (default: 0)
  2120. * @param max the max value to clamp to (default: 1)
  2121. * @returns the clamped value
  2122. */
  2123. static Clamp(value: number, min?: number, max?: number): number;
  2124. /**
  2125. * the log2 of value.
  2126. * @param value the value to compute log2 of
  2127. * @returns the log2 of value.
  2128. */
  2129. static Log2(value: number): number;
  2130. /**
  2131. * Loops the value, so that it is never larger than length and never smaller than 0.
  2132. *
  2133. * This is similar to the modulo operator but it works with floating point numbers.
  2134. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2135. * With t = 5 and length = 2.5, the result would be 0.0.
  2136. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2137. * @param value the value
  2138. * @param length the length
  2139. * @returns the looped value
  2140. */
  2141. static Repeat(value: number, length: number): number;
  2142. /**
  2143. * Normalize the value between 0.0 and 1.0 using min and max values
  2144. * @param value value to normalize
  2145. * @param min max to normalize between
  2146. * @param max min to normalize between
  2147. * @returns the normalized value
  2148. */
  2149. static Normalize(value: number, min: number, max: number): number;
  2150. /**
  2151. * Denormalize the value from 0.0 and 1.0 using min and max values
  2152. * @param normalized value to denormalize
  2153. * @param min max to denormalize between
  2154. * @param max min to denormalize between
  2155. * @returns the denormalized value
  2156. */
  2157. static Denormalize(normalized: number, min: number, max: number): number;
  2158. /**
  2159. * Calculates the shortest difference between two given angles given in degrees.
  2160. * @param current current angle in degrees
  2161. * @param target target angle in degrees
  2162. * @returns the delta
  2163. */
  2164. static DeltaAngle(current: number, target: number): number;
  2165. /**
  2166. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2167. * @param tx value
  2168. * @param length length
  2169. * @returns The returned value will move back and forth between 0 and length
  2170. */
  2171. static PingPong(tx: number, length: number): number;
  2172. /**
  2173. * Interpolates between min and max with smoothing at the limits.
  2174. *
  2175. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2176. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2177. * @param from from
  2178. * @param to to
  2179. * @param tx value
  2180. * @returns the smooth stepped value
  2181. */
  2182. static SmoothStep(from: number, to: number, tx: number): number;
  2183. /**
  2184. * Moves a value current towards target.
  2185. *
  2186. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2187. * Negative values of maxDelta pushes the value away from target.
  2188. * @param current current value
  2189. * @param target target value
  2190. * @param maxDelta max distance to move
  2191. * @returns resulting value
  2192. */
  2193. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2194. /**
  2195. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2196. *
  2197. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2198. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2199. * @param current current value
  2200. * @param target target value
  2201. * @param maxDelta max distance to move
  2202. * @returns resulting angle
  2203. */
  2204. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2205. /**
  2206. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2207. * @param start start value
  2208. * @param end target value
  2209. * @param amount amount to lerp between
  2210. * @returns the lerped value
  2211. */
  2212. static Lerp(start: number, end: number, amount: number): number;
  2213. /**
  2214. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2215. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2216. * @param start start value
  2217. * @param end target value
  2218. * @param amount amount to lerp between
  2219. * @returns the lerped value
  2220. */
  2221. static LerpAngle(start: number, end: number, amount: number): number;
  2222. /**
  2223. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2224. * @param a start value
  2225. * @param b target value
  2226. * @param value value between a and b
  2227. * @returns the inverseLerp value
  2228. */
  2229. static InverseLerp(a: number, b: number, value: number): number;
  2230. /**
  2231. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2232. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2233. * @param value1 spline value
  2234. * @param tangent1 spline value
  2235. * @param value2 spline value
  2236. * @param tangent2 spline value
  2237. * @param amount input value
  2238. * @returns hermite result
  2239. */
  2240. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2241. /**
  2242. * Returns a random float number between and min and max values
  2243. * @param min min value of random
  2244. * @param max max value of random
  2245. * @returns random value
  2246. */
  2247. static RandomRange(min: number, max: number): number;
  2248. /**
  2249. * This function returns percentage of a number in a given range.
  2250. *
  2251. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2252. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2253. * @param number to convert to percentage
  2254. * @param min min range
  2255. * @param max max range
  2256. * @returns the percentage
  2257. */
  2258. static RangeToPercent(number: number, min: number, max: number): number;
  2259. /**
  2260. * This function returns number that corresponds to the percentage in a given range.
  2261. *
  2262. * PercentToRange(0.34,0,100) will return 34.
  2263. * @param percent to convert to number
  2264. * @param min min range
  2265. * @param max max range
  2266. * @returns the number
  2267. */
  2268. static PercentToRange(percent: number, min: number, max: number): number;
  2269. /**
  2270. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2271. * @param angle The angle to normalize in radian.
  2272. * @return The converted angle.
  2273. */
  2274. static NormalizeRadians(angle: number): number;
  2275. }
  2276. }
  2277. declare module "babylonjs/Maths/math.constants" {
  2278. /**
  2279. * Constant used to convert a value to gamma space
  2280. * @ignorenaming
  2281. */
  2282. export const ToGammaSpace: number;
  2283. /**
  2284. * Constant used to convert a value to linear space
  2285. * @ignorenaming
  2286. */
  2287. export const ToLinearSpace = 2.2;
  2288. /**
  2289. * Constant used to define the minimal number value in Babylon.js
  2290. * @ignorenaming
  2291. */
  2292. let Epsilon: number;
  2293. export { Epsilon };
  2294. }
  2295. declare module "babylonjs/Maths/math.viewport" {
  2296. /**
  2297. * Class used to represent a viewport on screen
  2298. */
  2299. export class Viewport {
  2300. /** viewport left coordinate */
  2301. x: number;
  2302. /** viewport top coordinate */
  2303. y: number;
  2304. /**viewport width */
  2305. width: number;
  2306. /** viewport height */
  2307. height: number;
  2308. /**
  2309. * Creates a Viewport object located at (x, y) and sized (width, height)
  2310. * @param x defines viewport left coordinate
  2311. * @param y defines viewport top coordinate
  2312. * @param width defines the viewport width
  2313. * @param height defines the viewport height
  2314. */
  2315. constructor(
  2316. /** viewport left coordinate */
  2317. x: number,
  2318. /** viewport top coordinate */
  2319. y: number,
  2320. /**viewport width */
  2321. width: number,
  2322. /** viewport height */
  2323. height: number);
  2324. /**
  2325. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2326. * @param renderWidth defines the rendering width
  2327. * @param renderHeight defines the rendering height
  2328. * @returns a new Viewport
  2329. */
  2330. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2331. /**
  2332. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2333. * @param renderWidth defines the rendering width
  2334. * @param renderHeight defines the rendering height
  2335. * @param ref defines the target viewport
  2336. * @returns the current viewport
  2337. */
  2338. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2339. /**
  2340. * Returns a new Viewport copied from the current one
  2341. * @returns a new Viewport
  2342. */
  2343. clone(): Viewport;
  2344. }
  2345. }
  2346. declare module "babylonjs/Misc/arrayTools" {
  2347. /**
  2348. * Class containing a set of static utilities functions for arrays.
  2349. */
  2350. export class ArrayTools {
  2351. /**
  2352. * Returns an array of the given size filled with element built from the given constructor and the paramters
  2353. * @param size the number of element to construct and put in the array
  2354. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2355. * @returns a new array filled with new objects
  2356. */
  2357. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2358. }
  2359. }
  2360. declare module "babylonjs/Maths/math.plane" {
  2361. import { DeepImmutable } from "babylonjs/types";
  2362. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  2363. /**
  2364. * Represents a plane by the equation ax + by + cz + d = 0
  2365. */
  2366. export class Plane {
  2367. private static _TmpMatrix;
  2368. /**
  2369. * Normal of the plane (a,b,c)
  2370. */
  2371. normal: Vector3;
  2372. /**
  2373. * d component of the plane
  2374. */
  2375. d: number;
  2376. /**
  2377. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2378. * @param a a component of the plane
  2379. * @param b b component of the plane
  2380. * @param c c component of the plane
  2381. * @param d d component of the plane
  2382. */
  2383. constructor(a: number, b: number, c: number, d: number);
  2384. /**
  2385. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2386. */
  2387. asArray(): number[];
  2388. /**
  2389. * @returns a new plane copied from the current Plane.
  2390. */
  2391. clone(): Plane;
  2392. /**
  2393. * @returns the string "Plane".
  2394. */
  2395. getClassName(): string;
  2396. /**
  2397. * @returns the Plane hash code.
  2398. */
  2399. getHashCode(): number;
  2400. /**
  2401. * Normalize the current Plane in place.
  2402. * @returns the updated Plane.
  2403. */
  2404. normalize(): Plane;
  2405. /**
  2406. * Applies a transformation the plane and returns the result
  2407. * @param transformation the transformation matrix to be applied to the plane
  2408. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2409. */
  2410. transform(transformation: DeepImmutable<Matrix>): Plane;
  2411. /**
  2412. * Compute the dot product between the point and the plane normal
  2413. * @param point point to calculate the dot product with
  2414. * @returns the dot product (float) of the point coordinates and the plane normal.
  2415. */
  2416. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2417. /**
  2418. * Updates the current Plane from the plane defined by the three given points.
  2419. * @param point1 one of the points used to contruct the plane
  2420. * @param point2 one of the points used to contruct the plane
  2421. * @param point3 one of the points used to contruct the plane
  2422. * @returns the updated Plane.
  2423. */
  2424. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2425. /**
  2426. * Checks if the plane is facing a given direction
  2427. * @param direction the direction to check if the plane is facing
  2428. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2429. * @returns True is the vector "direction" is the same side than the plane normal.
  2430. */
  2431. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2432. /**
  2433. * Calculates the distance to a point
  2434. * @param point point to calculate distance to
  2435. * @returns the signed distance (float) from the given point to the Plane.
  2436. */
  2437. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2438. /**
  2439. * Creates a plane from an array
  2440. * @param array the array to create a plane from
  2441. * @returns a new Plane from the given array.
  2442. */
  2443. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2444. /**
  2445. * Creates a plane from three points
  2446. * @param point1 point used to create the plane
  2447. * @param point2 point used to create the plane
  2448. * @param point3 point used to create the plane
  2449. * @returns a new Plane defined by the three given points.
  2450. */
  2451. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2452. /**
  2453. * Creates a plane from an origin point and a normal
  2454. * @param origin origin of the plane to be constructed
  2455. * @param normal normal of the plane to be constructed
  2456. * @returns a new Plane the normal vector to this plane at the given origin point.
  2457. * Note : the vector "normal" is updated because normalized.
  2458. */
  2459. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2460. /**
  2461. * Calculates the distance from a plane and a point
  2462. * @param origin origin of the plane to be constructed
  2463. * @param normal normal of the plane to be constructed
  2464. * @param point point to calculate distance to
  2465. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2466. */
  2467. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2468. }
  2469. }
  2470. declare module "babylonjs/Engines/performanceConfigurator" {
  2471. /** @hidden */
  2472. export class PerformanceConfigurator {
  2473. /** @hidden */
  2474. static MatrixUse64Bits: boolean;
  2475. /** @hidden */
  2476. static MatrixTrackPrecisionChange: boolean;
  2477. /** @hidden */
  2478. static MatrixCurrentType: any;
  2479. /** @hidden */
  2480. static MatrixTrackedMatrices: Array<any> | null;
  2481. /** @hidden */
  2482. static SetMatrixPrecision(use64bits: boolean): void;
  2483. }
  2484. }
  2485. declare module "babylonjs/Maths/math.vector" {
  2486. import { Viewport } from "babylonjs/Maths/math.viewport";
  2487. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2488. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2489. import { Plane } from "babylonjs/Maths/math.plane";
  2490. /**
  2491. * Class representing a vector containing 2 coordinates
  2492. */
  2493. export class Vector2 {
  2494. /** defines the first coordinate */
  2495. x: number;
  2496. /** defines the second coordinate */
  2497. y: number;
  2498. /**
  2499. * Creates a new Vector2 from the given x and y coordinates
  2500. * @param x defines the first coordinate
  2501. * @param y defines the second coordinate
  2502. */
  2503. constructor(
  2504. /** defines the first coordinate */
  2505. x?: number,
  2506. /** defines the second coordinate */
  2507. y?: number);
  2508. /**
  2509. * Gets a string with the Vector2 coordinates
  2510. * @returns a string with the Vector2 coordinates
  2511. */
  2512. toString(): string;
  2513. /**
  2514. * Gets class name
  2515. * @returns the string "Vector2"
  2516. */
  2517. getClassName(): string;
  2518. /**
  2519. * Gets current vector hash code
  2520. * @returns the Vector2 hash code as a number
  2521. */
  2522. getHashCode(): number;
  2523. /**
  2524. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2525. * @param array defines the source array
  2526. * @param index defines the offset in source array
  2527. * @returns the current Vector2
  2528. */
  2529. toArray(array: FloatArray, index?: number): Vector2;
  2530. /**
  2531. * Update the current vector from an array
  2532. * @param array defines the destination array
  2533. * @param index defines the offset in the destination array
  2534. * @returns the current Vector3
  2535. */
  2536. fromArray(array: FloatArray, index?: number): Vector2;
  2537. /**
  2538. * Copy the current vector to an array
  2539. * @returns a new array with 2 elements: the Vector2 coordinates.
  2540. */
  2541. asArray(): number[];
  2542. /**
  2543. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2544. * @param source defines the source Vector2
  2545. * @returns the current updated Vector2
  2546. */
  2547. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2548. /**
  2549. * Sets the Vector2 coordinates with the given floats
  2550. * @param x defines the first coordinate
  2551. * @param y defines the second coordinate
  2552. * @returns the current updated Vector2
  2553. */
  2554. copyFromFloats(x: number, y: number): Vector2;
  2555. /**
  2556. * Sets the Vector2 coordinates with the given floats
  2557. * @param x defines the first coordinate
  2558. * @param y defines the second coordinate
  2559. * @returns the current updated Vector2
  2560. */
  2561. set(x: number, y: number): Vector2;
  2562. /**
  2563. * Add another vector with the current one
  2564. * @param otherVector defines the other vector
  2565. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2566. */
  2567. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2568. /**
  2569. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2570. * @param otherVector defines the other vector
  2571. * @param result defines the target vector
  2572. * @returns the unmodified current Vector2
  2573. */
  2574. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2575. /**
  2576. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2577. * @param otherVector defines the other vector
  2578. * @returns the current updated Vector2
  2579. */
  2580. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2581. /**
  2582. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2583. * @param otherVector defines the other vector
  2584. * @returns a new Vector2
  2585. */
  2586. addVector3(otherVector: Vector3): Vector2;
  2587. /**
  2588. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2589. * @param otherVector defines the other vector
  2590. * @returns a new Vector2
  2591. */
  2592. subtract(otherVector: Vector2): Vector2;
  2593. /**
  2594. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2595. * @param otherVector defines the other vector
  2596. * @param result defines the target vector
  2597. * @returns the unmodified current Vector2
  2598. */
  2599. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2600. /**
  2601. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2602. * @param otherVector defines the other vector
  2603. * @returns the current updated Vector2
  2604. */
  2605. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2606. /**
  2607. * Multiplies in place the current Vector2 coordinates by the given ones
  2608. * @param otherVector defines the other vector
  2609. * @returns the current updated Vector2
  2610. */
  2611. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2612. /**
  2613. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2614. * @param otherVector defines the other vector
  2615. * @returns a new Vector2
  2616. */
  2617. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2618. /**
  2619. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2620. * @param otherVector defines the other vector
  2621. * @param result defines the target vector
  2622. * @returns the unmodified current Vector2
  2623. */
  2624. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2625. /**
  2626. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2627. * @param x defines the first coordinate
  2628. * @param y defines the second coordinate
  2629. * @returns a new Vector2
  2630. */
  2631. multiplyByFloats(x: number, y: number): Vector2;
  2632. /**
  2633. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2634. * @param otherVector defines the other vector
  2635. * @returns a new Vector2
  2636. */
  2637. divide(otherVector: Vector2): Vector2;
  2638. /**
  2639. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2640. * @param otherVector defines the other vector
  2641. * @param result defines the target vector
  2642. * @returns the unmodified current Vector2
  2643. */
  2644. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2645. /**
  2646. * Divides the current Vector2 coordinates by the given ones
  2647. * @param otherVector defines the other vector
  2648. * @returns the current updated Vector2
  2649. */
  2650. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2651. /**
  2652. * Gets a new Vector2 with current Vector2 negated coordinates
  2653. * @returns a new Vector2
  2654. */
  2655. negate(): Vector2;
  2656. /**
  2657. * Negate this vector in place
  2658. * @returns this
  2659. */
  2660. negateInPlace(): Vector2;
  2661. /**
  2662. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2663. * @param result defines the Vector3 object where to store the result
  2664. * @returns the current Vector2
  2665. */
  2666. negateToRef(result: Vector2): Vector2;
  2667. /**
  2668. * Multiply the Vector2 coordinates by scale
  2669. * @param scale defines the scaling factor
  2670. * @returns the current updated Vector2
  2671. */
  2672. scaleInPlace(scale: number): Vector2;
  2673. /**
  2674. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2675. * @param scale defines the scaling factor
  2676. * @returns a new Vector2
  2677. */
  2678. scale(scale: number): Vector2;
  2679. /**
  2680. * Scale the current Vector2 values by a factor to a given Vector2
  2681. * @param scale defines the scale factor
  2682. * @param result defines the Vector2 object where to store the result
  2683. * @returns the unmodified current Vector2
  2684. */
  2685. scaleToRef(scale: number, result: Vector2): Vector2;
  2686. /**
  2687. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2688. * @param scale defines the scale factor
  2689. * @param result defines the Vector2 object where to store the result
  2690. * @returns the unmodified current Vector2
  2691. */
  2692. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2693. /**
  2694. * Gets a boolean if two vectors are equals
  2695. * @param otherVector defines the other vector
  2696. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2697. */
  2698. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2699. /**
  2700. * Gets a boolean if two vectors are equals (using an epsilon value)
  2701. * @param otherVector defines the other vector
  2702. * @param epsilon defines the minimal distance to consider equality
  2703. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2704. */
  2705. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2706. /**
  2707. * Gets a new Vector2 from current Vector2 floored values
  2708. * @returns a new Vector2
  2709. */
  2710. floor(): Vector2;
  2711. /**
  2712. * Gets a new Vector2 from current Vector2 floored values
  2713. * @returns a new Vector2
  2714. */
  2715. fract(): Vector2;
  2716. /**
  2717. * Gets the length of the vector
  2718. * @returns the vector length (float)
  2719. */
  2720. length(): number;
  2721. /**
  2722. * Gets the vector squared length
  2723. * @returns the vector squared length (float)
  2724. */
  2725. lengthSquared(): number;
  2726. /**
  2727. * Normalize the vector
  2728. * @returns the current updated Vector2
  2729. */
  2730. normalize(): Vector2;
  2731. /**
  2732. * Gets a new Vector2 copied from the Vector2
  2733. * @returns a new Vector2
  2734. */
  2735. clone(): Vector2;
  2736. /**
  2737. * Gets a new Vector2(0, 0)
  2738. * @returns a new Vector2
  2739. */
  2740. static Zero(): Vector2;
  2741. /**
  2742. * Gets a new Vector2(1, 1)
  2743. * @returns a new Vector2
  2744. */
  2745. static One(): Vector2;
  2746. /**
  2747. * Gets a new Vector2 set from the given index element of the given array
  2748. * @param array defines the data source
  2749. * @param offset defines the offset in the data source
  2750. * @returns a new Vector2
  2751. */
  2752. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2753. /**
  2754. * Sets "result" from the given index element of the given array
  2755. * @param array defines the data source
  2756. * @param offset defines the offset in the data source
  2757. * @param result defines the target vector
  2758. */
  2759. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2760. /**
  2761. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2762. * @param value1 defines 1st point of control
  2763. * @param value2 defines 2nd point of control
  2764. * @param value3 defines 3rd point of control
  2765. * @param value4 defines 4th point of control
  2766. * @param amount defines the interpolation factor
  2767. * @returns a new Vector2
  2768. */
  2769. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2770. /**
  2771. * 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".
  2772. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2773. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2774. * @param value defines the value to clamp
  2775. * @param min defines the lower limit
  2776. * @param max defines the upper limit
  2777. * @returns a new Vector2
  2778. */
  2779. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2780. /**
  2781. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2782. * @param value1 defines the 1st control point
  2783. * @param tangent1 defines the outgoing tangent
  2784. * @param value2 defines the 2nd control point
  2785. * @param tangent2 defines the incoming tangent
  2786. * @param amount defines the interpolation factor
  2787. * @returns a new Vector2
  2788. */
  2789. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2790. /**
  2791. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2792. * @param start defines the start vector
  2793. * @param end defines the end vector
  2794. * @param amount defines the interpolation factor
  2795. * @returns a new Vector2
  2796. */
  2797. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2798. /**
  2799. * Gets the dot product of the vector "left" and the vector "right"
  2800. * @param left defines first vector
  2801. * @param right defines second vector
  2802. * @returns the dot product (float)
  2803. */
  2804. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2805. /**
  2806. * Returns a new Vector2 equal to the normalized given vector
  2807. * @param vector defines the vector to normalize
  2808. * @returns a new Vector2
  2809. */
  2810. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2811. /**
  2812. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2813. * @param left defines 1st vector
  2814. * @param right defines 2nd vector
  2815. * @returns a new Vector2
  2816. */
  2817. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2818. /**
  2819. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2820. * @param left defines 1st vector
  2821. * @param right defines 2nd vector
  2822. * @returns a new Vector2
  2823. */
  2824. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2825. /**
  2826. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2827. * @param vector defines the vector to transform
  2828. * @param transformation defines the matrix to apply
  2829. * @returns a new Vector2
  2830. */
  2831. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2832. /**
  2833. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2834. * @param vector defines the vector to transform
  2835. * @param transformation defines the matrix to apply
  2836. * @param result defines the target vector
  2837. */
  2838. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2839. /**
  2840. * Determines if a given vector is included in a triangle
  2841. * @param p defines the vector to test
  2842. * @param p0 defines 1st triangle point
  2843. * @param p1 defines 2nd triangle point
  2844. * @param p2 defines 3rd triangle point
  2845. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2846. */
  2847. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2848. /**
  2849. * Gets the distance between the vectors "value1" and "value2"
  2850. * @param value1 defines first vector
  2851. * @param value2 defines second vector
  2852. * @returns the distance between vectors
  2853. */
  2854. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2855. /**
  2856. * Returns the squared distance between the vectors "value1" and "value2"
  2857. * @param value1 defines first vector
  2858. * @param value2 defines second vector
  2859. * @returns the squared distance between vectors
  2860. */
  2861. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2862. /**
  2863. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2864. * @param value1 defines first vector
  2865. * @param value2 defines second vector
  2866. * @returns a new Vector2
  2867. */
  2868. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2869. /**
  2870. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2871. * @param p defines the middle point
  2872. * @param segA defines one point of the segment
  2873. * @param segB defines the other point of the segment
  2874. * @returns the shortest distance
  2875. */
  2876. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2877. }
  2878. /**
  2879. * Class used to store (x,y,z) vector representation
  2880. * A Vector3 is the main object used in 3D geometry
  2881. * It can represent etiher the coordinates of a point the space, either a direction
  2882. * Reminder: js uses a left handed forward facing system
  2883. */
  2884. export class Vector3 {
  2885. private static _UpReadOnly;
  2886. private static _ZeroReadOnly;
  2887. /** @hidden */
  2888. _x: number;
  2889. /** @hidden */
  2890. _y: number;
  2891. /** @hidden */
  2892. _z: number;
  2893. /** @hidden */
  2894. _isDirty: boolean;
  2895. /** Gets or sets the x coordinate */
  2896. get x(): number;
  2897. set x(value: number);
  2898. /** Gets or sets the y coordinate */
  2899. get y(): number;
  2900. set y(value: number);
  2901. /** Gets or sets the z coordinate */
  2902. get z(): number;
  2903. set z(value: number);
  2904. /**
  2905. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2906. * @param x defines the first coordinates (on X axis)
  2907. * @param y defines the second coordinates (on Y axis)
  2908. * @param z defines the third coordinates (on Z axis)
  2909. */
  2910. constructor(x?: number, y?: number, z?: number);
  2911. /**
  2912. * Creates a string representation of the Vector3
  2913. * @returns a string with the Vector3 coordinates.
  2914. */
  2915. toString(): string;
  2916. /**
  2917. * Gets the class name
  2918. * @returns the string "Vector3"
  2919. */
  2920. getClassName(): string;
  2921. /**
  2922. * Creates the Vector3 hash code
  2923. * @returns a number which tends to be unique between Vector3 instances
  2924. */
  2925. getHashCode(): number;
  2926. /**
  2927. * Creates an array containing three elements : the coordinates of the Vector3
  2928. * @returns a new array of numbers
  2929. */
  2930. asArray(): number[];
  2931. /**
  2932. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2933. * @param array defines the destination array
  2934. * @param index defines the offset in the destination array
  2935. * @returns the current Vector3
  2936. */
  2937. toArray(array: FloatArray, index?: number): Vector3;
  2938. /**
  2939. * Update the current vector from an array
  2940. * @param array defines the destination array
  2941. * @param index defines the offset in the destination array
  2942. * @returns the current Vector3
  2943. */
  2944. fromArray(array: FloatArray, index?: number): Vector3;
  2945. /**
  2946. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2947. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2948. */
  2949. toQuaternion(): Quaternion;
  2950. /**
  2951. * Adds the given vector to the current Vector3
  2952. * @param otherVector defines the second operand
  2953. * @returns the current updated Vector3
  2954. */
  2955. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2956. /**
  2957. * Adds the given coordinates to the current Vector3
  2958. * @param x defines the x coordinate of the operand
  2959. * @param y defines the y coordinate of the operand
  2960. * @param z defines the z coordinate of the operand
  2961. * @returns the current updated Vector3
  2962. */
  2963. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2964. /**
  2965. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2966. * @param otherVector defines the second operand
  2967. * @returns the resulting Vector3
  2968. */
  2969. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2970. /**
  2971. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2972. * @param otherVector defines the second operand
  2973. * @param result defines the Vector3 object where to store the result
  2974. * @returns the current Vector3
  2975. */
  2976. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2977. /**
  2978. * Subtract the given vector from the current Vector3
  2979. * @param otherVector defines the second operand
  2980. * @returns the current updated Vector3
  2981. */
  2982. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2983. /**
  2984. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2985. * @param otherVector defines the second operand
  2986. * @returns the resulting Vector3
  2987. */
  2988. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2989. /**
  2990. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2991. * @param otherVector defines the second operand
  2992. * @param result defines the Vector3 object where to store the result
  2993. * @returns the current Vector3
  2994. */
  2995. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2996. /**
  2997. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2998. * @param x defines the x coordinate of the operand
  2999. * @param y defines the y coordinate of the operand
  3000. * @param z defines the z coordinate of the operand
  3001. * @returns the resulting Vector3
  3002. */
  3003. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3004. /**
  3005. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  3006. * @param x defines the x coordinate of the operand
  3007. * @param y defines the y coordinate of the operand
  3008. * @param z defines the z coordinate of the operand
  3009. * @param result defines the Vector3 object where to store the result
  3010. * @returns the current Vector3
  3011. */
  3012. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3013. /**
  3014. * Gets a new Vector3 set with the current Vector3 negated coordinates
  3015. * @returns a new Vector3
  3016. */
  3017. negate(): Vector3;
  3018. /**
  3019. * Negate this vector in place
  3020. * @returns this
  3021. */
  3022. negateInPlace(): Vector3;
  3023. /**
  3024. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  3025. * @param result defines the Vector3 object where to store the result
  3026. * @returns the current Vector3
  3027. */
  3028. negateToRef(result: Vector3): Vector3;
  3029. /**
  3030. * Multiplies the Vector3 coordinates by the float "scale"
  3031. * @param scale defines the multiplier factor
  3032. * @returns the current updated Vector3
  3033. */
  3034. scaleInPlace(scale: number): Vector3;
  3035. /**
  3036. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3037. * @param scale defines the multiplier factor
  3038. * @returns a new Vector3
  3039. */
  3040. scale(scale: number): Vector3;
  3041. /**
  3042. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3043. * @param scale defines the multiplier factor
  3044. * @param result defines the Vector3 object where to store the result
  3045. * @returns the current Vector3
  3046. */
  3047. scaleToRef(scale: number, result: Vector3): Vector3;
  3048. /**
  3049. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3050. * @param scale defines the scale factor
  3051. * @param result defines the Vector3 object where to store the result
  3052. * @returns the unmodified current Vector3
  3053. */
  3054. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3055. /**
  3056. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3057. * @param origin defines the origin of the projection ray
  3058. * @param plane defines the plane to project to
  3059. * @returns the projected vector3
  3060. */
  3061. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3062. /**
  3063. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3064. * @param origin defines the origin of the projection ray
  3065. * @param plane defines the plane to project to
  3066. * @param result defines the Vector3 where to store the result
  3067. */
  3068. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3069. /**
  3070. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3071. * @param otherVector defines the second operand
  3072. * @returns true if both vectors are equals
  3073. */
  3074. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3075. /**
  3076. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3077. * @param otherVector defines the second operand
  3078. * @param epsilon defines the minimal distance to define values as equals
  3079. * @returns true if both vectors are distant less than epsilon
  3080. */
  3081. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3082. /**
  3083. * Returns true if the current Vector3 coordinates equals the given floats
  3084. * @param x defines the x coordinate of the operand
  3085. * @param y defines the y coordinate of the operand
  3086. * @param z defines the z coordinate of the operand
  3087. * @returns true if both vectors are equals
  3088. */
  3089. equalsToFloats(x: number, y: number, z: number): boolean;
  3090. /**
  3091. * Multiplies the current Vector3 coordinates by the given ones
  3092. * @param otherVector defines the second operand
  3093. * @returns the current updated Vector3
  3094. */
  3095. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3096. /**
  3097. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3098. * @param otherVector defines the second operand
  3099. * @returns the new Vector3
  3100. */
  3101. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3102. /**
  3103. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3104. * @param otherVector defines the second operand
  3105. * @param result defines the Vector3 object where to store the result
  3106. * @returns the current Vector3
  3107. */
  3108. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3109. /**
  3110. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3111. * @param x defines the x coordinate of the operand
  3112. * @param y defines the y coordinate of the operand
  3113. * @param z defines the z coordinate of the operand
  3114. * @returns the new Vector3
  3115. */
  3116. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3117. /**
  3118. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3119. * @param otherVector defines the second operand
  3120. * @returns the new Vector3
  3121. */
  3122. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3123. /**
  3124. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3125. * @param otherVector defines the second operand
  3126. * @param result defines the Vector3 object where to store the result
  3127. * @returns the current Vector3
  3128. */
  3129. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3130. /**
  3131. * Divides the current Vector3 coordinates by the given ones.
  3132. * @param otherVector defines the second operand
  3133. * @returns the current updated Vector3
  3134. */
  3135. divideInPlace(otherVector: Vector3): Vector3;
  3136. /**
  3137. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3138. * @param other defines the second operand
  3139. * @returns the current updated Vector3
  3140. */
  3141. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3142. /**
  3143. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3144. * @param other defines the second operand
  3145. * @returns the current updated Vector3
  3146. */
  3147. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3148. /**
  3149. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3150. * @param x defines the x coordinate of the operand
  3151. * @param y defines the y coordinate of the operand
  3152. * @param z defines the z coordinate of the operand
  3153. * @returns the current updated Vector3
  3154. */
  3155. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3156. /**
  3157. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3158. * @param x defines the x coordinate of the operand
  3159. * @param y defines the y coordinate of the operand
  3160. * @param z defines the z coordinate of the operand
  3161. * @returns the current updated Vector3
  3162. */
  3163. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3164. /**
  3165. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3166. * Check if is non uniform within a certain amount of decimal places to account for this
  3167. * @param epsilon the amount the values can differ
  3168. * @returns if the the vector is non uniform to a certain number of decimal places
  3169. */
  3170. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3171. /**
  3172. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3173. */
  3174. get isNonUniform(): boolean;
  3175. /**
  3176. * Gets a new Vector3 from current Vector3 floored values
  3177. * @returns a new Vector3
  3178. */
  3179. floor(): Vector3;
  3180. /**
  3181. * Gets a new Vector3 from current Vector3 floored values
  3182. * @returns a new Vector3
  3183. */
  3184. fract(): Vector3;
  3185. /**
  3186. * Gets the length of the Vector3
  3187. * @returns the length of the Vector3
  3188. */
  3189. length(): number;
  3190. /**
  3191. * Gets the squared length of the Vector3
  3192. * @returns squared length of the Vector3
  3193. */
  3194. lengthSquared(): number;
  3195. /**
  3196. * Normalize the current Vector3.
  3197. * Please note that this is an in place operation.
  3198. * @returns the current updated Vector3
  3199. */
  3200. normalize(): Vector3;
  3201. /**
  3202. * Reorders the x y z properties of the vector in place
  3203. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3204. * @returns the current updated vector
  3205. */
  3206. reorderInPlace(order: string): this;
  3207. /**
  3208. * Rotates the vector around 0,0,0 by a quaternion
  3209. * @param quaternion the rotation quaternion
  3210. * @param result vector to store the result
  3211. * @returns the resulting vector
  3212. */
  3213. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3214. /**
  3215. * Rotates a vector around a given point
  3216. * @param quaternion the rotation quaternion
  3217. * @param point the point to rotate around
  3218. * @param result vector to store the result
  3219. * @returns the resulting vector
  3220. */
  3221. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3222. /**
  3223. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3224. * The cross product is then orthogonal to both current and "other"
  3225. * @param other defines the right operand
  3226. * @returns the cross product
  3227. */
  3228. cross(other: Vector3): Vector3;
  3229. /**
  3230. * Normalize the current Vector3 with the given input length.
  3231. * Please note that this is an in place operation.
  3232. * @param len the length of the vector
  3233. * @returns the current updated Vector3
  3234. */
  3235. normalizeFromLength(len: number): Vector3;
  3236. /**
  3237. * Normalize the current Vector3 to a new vector
  3238. * @returns the new Vector3
  3239. */
  3240. normalizeToNew(): Vector3;
  3241. /**
  3242. * Normalize the current Vector3 to the reference
  3243. * @param reference define the Vector3 to update
  3244. * @returns the updated Vector3
  3245. */
  3246. normalizeToRef(reference: Vector3): Vector3;
  3247. /**
  3248. * Creates a new Vector3 copied from the current Vector3
  3249. * @returns the new Vector3
  3250. */
  3251. clone(): Vector3;
  3252. /**
  3253. * Copies the given vector coordinates to the current Vector3 ones
  3254. * @param source defines the source Vector3
  3255. * @returns the current updated Vector3
  3256. */
  3257. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3258. /**
  3259. * Copies the given floats to the current Vector3 coordinates
  3260. * @param x defines the x coordinate of the operand
  3261. * @param y defines the y coordinate of the operand
  3262. * @param z defines the z coordinate of the operand
  3263. * @returns the current updated Vector3
  3264. */
  3265. copyFromFloats(x: number, y: number, z: number): Vector3;
  3266. /**
  3267. * Copies the given floats to the current Vector3 coordinates
  3268. * @param x defines the x coordinate of the operand
  3269. * @param y defines the y coordinate of the operand
  3270. * @param z defines the z coordinate of the operand
  3271. * @returns the current updated Vector3
  3272. */
  3273. set(x: number, y: number, z: number): Vector3;
  3274. /**
  3275. * Copies the given float to the current Vector3 coordinates
  3276. * @param v defines the x, y and z coordinates of the operand
  3277. * @returns the current updated Vector3
  3278. */
  3279. setAll(v: number): Vector3;
  3280. /**
  3281. * Get the clip factor between two vectors
  3282. * @param vector0 defines the first operand
  3283. * @param vector1 defines the second operand
  3284. * @param axis defines the axis to use
  3285. * @param size defines the size along the axis
  3286. * @returns the clip factor
  3287. */
  3288. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3289. /**
  3290. * Get angle between two vectors
  3291. * @param vector0 angle between vector0 and vector1
  3292. * @param vector1 angle between vector0 and vector1
  3293. * @param normal direction of the normal
  3294. * @return the angle between vector0 and vector1
  3295. */
  3296. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3297. /**
  3298. * Returns a new Vector3 set from the index "offset" of the given array
  3299. * @param array defines the source array
  3300. * @param offset defines the offset in the source array
  3301. * @returns the new Vector3
  3302. */
  3303. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3304. /**
  3305. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3306. * @param array defines the source array
  3307. * @param offset defines the offset in the source array
  3308. * @returns the new Vector3
  3309. * @deprecated Please use FromArray instead.
  3310. */
  3311. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3312. /**
  3313. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3314. * @param array defines the source array
  3315. * @param offset defines the offset in the source array
  3316. * @param result defines the Vector3 where to store the result
  3317. */
  3318. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3319. /**
  3320. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3321. * @param array defines the source array
  3322. * @param offset defines the offset in the source array
  3323. * @param result defines the Vector3 where to store the result
  3324. * @deprecated Please use FromArrayToRef instead.
  3325. */
  3326. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3327. /**
  3328. * Sets the given vector "result" with the given floats.
  3329. * @param x defines the x coordinate of the source
  3330. * @param y defines the y coordinate of the source
  3331. * @param z defines the z coordinate of the source
  3332. * @param result defines the Vector3 where to store the result
  3333. */
  3334. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3335. /**
  3336. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3337. * @returns a new empty Vector3
  3338. */
  3339. static Zero(): Vector3;
  3340. /**
  3341. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3342. * @returns a new unit Vector3
  3343. */
  3344. static One(): Vector3;
  3345. /**
  3346. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3347. * @returns a new up Vector3
  3348. */
  3349. static Up(): Vector3;
  3350. /**
  3351. * Gets a up Vector3 that must not be updated
  3352. */
  3353. static get UpReadOnly(): DeepImmutable<Vector3>;
  3354. /**
  3355. * Gets a zero Vector3 that must not be updated
  3356. */
  3357. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3358. /**
  3359. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3360. * @returns a new down Vector3
  3361. */
  3362. static Down(): Vector3;
  3363. /**
  3364. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3365. * @param rightHandedSystem is the scene right-handed (negative z)
  3366. * @returns a new forward Vector3
  3367. */
  3368. static Forward(rightHandedSystem?: boolean): Vector3;
  3369. /**
  3370. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3371. * @param rightHandedSystem is the scene right-handed (negative-z)
  3372. * @returns a new forward Vector3
  3373. */
  3374. static Backward(rightHandedSystem?: boolean): Vector3;
  3375. /**
  3376. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3377. * @returns a new right Vector3
  3378. */
  3379. static Right(): Vector3;
  3380. /**
  3381. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3382. * @returns a new left Vector3
  3383. */
  3384. static Left(): Vector3;
  3385. /**
  3386. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3387. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3388. * @param vector defines the Vector3 to transform
  3389. * @param transformation defines the transformation matrix
  3390. * @returns the transformed Vector3
  3391. */
  3392. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3393. /**
  3394. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3395. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3396. * @param vector defines the Vector3 to transform
  3397. * @param transformation defines the transformation matrix
  3398. * @param result defines the Vector3 where to store the result
  3399. */
  3400. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3401. /**
  3402. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3403. * This method computes tranformed coordinates only, not transformed direction vectors
  3404. * @param x define the x coordinate of the source vector
  3405. * @param y define the y coordinate of the source vector
  3406. * @param z define the z coordinate of the source vector
  3407. * @param transformation defines the transformation matrix
  3408. * @param result defines the Vector3 where to store the result
  3409. */
  3410. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3411. /**
  3412. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3413. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3414. * @param vector defines the Vector3 to transform
  3415. * @param transformation defines the transformation matrix
  3416. * @returns the new Vector3
  3417. */
  3418. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3419. /**
  3420. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3421. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3422. * @param vector defines the Vector3 to transform
  3423. * @param transformation defines the transformation matrix
  3424. * @param result defines the Vector3 where to store the result
  3425. */
  3426. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3427. /**
  3428. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3429. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3430. * @param x define the x coordinate of the source vector
  3431. * @param y define the y coordinate of the source vector
  3432. * @param z define the z coordinate of the source vector
  3433. * @param transformation defines the transformation matrix
  3434. * @param result defines the Vector3 where to store the result
  3435. */
  3436. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3437. /**
  3438. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3439. * @param value1 defines the first control point
  3440. * @param value2 defines the second control point
  3441. * @param value3 defines the third control point
  3442. * @param value4 defines the fourth control point
  3443. * @param amount defines the amount on the spline to use
  3444. * @returns the new Vector3
  3445. */
  3446. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3447. /**
  3448. * 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"
  3449. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3450. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3451. * @param value defines the current value
  3452. * @param min defines the lower range value
  3453. * @param max defines the upper range value
  3454. * @returns the new Vector3
  3455. */
  3456. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3457. /**
  3458. * 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"
  3459. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3460. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3461. * @param value defines the current value
  3462. * @param min defines the lower range value
  3463. * @param max defines the upper range value
  3464. * @param result defines the Vector3 where to store the result
  3465. */
  3466. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3467. /**
  3468. * Checks if a given vector is inside a specific range
  3469. * @param v defines the vector to test
  3470. * @param min defines the minimum range
  3471. * @param max defines the maximum range
  3472. */
  3473. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3474. /**
  3475. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3476. * @param value1 defines the first control point
  3477. * @param tangent1 defines the first tangent vector
  3478. * @param value2 defines the second control point
  3479. * @param tangent2 defines the second tangent vector
  3480. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3481. * @returns the new Vector3
  3482. */
  3483. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3484. /**
  3485. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3486. * @param start defines the start value
  3487. * @param end defines the end value
  3488. * @param amount max defines amount between both (between 0 and 1)
  3489. * @returns the new Vector3
  3490. */
  3491. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3492. /**
  3493. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3494. * @param start defines the start value
  3495. * @param end defines the end value
  3496. * @param amount max defines amount between both (between 0 and 1)
  3497. * @param result defines the Vector3 where to store the result
  3498. */
  3499. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3500. /**
  3501. * Returns the dot product (float) between the vectors "left" and "right"
  3502. * @param left defines the left operand
  3503. * @param right defines the right operand
  3504. * @returns the dot product
  3505. */
  3506. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3507. /**
  3508. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3509. * The cross product is then orthogonal to both "left" and "right"
  3510. * @param left defines the left operand
  3511. * @param right defines the right operand
  3512. * @returns the cross product
  3513. */
  3514. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3515. /**
  3516. * Sets the given vector "result" with the cross product of "left" and "right"
  3517. * The cross product is then orthogonal to both "left" and "right"
  3518. * @param left defines the left operand
  3519. * @param right defines the right operand
  3520. * @param result defines the Vector3 where to store the result
  3521. */
  3522. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3523. /**
  3524. * Returns a new Vector3 as the normalization of the given vector
  3525. * @param vector defines the Vector3 to normalize
  3526. * @returns the new Vector3
  3527. */
  3528. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3529. /**
  3530. * Sets the given vector "result" with the normalization of the given first vector
  3531. * @param vector defines the Vector3 to normalize
  3532. * @param result defines the Vector3 where to store the result
  3533. */
  3534. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3535. /**
  3536. * Project a Vector3 onto screen space
  3537. * @param vector defines the Vector3 to project
  3538. * @param world defines the world matrix to use
  3539. * @param transform defines the transform (view x projection) matrix to use
  3540. * @param viewport defines the screen viewport to use
  3541. * @returns the new Vector3
  3542. */
  3543. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3544. /**
  3545. * Project a Vector3 onto screen space to reference
  3546. * @param vector defines the Vector3 to project
  3547. * @param world defines the world matrix to use
  3548. * @param transform defines the transform (view x projection) matrix to use
  3549. * @param viewport defines the screen viewport to use
  3550. * @param result the vector in which the screen space will be stored
  3551. * @returns the new Vector3
  3552. */
  3553. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3554. /** @hidden */
  3555. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3556. /**
  3557. * Unproject from screen space to object space
  3558. * @param source defines the screen space Vector3 to use
  3559. * @param viewportWidth defines the current width of the viewport
  3560. * @param viewportHeight defines the current height of the viewport
  3561. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3562. * @param transform defines the transform (view x projection) matrix to use
  3563. * @returns the new Vector3
  3564. */
  3565. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3566. /**
  3567. * Unproject from screen space to object space
  3568. * @param source defines the screen space Vector3 to use
  3569. * @param viewportWidth defines the current width of the viewport
  3570. * @param viewportHeight defines the current height of the viewport
  3571. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3572. * @param view defines the view matrix to use
  3573. * @param projection defines the projection matrix to use
  3574. * @returns the new Vector3
  3575. */
  3576. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3577. /**
  3578. * Unproject from screen space to object space
  3579. * @param source defines the screen space Vector3 to use
  3580. * @param viewportWidth defines the current width of the viewport
  3581. * @param viewportHeight defines the current height of the viewport
  3582. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3583. * @param view defines the view matrix to use
  3584. * @param projection defines the projection matrix to use
  3585. * @param result defines the Vector3 where to store the result
  3586. */
  3587. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3588. /**
  3589. * Unproject from screen space to object space
  3590. * @param sourceX defines the screen space x coordinate to use
  3591. * @param sourceY defines the screen space y coordinate to use
  3592. * @param sourceZ defines the screen space z coordinate to use
  3593. * @param viewportWidth defines the current width of the viewport
  3594. * @param viewportHeight defines the current height of the viewport
  3595. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3596. * @param view defines the view matrix to use
  3597. * @param projection defines the projection matrix to use
  3598. * @param result defines the Vector3 where to store the result
  3599. */
  3600. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3601. /**
  3602. * Gets the minimal coordinate values between two Vector3
  3603. * @param left defines the first operand
  3604. * @param right defines the second operand
  3605. * @returns the new Vector3
  3606. */
  3607. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3608. /**
  3609. * Gets the maximal coordinate values between two Vector3
  3610. * @param left defines the first operand
  3611. * @param right defines the second operand
  3612. * @returns the new Vector3
  3613. */
  3614. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3615. /**
  3616. * Returns the distance between the vectors "value1" and "value2"
  3617. * @param value1 defines the first operand
  3618. * @param value2 defines the second operand
  3619. * @returns the distance
  3620. */
  3621. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3622. /**
  3623. * Returns the squared distance between the vectors "value1" and "value2"
  3624. * @param value1 defines the first operand
  3625. * @param value2 defines the second operand
  3626. * @returns the squared distance
  3627. */
  3628. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3629. /**
  3630. * Returns a new Vector3 located at the center between "value1" and "value2"
  3631. * @param value1 defines the first operand
  3632. * @param value2 defines the second operand
  3633. * @returns the new Vector3
  3634. */
  3635. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3636. /**
  3637. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3638. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3639. * to something in order to rotate it from its local system to the given target system
  3640. * Note: axis1, axis2 and axis3 are normalized during this operation
  3641. * @param axis1 defines the first axis
  3642. * @param axis2 defines the second axis
  3643. * @param axis3 defines the third axis
  3644. * @returns a new Vector3
  3645. */
  3646. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3647. /**
  3648. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3649. * @param axis1 defines the first axis
  3650. * @param axis2 defines the second axis
  3651. * @param axis3 defines the third axis
  3652. * @param ref defines the Vector3 where to store the result
  3653. */
  3654. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3655. }
  3656. /**
  3657. * Vector4 class created for EulerAngle class conversion to Quaternion
  3658. */
  3659. export class Vector4 {
  3660. /** x value of the vector */
  3661. x: number;
  3662. /** y value of the vector */
  3663. y: number;
  3664. /** z value of the vector */
  3665. z: number;
  3666. /** w value of the vector */
  3667. w: number;
  3668. /**
  3669. * Creates a Vector4 object from the given floats.
  3670. * @param x x value of the vector
  3671. * @param y y value of the vector
  3672. * @param z z value of the vector
  3673. * @param w w value of the vector
  3674. */
  3675. constructor(
  3676. /** x value of the vector */
  3677. x: number,
  3678. /** y value of the vector */
  3679. y: number,
  3680. /** z value of the vector */
  3681. z: number,
  3682. /** w value of the vector */
  3683. w: number);
  3684. /**
  3685. * Returns the string with the Vector4 coordinates.
  3686. * @returns a string containing all the vector values
  3687. */
  3688. toString(): string;
  3689. /**
  3690. * Returns the string "Vector4".
  3691. * @returns "Vector4"
  3692. */
  3693. getClassName(): string;
  3694. /**
  3695. * Returns the Vector4 hash code.
  3696. * @returns a unique hash code
  3697. */
  3698. getHashCode(): number;
  3699. /**
  3700. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3701. * @returns the resulting array
  3702. */
  3703. asArray(): number[];
  3704. /**
  3705. * Populates the given array from the given index with the Vector4 coordinates.
  3706. * @param array array to populate
  3707. * @param index index of the array to start at (default: 0)
  3708. * @returns the Vector4.
  3709. */
  3710. toArray(array: FloatArray, index?: number): Vector4;
  3711. /**
  3712. * Update the current vector from an array
  3713. * @param array defines the destination array
  3714. * @param index defines the offset in the destination array
  3715. * @returns the current Vector3
  3716. */
  3717. fromArray(array: FloatArray, index?: number): Vector4;
  3718. /**
  3719. * Adds the given vector to the current Vector4.
  3720. * @param otherVector the vector to add
  3721. * @returns the updated Vector4.
  3722. */
  3723. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3724. /**
  3725. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3726. * @param otherVector the vector to add
  3727. * @returns the resulting vector
  3728. */
  3729. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3730. /**
  3731. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3732. * @param otherVector the vector to add
  3733. * @param result the vector to store the result
  3734. * @returns the current Vector4.
  3735. */
  3736. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3737. /**
  3738. * Subtract in place the given vector from the current Vector4.
  3739. * @param otherVector the vector to subtract
  3740. * @returns the updated Vector4.
  3741. */
  3742. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3743. /**
  3744. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3745. * @param otherVector the vector to add
  3746. * @returns the new vector with the result
  3747. */
  3748. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3749. /**
  3750. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3751. * @param otherVector the vector to subtract
  3752. * @param result the vector to store the result
  3753. * @returns the current Vector4.
  3754. */
  3755. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3756. /**
  3757. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3758. */
  3759. /**
  3760. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3761. * @param x value to subtract
  3762. * @param y value to subtract
  3763. * @param z value to subtract
  3764. * @param w value to subtract
  3765. * @returns new vector containing the result
  3766. */
  3767. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3768. /**
  3769. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3770. * @param x value to subtract
  3771. * @param y value to subtract
  3772. * @param z value to subtract
  3773. * @param w value to subtract
  3774. * @param result the vector to store the result in
  3775. * @returns the current Vector4.
  3776. */
  3777. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3778. /**
  3779. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3780. * @returns a new vector with the negated values
  3781. */
  3782. negate(): Vector4;
  3783. /**
  3784. * Negate this vector in place
  3785. * @returns this
  3786. */
  3787. negateInPlace(): Vector4;
  3788. /**
  3789. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3790. * @param result defines the Vector3 object where to store the result
  3791. * @returns the current Vector4
  3792. */
  3793. negateToRef(result: Vector4): Vector4;
  3794. /**
  3795. * Multiplies the current Vector4 coordinates by scale (float).
  3796. * @param scale the number to scale with
  3797. * @returns the updated Vector4.
  3798. */
  3799. scaleInPlace(scale: number): Vector4;
  3800. /**
  3801. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3802. * @param scale the number to scale with
  3803. * @returns a new vector with the result
  3804. */
  3805. scale(scale: number): Vector4;
  3806. /**
  3807. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3808. * @param scale the number to scale with
  3809. * @param result a vector to store the result in
  3810. * @returns the current Vector4.
  3811. */
  3812. scaleToRef(scale: number, result: Vector4): Vector4;
  3813. /**
  3814. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3815. * @param scale defines the scale factor
  3816. * @param result defines the Vector4 object where to store the result
  3817. * @returns the unmodified current Vector4
  3818. */
  3819. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3820. /**
  3821. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3822. * @param otherVector the vector to compare against
  3823. * @returns true if they are equal
  3824. */
  3825. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3826. /**
  3827. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3828. * @param otherVector vector to compare against
  3829. * @param epsilon (Default: very small number)
  3830. * @returns true if they are equal
  3831. */
  3832. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3833. /**
  3834. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3835. * @param x x value to compare against
  3836. * @param y y value to compare against
  3837. * @param z z value to compare against
  3838. * @param w w value to compare against
  3839. * @returns true if equal
  3840. */
  3841. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3842. /**
  3843. * Multiplies in place the current Vector4 by the given one.
  3844. * @param otherVector vector to multiple with
  3845. * @returns the updated Vector4.
  3846. */
  3847. multiplyInPlace(otherVector: Vector4): Vector4;
  3848. /**
  3849. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3850. * @param otherVector vector to multiple with
  3851. * @returns resulting new vector
  3852. */
  3853. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3854. /**
  3855. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3856. * @param otherVector vector to multiple with
  3857. * @param result vector to store the result
  3858. * @returns the current Vector4.
  3859. */
  3860. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3861. /**
  3862. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3863. * @param x x value multiply with
  3864. * @param y y value multiply with
  3865. * @param z z value multiply with
  3866. * @param w w value multiply with
  3867. * @returns resulting new vector
  3868. */
  3869. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3870. /**
  3871. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3872. * @param otherVector vector to devide with
  3873. * @returns resulting new vector
  3874. */
  3875. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3876. /**
  3877. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3878. * @param otherVector vector to devide with
  3879. * @param result vector to store the result
  3880. * @returns the current Vector4.
  3881. */
  3882. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3883. /**
  3884. * Divides the current Vector3 coordinates by the given ones.
  3885. * @param otherVector vector to devide with
  3886. * @returns the updated Vector3.
  3887. */
  3888. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3889. /**
  3890. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3891. * @param other defines the second operand
  3892. * @returns the current updated Vector4
  3893. */
  3894. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3895. /**
  3896. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3897. * @param other defines the second operand
  3898. * @returns the current updated Vector4
  3899. */
  3900. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3901. /**
  3902. * Gets a new Vector4 from current Vector4 floored values
  3903. * @returns a new Vector4
  3904. */
  3905. floor(): Vector4;
  3906. /**
  3907. * Gets a new Vector4 from current Vector3 floored values
  3908. * @returns a new Vector4
  3909. */
  3910. fract(): Vector4;
  3911. /**
  3912. * Returns the Vector4 length (float).
  3913. * @returns the length
  3914. */
  3915. length(): number;
  3916. /**
  3917. * Returns the Vector4 squared length (float).
  3918. * @returns the length squared
  3919. */
  3920. lengthSquared(): number;
  3921. /**
  3922. * Normalizes in place the Vector4.
  3923. * @returns the updated Vector4.
  3924. */
  3925. normalize(): Vector4;
  3926. /**
  3927. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3928. * @returns this converted to a new vector3
  3929. */
  3930. toVector3(): Vector3;
  3931. /**
  3932. * Returns a new Vector4 copied from the current one.
  3933. * @returns the new cloned vector
  3934. */
  3935. clone(): Vector4;
  3936. /**
  3937. * Updates the current Vector4 with the given one coordinates.
  3938. * @param source the source vector to copy from
  3939. * @returns the updated Vector4.
  3940. */
  3941. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3942. /**
  3943. * Updates the current Vector4 coordinates with the given floats.
  3944. * @param x float to copy from
  3945. * @param y float to copy from
  3946. * @param z float to copy from
  3947. * @param w float to copy from
  3948. * @returns the updated Vector4.
  3949. */
  3950. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3951. /**
  3952. * Updates the current Vector4 coordinates with the given floats.
  3953. * @param x float to set from
  3954. * @param y float to set from
  3955. * @param z float to set from
  3956. * @param w float to set from
  3957. * @returns the updated Vector4.
  3958. */
  3959. set(x: number, y: number, z: number, w: number): Vector4;
  3960. /**
  3961. * Copies the given float to the current Vector3 coordinates
  3962. * @param v defines the x, y, z and w coordinates of the operand
  3963. * @returns the current updated Vector3
  3964. */
  3965. setAll(v: number): Vector4;
  3966. /**
  3967. * Returns a new Vector4 set from the starting index of the given array.
  3968. * @param array the array to pull values from
  3969. * @param offset the offset into the array to start at
  3970. * @returns the new vector
  3971. */
  3972. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3973. /**
  3974. * Updates the given vector "result" from the starting index of the given array.
  3975. * @param array the array to pull values from
  3976. * @param offset the offset into the array to start at
  3977. * @param result the vector to store the result in
  3978. */
  3979. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3980. /**
  3981. * Updates the given vector "result" from the starting index of the given Float32Array.
  3982. * @param array the array to pull values from
  3983. * @param offset the offset into the array to start at
  3984. * @param result the vector to store the result in
  3985. */
  3986. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3987. /**
  3988. * Updates the given vector "result" coordinates from the given floats.
  3989. * @param x float to set from
  3990. * @param y float to set from
  3991. * @param z float to set from
  3992. * @param w float to set from
  3993. * @param result the vector to the floats in
  3994. */
  3995. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3996. /**
  3997. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3998. * @returns the new vector
  3999. */
  4000. static Zero(): Vector4;
  4001. /**
  4002. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  4003. * @returns the new vector
  4004. */
  4005. static One(): Vector4;
  4006. /**
  4007. * Returns a new normalized Vector4 from the given one.
  4008. * @param vector the vector to normalize
  4009. * @returns the vector
  4010. */
  4011. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  4012. /**
  4013. * Updates the given vector "result" from the normalization of the given one.
  4014. * @param vector the vector to normalize
  4015. * @param result the vector to store the result in
  4016. */
  4017. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  4018. /**
  4019. * Returns a vector with the minimum values from the left and right vectors
  4020. * @param left left vector to minimize
  4021. * @param right right vector to minimize
  4022. * @returns a new vector with the minimum of the left and right vector values
  4023. */
  4024. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4025. /**
  4026. * Returns a vector with the maximum values from the left and right vectors
  4027. * @param left left vector to maximize
  4028. * @param right right vector to maximize
  4029. * @returns a new vector with the maximum of the left and right vector values
  4030. */
  4031. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4032. /**
  4033. * Returns the distance (float) between the vectors "value1" and "value2".
  4034. * @param value1 value to calulate the distance between
  4035. * @param value2 value to calulate the distance between
  4036. * @return the distance between the two vectors
  4037. */
  4038. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4039. /**
  4040. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4041. * @param value1 value to calulate the distance between
  4042. * @param value2 value to calulate the distance between
  4043. * @return the distance between the two vectors squared
  4044. */
  4045. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4046. /**
  4047. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4048. * @param value1 value to calulate the center between
  4049. * @param value2 value to calulate the center between
  4050. * @return the center between the two vectors
  4051. */
  4052. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4053. /**
  4054. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4055. * This methods computes transformed normalized direction vectors only.
  4056. * @param vector the vector to transform
  4057. * @param transformation the transformation matrix to apply
  4058. * @returns the new vector
  4059. */
  4060. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4061. /**
  4062. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4063. * This methods computes transformed normalized direction vectors only.
  4064. * @param vector the vector to transform
  4065. * @param transformation the transformation matrix to apply
  4066. * @param result the vector to store the result in
  4067. */
  4068. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4069. /**
  4070. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4071. * This methods computes transformed normalized direction vectors only.
  4072. * @param x value to transform
  4073. * @param y value to transform
  4074. * @param z value to transform
  4075. * @param w value to transform
  4076. * @param transformation the transformation matrix to apply
  4077. * @param result the vector to store the results in
  4078. */
  4079. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4080. /**
  4081. * Creates a new Vector4 from a Vector3
  4082. * @param source defines the source data
  4083. * @param w defines the 4th component (default is 0)
  4084. * @returns a new Vector4
  4085. */
  4086. static FromVector3(source: Vector3, w?: number): Vector4;
  4087. }
  4088. /**
  4089. * Class used to store quaternion data
  4090. * @see https://en.wikipedia.org/wiki/Quaternion
  4091. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4092. */
  4093. export class Quaternion {
  4094. /** @hidden */
  4095. _x: number;
  4096. /** @hidden */
  4097. _y: number;
  4098. /** @hidden */
  4099. _z: number;
  4100. /** @hidden */
  4101. _w: number;
  4102. /** @hidden */
  4103. _isDirty: boolean;
  4104. /** Gets or sets the x coordinate */
  4105. get x(): number;
  4106. set x(value: number);
  4107. /** Gets or sets the y coordinate */
  4108. get y(): number;
  4109. set y(value: number);
  4110. /** Gets or sets the z coordinate */
  4111. get z(): number;
  4112. set z(value: number);
  4113. /** Gets or sets the w coordinate */
  4114. get w(): number;
  4115. set w(value: number);
  4116. /**
  4117. * Creates a new Quaternion from the given floats
  4118. * @param x defines the first component (0 by default)
  4119. * @param y defines the second component (0 by default)
  4120. * @param z defines the third component (0 by default)
  4121. * @param w defines the fourth component (1.0 by default)
  4122. */
  4123. constructor(x?: number, y?: number, z?: number, w?: number);
  4124. /**
  4125. * Gets a string representation for the current quaternion
  4126. * @returns a string with the Quaternion coordinates
  4127. */
  4128. toString(): string;
  4129. /**
  4130. * Gets the class name of the quaternion
  4131. * @returns the string "Quaternion"
  4132. */
  4133. getClassName(): string;
  4134. /**
  4135. * Gets a hash code for this quaternion
  4136. * @returns the quaternion hash code
  4137. */
  4138. getHashCode(): number;
  4139. /**
  4140. * Copy the quaternion to an array
  4141. * @returns a new array populated with 4 elements from the quaternion coordinates
  4142. */
  4143. asArray(): number[];
  4144. /**
  4145. * Check if two quaternions are equals
  4146. * @param otherQuaternion defines the second operand
  4147. * @return true if the current quaternion and the given one coordinates are strictly equals
  4148. */
  4149. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4150. /**
  4151. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4152. * @param otherQuaternion defines the other quaternion
  4153. * @param epsilon defines the minimal distance to consider equality
  4154. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4155. */
  4156. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4157. /**
  4158. * Clone the current quaternion
  4159. * @returns a new quaternion copied from the current one
  4160. */
  4161. clone(): Quaternion;
  4162. /**
  4163. * Copy a quaternion to the current one
  4164. * @param other defines the other quaternion
  4165. * @returns the updated current quaternion
  4166. */
  4167. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4168. /**
  4169. * Updates the current quaternion with the given float coordinates
  4170. * @param x defines the x coordinate
  4171. * @param y defines the y coordinate
  4172. * @param z defines the z coordinate
  4173. * @param w defines the w coordinate
  4174. * @returns the updated current quaternion
  4175. */
  4176. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4177. /**
  4178. * Updates the current quaternion from the given float coordinates
  4179. * @param x defines the x coordinate
  4180. * @param y defines the y coordinate
  4181. * @param z defines the z coordinate
  4182. * @param w defines the w coordinate
  4183. * @returns the updated current quaternion
  4184. */
  4185. set(x: number, y: number, z: number, w: number): Quaternion;
  4186. /**
  4187. * Adds two quaternions
  4188. * @param other defines the second operand
  4189. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4190. */
  4191. add(other: DeepImmutable<Quaternion>): Quaternion;
  4192. /**
  4193. * Add a quaternion to the current one
  4194. * @param other defines the quaternion to add
  4195. * @returns the current quaternion
  4196. */
  4197. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4198. /**
  4199. * Subtract two quaternions
  4200. * @param other defines the second operand
  4201. * @returns a new quaternion as the subtraction result of the given one from the current one
  4202. */
  4203. subtract(other: Quaternion): Quaternion;
  4204. /**
  4205. * Multiplies the current quaternion by a scale factor
  4206. * @param value defines the scale factor
  4207. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4208. */
  4209. scale(value: number): Quaternion;
  4210. /**
  4211. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4212. * @param scale defines the scale factor
  4213. * @param result defines the Quaternion object where to store the result
  4214. * @returns the unmodified current quaternion
  4215. */
  4216. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4217. /**
  4218. * Multiplies in place the current quaternion by a scale factor
  4219. * @param value defines the scale factor
  4220. * @returns the current modified quaternion
  4221. */
  4222. scaleInPlace(value: number): Quaternion;
  4223. /**
  4224. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4225. * @param scale defines the scale factor
  4226. * @param result defines the Quaternion object where to store the result
  4227. * @returns the unmodified current quaternion
  4228. */
  4229. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4230. /**
  4231. * Multiplies two quaternions
  4232. * @param q1 defines the second operand
  4233. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4234. */
  4235. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4236. /**
  4237. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4238. * @param q1 defines the second operand
  4239. * @param result defines the target quaternion
  4240. * @returns the current quaternion
  4241. */
  4242. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4243. /**
  4244. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4245. * @param q1 defines the second operand
  4246. * @returns the currentupdated quaternion
  4247. */
  4248. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4249. /**
  4250. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4251. * @param ref defines the target quaternion
  4252. * @returns the current quaternion
  4253. */
  4254. conjugateToRef(ref: Quaternion): Quaternion;
  4255. /**
  4256. * Conjugates in place (1-q) the current quaternion
  4257. * @returns the current updated quaternion
  4258. */
  4259. conjugateInPlace(): Quaternion;
  4260. /**
  4261. * Conjugates in place (1-q) the current quaternion
  4262. * @returns a new quaternion
  4263. */
  4264. conjugate(): Quaternion;
  4265. /**
  4266. * Gets length of current quaternion
  4267. * @returns the quaternion length (float)
  4268. */
  4269. length(): number;
  4270. /**
  4271. * Normalize in place the current quaternion
  4272. * @returns the current updated quaternion
  4273. */
  4274. normalize(): Quaternion;
  4275. /**
  4276. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4277. * @param order is a reserved parameter and is ignored for now
  4278. * @returns a new Vector3 containing the Euler angles
  4279. */
  4280. toEulerAngles(order?: string): Vector3;
  4281. /**
  4282. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4283. * @param result defines the vector which will be filled with the Euler angles
  4284. * @returns the current unchanged quaternion
  4285. */
  4286. toEulerAnglesToRef(result: Vector3): Quaternion;
  4287. /**
  4288. * Updates the given rotation matrix with the current quaternion values
  4289. * @param result defines the target matrix
  4290. * @returns the current unchanged quaternion
  4291. */
  4292. toRotationMatrix(result: Matrix): Quaternion;
  4293. /**
  4294. * Updates the current quaternion from the given rotation matrix values
  4295. * @param matrix defines the source matrix
  4296. * @returns the current updated quaternion
  4297. */
  4298. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4299. /**
  4300. * Creates a new quaternion from a rotation matrix
  4301. * @param matrix defines the source matrix
  4302. * @returns a new quaternion created from the given rotation matrix values
  4303. */
  4304. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4305. /**
  4306. * Updates the given quaternion with the given rotation matrix values
  4307. * @param matrix defines the source matrix
  4308. * @param result defines the target quaternion
  4309. */
  4310. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4311. /**
  4312. * Returns the dot product (float) between the quaternions "left" and "right"
  4313. * @param left defines the left operand
  4314. * @param right defines the right operand
  4315. * @returns the dot product
  4316. */
  4317. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4318. /**
  4319. * Checks if the two quaternions are close to each other
  4320. * @param quat0 defines the first quaternion to check
  4321. * @param quat1 defines the second quaternion to check
  4322. * @returns true if the two quaternions are close to each other
  4323. */
  4324. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4325. /**
  4326. * Creates an empty quaternion
  4327. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4328. */
  4329. static Zero(): Quaternion;
  4330. /**
  4331. * Inverse a given quaternion
  4332. * @param q defines the source quaternion
  4333. * @returns a new quaternion as the inverted current quaternion
  4334. */
  4335. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4336. /**
  4337. * Inverse a given quaternion
  4338. * @param q defines the source quaternion
  4339. * @param result the quaternion the result will be stored in
  4340. * @returns the result quaternion
  4341. */
  4342. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4343. /**
  4344. * Creates an identity quaternion
  4345. * @returns the identity quaternion
  4346. */
  4347. static Identity(): Quaternion;
  4348. /**
  4349. * Gets a boolean indicating if the given quaternion is identity
  4350. * @param quaternion defines the quaternion to check
  4351. * @returns true if the quaternion is identity
  4352. */
  4353. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4354. /**
  4355. * Creates a quaternion from a rotation around an axis
  4356. * @param axis defines the axis to use
  4357. * @param angle defines the angle to use
  4358. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4359. */
  4360. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4361. /**
  4362. * Creates a rotation around an axis and stores it into the given quaternion
  4363. * @param axis defines the axis to use
  4364. * @param angle defines the angle to use
  4365. * @param result defines the target quaternion
  4366. * @returns the target quaternion
  4367. */
  4368. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4369. /**
  4370. * Creates a new quaternion from data stored into an array
  4371. * @param array defines the data source
  4372. * @param offset defines the offset in the source array where the data starts
  4373. * @returns a new quaternion
  4374. */
  4375. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4376. /**
  4377. * Updates the given quaternion "result" from the starting index of the given array.
  4378. * @param array the array to pull values from
  4379. * @param offset the offset into the array to start at
  4380. * @param result the quaternion to store the result in
  4381. */
  4382. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4383. /**
  4384. * Create a quaternion from Euler rotation angles
  4385. * @param x Pitch
  4386. * @param y Yaw
  4387. * @param z Roll
  4388. * @returns the new Quaternion
  4389. */
  4390. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4391. /**
  4392. * Updates a quaternion from Euler rotation angles
  4393. * @param x Pitch
  4394. * @param y Yaw
  4395. * @param z Roll
  4396. * @param result the quaternion to store the result
  4397. * @returns the updated quaternion
  4398. */
  4399. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4400. /**
  4401. * Create a quaternion from Euler rotation vector
  4402. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4403. * @returns the new Quaternion
  4404. */
  4405. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4406. /**
  4407. * Updates a quaternion from Euler rotation vector
  4408. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4409. * @param result the quaternion to store the result
  4410. * @returns the updated quaternion
  4411. */
  4412. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4413. /**
  4414. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4415. * @param yaw defines the rotation around Y axis
  4416. * @param pitch defines the rotation around X axis
  4417. * @param roll defines the rotation around Z axis
  4418. * @returns the new quaternion
  4419. */
  4420. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4421. /**
  4422. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4423. * @param yaw defines the rotation around Y axis
  4424. * @param pitch defines the rotation around X axis
  4425. * @param roll defines the rotation around Z axis
  4426. * @param result defines the target quaternion
  4427. */
  4428. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4429. /**
  4430. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4431. * @param alpha defines the rotation around first axis
  4432. * @param beta defines the rotation around second axis
  4433. * @param gamma defines the rotation around third axis
  4434. * @returns the new quaternion
  4435. */
  4436. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4437. /**
  4438. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4439. * @param alpha defines the rotation around first axis
  4440. * @param beta defines the rotation around second axis
  4441. * @param gamma defines the rotation around third axis
  4442. * @param result defines the target quaternion
  4443. */
  4444. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4445. /**
  4446. * 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)
  4447. * @param axis1 defines the first axis
  4448. * @param axis2 defines the second axis
  4449. * @param axis3 defines the third axis
  4450. * @returns the new quaternion
  4451. */
  4452. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4453. /**
  4454. * 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
  4455. * @param axis1 defines the first axis
  4456. * @param axis2 defines the second axis
  4457. * @param axis3 defines the third axis
  4458. * @param ref defines the target quaternion
  4459. */
  4460. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4461. /**
  4462. * Interpolates between two quaternions
  4463. * @param left defines first quaternion
  4464. * @param right defines second quaternion
  4465. * @param amount defines the gradient to use
  4466. * @returns the new interpolated quaternion
  4467. */
  4468. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4469. /**
  4470. * Interpolates between two quaternions and stores it into a target quaternion
  4471. * @param left defines first quaternion
  4472. * @param right defines second quaternion
  4473. * @param amount defines the gradient to use
  4474. * @param result defines the target quaternion
  4475. */
  4476. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4477. /**
  4478. * Interpolate between two quaternions using Hermite interpolation
  4479. * @param value1 defines first quaternion
  4480. * @param tangent1 defines the incoming tangent
  4481. * @param value2 defines second quaternion
  4482. * @param tangent2 defines the outgoing tangent
  4483. * @param amount defines the target quaternion
  4484. * @returns the new interpolated quaternion
  4485. */
  4486. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4487. }
  4488. /**
  4489. * Class used to store matrix data (4x4)
  4490. */
  4491. export class Matrix {
  4492. /**
  4493. * Gets the precision of matrix computations
  4494. */
  4495. static get Use64Bits(): boolean;
  4496. private static _updateFlagSeed;
  4497. private static _identityReadOnly;
  4498. private _isIdentity;
  4499. private _isIdentityDirty;
  4500. private _isIdentity3x2;
  4501. private _isIdentity3x2Dirty;
  4502. /**
  4503. * Gets the update flag of the matrix which is an unique number for the matrix.
  4504. * It will be incremented every time the matrix data change.
  4505. * You can use it to speed the comparison between two versions of the same matrix.
  4506. */
  4507. updateFlag: number;
  4508. private readonly _m;
  4509. /**
  4510. * Gets the internal data of the matrix
  4511. */
  4512. get m(): DeepImmutable<Float32Array | Array<number>>;
  4513. /** @hidden */
  4514. _markAsUpdated(): void;
  4515. /** @hidden */
  4516. private _updateIdentityStatus;
  4517. /**
  4518. * Creates an empty matrix (filled with zeros)
  4519. */
  4520. constructor();
  4521. /**
  4522. * Check if the current matrix is identity
  4523. * @returns true is the matrix is the identity matrix
  4524. */
  4525. isIdentity(): boolean;
  4526. /**
  4527. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4528. * @returns true is the matrix is the identity matrix
  4529. */
  4530. isIdentityAs3x2(): boolean;
  4531. /**
  4532. * Gets the determinant of the matrix
  4533. * @returns the matrix determinant
  4534. */
  4535. determinant(): number;
  4536. /**
  4537. * Returns the matrix as a Float32Array or Array<number>
  4538. * @returns the matrix underlying array
  4539. */
  4540. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4541. /**
  4542. * Returns the matrix as a Float32Array or Array<number>
  4543. * @returns the matrix underlying array.
  4544. */
  4545. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4546. /**
  4547. * Inverts the current matrix in place
  4548. * @returns the current inverted matrix
  4549. */
  4550. invert(): Matrix;
  4551. /**
  4552. * Sets all the matrix elements to zero
  4553. * @returns the current matrix
  4554. */
  4555. reset(): Matrix;
  4556. /**
  4557. * Adds the current matrix with a second one
  4558. * @param other defines the matrix to add
  4559. * @returns a new matrix as the addition of the current matrix and the given one
  4560. */
  4561. add(other: DeepImmutable<Matrix>): Matrix;
  4562. /**
  4563. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4564. * @param other defines the matrix to add
  4565. * @param result defines the target matrix
  4566. * @returns the current matrix
  4567. */
  4568. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4569. /**
  4570. * Adds in place the given matrix to the current matrix
  4571. * @param other defines the second operand
  4572. * @returns the current updated matrix
  4573. */
  4574. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4575. /**
  4576. * Sets the given matrix to the current inverted Matrix
  4577. * @param other defines the target matrix
  4578. * @returns the unmodified current matrix
  4579. */
  4580. invertToRef(other: Matrix): Matrix;
  4581. /**
  4582. * add a value at the specified position in the current Matrix
  4583. * @param index the index of the value within the matrix. between 0 and 15.
  4584. * @param value the value to be added
  4585. * @returns the current updated matrix
  4586. */
  4587. addAtIndex(index: number, value: number): Matrix;
  4588. /**
  4589. * mutiply the specified position in the current Matrix by a value
  4590. * @param index the index of the value within the matrix. between 0 and 15.
  4591. * @param value the value to be added
  4592. * @returns the current updated matrix
  4593. */
  4594. multiplyAtIndex(index: number, value: number): Matrix;
  4595. /**
  4596. * Inserts the translation vector (using 3 floats) in the current matrix
  4597. * @param x defines the 1st component of the translation
  4598. * @param y defines the 2nd component of the translation
  4599. * @param z defines the 3rd component of the translation
  4600. * @returns the current updated matrix
  4601. */
  4602. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4603. /**
  4604. * Adds the translation vector (using 3 floats) in the current matrix
  4605. * @param x defines the 1st component of the translation
  4606. * @param y defines the 2nd component of the translation
  4607. * @param z defines the 3rd component of the translation
  4608. * @returns the current updated matrix
  4609. */
  4610. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4611. /**
  4612. * Inserts the translation vector in the current matrix
  4613. * @param vector3 defines the translation to insert
  4614. * @returns the current updated matrix
  4615. */
  4616. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4617. /**
  4618. * Gets the translation value of the current matrix
  4619. * @returns a new Vector3 as the extracted translation from the matrix
  4620. */
  4621. getTranslation(): Vector3;
  4622. /**
  4623. * Fill a Vector3 with the extracted translation from the matrix
  4624. * @param result defines the Vector3 where to store the translation
  4625. * @returns the current matrix
  4626. */
  4627. getTranslationToRef(result: Vector3): Matrix;
  4628. /**
  4629. * Remove rotation and scaling part from the matrix
  4630. * @returns the updated matrix
  4631. */
  4632. removeRotationAndScaling(): Matrix;
  4633. /**
  4634. * Multiply two matrices
  4635. * @param other defines the second operand
  4636. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4637. */
  4638. multiply(other: DeepImmutable<Matrix>): Matrix;
  4639. /**
  4640. * Copy the current matrix from the given one
  4641. * @param other defines the source matrix
  4642. * @returns the current updated matrix
  4643. */
  4644. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4645. /**
  4646. * Populates the given array from the starting index with the current matrix values
  4647. * @param array defines the target array
  4648. * @param offset defines the offset in the target array where to start storing values
  4649. * @returns the current matrix
  4650. */
  4651. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4652. /**
  4653. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4654. * @param other defines the second operand
  4655. * @param result defines the matrix where to store the multiplication
  4656. * @returns the current matrix
  4657. */
  4658. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4659. /**
  4660. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4661. * @param other defines the second operand
  4662. * @param result defines the array where to store the multiplication
  4663. * @param offset defines the offset in the target array where to start storing values
  4664. * @returns the current matrix
  4665. */
  4666. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4667. /**
  4668. * Check equality between this matrix and a second one
  4669. * @param value defines the second matrix to compare
  4670. * @returns true is the current matrix and the given one values are strictly equal
  4671. */
  4672. equals(value: DeepImmutable<Matrix>): boolean;
  4673. /**
  4674. * Clone the current matrix
  4675. * @returns a new matrix from the current matrix
  4676. */
  4677. clone(): Matrix;
  4678. /**
  4679. * Returns the name of the current matrix class
  4680. * @returns the string "Matrix"
  4681. */
  4682. getClassName(): string;
  4683. /**
  4684. * Gets the hash code of the current matrix
  4685. * @returns the hash code
  4686. */
  4687. getHashCode(): number;
  4688. /**
  4689. * Decomposes the current Matrix into a translation, rotation and scaling components
  4690. * @param scale defines the scale vector3 given as a reference to update
  4691. * @param rotation defines the rotation quaternion given as a reference to update
  4692. * @param translation defines the translation vector3 given as a reference to update
  4693. * @returns true if operation was successful
  4694. */
  4695. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4696. /**
  4697. * Gets specific row of the matrix
  4698. * @param index defines the number of the row to get
  4699. * @returns the index-th row of the current matrix as a new Vector4
  4700. */
  4701. getRow(index: number): Nullable<Vector4>;
  4702. /**
  4703. * Sets the index-th row of the current matrix to the vector4 values
  4704. * @param index defines the number of the row to set
  4705. * @param row defines the target vector4
  4706. * @returns the updated current matrix
  4707. */
  4708. setRow(index: number, row: Vector4): Matrix;
  4709. /**
  4710. * Compute the transpose of the matrix
  4711. * @returns the new transposed matrix
  4712. */
  4713. transpose(): Matrix;
  4714. /**
  4715. * Compute the transpose of the matrix and store it in a given matrix
  4716. * @param result defines the target matrix
  4717. * @returns the current matrix
  4718. */
  4719. transposeToRef(result: Matrix): Matrix;
  4720. /**
  4721. * Sets the index-th row of the current matrix with the given 4 x float values
  4722. * @param index defines the row index
  4723. * @param x defines the x component to set
  4724. * @param y defines the y component to set
  4725. * @param z defines the z component to set
  4726. * @param w defines the w component to set
  4727. * @returns the updated current matrix
  4728. */
  4729. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4730. /**
  4731. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4732. * @param scale defines the scale factor
  4733. * @returns a new matrix
  4734. */
  4735. scale(scale: number): Matrix;
  4736. /**
  4737. * Scale the current matrix values by a factor to a given result matrix
  4738. * @param scale defines the scale factor
  4739. * @param result defines the matrix to store the result
  4740. * @returns the current matrix
  4741. */
  4742. scaleToRef(scale: number, result: Matrix): Matrix;
  4743. /**
  4744. * Scale the current matrix values by a factor and add the result to a given matrix
  4745. * @param scale defines the scale factor
  4746. * @param result defines the Matrix to store the result
  4747. * @returns the current matrix
  4748. */
  4749. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4750. /**
  4751. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4752. * @param ref matrix to store the result
  4753. */
  4754. toNormalMatrix(ref: Matrix): void;
  4755. /**
  4756. * Gets only rotation part of the current matrix
  4757. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4758. */
  4759. getRotationMatrix(): Matrix;
  4760. /**
  4761. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4762. * @param result defines the target matrix to store data to
  4763. * @returns the current matrix
  4764. */
  4765. getRotationMatrixToRef(result: Matrix): Matrix;
  4766. /**
  4767. * Toggles model matrix from being right handed to left handed in place and vice versa
  4768. */
  4769. toggleModelMatrixHandInPlace(): void;
  4770. /**
  4771. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4772. */
  4773. toggleProjectionMatrixHandInPlace(): void;
  4774. /**
  4775. * Creates a matrix from an array
  4776. * @param array defines the source array
  4777. * @param offset defines an offset in the source array
  4778. * @returns a new Matrix set from the starting index of the given array
  4779. */
  4780. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4781. /**
  4782. * Copy the content of an array into a given matrix
  4783. * @param array defines the source array
  4784. * @param offset defines an offset in the source array
  4785. * @param result defines the target matrix
  4786. */
  4787. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4788. /**
  4789. * Stores an array into a matrix after having multiplied each component by a given factor
  4790. * @param array defines the source array
  4791. * @param offset defines the offset in the source array
  4792. * @param scale defines the scaling factor
  4793. * @param result defines the target matrix
  4794. */
  4795. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4796. /**
  4797. * Gets an identity matrix that must not be updated
  4798. */
  4799. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4800. /**
  4801. * Stores a list of values (16) inside a given matrix
  4802. * @param initialM11 defines 1st value of 1st row
  4803. * @param initialM12 defines 2nd value of 1st row
  4804. * @param initialM13 defines 3rd value of 1st row
  4805. * @param initialM14 defines 4th value of 1st row
  4806. * @param initialM21 defines 1st value of 2nd row
  4807. * @param initialM22 defines 2nd value of 2nd row
  4808. * @param initialM23 defines 3rd value of 2nd row
  4809. * @param initialM24 defines 4th value of 2nd row
  4810. * @param initialM31 defines 1st value of 3rd row
  4811. * @param initialM32 defines 2nd value of 3rd row
  4812. * @param initialM33 defines 3rd value of 3rd row
  4813. * @param initialM34 defines 4th value of 3rd row
  4814. * @param initialM41 defines 1st value of 4th row
  4815. * @param initialM42 defines 2nd value of 4th row
  4816. * @param initialM43 defines 3rd value of 4th row
  4817. * @param initialM44 defines 4th value of 4th row
  4818. * @param result defines the target matrix
  4819. */
  4820. 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;
  4821. /**
  4822. * Creates new matrix from a list of values (16)
  4823. * @param initialM11 defines 1st value of 1st row
  4824. * @param initialM12 defines 2nd value of 1st row
  4825. * @param initialM13 defines 3rd value of 1st row
  4826. * @param initialM14 defines 4th value of 1st row
  4827. * @param initialM21 defines 1st value of 2nd row
  4828. * @param initialM22 defines 2nd value of 2nd row
  4829. * @param initialM23 defines 3rd value of 2nd row
  4830. * @param initialM24 defines 4th value of 2nd row
  4831. * @param initialM31 defines 1st value of 3rd row
  4832. * @param initialM32 defines 2nd value of 3rd row
  4833. * @param initialM33 defines 3rd value of 3rd row
  4834. * @param initialM34 defines 4th value of 3rd row
  4835. * @param initialM41 defines 1st value of 4th row
  4836. * @param initialM42 defines 2nd value of 4th row
  4837. * @param initialM43 defines 3rd value of 4th row
  4838. * @param initialM44 defines 4th value of 4th row
  4839. * @returns the new matrix
  4840. */
  4841. 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;
  4842. /**
  4843. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4844. * @param scale defines the scale vector3
  4845. * @param rotation defines the rotation quaternion
  4846. * @param translation defines the translation vector3
  4847. * @returns a new matrix
  4848. */
  4849. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4850. /**
  4851. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4852. * @param scale defines the scale vector3
  4853. * @param rotation defines the rotation quaternion
  4854. * @param translation defines the translation vector3
  4855. * @param result defines the target matrix
  4856. */
  4857. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4858. /**
  4859. * Creates a new identity matrix
  4860. * @returns a new identity matrix
  4861. */
  4862. static Identity(): Matrix;
  4863. /**
  4864. * Creates a new identity matrix and stores the result in a given matrix
  4865. * @param result defines the target matrix
  4866. */
  4867. static IdentityToRef(result: Matrix): void;
  4868. /**
  4869. * Creates a new zero matrix
  4870. * @returns a new zero matrix
  4871. */
  4872. static Zero(): Matrix;
  4873. /**
  4874. * Creates a new rotation matrix for "angle" radians around the X axis
  4875. * @param angle defines the angle (in radians) to use
  4876. * @return the new matrix
  4877. */
  4878. static RotationX(angle: number): Matrix;
  4879. /**
  4880. * Creates a new matrix as the invert of a given matrix
  4881. * @param source defines the source matrix
  4882. * @returns the new matrix
  4883. */
  4884. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4885. /**
  4886. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4887. * @param angle defines the angle (in radians) to use
  4888. * @param result defines the target matrix
  4889. */
  4890. static RotationXToRef(angle: number, result: Matrix): void;
  4891. /**
  4892. * Creates a new rotation matrix for "angle" radians around the Y axis
  4893. * @param angle defines the angle (in radians) to use
  4894. * @return the new matrix
  4895. */
  4896. static RotationY(angle: number): Matrix;
  4897. /**
  4898. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4899. * @param angle defines the angle (in radians) to use
  4900. * @param result defines the target matrix
  4901. */
  4902. static RotationYToRef(angle: number, result: Matrix): void;
  4903. /**
  4904. * Creates a new rotation matrix for "angle" radians around the Z axis
  4905. * @param angle defines the angle (in radians) to use
  4906. * @return the new matrix
  4907. */
  4908. static RotationZ(angle: number): Matrix;
  4909. /**
  4910. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4911. * @param angle defines the angle (in radians) to use
  4912. * @param result defines the target matrix
  4913. */
  4914. static RotationZToRef(angle: number, result: Matrix): void;
  4915. /**
  4916. * Creates a new rotation matrix for "angle" radians around the given axis
  4917. * @param axis defines the axis to use
  4918. * @param angle defines the angle (in radians) to use
  4919. * @return the new matrix
  4920. */
  4921. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4922. /**
  4923. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4924. * @param axis defines the axis to use
  4925. * @param angle defines the angle (in radians) to use
  4926. * @param result defines the target matrix
  4927. */
  4928. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4929. /**
  4930. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4931. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4932. * @param from defines the vector to align
  4933. * @param to defines the vector to align to
  4934. * @param result defines the target matrix
  4935. */
  4936. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4937. /**
  4938. * Creates a rotation matrix
  4939. * @param yaw defines the yaw angle in radians (Y axis)
  4940. * @param pitch defines the pitch angle in radians (X axis)
  4941. * @param roll defines the roll angle in radians (Z axis)
  4942. * @returns the new rotation matrix
  4943. */
  4944. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4945. /**
  4946. * Creates a rotation matrix and stores it in a given matrix
  4947. * @param yaw defines the yaw angle in radians (Y axis)
  4948. * @param pitch defines the pitch angle in radians (X axis)
  4949. * @param roll defines the roll angle in radians (Z axis)
  4950. * @param result defines the target matrix
  4951. */
  4952. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4953. /**
  4954. * Creates a scaling matrix
  4955. * @param x defines the scale factor on X axis
  4956. * @param y defines the scale factor on Y axis
  4957. * @param z defines the scale factor on Z axis
  4958. * @returns the new matrix
  4959. */
  4960. static Scaling(x: number, y: number, z: number): Matrix;
  4961. /**
  4962. * Creates a scaling matrix and stores it in a given matrix
  4963. * @param x defines the scale factor on X axis
  4964. * @param y defines the scale factor on Y axis
  4965. * @param z defines the scale factor on Z axis
  4966. * @param result defines the target matrix
  4967. */
  4968. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4969. /**
  4970. * Creates a translation matrix
  4971. * @param x defines the translation on X axis
  4972. * @param y defines the translation on Y axis
  4973. * @param z defines the translationon Z axis
  4974. * @returns the new matrix
  4975. */
  4976. static Translation(x: number, y: number, z: number): Matrix;
  4977. /**
  4978. * Creates a translation matrix and stores it in a given matrix
  4979. * @param x defines the translation on X axis
  4980. * @param y defines the translation on Y axis
  4981. * @param z defines the translationon Z axis
  4982. * @param result defines the target matrix
  4983. */
  4984. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4985. /**
  4986. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4987. * @param startValue defines the start value
  4988. * @param endValue defines the end value
  4989. * @param gradient defines the gradient factor
  4990. * @returns the new matrix
  4991. */
  4992. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4993. /**
  4994. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4995. * @param startValue defines the start value
  4996. * @param endValue defines the end value
  4997. * @param gradient defines the gradient factor
  4998. * @param result defines the Matrix object where to store data
  4999. */
  5000. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5001. /**
  5002. * Builds a new matrix whose values are computed by:
  5003. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5004. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5005. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5006. * @param startValue defines the first matrix
  5007. * @param endValue defines the second matrix
  5008. * @param gradient defines the gradient between the two matrices
  5009. * @returns the new matrix
  5010. */
  5011. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5012. /**
  5013. * Update a matrix to values which are computed by:
  5014. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5015. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5016. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5017. * @param startValue defines the first matrix
  5018. * @param endValue defines the second matrix
  5019. * @param gradient defines the gradient between the two matrices
  5020. * @param result defines the target matrix
  5021. */
  5022. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5023. /**
  5024. * 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"
  5025. * This function works in left handed mode
  5026. * @param eye defines the final position of the entity
  5027. * @param target defines where the entity should look at
  5028. * @param up defines the up vector for the entity
  5029. * @returns the new matrix
  5030. */
  5031. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5032. /**
  5033. * 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".
  5034. * This function works in left handed mode
  5035. * @param eye defines the final position of the entity
  5036. * @param target defines where the entity should look at
  5037. * @param up defines the up vector for the entity
  5038. * @param result defines the target matrix
  5039. */
  5040. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5041. /**
  5042. * 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"
  5043. * This function works in right handed mode
  5044. * @param eye defines the final position of the entity
  5045. * @param target defines where the entity should look at
  5046. * @param up defines the up vector for the entity
  5047. * @returns the new matrix
  5048. */
  5049. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5050. /**
  5051. * 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".
  5052. * This function works in right handed mode
  5053. * @param eye defines the final position of the entity
  5054. * @param target defines where the entity should look at
  5055. * @param up defines the up vector for the entity
  5056. * @param result defines the target matrix
  5057. */
  5058. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5059. /**
  5060. * Create a left-handed orthographic projection matrix
  5061. * @param width defines the viewport width
  5062. * @param height defines the viewport height
  5063. * @param znear defines the near clip plane
  5064. * @param zfar defines the far clip plane
  5065. * @returns a new matrix as a left-handed orthographic projection matrix
  5066. */
  5067. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5068. /**
  5069. * Store a left-handed orthographic projection to a given matrix
  5070. * @param width defines the viewport width
  5071. * @param height defines the viewport height
  5072. * @param znear defines the near clip plane
  5073. * @param zfar defines the far clip plane
  5074. * @param result defines the target matrix
  5075. */
  5076. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5077. /**
  5078. * Create a left-handed orthographic projection matrix
  5079. * @param left defines the viewport left coordinate
  5080. * @param right defines the viewport right coordinate
  5081. * @param bottom defines the viewport bottom coordinate
  5082. * @param top defines the viewport top coordinate
  5083. * @param znear defines the near clip plane
  5084. * @param zfar defines the far clip plane
  5085. * @returns a new matrix as a left-handed orthographic projection matrix
  5086. */
  5087. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5088. /**
  5089. * Stores a left-handed orthographic projection into a given matrix
  5090. * @param left defines the viewport left coordinate
  5091. * @param right defines the viewport right coordinate
  5092. * @param bottom defines the viewport bottom coordinate
  5093. * @param top defines the viewport top coordinate
  5094. * @param znear defines the near clip plane
  5095. * @param zfar defines the far clip plane
  5096. * @param result defines the target matrix
  5097. */
  5098. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5099. /**
  5100. * Creates a right-handed orthographic projection matrix
  5101. * @param left defines the viewport left coordinate
  5102. * @param right defines the viewport right coordinate
  5103. * @param bottom defines the viewport bottom coordinate
  5104. * @param top defines the viewport top coordinate
  5105. * @param znear defines the near clip plane
  5106. * @param zfar defines the far clip plane
  5107. * @returns a new matrix as a right-handed orthographic projection matrix
  5108. */
  5109. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5110. /**
  5111. * Stores a right-handed orthographic projection into a given matrix
  5112. * @param left defines the viewport left coordinate
  5113. * @param right defines the viewport right coordinate
  5114. * @param bottom defines the viewport bottom coordinate
  5115. * @param top defines the viewport top coordinate
  5116. * @param znear defines the near clip plane
  5117. * @param zfar defines the far clip plane
  5118. * @param result defines the target matrix
  5119. */
  5120. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5121. /**
  5122. * Creates a left-handed perspective projection matrix
  5123. * @param width defines the viewport width
  5124. * @param height defines the viewport height
  5125. * @param znear defines the near clip plane
  5126. * @param zfar defines the far clip plane
  5127. * @returns a new matrix as a left-handed perspective projection matrix
  5128. */
  5129. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5130. /**
  5131. * Creates a left-handed perspective projection matrix
  5132. * @param fov defines the horizontal field of view
  5133. * @param aspect defines the aspect ratio
  5134. * @param znear defines the near clip plane
  5135. * @param zfar defines the far clip plane
  5136. * @returns a new matrix as a left-handed perspective projection matrix
  5137. */
  5138. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5139. /**
  5140. * Stores a left-handed perspective projection into a given matrix
  5141. * @param fov defines the horizontal field of view
  5142. * @param aspect defines the aspect ratio
  5143. * @param znear defines the near clip plane
  5144. * @param zfar defines the far clip plane
  5145. * @param result defines the target matrix
  5146. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5147. */
  5148. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5149. /**
  5150. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5151. * @param fov defines the horizontal field of view
  5152. * @param aspect defines the aspect ratio
  5153. * @param znear defines the near clip plane
  5154. * @param zfar not used as infinity is used as far clip
  5155. * @param result defines the target matrix
  5156. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5157. */
  5158. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5159. /**
  5160. * Creates a right-handed perspective projection matrix
  5161. * @param fov defines the horizontal field of view
  5162. * @param aspect defines the aspect ratio
  5163. * @param znear defines the near clip plane
  5164. * @param zfar defines the far clip plane
  5165. * @returns a new matrix as a right-handed perspective projection matrix
  5166. */
  5167. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5168. /**
  5169. * Stores a right-handed perspective projection into a given matrix
  5170. * @param fov defines the horizontal field of view
  5171. * @param aspect defines the aspect ratio
  5172. * @param znear defines the near clip plane
  5173. * @param zfar defines the far clip plane
  5174. * @param result defines the target matrix
  5175. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5176. */
  5177. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5178. /**
  5179. * Stores a right-handed perspective projection into a given matrix
  5180. * @param fov defines the horizontal field of view
  5181. * @param aspect defines the aspect ratio
  5182. * @param znear defines the near clip plane
  5183. * @param zfar not used as infinity is used as far clip
  5184. * @param result defines the target matrix
  5185. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5186. */
  5187. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5188. /**
  5189. * Stores a perspective projection for WebVR info a given matrix
  5190. * @param fov defines the field of view
  5191. * @param znear defines the near clip plane
  5192. * @param zfar defines the far clip plane
  5193. * @param result defines the target matrix
  5194. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5195. */
  5196. static PerspectiveFovWebVRToRef(fov: {
  5197. upDegrees: number;
  5198. downDegrees: number;
  5199. leftDegrees: number;
  5200. rightDegrees: number;
  5201. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5202. /**
  5203. * Computes a complete transformation matrix
  5204. * @param viewport defines the viewport to use
  5205. * @param world defines the world matrix
  5206. * @param view defines the view matrix
  5207. * @param projection defines the projection matrix
  5208. * @param zmin defines the near clip plane
  5209. * @param zmax defines the far clip plane
  5210. * @returns the transformation matrix
  5211. */
  5212. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5213. /**
  5214. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5215. * @param matrix defines the matrix to use
  5216. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5217. */
  5218. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5219. /**
  5220. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5221. * @param matrix defines the matrix to use
  5222. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5223. */
  5224. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5225. /**
  5226. * Compute the transpose of a given matrix
  5227. * @param matrix defines the matrix to transpose
  5228. * @returns the new matrix
  5229. */
  5230. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5231. /**
  5232. * Compute the transpose of a matrix and store it in a target matrix
  5233. * @param matrix defines the matrix to transpose
  5234. * @param result defines the target matrix
  5235. */
  5236. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5237. /**
  5238. * Computes a reflection matrix from a plane
  5239. * @param plane defines the reflection plane
  5240. * @returns a new matrix
  5241. */
  5242. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5243. /**
  5244. * Computes a reflection matrix from a plane
  5245. * @param plane defines the reflection plane
  5246. * @param result defines the target matrix
  5247. */
  5248. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5249. /**
  5250. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5251. * @param xaxis defines the value of the 1st axis
  5252. * @param yaxis defines the value of the 2nd axis
  5253. * @param zaxis defines the value of the 3rd axis
  5254. * @param result defines the target matrix
  5255. */
  5256. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5257. /**
  5258. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5259. * @param quat defines the quaternion to use
  5260. * @param result defines the target matrix
  5261. */
  5262. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5263. }
  5264. /**
  5265. * @hidden
  5266. */
  5267. export class TmpVectors {
  5268. static Vector2: Vector2[];
  5269. static Vector3: Vector3[];
  5270. static Vector4: Vector4[];
  5271. static Quaternion: Quaternion[];
  5272. static Matrix: Matrix[];
  5273. }
  5274. }
  5275. declare module "babylonjs/Maths/math.path" {
  5276. import { DeepImmutable, Nullable } from "babylonjs/types";
  5277. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5278. /**
  5279. * Defines potential orientation for back face culling
  5280. */
  5281. export enum Orientation {
  5282. /**
  5283. * Clockwise
  5284. */
  5285. CW = 0,
  5286. /** Counter clockwise */
  5287. CCW = 1
  5288. }
  5289. /** Class used to represent a Bezier curve */
  5290. export class BezierCurve {
  5291. /**
  5292. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5293. * @param t defines the time
  5294. * @param x1 defines the left coordinate on X axis
  5295. * @param y1 defines the left coordinate on Y axis
  5296. * @param x2 defines the right coordinate on X axis
  5297. * @param y2 defines the right coordinate on Y axis
  5298. * @returns the interpolated value
  5299. */
  5300. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5301. }
  5302. /**
  5303. * Defines angle representation
  5304. */
  5305. export class Angle {
  5306. private _radians;
  5307. /**
  5308. * Creates an Angle object of "radians" radians (float).
  5309. * @param radians the angle in radians
  5310. */
  5311. constructor(radians: number);
  5312. /**
  5313. * Get value in degrees
  5314. * @returns the Angle value in degrees (float)
  5315. */
  5316. degrees(): number;
  5317. /**
  5318. * Get value in radians
  5319. * @returns the Angle value in radians (float)
  5320. */
  5321. radians(): number;
  5322. /**
  5323. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5324. * @param a defines first point as the origin
  5325. * @param b defines point
  5326. * @returns a new Angle
  5327. */
  5328. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5329. /**
  5330. * Gets a new Angle object from the given float in radians
  5331. * @param radians defines the angle value in radians
  5332. * @returns a new Angle
  5333. */
  5334. static FromRadians(radians: number): Angle;
  5335. /**
  5336. * Gets a new Angle object from the given float in degrees
  5337. * @param degrees defines the angle value in degrees
  5338. * @returns a new Angle
  5339. */
  5340. static FromDegrees(degrees: number): Angle;
  5341. }
  5342. /**
  5343. * This represents an arc in a 2d space.
  5344. */
  5345. export class Arc2 {
  5346. /** Defines the start point of the arc */
  5347. startPoint: Vector2;
  5348. /** Defines the mid point of the arc */
  5349. midPoint: Vector2;
  5350. /** Defines the end point of the arc */
  5351. endPoint: Vector2;
  5352. /**
  5353. * Defines the center point of the arc.
  5354. */
  5355. centerPoint: Vector2;
  5356. /**
  5357. * Defines the radius of the arc.
  5358. */
  5359. radius: number;
  5360. /**
  5361. * Defines the angle of the arc (from mid point to end point).
  5362. */
  5363. angle: Angle;
  5364. /**
  5365. * Defines the start angle of the arc (from start point to middle point).
  5366. */
  5367. startAngle: Angle;
  5368. /**
  5369. * Defines the orientation of the arc (clock wise/counter clock wise).
  5370. */
  5371. orientation: Orientation;
  5372. /**
  5373. * Creates an Arc object from the three given points : start, middle and end.
  5374. * @param startPoint Defines the start point of the arc
  5375. * @param midPoint Defines the midlle point of the arc
  5376. * @param endPoint Defines the end point of the arc
  5377. */
  5378. constructor(
  5379. /** Defines the start point of the arc */
  5380. startPoint: Vector2,
  5381. /** Defines the mid point of the arc */
  5382. midPoint: Vector2,
  5383. /** Defines the end point of the arc */
  5384. endPoint: Vector2);
  5385. }
  5386. /**
  5387. * Represents a 2D path made up of multiple 2D points
  5388. */
  5389. export class Path2 {
  5390. private _points;
  5391. private _length;
  5392. /**
  5393. * If the path start and end point are the same
  5394. */
  5395. closed: boolean;
  5396. /**
  5397. * Creates a Path2 object from the starting 2D coordinates x and y.
  5398. * @param x the starting points x value
  5399. * @param y the starting points y value
  5400. */
  5401. constructor(x: number, y: number);
  5402. /**
  5403. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5404. * @param x the added points x value
  5405. * @param y the added points y value
  5406. * @returns the updated Path2.
  5407. */
  5408. addLineTo(x: number, y: number): Path2;
  5409. /**
  5410. * 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.
  5411. * @param midX middle point x value
  5412. * @param midY middle point y value
  5413. * @param endX end point x value
  5414. * @param endY end point y value
  5415. * @param numberOfSegments (default: 36)
  5416. * @returns the updated Path2.
  5417. */
  5418. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5419. /**
  5420. * Closes the Path2.
  5421. * @returns the Path2.
  5422. */
  5423. close(): Path2;
  5424. /**
  5425. * Gets the sum of the distance between each sequential point in the path
  5426. * @returns the Path2 total length (float).
  5427. */
  5428. length(): number;
  5429. /**
  5430. * Gets the points which construct the path
  5431. * @returns the Path2 internal array of points.
  5432. */
  5433. getPoints(): Vector2[];
  5434. /**
  5435. * Retreives the point at the distance aways from the starting point
  5436. * @param normalizedLengthPosition the length along the path to retreive the point from
  5437. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5438. */
  5439. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5440. /**
  5441. * Creates a new path starting from an x and y position
  5442. * @param x starting x value
  5443. * @param y starting y value
  5444. * @returns a new Path2 starting at the coordinates (x, y).
  5445. */
  5446. static StartingAt(x: number, y: number): Path2;
  5447. }
  5448. /**
  5449. * Represents a 3D path made up of multiple 3D points
  5450. */
  5451. export class Path3D {
  5452. /**
  5453. * an array of Vector3, the curve axis of the Path3D
  5454. */
  5455. path: Vector3[];
  5456. private _curve;
  5457. private _distances;
  5458. private _tangents;
  5459. private _normals;
  5460. private _binormals;
  5461. private _raw;
  5462. private _alignTangentsWithPath;
  5463. private readonly _pointAtData;
  5464. /**
  5465. * new Path3D(path, normal, raw)
  5466. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5467. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5468. * @param path an array of Vector3, the curve axis of the Path3D
  5469. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5470. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5471. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5472. */
  5473. constructor(
  5474. /**
  5475. * an array of Vector3, the curve axis of the Path3D
  5476. */
  5477. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5478. /**
  5479. * Returns the Path3D array of successive Vector3 designing its curve.
  5480. * @returns the Path3D array of successive Vector3 designing its curve.
  5481. */
  5482. getCurve(): Vector3[];
  5483. /**
  5484. * Returns the Path3D array of successive Vector3 designing its curve.
  5485. * @returns the Path3D array of successive Vector3 designing its curve.
  5486. */
  5487. getPoints(): Vector3[];
  5488. /**
  5489. * @returns the computed length (float) of the path.
  5490. */
  5491. length(): number;
  5492. /**
  5493. * Returns an array populated with tangent vectors on each Path3D curve point.
  5494. * @returns an array populated with tangent vectors on each Path3D curve point.
  5495. */
  5496. getTangents(): Vector3[];
  5497. /**
  5498. * Returns an array populated with normal vectors on each Path3D curve point.
  5499. * @returns an array populated with normal vectors on each Path3D curve point.
  5500. */
  5501. getNormals(): Vector3[];
  5502. /**
  5503. * Returns an array populated with binormal vectors on each Path3D curve point.
  5504. * @returns an array populated with binormal vectors on each Path3D curve point.
  5505. */
  5506. getBinormals(): Vector3[];
  5507. /**
  5508. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5509. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5510. */
  5511. getDistances(): number[];
  5512. /**
  5513. * Returns an interpolated point along this path
  5514. * @param position the position of the point along this path, from 0.0 to 1.0
  5515. * @returns a new Vector3 as the point
  5516. */
  5517. getPointAt(position: number): Vector3;
  5518. /**
  5519. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5520. * @param position the position of the point along this path, from 0.0 to 1.0
  5521. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5522. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5523. */
  5524. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5525. /**
  5526. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5527. * @param position the position of the point along this path, from 0.0 to 1.0
  5528. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5529. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5530. */
  5531. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5532. /**
  5533. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5534. * @param position the position of the point along this path, from 0.0 to 1.0
  5535. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5536. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5537. */
  5538. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5539. /**
  5540. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5541. * @param position the position of the point along this path, from 0.0 to 1.0
  5542. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5543. */
  5544. getDistanceAt(position: number): number;
  5545. /**
  5546. * Returns the array index of the previous point of an interpolated point along this path
  5547. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5548. * @returns the array index
  5549. */
  5550. getPreviousPointIndexAt(position: number): number;
  5551. /**
  5552. * 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)
  5553. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5554. * @returns the sub position
  5555. */
  5556. getSubPositionAt(position: number): number;
  5557. /**
  5558. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5559. * @param target the vector of which to get the closest position to
  5560. * @returns the position of the closest virtual point on this path to the target vector
  5561. */
  5562. getClosestPositionTo(target: Vector3): number;
  5563. /**
  5564. * Returns a sub path (slice) of this path
  5565. * @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
  5566. * @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
  5567. * @returns a sub path (slice) of this path
  5568. */
  5569. slice(start?: number, end?: number): Path3D;
  5570. /**
  5571. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5572. * @param path path which all values are copied into the curves points
  5573. * @param firstNormal which should be projected onto the curve
  5574. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5575. * @returns the same object updated.
  5576. */
  5577. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5578. private _compute;
  5579. private _getFirstNonNullVector;
  5580. private _getLastNonNullVector;
  5581. private _normalVector;
  5582. /**
  5583. * Updates the point at data for an interpolated point along this curve
  5584. * @param position the position of the point along this curve, from 0.0 to 1.0
  5585. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5586. * @returns the (updated) point at data
  5587. */
  5588. private _updatePointAtData;
  5589. /**
  5590. * Updates the point at data from the specified parameters
  5591. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5592. * @param point the interpolated point
  5593. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5594. */
  5595. private _setPointAtData;
  5596. /**
  5597. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5598. */
  5599. private _updateInterpolationMatrix;
  5600. }
  5601. /**
  5602. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5603. * A Curve3 is designed from a series of successive Vector3.
  5604. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5605. */
  5606. export class Curve3 {
  5607. private _points;
  5608. private _length;
  5609. /**
  5610. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5611. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5612. * @param v1 (Vector3) the control point
  5613. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5614. * @param nbPoints (integer) the wanted number of points in the curve
  5615. * @returns the created Curve3
  5616. */
  5617. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5618. /**
  5619. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5620. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5621. * @param v1 (Vector3) the first control point
  5622. * @param v2 (Vector3) the second control point
  5623. * @param v3 (Vector3) the end point of the Cubic Bezier
  5624. * @param nbPoints (integer) the wanted number of points in the curve
  5625. * @returns the created Curve3
  5626. */
  5627. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5628. /**
  5629. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5630. * @param p1 (Vector3) the origin point of the Hermite Spline
  5631. * @param t1 (Vector3) the tangent vector at the origin point
  5632. * @param p2 (Vector3) the end point of the Hermite Spline
  5633. * @param t2 (Vector3) the tangent vector at the end point
  5634. * @param nbPoints (integer) the wanted number of points in the curve
  5635. * @returns the created Curve3
  5636. */
  5637. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5638. /**
  5639. * Returns a Curve3 object along a CatmullRom Spline curve :
  5640. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5641. * @param nbPoints (integer) the wanted number of points between each curve control points
  5642. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5643. * @returns the created Curve3
  5644. */
  5645. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5646. /**
  5647. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5648. * A Curve3 is designed from a series of successive Vector3.
  5649. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5650. * @param points points which make up the curve
  5651. */
  5652. constructor(points: Vector3[]);
  5653. /**
  5654. * @returns the Curve3 stored array of successive Vector3
  5655. */
  5656. getPoints(): Vector3[];
  5657. /**
  5658. * @returns the computed length (float) of the curve.
  5659. */
  5660. length(): number;
  5661. /**
  5662. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5663. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5664. * curveA and curveB keep unchanged.
  5665. * @param curve the curve to continue from this curve
  5666. * @returns the newly constructed curve
  5667. */
  5668. continue(curve: DeepImmutable<Curve3>): Curve3;
  5669. private _computeLength;
  5670. }
  5671. }
  5672. declare module "babylonjs/Animations/easing" {
  5673. /**
  5674. * This represents the main contract an easing function should follow.
  5675. * Easing functions are used throughout the animation system.
  5676. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5677. */
  5678. export interface IEasingFunction {
  5679. /**
  5680. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5681. * of the easing function.
  5682. * The link below provides some of the most common examples of easing functions.
  5683. * @see https://easings.net/
  5684. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5685. * @returns the corresponding value on the curve defined by the easing function
  5686. */
  5687. ease(gradient: number): number;
  5688. }
  5689. /**
  5690. * Base class used for every default easing function.
  5691. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5692. */
  5693. export class EasingFunction implements IEasingFunction {
  5694. /**
  5695. * Interpolation follows the mathematical formula associated with the easing function.
  5696. */
  5697. static readonly EASINGMODE_EASEIN: number;
  5698. /**
  5699. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5700. */
  5701. static readonly EASINGMODE_EASEOUT: number;
  5702. /**
  5703. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5704. */
  5705. static readonly EASINGMODE_EASEINOUT: number;
  5706. private _easingMode;
  5707. /**
  5708. * Sets the easing mode of the current function.
  5709. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5710. */
  5711. setEasingMode(easingMode: number): void;
  5712. /**
  5713. * Gets the current easing mode.
  5714. * @returns the easing mode
  5715. */
  5716. getEasingMode(): number;
  5717. /**
  5718. * @hidden
  5719. */
  5720. easeInCore(gradient: number): number;
  5721. /**
  5722. * Given an input gradient between 0 and 1, this returns the corresponding value
  5723. * of the easing function.
  5724. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5725. * @returns the corresponding value on the curve defined by the easing function
  5726. */
  5727. ease(gradient: number): number;
  5728. }
  5729. /**
  5730. * Easing function with a circle shape (see link below).
  5731. * @see https://easings.net/#easeInCirc
  5732. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5733. */
  5734. export class CircleEase extends EasingFunction implements IEasingFunction {
  5735. /** @hidden */
  5736. easeInCore(gradient: number): number;
  5737. }
  5738. /**
  5739. * Easing function with a ease back shape (see link below).
  5740. * @see https://easings.net/#easeInBack
  5741. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5742. */
  5743. export class BackEase extends EasingFunction implements IEasingFunction {
  5744. /** Defines the amplitude of the function */
  5745. amplitude: number;
  5746. /**
  5747. * Instantiates a back ease easing
  5748. * @see https://easings.net/#easeInBack
  5749. * @param amplitude Defines the amplitude of the function
  5750. */
  5751. constructor(
  5752. /** Defines the amplitude of the function */
  5753. amplitude?: number);
  5754. /** @hidden */
  5755. easeInCore(gradient: number): number;
  5756. }
  5757. /**
  5758. * Easing function with a bouncing shape (see link below).
  5759. * @see https://easings.net/#easeInBounce
  5760. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5761. */
  5762. export class BounceEase extends EasingFunction implements IEasingFunction {
  5763. /** Defines the number of bounces */
  5764. bounces: number;
  5765. /** Defines the amplitude of the bounce */
  5766. bounciness: number;
  5767. /**
  5768. * Instantiates a bounce easing
  5769. * @see https://easings.net/#easeInBounce
  5770. * @param bounces Defines the number of bounces
  5771. * @param bounciness Defines the amplitude of the bounce
  5772. */
  5773. constructor(
  5774. /** Defines the number of bounces */
  5775. bounces?: number,
  5776. /** Defines the amplitude of the bounce */
  5777. bounciness?: number);
  5778. /** @hidden */
  5779. easeInCore(gradient: number): number;
  5780. }
  5781. /**
  5782. * Easing function with a power of 3 shape (see link below).
  5783. * @see https://easings.net/#easeInCubic
  5784. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5785. */
  5786. export class CubicEase extends EasingFunction implements IEasingFunction {
  5787. /** @hidden */
  5788. easeInCore(gradient: number): number;
  5789. }
  5790. /**
  5791. * Easing function with an elastic shape (see link below).
  5792. * @see https://easings.net/#easeInElastic
  5793. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5794. */
  5795. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5796. /** Defines the number of oscillations*/
  5797. oscillations: number;
  5798. /** Defines the amplitude of the oscillations*/
  5799. springiness: number;
  5800. /**
  5801. * Instantiates an elastic easing function
  5802. * @see https://easings.net/#easeInElastic
  5803. * @param oscillations Defines the number of oscillations
  5804. * @param springiness Defines the amplitude of the oscillations
  5805. */
  5806. constructor(
  5807. /** Defines the number of oscillations*/
  5808. oscillations?: number,
  5809. /** Defines the amplitude of the oscillations*/
  5810. springiness?: number);
  5811. /** @hidden */
  5812. easeInCore(gradient: number): number;
  5813. }
  5814. /**
  5815. * Easing function with an exponential shape (see link below).
  5816. * @see https://easings.net/#easeInExpo
  5817. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5818. */
  5819. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5820. /** Defines the exponent of the function */
  5821. exponent: number;
  5822. /**
  5823. * Instantiates an exponential easing function
  5824. * @see https://easings.net/#easeInExpo
  5825. * @param exponent Defines the exponent of the function
  5826. */
  5827. constructor(
  5828. /** Defines the exponent of the function */
  5829. exponent?: number);
  5830. /** @hidden */
  5831. easeInCore(gradient: number): number;
  5832. }
  5833. /**
  5834. * Easing function with a power shape (see link below).
  5835. * @see https://easings.net/#easeInQuad
  5836. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5837. */
  5838. export class PowerEase extends EasingFunction implements IEasingFunction {
  5839. /** Defines the power of the function */
  5840. power: number;
  5841. /**
  5842. * Instantiates an power base easing function
  5843. * @see https://easings.net/#easeInQuad
  5844. * @param power Defines the power of the function
  5845. */
  5846. constructor(
  5847. /** Defines the power of the function */
  5848. power?: number);
  5849. /** @hidden */
  5850. easeInCore(gradient: number): number;
  5851. }
  5852. /**
  5853. * Easing function with a power of 2 shape (see link below).
  5854. * @see https://easings.net/#easeInQuad
  5855. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5856. */
  5857. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5858. /** @hidden */
  5859. easeInCore(gradient: number): number;
  5860. }
  5861. /**
  5862. * Easing function with a power of 4 shape (see link below).
  5863. * @see https://easings.net/#easeInQuart
  5864. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5865. */
  5866. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5867. /** @hidden */
  5868. easeInCore(gradient: number): number;
  5869. }
  5870. /**
  5871. * Easing function with a power of 5 shape (see link below).
  5872. * @see https://easings.net/#easeInQuint
  5873. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5874. */
  5875. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5876. /** @hidden */
  5877. easeInCore(gradient: number): number;
  5878. }
  5879. /**
  5880. * Easing function with a sin shape (see link below).
  5881. * @see https://easings.net/#easeInSine
  5882. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5883. */
  5884. export class SineEase extends EasingFunction implements IEasingFunction {
  5885. /** @hidden */
  5886. easeInCore(gradient: number): number;
  5887. }
  5888. /**
  5889. * Easing function with a bezier shape (see link below).
  5890. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5891. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5892. */
  5893. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5894. /** Defines the x component of the start tangent in the bezier curve */
  5895. x1: number;
  5896. /** Defines the y component of the start tangent in the bezier curve */
  5897. y1: number;
  5898. /** Defines the x component of the end tangent in the bezier curve */
  5899. x2: number;
  5900. /** Defines the y component of the end tangent in the bezier curve */
  5901. y2: number;
  5902. /**
  5903. * Instantiates a bezier function
  5904. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5905. * @param x1 Defines the x component of the start tangent in the bezier curve
  5906. * @param y1 Defines the y component of the start tangent in the bezier curve
  5907. * @param x2 Defines the x component of the end tangent in the bezier curve
  5908. * @param y2 Defines the y component of the end tangent in the bezier curve
  5909. */
  5910. constructor(
  5911. /** Defines the x component of the start tangent in the bezier curve */
  5912. x1?: number,
  5913. /** Defines the y component of the start tangent in the bezier curve */
  5914. y1?: number,
  5915. /** Defines the x component of the end tangent in the bezier curve */
  5916. x2?: number,
  5917. /** Defines the y component of the end tangent in the bezier curve */
  5918. y2?: number);
  5919. /** @hidden */
  5920. easeInCore(gradient: number): number;
  5921. }
  5922. }
  5923. declare module "babylonjs/Maths/math.color" {
  5924. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5925. /**
  5926. * Class used to hold a RBG color
  5927. */
  5928. export class Color3 {
  5929. /**
  5930. * Defines the red component (between 0 and 1, default is 0)
  5931. */
  5932. r: number;
  5933. /**
  5934. * Defines the green component (between 0 and 1, default is 0)
  5935. */
  5936. g: number;
  5937. /**
  5938. * Defines the blue component (between 0 and 1, default is 0)
  5939. */
  5940. b: number;
  5941. /**
  5942. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5943. * @param r defines the red component (between 0 and 1, default is 0)
  5944. * @param g defines the green component (between 0 and 1, default is 0)
  5945. * @param b defines the blue component (between 0 and 1, default is 0)
  5946. */
  5947. constructor(
  5948. /**
  5949. * Defines the red component (between 0 and 1, default is 0)
  5950. */
  5951. r?: number,
  5952. /**
  5953. * Defines the green component (between 0 and 1, default is 0)
  5954. */
  5955. g?: number,
  5956. /**
  5957. * Defines the blue component (between 0 and 1, default is 0)
  5958. */
  5959. b?: number);
  5960. /**
  5961. * Creates a string with the Color3 current values
  5962. * @returns the string representation of the Color3 object
  5963. */
  5964. toString(): string;
  5965. /**
  5966. * Returns the string "Color3"
  5967. * @returns "Color3"
  5968. */
  5969. getClassName(): string;
  5970. /**
  5971. * Compute the Color3 hash code
  5972. * @returns an unique number that can be used to hash Color3 objects
  5973. */
  5974. getHashCode(): number;
  5975. /**
  5976. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5977. * @param array defines the array where to store the r,g,b components
  5978. * @param index defines an optional index in the target array to define where to start storing values
  5979. * @returns the current Color3 object
  5980. */
  5981. toArray(array: FloatArray, index?: number): Color3;
  5982. /**
  5983. * Update the current color with values stored in an array from the starting index of the given array
  5984. * @param array defines the source array
  5985. * @param offset defines an offset in the source array
  5986. * @returns the current Color3 object
  5987. */
  5988. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5989. /**
  5990. * Returns a new Color4 object from the current Color3 and the given alpha
  5991. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5992. * @returns a new Color4 object
  5993. */
  5994. toColor4(alpha?: number): Color4;
  5995. /**
  5996. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5997. * @returns the new array
  5998. */
  5999. asArray(): number[];
  6000. /**
  6001. * Returns the luminance value
  6002. * @returns a float value
  6003. */
  6004. toLuminance(): number;
  6005. /**
  6006. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  6007. * @param otherColor defines the second operand
  6008. * @returns the new Color3 object
  6009. */
  6010. multiply(otherColor: DeepImmutable<Color3>): Color3;
  6011. /**
  6012. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  6013. * @param otherColor defines the second operand
  6014. * @param result defines the Color3 object where to store the result
  6015. * @returns the current Color3
  6016. */
  6017. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6018. /**
  6019. * Determines equality between Color3 objects
  6020. * @param otherColor defines the second operand
  6021. * @returns true if the rgb values are equal to the given ones
  6022. */
  6023. equals(otherColor: DeepImmutable<Color3>): boolean;
  6024. /**
  6025. * Determines equality between the current Color3 object and a set of r,b,g values
  6026. * @param r defines the red component to check
  6027. * @param g defines the green component to check
  6028. * @param b defines the blue component to check
  6029. * @returns true if the rgb values are equal to the given ones
  6030. */
  6031. equalsFloats(r: number, g: number, b: number): boolean;
  6032. /**
  6033. * Multiplies in place each rgb value by scale
  6034. * @param scale defines the scaling factor
  6035. * @returns the updated Color3
  6036. */
  6037. scale(scale: number): Color3;
  6038. /**
  6039. * Multiplies the rgb values by scale and stores the result into "result"
  6040. * @param scale defines the scaling factor
  6041. * @param result defines the Color3 object where to store the result
  6042. * @returns the unmodified current Color3
  6043. */
  6044. scaleToRef(scale: number, result: Color3): Color3;
  6045. /**
  6046. * Scale the current Color3 values by a factor and add the result to a given Color3
  6047. * @param scale defines the scale factor
  6048. * @param result defines color to store the result into
  6049. * @returns the unmodified current Color3
  6050. */
  6051. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6052. /**
  6053. * Clamps the rgb values by the min and max values and stores the result into "result"
  6054. * @param min defines minimum clamping value (default is 0)
  6055. * @param max defines maximum clamping value (default is 1)
  6056. * @param result defines color to store the result into
  6057. * @returns the original Color3
  6058. */
  6059. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6060. /**
  6061. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6062. * @param otherColor defines the second operand
  6063. * @returns the new Color3
  6064. */
  6065. add(otherColor: DeepImmutable<Color3>): Color3;
  6066. /**
  6067. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6068. * @param otherColor defines the second operand
  6069. * @param result defines Color3 object to store the result into
  6070. * @returns the unmodified current Color3
  6071. */
  6072. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6073. /**
  6074. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6075. * @param otherColor defines the second operand
  6076. * @returns the new Color3
  6077. */
  6078. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6079. /**
  6080. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6081. * @param otherColor defines the second operand
  6082. * @param result defines Color3 object to store the result into
  6083. * @returns the unmodified current Color3
  6084. */
  6085. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6086. /**
  6087. * Copy the current object
  6088. * @returns a new Color3 copied the current one
  6089. */
  6090. clone(): Color3;
  6091. /**
  6092. * Copies the rgb values from the source in the current Color3
  6093. * @param source defines the source Color3 object
  6094. * @returns the updated Color3 object
  6095. */
  6096. copyFrom(source: DeepImmutable<Color3>): Color3;
  6097. /**
  6098. * Updates the Color3 rgb values from the given floats
  6099. * @param r defines the red component to read from
  6100. * @param g defines the green component to read from
  6101. * @param b defines the blue component to read from
  6102. * @returns the current Color3 object
  6103. */
  6104. copyFromFloats(r: number, g: number, b: number): Color3;
  6105. /**
  6106. * Updates the Color3 rgb values from the given floats
  6107. * @param r defines the red component to read from
  6108. * @param g defines the green component to read from
  6109. * @param b defines the blue component to read from
  6110. * @returns the current Color3 object
  6111. */
  6112. set(r: number, g: number, b: number): Color3;
  6113. /**
  6114. * Compute the Color3 hexadecimal code as a string
  6115. * @returns a string containing the hexadecimal representation of the Color3 object
  6116. */
  6117. toHexString(): string;
  6118. /**
  6119. * Computes a new Color3 converted from the current one to linear space
  6120. * @returns a new Color3 object
  6121. */
  6122. toLinearSpace(): Color3;
  6123. /**
  6124. * Converts current color in rgb space to HSV values
  6125. * @returns a new color3 representing the HSV values
  6126. */
  6127. toHSV(): Color3;
  6128. /**
  6129. * Converts current color in rgb space to HSV values
  6130. * @param result defines the Color3 where to store the HSV values
  6131. */
  6132. toHSVToRef(result: Color3): void;
  6133. /**
  6134. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6135. * @param convertedColor defines the Color3 object where to store the linear space version
  6136. * @returns the unmodified Color3
  6137. */
  6138. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6139. /**
  6140. * Computes a new Color3 converted from the current one to gamma space
  6141. * @returns a new Color3 object
  6142. */
  6143. toGammaSpace(): Color3;
  6144. /**
  6145. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6146. * @param convertedColor defines the Color3 object where to store the gamma space version
  6147. * @returns the unmodified Color3
  6148. */
  6149. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6150. private static _BlackReadOnly;
  6151. /**
  6152. * Convert Hue, saturation and value to a Color3 (RGB)
  6153. * @param hue defines the hue
  6154. * @param saturation defines the saturation
  6155. * @param value defines the value
  6156. * @param result defines the Color3 where to store the RGB values
  6157. */
  6158. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6159. /**
  6160. * Creates a new Color3 from the string containing valid hexadecimal values
  6161. * @param hex defines a string containing valid hexadecimal values
  6162. * @returns a new Color3 object
  6163. */
  6164. static FromHexString(hex: string): Color3;
  6165. /**
  6166. * Creates a new Color3 from the starting index of the given array
  6167. * @param array defines the source array
  6168. * @param offset defines an offset in the source array
  6169. * @returns a new Color3 object
  6170. */
  6171. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6172. /**
  6173. * Creates a new Color3 from the starting index element of the given array
  6174. * @param array defines the source array to read from
  6175. * @param offset defines the offset in the source array
  6176. * @param result defines the target Color3 object
  6177. */
  6178. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6179. /**
  6180. * Creates a new Color3 from integer values (< 256)
  6181. * @param r defines the red component to read from (value between 0 and 255)
  6182. * @param g defines the green component to read from (value between 0 and 255)
  6183. * @param b defines the blue component to read from (value between 0 and 255)
  6184. * @returns a new Color3 object
  6185. */
  6186. static FromInts(r: number, g: number, b: number): Color3;
  6187. /**
  6188. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6189. * @param start defines the start Color3 value
  6190. * @param end defines the end Color3 value
  6191. * @param amount defines the gradient value between start and end
  6192. * @returns a new Color3 object
  6193. */
  6194. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6195. /**
  6196. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6197. * @param left defines the start value
  6198. * @param right defines the end value
  6199. * @param amount defines the gradient factor
  6200. * @param result defines the Color3 object where to store the result
  6201. */
  6202. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6203. /**
  6204. * Returns a Color3 value containing a red color
  6205. * @returns a new Color3 object
  6206. */
  6207. static Red(): Color3;
  6208. /**
  6209. * Returns a Color3 value containing a green color
  6210. * @returns a new Color3 object
  6211. */
  6212. static Green(): Color3;
  6213. /**
  6214. * Returns a Color3 value containing a blue color
  6215. * @returns a new Color3 object
  6216. */
  6217. static Blue(): Color3;
  6218. /**
  6219. * Returns a Color3 value containing a black color
  6220. * @returns a new Color3 object
  6221. */
  6222. static Black(): Color3;
  6223. /**
  6224. * Gets a Color3 value containing a black color that must not be updated
  6225. */
  6226. static get BlackReadOnly(): DeepImmutable<Color3>;
  6227. /**
  6228. * Returns a Color3 value containing a white color
  6229. * @returns a new Color3 object
  6230. */
  6231. static White(): Color3;
  6232. /**
  6233. * Returns a Color3 value containing a purple color
  6234. * @returns a new Color3 object
  6235. */
  6236. static Purple(): Color3;
  6237. /**
  6238. * Returns a Color3 value containing a magenta color
  6239. * @returns a new Color3 object
  6240. */
  6241. static Magenta(): Color3;
  6242. /**
  6243. * Returns a Color3 value containing a yellow color
  6244. * @returns a new Color3 object
  6245. */
  6246. static Yellow(): Color3;
  6247. /**
  6248. * Returns a Color3 value containing a gray color
  6249. * @returns a new Color3 object
  6250. */
  6251. static Gray(): Color3;
  6252. /**
  6253. * Returns a Color3 value containing a teal color
  6254. * @returns a new Color3 object
  6255. */
  6256. static Teal(): Color3;
  6257. /**
  6258. * Returns a Color3 value containing a random color
  6259. * @returns a new Color3 object
  6260. */
  6261. static Random(): Color3;
  6262. }
  6263. /**
  6264. * Class used to hold a RBGA color
  6265. */
  6266. export class Color4 {
  6267. /**
  6268. * Defines the red component (between 0 and 1, default is 0)
  6269. */
  6270. r: number;
  6271. /**
  6272. * Defines the green component (between 0 and 1, default is 0)
  6273. */
  6274. g: number;
  6275. /**
  6276. * Defines the blue component (between 0 and 1, default is 0)
  6277. */
  6278. b: number;
  6279. /**
  6280. * Defines the alpha component (between 0 and 1, default is 1)
  6281. */
  6282. a: number;
  6283. /**
  6284. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6285. * @param r defines the red component (between 0 and 1, default is 0)
  6286. * @param g defines the green component (between 0 and 1, default is 0)
  6287. * @param b defines the blue component (between 0 and 1, default is 0)
  6288. * @param a defines the alpha component (between 0 and 1, default is 1)
  6289. */
  6290. constructor(
  6291. /**
  6292. * Defines the red component (between 0 and 1, default is 0)
  6293. */
  6294. r?: number,
  6295. /**
  6296. * Defines the green component (between 0 and 1, default is 0)
  6297. */
  6298. g?: number,
  6299. /**
  6300. * Defines the blue component (between 0 and 1, default is 0)
  6301. */
  6302. b?: number,
  6303. /**
  6304. * Defines the alpha component (between 0 and 1, default is 1)
  6305. */
  6306. a?: number);
  6307. /**
  6308. * Adds in place the given Color4 values to the current Color4 object
  6309. * @param right defines the second operand
  6310. * @returns the current updated Color4 object
  6311. */
  6312. addInPlace(right: DeepImmutable<Color4>): Color4;
  6313. /**
  6314. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6315. * @returns the new array
  6316. */
  6317. asArray(): number[];
  6318. /**
  6319. * Stores from the starting index in the given array the Color4 successive values
  6320. * @param array defines the array where to store the r,g,b components
  6321. * @param index defines an optional index in the target array to define where to start storing values
  6322. * @returns the current Color4 object
  6323. */
  6324. toArray(array: number[], index?: number): Color4;
  6325. /**
  6326. * Update the current color with values stored in an array from the starting index of the given array
  6327. * @param array defines the source array
  6328. * @param offset defines an offset in the source array
  6329. * @returns the current Color4 object
  6330. */
  6331. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6332. /**
  6333. * Determines equality between Color4 objects
  6334. * @param otherColor defines the second operand
  6335. * @returns true if the rgba values are equal to the given ones
  6336. */
  6337. equals(otherColor: DeepImmutable<Color4>): boolean;
  6338. /**
  6339. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6340. * @param right defines the second operand
  6341. * @returns a new Color4 object
  6342. */
  6343. add(right: DeepImmutable<Color4>): Color4;
  6344. /**
  6345. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6346. * @param right defines the second operand
  6347. * @returns a new Color4 object
  6348. */
  6349. subtract(right: DeepImmutable<Color4>): Color4;
  6350. /**
  6351. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6352. * @param right defines the second operand
  6353. * @param result defines the Color4 object where to store the result
  6354. * @returns the current Color4 object
  6355. */
  6356. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6357. /**
  6358. * Creates a new Color4 with the current Color4 values multiplied by scale
  6359. * @param scale defines the scaling factor to apply
  6360. * @returns a new Color4 object
  6361. */
  6362. scale(scale: number): Color4;
  6363. /**
  6364. * Multiplies the current Color4 values by scale and stores the result in "result"
  6365. * @param scale defines the scaling factor to apply
  6366. * @param result defines the Color4 object where to store the result
  6367. * @returns the current unmodified Color4
  6368. */
  6369. scaleToRef(scale: number, result: Color4): Color4;
  6370. /**
  6371. * Scale the current Color4 values by a factor and add the result to a given Color4
  6372. * @param scale defines the scale factor
  6373. * @param result defines the Color4 object where to store the result
  6374. * @returns the unmodified current Color4
  6375. */
  6376. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6377. /**
  6378. * Clamps the rgb values by the min and max values and stores the result into "result"
  6379. * @param min defines minimum clamping value (default is 0)
  6380. * @param max defines maximum clamping value (default is 1)
  6381. * @param result defines color to store the result into.
  6382. * @returns the cuurent Color4
  6383. */
  6384. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6385. /**
  6386. * Multipy an Color4 value by another and return a new Color4 object
  6387. * @param color defines the Color4 value to multiply by
  6388. * @returns a new Color4 object
  6389. */
  6390. multiply(color: Color4): Color4;
  6391. /**
  6392. * Multipy a Color4 value by another and push the result in a reference value
  6393. * @param color defines the Color4 value to multiply by
  6394. * @param result defines the Color4 to fill the result in
  6395. * @returns the result Color4
  6396. */
  6397. multiplyToRef(color: Color4, result: Color4): Color4;
  6398. /**
  6399. * Creates a string with the Color4 current values
  6400. * @returns the string representation of the Color4 object
  6401. */
  6402. toString(): string;
  6403. /**
  6404. * Returns the string "Color4"
  6405. * @returns "Color4"
  6406. */
  6407. getClassName(): string;
  6408. /**
  6409. * Compute the Color4 hash code
  6410. * @returns an unique number that can be used to hash Color4 objects
  6411. */
  6412. getHashCode(): number;
  6413. /**
  6414. * Creates a new Color4 copied from the current one
  6415. * @returns a new Color4 object
  6416. */
  6417. clone(): Color4;
  6418. /**
  6419. * Copies the given Color4 values into the current one
  6420. * @param source defines the source Color4 object
  6421. * @returns the current updated Color4 object
  6422. */
  6423. copyFrom(source: Color4): Color4;
  6424. /**
  6425. * Copies the given float values into the current one
  6426. * @param r defines the red component to read from
  6427. * @param g defines the green component to read from
  6428. * @param b defines the blue component to read from
  6429. * @param a defines the alpha component to read from
  6430. * @returns the current updated Color4 object
  6431. */
  6432. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6433. /**
  6434. * Copies the given float values into the current one
  6435. * @param r defines the red component to read from
  6436. * @param g defines the green component to read from
  6437. * @param b defines the blue component to read from
  6438. * @param a defines the alpha component to read from
  6439. * @returns the current updated Color4 object
  6440. */
  6441. set(r: number, g: number, b: number, a: number): Color4;
  6442. /**
  6443. * Compute the Color4 hexadecimal code as a string
  6444. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6445. * @returns a string containing the hexadecimal representation of the Color4 object
  6446. */
  6447. toHexString(returnAsColor3?: boolean): string;
  6448. /**
  6449. * Computes a new Color4 converted from the current one to linear space
  6450. * @returns a new Color4 object
  6451. */
  6452. toLinearSpace(): Color4;
  6453. /**
  6454. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6455. * @param convertedColor defines the Color4 object where to store the linear space version
  6456. * @returns the unmodified Color4
  6457. */
  6458. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6459. /**
  6460. * Computes a new Color4 converted from the current one to gamma space
  6461. * @returns a new Color4 object
  6462. */
  6463. toGammaSpace(): Color4;
  6464. /**
  6465. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6466. * @param convertedColor defines the Color4 object where to store the gamma space version
  6467. * @returns the unmodified Color4
  6468. */
  6469. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6470. /**
  6471. * Creates a new Color4 from the string containing valid hexadecimal values
  6472. * @param hex defines a string containing valid hexadecimal values
  6473. * @returns a new Color4 object
  6474. */
  6475. static FromHexString(hex: string): Color4;
  6476. /**
  6477. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6478. * @param left defines the start value
  6479. * @param right defines the end value
  6480. * @param amount defines the gradient factor
  6481. * @returns a new Color4 object
  6482. */
  6483. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6484. /**
  6485. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6486. * @param left defines the start value
  6487. * @param right defines the end value
  6488. * @param amount defines the gradient factor
  6489. * @param result defines the Color4 object where to store data
  6490. */
  6491. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6492. /**
  6493. * Creates a new Color4 from a Color3 and an alpha value
  6494. * @param color3 defines the source Color3 to read from
  6495. * @param alpha defines the alpha component (1.0 by default)
  6496. * @returns a new Color4 object
  6497. */
  6498. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6499. /**
  6500. * Creates a new Color4 from the starting index element of the given array
  6501. * @param array defines the source array to read from
  6502. * @param offset defines the offset in the source array
  6503. * @returns a new Color4 object
  6504. */
  6505. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6506. /**
  6507. * Creates a new Color4 from the starting index element of the given array
  6508. * @param array defines the source array to read from
  6509. * @param offset defines the offset in the source array
  6510. * @param result defines the target Color4 object
  6511. */
  6512. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6513. /**
  6514. * Creates a new Color3 from integer values (< 256)
  6515. * @param r defines the red component to read from (value between 0 and 255)
  6516. * @param g defines the green component to read from (value between 0 and 255)
  6517. * @param b defines the blue component to read from (value between 0 and 255)
  6518. * @param a defines the alpha component to read from (value between 0 and 255)
  6519. * @returns a new Color3 object
  6520. */
  6521. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6522. /**
  6523. * Check the content of a given array and convert it to an array containing RGBA data
  6524. * If the original array was already containing count * 4 values then it is returned directly
  6525. * @param colors defines the array to check
  6526. * @param count defines the number of RGBA data to expect
  6527. * @returns an array containing count * 4 values (RGBA)
  6528. */
  6529. static CheckColors4(colors: number[], count: number): number[];
  6530. }
  6531. /**
  6532. * @hidden
  6533. */
  6534. export class TmpColors {
  6535. static Color3: Color3[];
  6536. static Color4: Color4[];
  6537. }
  6538. }
  6539. declare module "babylonjs/Animations/animationKey" {
  6540. /**
  6541. * Defines an interface which represents an animation key frame
  6542. */
  6543. export interface IAnimationKey {
  6544. /**
  6545. * Frame of the key frame
  6546. */
  6547. frame: number;
  6548. /**
  6549. * Value at the specifies key frame
  6550. */
  6551. value: any;
  6552. /**
  6553. * The input tangent for the cubic hermite spline
  6554. */
  6555. inTangent?: any;
  6556. /**
  6557. * The output tangent for the cubic hermite spline
  6558. */
  6559. outTangent?: any;
  6560. /**
  6561. * The animation interpolation type
  6562. */
  6563. interpolation?: AnimationKeyInterpolation;
  6564. }
  6565. /**
  6566. * Enum for the animation key frame interpolation type
  6567. */
  6568. export enum AnimationKeyInterpolation {
  6569. /**
  6570. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6571. */
  6572. STEP = 1
  6573. }
  6574. }
  6575. declare module "babylonjs/Animations/animationRange" {
  6576. /**
  6577. * Represents the range of an animation
  6578. */
  6579. export class AnimationRange {
  6580. /**The name of the animation range**/
  6581. name: string;
  6582. /**The starting frame of the animation */
  6583. from: number;
  6584. /**The ending frame of the animation*/
  6585. to: number;
  6586. /**
  6587. * Initializes the range of an animation
  6588. * @param name The name of the animation range
  6589. * @param from The starting frame of the animation
  6590. * @param to The ending frame of the animation
  6591. */
  6592. constructor(
  6593. /**The name of the animation range**/
  6594. name: string,
  6595. /**The starting frame of the animation */
  6596. from: number,
  6597. /**The ending frame of the animation*/
  6598. to: number);
  6599. /**
  6600. * Makes a copy of the animation range
  6601. * @returns A copy of the animation range
  6602. */
  6603. clone(): AnimationRange;
  6604. }
  6605. }
  6606. declare module "babylonjs/Animations/animationEvent" {
  6607. /**
  6608. * Composed of a frame, and an action function
  6609. */
  6610. export class AnimationEvent {
  6611. /** The frame for which the event is triggered **/
  6612. frame: number;
  6613. /** The event to perform when triggered **/
  6614. action: (currentFrame: number) => void;
  6615. /** Specifies if the event should be triggered only once**/
  6616. onlyOnce?: boolean | undefined;
  6617. /**
  6618. * Specifies if the animation event is done
  6619. */
  6620. isDone: boolean;
  6621. /**
  6622. * Initializes the animation event
  6623. * @param frame The frame for which the event is triggered
  6624. * @param action The event to perform when triggered
  6625. * @param onlyOnce Specifies if the event should be triggered only once
  6626. */
  6627. constructor(
  6628. /** The frame for which the event is triggered **/
  6629. frame: number,
  6630. /** The event to perform when triggered **/
  6631. action: (currentFrame: number) => void,
  6632. /** Specifies if the event should be triggered only once**/
  6633. onlyOnce?: boolean | undefined);
  6634. /** @hidden */
  6635. _clone(): AnimationEvent;
  6636. }
  6637. }
  6638. declare module "babylonjs/Behaviors/behavior" {
  6639. import { Nullable } from "babylonjs/types";
  6640. /**
  6641. * Interface used to define a behavior
  6642. */
  6643. export interface Behavior<T> {
  6644. /** gets or sets behavior's name */
  6645. name: string;
  6646. /**
  6647. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6648. */
  6649. init(): void;
  6650. /**
  6651. * Called when the behavior is attached to a target
  6652. * @param target defines the target where the behavior is attached to
  6653. */
  6654. attach(target: T): void;
  6655. /**
  6656. * Called when the behavior is detached from its target
  6657. */
  6658. detach(): void;
  6659. }
  6660. /**
  6661. * Interface implemented by classes supporting behaviors
  6662. */
  6663. export interface IBehaviorAware<T> {
  6664. /**
  6665. * Attach a behavior
  6666. * @param behavior defines the behavior to attach
  6667. * @returns the current host
  6668. */
  6669. addBehavior(behavior: Behavior<T>): T;
  6670. /**
  6671. * Remove a behavior from the current object
  6672. * @param behavior defines the behavior to detach
  6673. * @returns the current host
  6674. */
  6675. removeBehavior(behavior: Behavior<T>): T;
  6676. /**
  6677. * Gets a behavior using its name to search
  6678. * @param name defines the name to search
  6679. * @returns the behavior or null if not found
  6680. */
  6681. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6682. }
  6683. }
  6684. declare module "babylonjs/Meshes/buffer" {
  6685. import { Nullable, DataArray } from "babylonjs/types";
  6686. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6687. /**
  6688. * Class used to store data that will be store in GPU memory
  6689. */
  6690. export class Buffer {
  6691. private _engine;
  6692. private _buffer;
  6693. /** @hidden */
  6694. _data: Nullable<DataArray>;
  6695. private _updatable;
  6696. private _instanced;
  6697. private _divisor;
  6698. /**
  6699. * Gets the byte stride.
  6700. */
  6701. readonly byteStride: number;
  6702. /**
  6703. * Constructor
  6704. * @param engine the engine
  6705. * @param data the data to use for this buffer
  6706. * @param updatable whether the data is updatable
  6707. * @param stride the stride (optional)
  6708. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6709. * @param instanced whether the buffer is instanced (optional)
  6710. * @param useBytes set to true if the stride in in bytes (optional)
  6711. * @param divisor sets an optional divisor for instances (1 by default)
  6712. */
  6713. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6714. /**
  6715. * Create a new VertexBuffer based on the current buffer
  6716. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6717. * @param offset defines offset in the buffer (0 by default)
  6718. * @param size defines the size in floats of attributes (position is 3 for instance)
  6719. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6720. * @param instanced defines if the vertex buffer contains indexed data
  6721. * @param useBytes defines if the offset and stride are in bytes *
  6722. * @param divisor sets an optional divisor for instances (1 by default)
  6723. * @returns the new vertex buffer
  6724. */
  6725. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6726. /**
  6727. * Gets a boolean indicating if the Buffer is updatable?
  6728. * @returns true if the buffer is updatable
  6729. */
  6730. isUpdatable(): boolean;
  6731. /**
  6732. * Gets current buffer's data
  6733. * @returns a DataArray or null
  6734. */
  6735. getData(): Nullable<DataArray>;
  6736. /**
  6737. * Gets underlying native buffer
  6738. * @returns underlying native buffer
  6739. */
  6740. getBuffer(): Nullable<DataBuffer>;
  6741. /**
  6742. * Gets the stride in float32 units (i.e. byte stride / 4).
  6743. * May not be an integer if the byte stride is not divisible by 4.
  6744. * @returns the stride in float32 units
  6745. * @deprecated Please use byteStride instead.
  6746. */
  6747. getStrideSize(): number;
  6748. /**
  6749. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6750. * @param data defines the data to store
  6751. */
  6752. create(data?: Nullable<DataArray>): void;
  6753. /** @hidden */
  6754. _rebuild(): void;
  6755. /**
  6756. * Update current buffer data
  6757. * @param data defines the data to store
  6758. */
  6759. update(data: DataArray): void;
  6760. /**
  6761. * Updates the data directly.
  6762. * @param data the new data
  6763. * @param offset the new offset
  6764. * @param vertexCount the vertex count (optional)
  6765. * @param useBytes set to true if the offset is in bytes
  6766. */
  6767. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6768. /**
  6769. * Release all resources
  6770. */
  6771. dispose(): void;
  6772. }
  6773. /**
  6774. * Specialized buffer used to store vertex data
  6775. */
  6776. export class VertexBuffer {
  6777. /** @hidden */
  6778. _buffer: Buffer;
  6779. private _kind;
  6780. private _size;
  6781. private _ownsBuffer;
  6782. private _instanced;
  6783. private _instanceDivisor;
  6784. /**
  6785. * The byte type.
  6786. */
  6787. static readonly BYTE: number;
  6788. /**
  6789. * The unsigned byte type.
  6790. */
  6791. static readonly UNSIGNED_BYTE: number;
  6792. /**
  6793. * The short type.
  6794. */
  6795. static readonly SHORT: number;
  6796. /**
  6797. * The unsigned short type.
  6798. */
  6799. static readonly UNSIGNED_SHORT: number;
  6800. /**
  6801. * The integer type.
  6802. */
  6803. static readonly INT: number;
  6804. /**
  6805. * The unsigned integer type.
  6806. */
  6807. static readonly UNSIGNED_INT: number;
  6808. /**
  6809. * The float type.
  6810. */
  6811. static readonly FLOAT: number;
  6812. /**
  6813. * Gets or sets the instance divisor when in instanced mode
  6814. */
  6815. get instanceDivisor(): number;
  6816. set instanceDivisor(value: number);
  6817. /**
  6818. * Gets the byte stride.
  6819. */
  6820. readonly byteStride: number;
  6821. /**
  6822. * Gets the byte offset.
  6823. */
  6824. readonly byteOffset: number;
  6825. /**
  6826. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6827. */
  6828. readonly normalized: boolean;
  6829. /**
  6830. * Gets the data type of each component in the array.
  6831. */
  6832. readonly type: number;
  6833. /**
  6834. * Constructor
  6835. * @param engine the engine
  6836. * @param data the data to use for this vertex buffer
  6837. * @param kind the vertex buffer kind
  6838. * @param updatable whether the data is updatable
  6839. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6840. * @param stride the stride (optional)
  6841. * @param instanced whether the buffer is instanced (optional)
  6842. * @param offset the offset of the data (optional)
  6843. * @param size the number of components (optional)
  6844. * @param type the type of the component (optional)
  6845. * @param normalized whether the data contains normalized data (optional)
  6846. * @param useBytes set to true if stride and offset are in bytes (optional)
  6847. * @param divisor defines the instance divisor to use (1 by default)
  6848. */
  6849. 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);
  6850. /** @hidden */
  6851. _rebuild(): void;
  6852. /**
  6853. * Returns the kind of the VertexBuffer (string)
  6854. * @returns a string
  6855. */
  6856. getKind(): string;
  6857. /**
  6858. * Gets a boolean indicating if the VertexBuffer is updatable?
  6859. * @returns true if the buffer is updatable
  6860. */
  6861. isUpdatable(): boolean;
  6862. /**
  6863. * Gets current buffer's data
  6864. * @returns a DataArray or null
  6865. */
  6866. getData(): Nullable<DataArray>;
  6867. /**
  6868. * Gets underlying native buffer
  6869. * @returns underlying native buffer
  6870. */
  6871. getBuffer(): Nullable<DataBuffer>;
  6872. /**
  6873. * Gets the stride in float32 units (i.e. byte stride / 4).
  6874. * May not be an integer if the byte stride is not divisible by 4.
  6875. * @returns the stride in float32 units
  6876. * @deprecated Please use byteStride instead.
  6877. */
  6878. getStrideSize(): number;
  6879. /**
  6880. * Returns the offset as a multiple of the type byte length.
  6881. * @returns the offset in bytes
  6882. * @deprecated Please use byteOffset instead.
  6883. */
  6884. getOffset(): number;
  6885. /**
  6886. * Returns the number of components per vertex attribute (integer)
  6887. * @returns the size in float
  6888. */
  6889. getSize(): number;
  6890. /**
  6891. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6892. * @returns true if this buffer is instanced
  6893. */
  6894. getIsInstanced(): boolean;
  6895. /**
  6896. * Returns the instancing divisor, zero for non-instanced (integer).
  6897. * @returns a number
  6898. */
  6899. getInstanceDivisor(): number;
  6900. /**
  6901. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6902. * @param data defines the data to store
  6903. */
  6904. create(data?: DataArray): void;
  6905. /**
  6906. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6907. * This function will create a new buffer if the current one is not updatable
  6908. * @param data defines the data to store
  6909. */
  6910. update(data: DataArray): void;
  6911. /**
  6912. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6913. * Returns the directly updated WebGLBuffer.
  6914. * @param data the new data
  6915. * @param offset the new offset
  6916. * @param useBytes set to true if the offset is in bytes
  6917. */
  6918. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6919. /**
  6920. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6921. */
  6922. dispose(): void;
  6923. /**
  6924. * Enumerates each value of this vertex buffer as numbers.
  6925. * @param count the number of values to enumerate
  6926. * @param callback the callback function called for each value
  6927. */
  6928. forEach(count: number, callback: (value: number, index: number) => void): void;
  6929. /**
  6930. * Positions
  6931. */
  6932. static readonly PositionKind: string;
  6933. /**
  6934. * Normals
  6935. */
  6936. static readonly NormalKind: string;
  6937. /**
  6938. * Tangents
  6939. */
  6940. static readonly TangentKind: string;
  6941. /**
  6942. * Texture coordinates
  6943. */
  6944. static readonly UVKind: string;
  6945. /**
  6946. * Texture coordinates 2
  6947. */
  6948. static readonly UV2Kind: string;
  6949. /**
  6950. * Texture coordinates 3
  6951. */
  6952. static readonly UV3Kind: string;
  6953. /**
  6954. * Texture coordinates 4
  6955. */
  6956. static readonly UV4Kind: string;
  6957. /**
  6958. * Texture coordinates 5
  6959. */
  6960. static readonly UV5Kind: string;
  6961. /**
  6962. * Texture coordinates 6
  6963. */
  6964. static readonly UV6Kind: string;
  6965. /**
  6966. * Colors
  6967. */
  6968. static readonly ColorKind: string;
  6969. /**
  6970. * Matrix indices (for bones)
  6971. */
  6972. static readonly MatricesIndicesKind: string;
  6973. /**
  6974. * Matrix weights (for bones)
  6975. */
  6976. static readonly MatricesWeightsKind: string;
  6977. /**
  6978. * Additional matrix indices (for bones)
  6979. */
  6980. static readonly MatricesIndicesExtraKind: string;
  6981. /**
  6982. * Additional matrix weights (for bones)
  6983. */
  6984. static readonly MatricesWeightsExtraKind: string;
  6985. /**
  6986. * Deduces the stride given a kind.
  6987. * @param kind The kind string to deduce
  6988. * @returns The deduced stride
  6989. */
  6990. static DeduceStride(kind: string): number;
  6991. /**
  6992. * Gets the byte length of the given type.
  6993. * @param type the type
  6994. * @returns the number of bytes
  6995. */
  6996. static GetTypeByteLength(type: number): number;
  6997. /**
  6998. * Enumerates each value of the given parameters as numbers.
  6999. * @param data the data to enumerate
  7000. * @param byteOffset the byte offset of the data
  7001. * @param byteStride the byte stride of the data
  7002. * @param componentCount the number of components per element
  7003. * @param componentType the type of the component
  7004. * @param count the number of values to enumerate
  7005. * @param normalized whether the data is normalized
  7006. * @param callback the callback function called for each value
  7007. */
  7008. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  7009. private static _GetFloatValue;
  7010. }
  7011. }
  7012. declare module "babylonjs/Collisions/intersectionInfo" {
  7013. import { Nullable } from "babylonjs/types";
  7014. /**
  7015. * @hidden
  7016. */
  7017. export class IntersectionInfo {
  7018. bu: Nullable<number>;
  7019. bv: Nullable<number>;
  7020. distance: number;
  7021. faceId: number;
  7022. subMeshId: number;
  7023. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7024. }
  7025. }
  7026. declare module "babylonjs/Culling/boundingSphere" {
  7027. import { DeepImmutable } from "babylonjs/types";
  7028. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7029. import { Plane } from "babylonjs/Maths/math.plane";
  7030. /**
  7031. * Class used to store bounding sphere information
  7032. */
  7033. export class BoundingSphere {
  7034. /**
  7035. * Gets the center of the bounding sphere in local space
  7036. */
  7037. readonly center: Vector3;
  7038. /**
  7039. * Radius of the bounding sphere in local space
  7040. */
  7041. radius: number;
  7042. /**
  7043. * Gets the center of the bounding sphere in world space
  7044. */
  7045. readonly centerWorld: Vector3;
  7046. /**
  7047. * Radius of the bounding sphere in world space
  7048. */
  7049. radiusWorld: number;
  7050. /**
  7051. * Gets the minimum vector in local space
  7052. */
  7053. readonly minimum: Vector3;
  7054. /**
  7055. * Gets the maximum vector in local space
  7056. */
  7057. readonly maximum: Vector3;
  7058. private _worldMatrix;
  7059. private static readonly TmpVector3;
  7060. /**
  7061. * Creates a new bounding sphere
  7062. * @param min defines the minimum vector (in local space)
  7063. * @param max defines the maximum vector (in local space)
  7064. * @param worldMatrix defines the new world matrix
  7065. */
  7066. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7067. /**
  7068. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7069. * @param min defines the new minimum vector (in local space)
  7070. * @param max defines the new maximum vector (in local space)
  7071. * @param worldMatrix defines the new world matrix
  7072. */
  7073. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7074. /**
  7075. * Scale the current bounding sphere by applying a scale factor
  7076. * @param factor defines the scale factor to apply
  7077. * @returns the current bounding box
  7078. */
  7079. scale(factor: number): BoundingSphere;
  7080. /**
  7081. * Gets the world matrix of the bounding box
  7082. * @returns a matrix
  7083. */
  7084. getWorldMatrix(): DeepImmutable<Matrix>;
  7085. /** @hidden */
  7086. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7087. /**
  7088. * Tests if the bounding sphere is intersecting the frustum planes
  7089. * @param frustumPlanes defines the frustum planes to test
  7090. * @returns true if there is an intersection
  7091. */
  7092. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7093. /**
  7094. * Tests if the bounding sphere center is in between the frustum planes.
  7095. * Used for optimistic fast inclusion.
  7096. * @param frustumPlanes defines the frustum planes to test
  7097. * @returns true if the sphere center is in between the frustum planes
  7098. */
  7099. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7100. /**
  7101. * Tests if a point is inside the bounding sphere
  7102. * @param point defines the point to test
  7103. * @returns true if the point is inside the bounding sphere
  7104. */
  7105. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7106. /**
  7107. * Checks if two sphere intersct
  7108. * @param sphere0 sphere 0
  7109. * @param sphere1 sphere 1
  7110. * @returns true if the speres intersect
  7111. */
  7112. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7113. }
  7114. }
  7115. declare module "babylonjs/Culling/boundingBox" {
  7116. import { DeepImmutable } from "babylonjs/types";
  7117. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7118. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7119. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7120. import { Plane } from "babylonjs/Maths/math.plane";
  7121. /**
  7122. * Class used to store bounding box information
  7123. */
  7124. export class BoundingBox implements ICullable {
  7125. /**
  7126. * Gets the 8 vectors representing the bounding box in local space
  7127. */
  7128. readonly vectors: Vector3[];
  7129. /**
  7130. * Gets the center of the bounding box in local space
  7131. */
  7132. readonly center: Vector3;
  7133. /**
  7134. * Gets the center of the bounding box in world space
  7135. */
  7136. readonly centerWorld: Vector3;
  7137. /**
  7138. * Gets the extend size in local space
  7139. */
  7140. readonly extendSize: Vector3;
  7141. /**
  7142. * Gets the extend size in world space
  7143. */
  7144. readonly extendSizeWorld: Vector3;
  7145. /**
  7146. * Gets the OBB (object bounding box) directions
  7147. */
  7148. readonly directions: Vector3[];
  7149. /**
  7150. * Gets the 8 vectors representing the bounding box in world space
  7151. */
  7152. readonly vectorsWorld: Vector3[];
  7153. /**
  7154. * Gets the minimum vector in world space
  7155. */
  7156. readonly minimumWorld: Vector3;
  7157. /**
  7158. * Gets the maximum vector in world space
  7159. */
  7160. readonly maximumWorld: Vector3;
  7161. /**
  7162. * Gets the minimum vector in local space
  7163. */
  7164. readonly minimum: Vector3;
  7165. /**
  7166. * Gets the maximum vector in local space
  7167. */
  7168. readonly maximum: Vector3;
  7169. private _worldMatrix;
  7170. private static readonly TmpVector3;
  7171. /**
  7172. * @hidden
  7173. */
  7174. _tag: number;
  7175. /**
  7176. * Creates a new bounding box
  7177. * @param min defines the minimum vector (in local space)
  7178. * @param max defines the maximum vector (in local space)
  7179. * @param worldMatrix defines the new world matrix
  7180. */
  7181. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7182. /**
  7183. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7184. * @param min defines the new minimum vector (in local space)
  7185. * @param max defines the new maximum vector (in local space)
  7186. * @param worldMatrix defines the new world matrix
  7187. */
  7188. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7189. /**
  7190. * Scale the current bounding box by applying a scale factor
  7191. * @param factor defines the scale factor to apply
  7192. * @returns the current bounding box
  7193. */
  7194. scale(factor: number): BoundingBox;
  7195. /**
  7196. * Gets the world matrix of the bounding box
  7197. * @returns a matrix
  7198. */
  7199. getWorldMatrix(): DeepImmutable<Matrix>;
  7200. /** @hidden */
  7201. _update(world: DeepImmutable<Matrix>): void;
  7202. /**
  7203. * Tests if the bounding box is intersecting the frustum planes
  7204. * @param frustumPlanes defines the frustum planes to test
  7205. * @returns true if there is an intersection
  7206. */
  7207. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7208. /**
  7209. * Tests if the bounding box is entirely inside the frustum planes
  7210. * @param frustumPlanes defines the frustum planes to test
  7211. * @returns true if there is an inclusion
  7212. */
  7213. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7214. /**
  7215. * Tests if a point is inside the bounding box
  7216. * @param point defines the point to test
  7217. * @returns true if the point is inside the bounding box
  7218. */
  7219. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7220. /**
  7221. * Tests if the bounding box intersects with a bounding sphere
  7222. * @param sphere defines the sphere to test
  7223. * @returns true if there is an intersection
  7224. */
  7225. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7226. /**
  7227. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7228. * @param min defines the min vector to use
  7229. * @param max defines the max vector to use
  7230. * @returns true if there is an intersection
  7231. */
  7232. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7233. /**
  7234. * Tests if two bounding boxes are intersections
  7235. * @param box0 defines the first box to test
  7236. * @param box1 defines the second box to test
  7237. * @returns true if there is an intersection
  7238. */
  7239. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7240. /**
  7241. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7242. * @param minPoint defines the minimum vector of the bounding box
  7243. * @param maxPoint defines the maximum vector of the bounding box
  7244. * @param sphereCenter defines the sphere center
  7245. * @param sphereRadius defines the sphere radius
  7246. * @returns true if there is an intersection
  7247. */
  7248. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7249. /**
  7250. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7251. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7252. * @param frustumPlanes defines the frustum planes to test
  7253. * @return true if there is an inclusion
  7254. */
  7255. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7256. /**
  7257. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7258. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7259. * @param frustumPlanes defines the frustum planes to test
  7260. * @return true if there is an intersection
  7261. */
  7262. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7263. }
  7264. }
  7265. declare module "babylonjs/Collisions/collider" {
  7266. import { Nullable, IndicesArray } from "babylonjs/types";
  7267. import { Vector3 } from "babylonjs/Maths/math.vector";
  7268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7269. import { Plane } from "babylonjs/Maths/math.plane";
  7270. /** @hidden */
  7271. export class Collider {
  7272. /** Define if a collision was found */
  7273. collisionFound: boolean;
  7274. /**
  7275. * Define last intersection point in local space
  7276. */
  7277. intersectionPoint: Vector3;
  7278. /**
  7279. * Define last collided mesh
  7280. */
  7281. collidedMesh: Nullable<AbstractMesh>;
  7282. private _collisionPoint;
  7283. private _planeIntersectionPoint;
  7284. private _tempVector;
  7285. private _tempVector2;
  7286. private _tempVector3;
  7287. private _tempVector4;
  7288. private _edge;
  7289. private _baseToVertex;
  7290. private _destinationPoint;
  7291. private _slidePlaneNormal;
  7292. private _displacementVector;
  7293. /** @hidden */
  7294. _radius: Vector3;
  7295. /** @hidden */
  7296. _retry: number;
  7297. private _velocity;
  7298. private _basePoint;
  7299. private _epsilon;
  7300. /** @hidden */
  7301. _velocityWorldLength: number;
  7302. /** @hidden */
  7303. _basePointWorld: Vector3;
  7304. private _velocityWorld;
  7305. private _normalizedVelocity;
  7306. /** @hidden */
  7307. _initialVelocity: Vector3;
  7308. /** @hidden */
  7309. _initialPosition: Vector3;
  7310. private _nearestDistance;
  7311. private _collisionMask;
  7312. get collisionMask(): number;
  7313. set collisionMask(mask: number);
  7314. /**
  7315. * Gets the plane normal used to compute the sliding response (in local space)
  7316. */
  7317. get slidePlaneNormal(): Vector3;
  7318. /** @hidden */
  7319. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7320. /** @hidden */
  7321. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7322. /** @hidden */
  7323. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7324. /** @hidden */
  7325. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7326. /** @hidden */
  7327. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7328. /** @hidden */
  7329. _getResponse(pos: Vector3, vel: Vector3): void;
  7330. }
  7331. }
  7332. declare module "babylonjs/Culling/boundingInfo" {
  7333. import { DeepImmutable } from "babylonjs/types";
  7334. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7335. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7336. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7337. import { Plane } from "babylonjs/Maths/math.plane";
  7338. import { Collider } from "babylonjs/Collisions/collider";
  7339. /**
  7340. * Interface for cullable objects
  7341. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7342. */
  7343. export interface ICullable {
  7344. /**
  7345. * Checks if the object or part of the object is in the frustum
  7346. * @param frustumPlanes Camera near/planes
  7347. * @returns true if the object is in frustum otherwise false
  7348. */
  7349. isInFrustum(frustumPlanes: Plane[]): boolean;
  7350. /**
  7351. * Checks if a cullable object (mesh...) is in the camera frustum
  7352. * Unlike isInFrustum this cheks the full bounding box
  7353. * @param frustumPlanes Camera near/planes
  7354. * @returns true if the object is in frustum otherwise false
  7355. */
  7356. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7357. }
  7358. /**
  7359. * Info for a bounding data of a mesh
  7360. */
  7361. export class BoundingInfo implements ICullable {
  7362. /**
  7363. * Bounding box for the mesh
  7364. */
  7365. readonly boundingBox: BoundingBox;
  7366. /**
  7367. * Bounding sphere for the mesh
  7368. */
  7369. readonly boundingSphere: BoundingSphere;
  7370. private _isLocked;
  7371. private static readonly TmpVector3;
  7372. /**
  7373. * Constructs bounding info
  7374. * @param minimum min vector of the bounding box/sphere
  7375. * @param maximum max vector of the bounding box/sphere
  7376. * @param worldMatrix defines the new world matrix
  7377. */
  7378. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7379. /**
  7380. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7381. * @param min defines the new minimum vector (in local space)
  7382. * @param max defines the new maximum vector (in local space)
  7383. * @param worldMatrix defines the new world matrix
  7384. */
  7385. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7386. /**
  7387. * min vector of the bounding box/sphere
  7388. */
  7389. get minimum(): Vector3;
  7390. /**
  7391. * max vector of the bounding box/sphere
  7392. */
  7393. get maximum(): Vector3;
  7394. /**
  7395. * If the info is locked and won't be updated to avoid perf overhead
  7396. */
  7397. get isLocked(): boolean;
  7398. set isLocked(value: boolean);
  7399. /**
  7400. * Updates the bounding sphere and box
  7401. * @param world world matrix to be used to update
  7402. */
  7403. update(world: DeepImmutable<Matrix>): void;
  7404. /**
  7405. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7406. * @param center New center of the bounding info
  7407. * @param extend New extend of the bounding info
  7408. * @returns the current bounding info
  7409. */
  7410. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7411. /**
  7412. * Scale the current bounding info by applying a scale factor
  7413. * @param factor defines the scale factor to apply
  7414. * @returns the current bounding info
  7415. */
  7416. scale(factor: number): BoundingInfo;
  7417. /**
  7418. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7419. * @param frustumPlanes defines the frustum to test
  7420. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7421. * @returns true if the bounding info is in the frustum planes
  7422. */
  7423. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7424. /**
  7425. * Gets the world distance between the min and max points of the bounding box
  7426. */
  7427. get diagonalLength(): number;
  7428. /**
  7429. * Checks if a cullable object (mesh...) is in the camera frustum
  7430. * Unlike isInFrustum this cheks the full bounding box
  7431. * @param frustumPlanes Camera near/planes
  7432. * @returns true if the object is in frustum otherwise false
  7433. */
  7434. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7435. /** @hidden */
  7436. _checkCollision(collider: Collider): boolean;
  7437. /**
  7438. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7439. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7440. * @param point the point to check intersection with
  7441. * @returns if the point intersects
  7442. */
  7443. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7444. /**
  7445. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7446. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7447. * @param boundingInfo the bounding info to check intersection with
  7448. * @param precise if the intersection should be done using OBB
  7449. * @returns if the bounding info intersects
  7450. */
  7451. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7452. }
  7453. }
  7454. declare module "babylonjs/Maths/math.functions" {
  7455. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7456. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7457. /**
  7458. * Extracts minimum and maximum values from a list of indexed positions
  7459. * @param positions defines the positions to use
  7460. * @param indices defines the indices to the positions
  7461. * @param indexStart defines the start index
  7462. * @param indexCount defines the end index
  7463. * @param bias defines bias value to add to the result
  7464. * @return minimum and maximum values
  7465. */
  7466. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7467. minimum: Vector3;
  7468. maximum: Vector3;
  7469. };
  7470. /**
  7471. * Extracts minimum and maximum values from a list of positions
  7472. * @param positions defines the positions to use
  7473. * @param start defines the start index in the positions array
  7474. * @param count defines the number of positions to handle
  7475. * @param bias defines bias value to add to the result
  7476. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7477. * @return minimum and maximum values
  7478. */
  7479. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7480. minimum: Vector3;
  7481. maximum: Vector3;
  7482. };
  7483. }
  7484. declare module "babylonjs/Misc/guid" {
  7485. /**
  7486. * Class used to manipulate GUIDs
  7487. */
  7488. export class GUID {
  7489. /**
  7490. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7491. * Be aware Math.random() could cause collisions, but:
  7492. * "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"
  7493. * @returns a pseudo random id
  7494. */
  7495. static RandomId(): string;
  7496. }
  7497. }
  7498. declare module "babylonjs/Materials/Textures/baseTexture" {
  7499. import { Observable } from "babylonjs/Misc/observable";
  7500. import { Nullable } from "babylonjs/types";
  7501. import { Scene } from "babylonjs/scene";
  7502. import { Matrix } from "babylonjs/Maths/math.vector";
  7503. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7504. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  7505. import "babylonjs/Misc/fileTools";
  7506. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7507. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  7508. /**
  7509. * Base class of all the textures in babylon.
  7510. * It groups all the common properties the materials, post process, lights... might need
  7511. * in order to make a correct use of the texture.
  7512. */
  7513. export class BaseTexture extends ThinTexture implements IAnimatable {
  7514. /**
  7515. * Default anisotropic filtering level for the application.
  7516. * It is set to 4 as a good tradeoff between perf and quality.
  7517. */
  7518. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7519. /**
  7520. * Gets or sets the unique id of the texture
  7521. */
  7522. uniqueId: number;
  7523. /**
  7524. * Define the name of the texture.
  7525. */
  7526. name: string;
  7527. /**
  7528. * Gets or sets an object used to store user defined information.
  7529. */
  7530. metadata: any;
  7531. /**
  7532. * For internal use only. Please do not use.
  7533. */
  7534. reservedDataStore: any;
  7535. private _hasAlpha;
  7536. /**
  7537. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7538. */
  7539. set hasAlpha(value: boolean);
  7540. get hasAlpha(): boolean;
  7541. /**
  7542. * Defines if the alpha value should be determined via the rgb values.
  7543. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7544. */
  7545. getAlphaFromRGB: boolean;
  7546. /**
  7547. * Intensity or strength of the texture.
  7548. * It is commonly used by materials to fine tune the intensity of the texture
  7549. */
  7550. level: number;
  7551. /**
  7552. * Define the UV chanel to use starting from 0 and defaulting to 0.
  7553. * This is part of the texture as textures usually maps to one uv set.
  7554. */
  7555. coordinatesIndex: number;
  7556. protected _coordinatesMode: number;
  7557. /**
  7558. * How a texture is mapped.
  7559. *
  7560. * | Value | Type | Description |
  7561. * | ----- | ----------------------------------- | ----------- |
  7562. * | 0 | EXPLICIT_MODE | |
  7563. * | 1 | SPHERICAL_MODE | |
  7564. * | 2 | PLANAR_MODE | |
  7565. * | 3 | CUBIC_MODE | |
  7566. * | 4 | PROJECTION_MODE | |
  7567. * | 5 | SKYBOX_MODE | |
  7568. * | 6 | INVCUBIC_MODE | |
  7569. * | 7 | EQUIRECTANGULAR_MODE | |
  7570. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7571. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7572. */
  7573. set coordinatesMode(value: number);
  7574. get coordinatesMode(): number;
  7575. /**
  7576. * | Value | Type | Description |
  7577. * | ----- | ------------------ | ----------- |
  7578. * | 0 | CLAMP_ADDRESSMODE | |
  7579. * | 1 | WRAP_ADDRESSMODE | |
  7580. * | 2 | MIRROR_ADDRESSMODE | |
  7581. */
  7582. get wrapU(): number;
  7583. set wrapU(value: number);
  7584. /**
  7585. * | Value | Type | Description |
  7586. * | ----- | ------------------ | ----------- |
  7587. * | 0 | CLAMP_ADDRESSMODE | |
  7588. * | 1 | WRAP_ADDRESSMODE | |
  7589. * | 2 | MIRROR_ADDRESSMODE | |
  7590. */
  7591. get wrapV(): number;
  7592. set wrapV(value: number);
  7593. /**
  7594. * | Value | Type | Description |
  7595. * | ----- | ------------------ | ----------- |
  7596. * | 0 | CLAMP_ADDRESSMODE | |
  7597. * | 1 | WRAP_ADDRESSMODE | |
  7598. * | 2 | MIRROR_ADDRESSMODE | |
  7599. */
  7600. wrapR: number;
  7601. /**
  7602. * With compliant hardware and browser (supporting anisotropic filtering)
  7603. * this defines the level of anisotropic filtering in the texture.
  7604. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7605. */
  7606. anisotropicFilteringLevel: number;
  7607. private _isCube;
  7608. /**
  7609. * Define if the texture is a cube texture or if false a 2d texture.
  7610. */
  7611. get isCube(): boolean;
  7612. set isCube(value: boolean);
  7613. /**
  7614. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7615. */
  7616. get is3D(): boolean;
  7617. set is3D(value: boolean);
  7618. /**
  7619. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7620. */
  7621. get is2DArray(): boolean;
  7622. set is2DArray(value: boolean);
  7623. private _gammaSpace;
  7624. /**
  7625. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7626. * HDR texture are usually stored in linear space.
  7627. * This only impacts the PBR and Background materials
  7628. */
  7629. get gammaSpace(): boolean;
  7630. set gammaSpace(gamma: boolean);
  7631. /**
  7632. * Gets or sets whether or not the texture contains RGBD data.
  7633. */
  7634. get isRGBD(): boolean;
  7635. set isRGBD(value: boolean);
  7636. /**
  7637. * Is Z inverted in the texture (useful in a cube texture).
  7638. */
  7639. invertZ: boolean;
  7640. /**
  7641. * Are mip maps generated for this texture or not.
  7642. */
  7643. get noMipmap(): boolean;
  7644. /**
  7645. * @hidden
  7646. */
  7647. lodLevelInAlpha: boolean;
  7648. /**
  7649. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7650. */
  7651. get lodGenerationOffset(): number;
  7652. set lodGenerationOffset(value: number);
  7653. /**
  7654. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7655. */
  7656. get lodGenerationScale(): number;
  7657. set lodGenerationScale(value: number);
  7658. /**
  7659. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7660. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7661. * average roughness values.
  7662. */
  7663. get linearSpecularLOD(): boolean;
  7664. set linearSpecularLOD(value: boolean);
  7665. /**
  7666. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7667. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7668. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7669. */
  7670. get irradianceTexture(): Nullable<BaseTexture>;
  7671. set irradianceTexture(value: Nullable<BaseTexture>);
  7672. /**
  7673. * Define if the texture is a render target.
  7674. */
  7675. isRenderTarget: boolean;
  7676. /**
  7677. * Define the unique id of the texture in the scene.
  7678. */
  7679. get uid(): string;
  7680. /** @hidden */
  7681. _prefiltered: boolean;
  7682. /**
  7683. * Return a string representation of the texture.
  7684. * @returns the texture as a string
  7685. */
  7686. toString(): string;
  7687. /**
  7688. * Get the class name of the texture.
  7689. * @returns "BaseTexture"
  7690. */
  7691. getClassName(): string;
  7692. /**
  7693. * Define the list of animation attached to the texture.
  7694. */
  7695. animations: import("babylonjs/Animations/animation").Animation[];
  7696. /**
  7697. * An event triggered when the texture is disposed.
  7698. */
  7699. onDisposeObservable: Observable<BaseTexture>;
  7700. private _onDisposeObserver;
  7701. /**
  7702. * Callback triggered when the texture has been disposed.
  7703. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7704. */
  7705. set onDispose(callback: () => void);
  7706. protected _scene: Nullable<Scene>;
  7707. /** @hidden */
  7708. _texture: Nullable<InternalTexture>;
  7709. private _uid;
  7710. /**
  7711. * Define if the texture is preventinga material to render or not.
  7712. * If not and the texture is not ready, the engine will use a default black texture instead.
  7713. */
  7714. get isBlocking(): boolean;
  7715. /**
  7716. * Instantiates a new BaseTexture.
  7717. * Base class of all the textures in babylon.
  7718. * It groups all the common properties the materials, post process, lights... might need
  7719. * in order to make a correct use of the texture.
  7720. * @param sceneOrEngine Define the scene or engine the texture blongs to
  7721. */
  7722. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  7723. /**
  7724. * Get the scene the texture belongs to.
  7725. * @returns the scene or null if undefined
  7726. */
  7727. getScene(): Nullable<Scene>;
  7728. /** @hidden */
  7729. protected _getEngine(): Nullable<ThinEngine>;
  7730. /**
  7731. * Checks if the texture has the same transform matrix than another texture
  7732. * @param texture texture to check against
  7733. * @returns true if the transforms are the same, else false
  7734. */
  7735. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  7736. /**
  7737. * Get the texture transform matrix used to offset tile the texture for istance.
  7738. * @returns the transformation matrix
  7739. */
  7740. getTextureMatrix(): Matrix;
  7741. /**
  7742. * Get the texture reflection matrix used to rotate/transform the reflection.
  7743. * @returns the reflection matrix
  7744. */
  7745. getReflectionTextureMatrix(): Matrix;
  7746. /**
  7747. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  7748. * @returns true if ready or not blocking
  7749. */
  7750. isReadyOrNotBlocking(): boolean;
  7751. /**
  7752. * Scales the texture if is `canRescale()`
  7753. * @param ratio the resize factor we want to use to rescale
  7754. */
  7755. scale(ratio: number): void;
  7756. /**
  7757. * Get if the texture can rescale.
  7758. */
  7759. get canRescale(): boolean;
  7760. /** @hidden */
  7761. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  7762. /** @hidden */
  7763. _rebuild(): void;
  7764. /**
  7765. * Clones the texture.
  7766. * @returns the cloned texture
  7767. */
  7768. clone(): Nullable<BaseTexture>;
  7769. /**
  7770. * Get the texture underlying type (INT, FLOAT...)
  7771. */
  7772. get textureType(): number;
  7773. /**
  7774. * Get the texture underlying format (RGB, RGBA...)
  7775. */
  7776. get textureFormat(): number;
  7777. /**
  7778. * Indicates that textures need to be re-calculated for all materials
  7779. */
  7780. protected _markAllSubMeshesAsTexturesDirty(): void;
  7781. /**
  7782. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  7783. * This will returns an RGBA array buffer containing either in values (0-255) or
  7784. * float values (0-1) depending of the underlying buffer type.
  7785. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  7786. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  7787. * @param buffer defines a user defined buffer to fill with data (can be null)
  7788. * @returns The Array buffer containing the pixels data.
  7789. */
  7790. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  7791. /** @hidden */
  7792. get _lodTextureHigh(): Nullable<BaseTexture>;
  7793. /** @hidden */
  7794. get _lodTextureMid(): Nullable<BaseTexture>;
  7795. /** @hidden */
  7796. get _lodTextureLow(): Nullable<BaseTexture>;
  7797. /**
  7798. * Dispose the texture and release its associated resources.
  7799. */
  7800. dispose(): void;
  7801. /**
  7802. * Serialize the texture into a JSON representation that can be parsed later on.
  7803. * @returns the JSON representation of the texture
  7804. */
  7805. serialize(): any;
  7806. /**
  7807. * Helper function to be called back once a list of texture contains only ready textures.
  7808. * @param textures Define the list of textures to wait for
  7809. * @param callback Define the callback triggered once the entire list will be ready
  7810. */
  7811. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  7812. private static _isScene;
  7813. }
  7814. }
  7815. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7816. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7817. /** @hidden */
  7818. export class WebGLDataBuffer extends DataBuffer {
  7819. private _buffer;
  7820. constructor(resource: WebGLBuffer);
  7821. get underlyingResource(): any;
  7822. }
  7823. }
  7824. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7825. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7826. import { Nullable } from "babylonjs/types";
  7827. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7828. /** @hidden */
  7829. export class WebGLPipelineContext implements IPipelineContext {
  7830. engine: ThinEngine;
  7831. program: Nullable<WebGLProgram>;
  7832. context?: WebGLRenderingContext;
  7833. vertexShader?: WebGLShader;
  7834. fragmentShader?: WebGLShader;
  7835. isParallelCompiled: boolean;
  7836. onCompiled?: () => void;
  7837. transformFeedback?: WebGLTransformFeedback | null;
  7838. vertexCompilationError: Nullable<string>;
  7839. fragmentCompilationError: Nullable<string>;
  7840. programLinkError: Nullable<string>;
  7841. programValidationError: Nullable<string>;
  7842. get isAsync(): boolean;
  7843. get isReady(): boolean;
  7844. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7845. _getVertexShaderCode(): string | null;
  7846. _getFragmentShaderCode(): string | null;
  7847. }
  7848. }
  7849. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7850. import { FloatArray, Nullable } from "babylonjs/types";
  7851. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7852. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7853. module "babylonjs/Engines/thinEngine" {
  7854. interface ThinEngine {
  7855. /**
  7856. * Create an uniform buffer
  7857. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7858. * @param elements defines the content of the uniform buffer
  7859. * @returns the webGL uniform buffer
  7860. */
  7861. createUniformBuffer(elements: FloatArray): DataBuffer;
  7862. /**
  7863. * Create a dynamic uniform buffer
  7864. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7865. * @param elements defines the content of the uniform buffer
  7866. * @returns the webGL uniform buffer
  7867. */
  7868. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7869. /**
  7870. * Update an existing uniform buffer
  7871. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7872. * @param uniformBuffer defines the target uniform buffer
  7873. * @param elements defines the content to update
  7874. * @param offset defines the offset in the uniform buffer where update should start
  7875. * @param count defines the size of the data to update
  7876. */
  7877. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7878. /**
  7879. * Bind an uniform buffer to the current webGL context
  7880. * @param buffer defines the buffer to bind
  7881. */
  7882. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7883. /**
  7884. * Bind a buffer to the current webGL context at a given location
  7885. * @param buffer defines the buffer to bind
  7886. * @param location defines the index where to bind the buffer
  7887. */
  7888. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7889. /**
  7890. * Bind a specific block at a given index in a specific shader program
  7891. * @param pipelineContext defines the pipeline context to use
  7892. * @param blockName defines the block name
  7893. * @param index defines the index where to bind the block
  7894. */
  7895. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7896. }
  7897. }
  7898. }
  7899. declare module "babylonjs/Materials/uniformBuffer" {
  7900. import { Nullable, FloatArray } from "babylonjs/types";
  7901. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7902. import { Engine } from "babylonjs/Engines/engine";
  7903. import { Effect } from "babylonjs/Materials/effect";
  7904. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7905. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7906. import { Color3 } from "babylonjs/Maths/math.color";
  7907. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7908. /**
  7909. * Uniform buffer objects.
  7910. *
  7911. * Handles blocks of uniform on the GPU.
  7912. *
  7913. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7914. *
  7915. * For more information, please refer to :
  7916. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7917. */
  7918. export class UniformBuffer {
  7919. private _engine;
  7920. private _buffer;
  7921. private _data;
  7922. private _bufferData;
  7923. private _dynamic?;
  7924. private _uniformLocations;
  7925. private _uniformSizes;
  7926. private _uniformLocationPointer;
  7927. private _needSync;
  7928. private _noUBO;
  7929. private _currentEffect;
  7930. /** @hidden */
  7931. _alreadyBound: boolean;
  7932. private static _MAX_UNIFORM_SIZE;
  7933. private static _tempBuffer;
  7934. /**
  7935. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7936. * This is dynamic to allow compat with webgl 1 and 2.
  7937. * You will need to pass the name of the uniform as well as the value.
  7938. */
  7939. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7940. /**
  7941. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7942. * This is dynamic to allow compat with webgl 1 and 2.
  7943. * You will need to pass the name of the uniform as well as the value.
  7944. */
  7945. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7946. /**
  7947. * Lambda to Update a single float in a uniform buffer.
  7948. * This is dynamic to allow compat with webgl 1 and 2.
  7949. * You will need to pass the name of the uniform as well as the value.
  7950. */
  7951. updateFloat: (name: string, x: number) => void;
  7952. /**
  7953. * Lambda to Update a vec2 of float in a uniform buffer.
  7954. * This is dynamic to allow compat with webgl 1 and 2.
  7955. * You will need to pass the name of the uniform as well as the value.
  7956. */
  7957. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7958. /**
  7959. * Lambda to Update a vec3 of float in a uniform buffer.
  7960. * This is dynamic to allow compat with webgl 1 and 2.
  7961. * You will need to pass the name of the uniform as well as the value.
  7962. */
  7963. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7964. /**
  7965. * Lambda to Update a vec4 of float in a uniform buffer.
  7966. * This is dynamic to allow compat with webgl 1 and 2.
  7967. * You will need to pass the name of the uniform as well as the value.
  7968. */
  7969. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7970. /**
  7971. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7972. * This is dynamic to allow compat with webgl 1 and 2.
  7973. * You will need to pass the name of the uniform as well as the value.
  7974. */
  7975. updateMatrix: (name: string, mat: Matrix) => void;
  7976. /**
  7977. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7978. * This is dynamic to allow compat with webgl 1 and 2.
  7979. * You will need to pass the name of the uniform as well as the value.
  7980. */
  7981. updateVector3: (name: string, vector: Vector3) => void;
  7982. /**
  7983. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7984. * This is dynamic to allow compat with webgl 1 and 2.
  7985. * You will need to pass the name of the uniform as well as the value.
  7986. */
  7987. updateVector4: (name: string, vector: Vector4) => void;
  7988. /**
  7989. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7990. * This is dynamic to allow compat with webgl 1 and 2.
  7991. * You will need to pass the name of the uniform as well as the value.
  7992. */
  7993. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7994. /**
  7995. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7996. * This is dynamic to allow compat with webgl 1 and 2.
  7997. * You will need to pass the name of the uniform as well as the value.
  7998. */
  7999. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8000. /**
  8001. * Instantiates a new Uniform buffer objects.
  8002. *
  8003. * Handles blocks of uniform on the GPU.
  8004. *
  8005. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8006. *
  8007. * For more information, please refer to :
  8008. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8009. * @param engine Define the engine the buffer is associated with
  8010. * @param data Define the data contained in the buffer
  8011. * @param dynamic Define if the buffer is updatable
  8012. */
  8013. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  8014. /**
  8015. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8016. * or just falling back on setUniformXXX calls.
  8017. */
  8018. get useUbo(): boolean;
  8019. /**
  8020. * Indicates if the WebGL underlying uniform buffer is in sync
  8021. * with the javascript cache data.
  8022. */
  8023. get isSync(): boolean;
  8024. /**
  8025. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8026. * Also, a dynamic UniformBuffer will disable cache verification and always
  8027. * update the underlying WebGL uniform buffer to the GPU.
  8028. * @returns if Dynamic, otherwise false
  8029. */
  8030. isDynamic(): boolean;
  8031. /**
  8032. * The data cache on JS side.
  8033. * @returns the underlying data as a float array
  8034. */
  8035. getData(): Float32Array;
  8036. /**
  8037. * The underlying WebGL Uniform buffer.
  8038. * @returns the webgl buffer
  8039. */
  8040. getBuffer(): Nullable<DataBuffer>;
  8041. /**
  8042. * std140 layout specifies how to align data within an UBO structure.
  8043. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8044. * for specs.
  8045. */
  8046. private _fillAlignment;
  8047. /**
  8048. * Adds an uniform in the buffer.
  8049. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8050. * for the layout to be correct !
  8051. * @param name Name of the uniform, as used in the uniform block in the shader.
  8052. * @param size Data size, or data directly.
  8053. */
  8054. addUniform(name: string, size: number | number[]): void;
  8055. /**
  8056. * Adds a Matrix 4x4 to the uniform buffer.
  8057. * @param name Name of the uniform, as used in the uniform block in the shader.
  8058. * @param mat A 4x4 matrix.
  8059. */
  8060. addMatrix(name: string, mat: Matrix): void;
  8061. /**
  8062. * Adds a vec2 to the uniform buffer.
  8063. * @param name Name of the uniform, as used in the uniform block in the shader.
  8064. * @param x Define the x component value of the vec2
  8065. * @param y Define the y component value of the vec2
  8066. */
  8067. addFloat2(name: string, x: number, y: number): void;
  8068. /**
  8069. * Adds a vec3 to the uniform buffer.
  8070. * @param name Name of the uniform, as used in the uniform block in the shader.
  8071. * @param x Define the x component value of the vec3
  8072. * @param y Define the y component value of the vec3
  8073. * @param z Define the z component value of the vec3
  8074. */
  8075. addFloat3(name: string, x: number, y: number, z: number): void;
  8076. /**
  8077. * Adds a vec3 to the uniform buffer.
  8078. * @param name Name of the uniform, as used in the uniform block in the shader.
  8079. * @param color Define the vec3 from a Color
  8080. */
  8081. addColor3(name: string, color: Color3): void;
  8082. /**
  8083. * Adds a vec4 to the uniform buffer.
  8084. * @param name Name of the uniform, as used in the uniform block in the shader.
  8085. * @param color Define the rgb components from a Color
  8086. * @param alpha Define the a component of the vec4
  8087. */
  8088. addColor4(name: string, color: Color3, alpha: number): void;
  8089. /**
  8090. * Adds a vec3 to the uniform buffer.
  8091. * @param name Name of the uniform, as used in the uniform block in the shader.
  8092. * @param vector Define the vec3 components from a Vector
  8093. */
  8094. addVector3(name: string, vector: Vector3): void;
  8095. /**
  8096. * Adds a Matrix 3x3 to the uniform buffer.
  8097. * @param name Name of the uniform, as used in the uniform block in the shader.
  8098. */
  8099. addMatrix3x3(name: string): void;
  8100. /**
  8101. * Adds a Matrix 2x2 to the uniform buffer.
  8102. * @param name Name of the uniform, as used in the uniform block in the shader.
  8103. */
  8104. addMatrix2x2(name: string): void;
  8105. /**
  8106. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8107. */
  8108. create(): void;
  8109. /** @hidden */
  8110. _rebuild(): void;
  8111. /**
  8112. * Updates the WebGL Uniform Buffer on the GPU.
  8113. * If the `dynamic` flag is set to true, no cache comparison is done.
  8114. * Otherwise, the buffer will be updated only if the cache differs.
  8115. */
  8116. update(): void;
  8117. /**
  8118. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8119. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8120. * @param data Define the flattened data
  8121. * @param size Define the size of the data.
  8122. */
  8123. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8124. private _valueCache;
  8125. private _cacheMatrix;
  8126. private _updateMatrix3x3ForUniform;
  8127. private _updateMatrix3x3ForEffect;
  8128. private _updateMatrix2x2ForEffect;
  8129. private _updateMatrix2x2ForUniform;
  8130. private _updateFloatForEffect;
  8131. private _updateFloatForUniform;
  8132. private _updateFloat2ForEffect;
  8133. private _updateFloat2ForUniform;
  8134. private _updateFloat3ForEffect;
  8135. private _updateFloat3ForUniform;
  8136. private _updateFloat4ForEffect;
  8137. private _updateFloat4ForUniform;
  8138. private _updateMatrixForEffect;
  8139. private _updateMatrixForUniform;
  8140. private _updateVector3ForEffect;
  8141. private _updateVector3ForUniform;
  8142. private _updateVector4ForEffect;
  8143. private _updateVector4ForUniform;
  8144. private _updateColor3ForEffect;
  8145. private _updateColor3ForUniform;
  8146. private _updateColor4ForEffect;
  8147. private _updateColor4ForUniform;
  8148. /**
  8149. * Sets a sampler uniform on the effect.
  8150. * @param name Define the name of the sampler.
  8151. * @param texture Define the texture to set in the sampler
  8152. */
  8153. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8154. /**
  8155. * Directly updates the value of the uniform in the cache AND on the GPU.
  8156. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8157. * @param data Define the flattened data
  8158. */
  8159. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8160. /**
  8161. * Binds this uniform buffer to an effect.
  8162. * @param effect Define the effect to bind the buffer to
  8163. * @param name Name of the uniform block in the shader.
  8164. */
  8165. bindToEffect(effect: Effect, name: string): void;
  8166. /**
  8167. * Disposes the uniform buffer.
  8168. */
  8169. dispose(): void;
  8170. }
  8171. }
  8172. declare module "babylonjs/Materials/materialDefines" {
  8173. /**
  8174. * Manages the defines for the Material
  8175. */
  8176. export class MaterialDefines {
  8177. /** @hidden */
  8178. protected _keys: string[];
  8179. private _isDirty;
  8180. /** @hidden */
  8181. _renderId: number;
  8182. /** @hidden */
  8183. _areLightsDirty: boolean;
  8184. /** @hidden */
  8185. _areLightsDisposed: boolean;
  8186. /** @hidden */
  8187. _areAttributesDirty: boolean;
  8188. /** @hidden */
  8189. _areTexturesDirty: boolean;
  8190. /** @hidden */
  8191. _areFresnelDirty: boolean;
  8192. /** @hidden */
  8193. _areMiscDirty: boolean;
  8194. /** @hidden */
  8195. _arePrePassDirty: boolean;
  8196. /** @hidden */
  8197. _areImageProcessingDirty: boolean;
  8198. /** @hidden */
  8199. _normals: boolean;
  8200. /** @hidden */
  8201. _uvs: boolean;
  8202. /** @hidden */
  8203. _needNormals: boolean;
  8204. /** @hidden */
  8205. _needUVs: boolean;
  8206. [id: string]: any;
  8207. /**
  8208. * Specifies if the material needs to be re-calculated
  8209. */
  8210. get isDirty(): boolean;
  8211. /**
  8212. * Marks the material to indicate that it has been re-calculated
  8213. */
  8214. markAsProcessed(): void;
  8215. /**
  8216. * Marks the material to indicate that it needs to be re-calculated
  8217. */
  8218. markAsUnprocessed(): void;
  8219. /**
  8220. * Marks the material to indicate all of its defines need to be re-calculated
  8221. */
  8222. markAllAsDirty(): void;
  8223. /**
  8224. * Marks the material to indicate that image processing needs to be re-calculated
  8225. */
  8226. markAsImageProcessingDirty(): void;
  8227. /**
  8228. * Marks the material to indicate the lights need to be re-calculated
  8229. * @param disposed Defines whether the light is dirty due to dispose or not
  8230. */
  8231. markAsLightDirty(disposed?: boolean): void;
  8232. /**
  8233. * Marks the attribute state as changed
  8234. */
  8235. markAsAttributesDirty(): void;
  8236. /**
  8237. * Marks the texture state as changed
  8238. */
  8239. markAsTexturesDirty(): void;
  8240. /**
  8241. * Marks the fresnel state as changed
  8242. */
  8243. markAsFresnelDirty(): void;
  8244. /**
  8245. * Marks the misc state as changed
  8246. */
  8247. markAsMiscDirty(): void;
  8248. /**
  8249. * Marks the prepass state as changed
  8250. */
  8251. markAsPrePassDirty(): void;
  8252. /**
  8253. * Rebuilds the material defines
  8254. */
  8255. rebuild(): void;
  8256. /**
  8257. * Specifies if two material defines are equal
  8258. * @param other - A material define instance to compare to
  8259. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8260. */
  8261. isEqual(other: MaterialDefines): boolean;
  8262. /**
  8263. * Clones this instance's defines to another instance
  8264. * @param other - material defines to clone values to
  8265. */
  8266. cloneTo(other: MaterialDefines): void;
  8267. /**
  8268. * Resets the material define values
  8269. */
  8270. reset(): void;
  8271. /**
  8272. * Converts the material define values to a string
  8273. * @returns - String of material define information
  8274. */
  8275. toString(): string;
  8276. }
  8277. }
  8278. declare module "babylonjs/Misc/iInspectable" {
  8279. /**
  8280. * Enum that determines the text-wrapping mode to use.
  8281. */
  8282. export enum InspectableType {
  8283. /**
  8284. * Checkbox for booleans
  8285. */
  8286. Checkbox = 0,
  8287. /**
  8288. * Sliders for numbers
  8289. */
  8290. Slider = 1,
  8291. /**
  8292. * Vector3
  8293. */
  8294. Vector3 = 2,
  8295. /**
  8296. * Quaternions
  8297. */
  8298. Quaternion = 3,
  8299. /**
  8300. * Color3
  8301. */
  8302. Color3 = 4,
  8303. /**
  8304. * String
  8305. */
  8306. String = 5
  8307. }
  8308. /**
  8309. * Interface used to define custom inspectable properties.
  8310. * This interface is used by the inspector to display custom property grids
  8311. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8312. */
  8313. export interface IInspectable {
  8314. /**
  8315. * Gets the label to display
  8316. */
  8317. label: string;
  8318. /**
  8319. * Gets the name of the property to edit
  8320. */
  8321. propertyName: string;
  8322. /**
  8323. * Gets the type of the editor to use
  8324. */
  8325. type: InspectableType;
  8326. /**
  8327. * Gets the minimum value of the property when using in "slider" mode
  8328. */
  8329. min?: number;
  8330. /**
  8331. * Gets the maximum value of the property when using in "slider" mode
  8332. */
  8333. max?: number;
  8334. /**
  8335. * Gets the setp to use when using in "slider" mode
  8336. */
  8337. step?: number;
  8338. }
  8339. }
  8340. declare module "babylonjs/Lights/light" {
  8341. import { Nullable } from "babylonjs/types";
  8342. import { Scene } from "babylonjs/scene";
  8343. import { Vector3 } from "babylonjs/Maths/math.vector";
  8344. import { Color3 } from "babylonjs/Maths/math.color";
  8345. import { Node } from "babylonjs/node";
  8346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8347. import { Effect } from "babylonjs/Materials/effect";
  8348. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8349. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  8350. /**
  8351. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8352. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8353. * 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.
  8354. */
  8355. export abstract class Light extends Node {
  8356. /**
  8357. * Falloff Default: light is falling off following the material specification:
  8358. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8359. */
  8360. static readonly FALLOFF_DEFAULT: number;
  8361. /**
  8362. * Falloff Physical: light is falling off following the inverse squared distance law.
  8363. */
  8364. static readonly FALLOFF_PHYSICAL: number;
  8365. /**
  8366. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8367. * to enhance interoperability with other engines.
  8368. */
  8369. static readonly FALLOFF_GLTF: number;
  8370. /**
  8371. * Falloff Standard: light is falling off like in the standard material
  8372. * to enhance interoperability with other materials.
  8373. */
  8374. static readonly FALLOFF_STANDARD: number;
  8375. /**
  8376. * If every light affecting the material is in this lightmapMode,
  8377. * material.lightmapTexture adds or multiplies
  8378. * (depends on material.useLightmapAsShadowmap)
  8379. * after every other light calculations.
  8380. */
  8381. static readonly LIGHTMAP_DEFAULT: number;
  8382. /**
  8383. * material.lightmapTexture as only diffuse lighting from this light
  8384. * adds only specular lighting from this light
  8385. * adds dynamic shadows
  8386. */
  8387. static readonly LIGHTMAP_SPECULAR: number;
  8388. /**
  8389. * material.lightmapTexture as only lighting
  8390. * no light calculation from this light
  8391. * only adds dynamic shadows from this light
  8392. */
  8393. static readonly LIGHTMAP_SHADOWSONLY: number;
  8394. /**
  8395. * Each light type uses the default quantity according to its type:
  8396. * point/spot lights use luminous intensity
  8397. * directional lights use illuminance
  8398. */
  8399. static readonly INTENSITYMODE_AUTOMATIC: number;
  8400. /**
  8401. * lumen (lm)
  8402. */
  8403. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8404. /**
  8405. * candela (lm/sr)
  8406. */
  8407. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8408. /**
  8409. * lux (lm/m^2)
  8410. */
  8411. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8412. /**
  8413. * nit (cd/m^2)
  8414. */
  8415. static readonly INTENSITYMODE_LUMINANCE: number;
  8416. /**
  8417. * Light type const id of the point light.
  8418. */
  8419. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8420. /**
  8421. * Light type const id of the directional light.
  8422. */
  8423. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8424. /**
  8425. * Light type const id of the spot light.
  8426. */
  8427. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8428. /**
  8429. * Light type const id of the hemispheric light.
  8430. */
  8431. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8432. /**
  8433. * Diffuse gives the basic color to an object.
  8434. */
  8435. diffuse: Color3;
  8436. /**
  8437. * Specular produces a highlight color on an object.
  8438. * Note: This is note affecting PBR materials.
  8439. */
  8440. specular: Color3;
  8441. /**
  8442. * Defines the falloff type for this light. This lets overrriding how punctual light are
  8443. * falling off base on range or angle.
  8444. * This can be set to any values in Light.FALLOFF_x.
  8445. *
  8446. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8447. * other types of materials.
  8448. */
  8449. falloffType: number;
  8450. /**
  8451. * Strength of the light.
  8452. * Note: By default it is define in the framework own unit.
  8453. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  8454. */
  8455. intensity: number;
  8456. private _range;
  8457. protected _inverseSquaredRange: number;
  8458. /**
  8459. * Defines how far from the source the light is impacting in scene units.
  8460. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8461. */
  8462. get range(): number;
  8463. /**
  8464. * Defines how far from the source the light is impacting in scene units.
  8465. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8466. */
  8467. set range(value: number);
  8468. /**
  8469. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  8470. * of light.
  8471. */
  8472. private _photometricScale;
  8473. private _intensityMode;
  8474. /**
  8475. * Gets the photometric scale used to interpret the intensity.
  8476. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8477. */
  8478. get intensityMode(): number;
  8479. /**
  8480. * Sets the photometric scale used to interpret the intensity.
  8481. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8482. */
  8483. set intensityMode(value: number);
  8484. private _radius;
  8485. /**
  8486. * Gets the light radius used by PBR Materials to simulate soft area lights.
  8487. */
  8488. get radius(): number;
  8489. /**
  8490. * sets the light radius used by PBR Materials to simulate soft area lights.
  8491. */
  8492. set radius(value: number);
  8493. private _renderPriority;
  8494. /**
  8495. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  8496. * exceeding the number allowed of the materials.
  8497. */
  8498. renderPriority: number;
  8499. private _shadowEnabled;
  8500. /**
  8501. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8502. * the current shadow generator.
  8503. */
  8504. get shadowEnabled(): boolean;
  8505. /**
  8506. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8507. * the current shadow generator.
  8508. */
  8509. set shadowEnabled(value: boolean);
  8510. private _includedOnlyMeshes;
  8511. /**
  8512. * Gets the only meshes impacted by this light.
  8513. */
  8514. get includedOnlyMeshes(): AbstractMesh[];
  8515. /**
  8516. * Sets the only meshes impacted by this light.
  8517. */
  8518. set includedOnlyMeshes(value: AbstractMesh[]);
  8519. private _excludedMeshes;
  8520. /**
  8521. * Gets the meshes not impacted by this light.
  8522. */
  8523. get excludedMeshes(): AbstractMesh[];
  8524. /**
  8525. * Sets the meshes not impacted by this light.
  8526. */
  8527. set excludedMeshes(value: AbstractMesh[]);
  8528. private _excludeWithLayerMask;
  8529. /**
  8530. * Gets the layer id use to find what meshes are not impacted by the light.
  8531. * Inactive if 0
  8532. */
  8533. get excludeWithLayerMask(): number;
  8534. /**
  8535. * Sets the layer id use to find what meshes are not impacted by the light.
  8536. * Inactive if 0
  8537. */
  8538. set excludeWithLayerMask(value: number);
  8539. private _includeOnlyWithLayerMask;
  8540. /**
  8541. * Gets the layer id use to find what meshes are impacted by the light.
  8542. * Inactive if 0
  8543. */
  8544. get includeOnlyWithLayerMask(): number;
  8545. /**
  8546. * Sets the layer id use to find what meshes are impacted by the light.
  8547. * Inactive if 0
  8548. */
  8549. set includeOnlyWithLayerMask(value: number);
  8550. private _lightmapMode;
  8551. /**
  8552. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8553. */
  8554. get lightmapMode(): number;
  8555. /**
  8556. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8557. */
  8558. set lightmapMode(value: number);
  8559. /**
  8560. * Shadow generator associted to the light.
  8561. * @hidden Internal use only.
  8562. */
  8563. _shadowGenerator: Nullable<IShadowGenerator>;
  8564. /**
  8565. * @hidden Internal use only.
  8566. */
  8567. _excludedMeshesIds: string[];
  8568. /**
  8569. * @hidden Internal use only.
  8570. */
  8571. _includedOnlyMeshesIds: string[];
  8572. /**
  8573. * The current light unifom buffer.
  8574. * @hidden Internal use only.
  8575. */
  8576. _uniformBuffer: UniformBuffer;
  8577. /** @hidden */
  8578. _renderId: number;
  8579. /**
  8580. * Creates a Light object in the scene.
  8581. * Documentation : https://doc.babylonjs.com/babylon101/lights
  8582. * @param name The firendly name of the light
  8583. * @param scene The scene the light belongs too
  8584. */
  8585. constructor(name: string, scene: Scene);
  8586. protected abstract _buildUniformLayout(): void;
  8587. /**
  8588. * Sets the passed Effect "effect" with the Light information.
  8589. * @param effect The effect to update
  8590. * @param lightIndex The index of the light in the effect to update
  8591. * @returns The light
  8592. */
  8593. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  8594. /**
  8595. * Sets the passed Effect "effect" with the Light textures.
  8596. * @param effect The effect to update
  8597. * @param lightIndex The index of the light in the effect to update
  8598. * @returns The light
  8599. */
  8600. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  8601. /**
  8602. * Binds the lights information from the scene to the effect for the given mesh.
  8603. * @param lightIndex Light index
  8604. * @param scene The scene where the light belongs to
  8605. * @param effect The effect we are binding the data to
  8606. * @param useSpecular Defines if specular is supported
  8607. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8608. */
  8609. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  8610. /**
  8611. * Sets the passed Effect "effect" with the Light information.
  8612. * @param effect The effect to update
  8613. * @param lightDataUniformName The uniform used to store light data (position or direction)
  8614. * @returns The light
  8615. */
  8616. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  8617. /**
  8618. * Returns the string "Light".
  8619. * @returns the class name
  8620. */
  8621. getClassName(): string;
  8622. /** @hidden */
  8623. readonly _isLight: boolean;
  8624. /**
  8625. * Converts the light information to a readable string for debug purpose.
  8626. * @param fullDetails Supports for multiple levels of logging within scene loading
  8627. * @returns the human readable light info
  8628. */
  8629. toString(fullDetails?: boolean): string;
  8630. /** @hidden */
  8631. protected _syncParentEnabledState(): void;
  8632. /**
  8633. * Set the enabled state of this node.
  8634. * @param value - the new enabled state
  8635. */
  8636. setEnabled(value: boolean): void;
  8637. /**
  8638. * Returns the Light associated shadow generator if any.
  8639. * @return the associated shadow generator.
  8640. */
  8641. getShadowGenerator(): Nullable<IShadowGenerator>;
  8642. /**
  8643. * Returns a Vector3, the absolute light position in the World.
  8644. * @returns the world space position of the light
  8645. */
  8646. getAbsolutePosition(): Vector3;
  8647. /**
  8648. * Specifies if the light will affect the passed mesh.
  8649. * @param mesh The mesh to test against the light
  8650. * @return true the mesh is affected otherwise, false.
  8651. */
  8652. canAffectMesh(mesh: AbstractMesh): boolean;
  8653. /**
  8654. * Sort function to order lights for rendering.
  8655. * @param a First Light object to compare to second.
  8656. * @param b Second Light object to compare first.
  8657. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  8658. */
  8659. static CompareLightsPriority(a: Light, b: Light): number;
  8660. /**
  8661. * Releases resources associated with this node.
  8662. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8663. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8664. */
  8665. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8666. /**
  8667. * Returns the light type ID (integer).
  8668. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  8669. */
  8670. getTypeID(): number;
  8671. /**
  8672. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  8673. * @returns the scaled intensity in intensity mode unit
  8674. */
  8675. getScaledIntensity(): number;
  8676. /**
  8677. * Returns a new Light object, named "name", from the current one.
  8678. * @param name The name of the cloned light
  8679. * @param newParent The parent of this light, if it has one
  8680. * @returns the new created light
  8681. */
  8682. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  8683. /**
  8684. * Serializes the current light into a Serialization object.
  8685. * @returns the serialized object.
  8686. */
  8687. serialize(): any;
  8688. /**
  8689. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  8690. * This new light is named "name" and added to the passed scene.
  8691. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  8692. * @param name The friendly name of the light
  8693. * @param scene The scene the new light will belong to
  8694. * @returns the constructor function
  8695. */
  8696. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  8697. /**
  8698. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  8699. * @param parsedLight The JSON representation of the light
  8700. * @param scene The scene to create the parsed light in
  8701. * @returns the created light after parsing
  8702. */
  8703. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  8704. private _hookArrayForExcluded;
  8705. private _hookArrayForIncludedOnly;
  8706. private _resyncMeshes;
  8707. /**
  8708. * Forces the meshes to update their light related information in their rendering used effects
  8709. * @hidden Internal Use Only
  8710. */
  8711. _markMeshesAsLightDirty(): void;
  8712. /**
  8713. * Recomputes the cached photometric scale if needed.
  8714. */
  8715. private _computePhotometricScale;
  8716. /**
  8717. * Returns the Photometric Scale according to the light type and intensity mode.
  8718. */
  8719. private _getPhotometricScale;
  8720. /**
  8721. * Reorder the light in the scene according to their defined priority.
  8722. * @hidden Internal Use Only
  8723. */
  8724. _reorderLightsInScene(): void;
  8725. /**
  8726. * Prepares the list of defines specific to the light type.
  8727. * @param defines the list of defines
  8728. * @param lightIndex defines the index of the light for the effect
  8729. */
  8730. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  8731. }
  8732. }
  8733. declare module "babylonjs/Maths/math.axis" {
  8734. import { Vector3 } from "babylonjs/Maths/math.vector";
  8735. /** Defines supported spaces */
  8736. export enum Space {
  8737. /** Local (object) space */
  8738. LOCAL = 0,
  8739. /** World space */
  8740. WORLD = 1,
  8741. /** Bone space */
  8742. BONE = 2
  8743. }
  8744. /** Defines the 3 main axes */
  8745. export class Axis {
  8746. /** X axis */
  8747. static X: Vector3;
  8748. /** Y axis */
  8749. static Y: Vector3;
  8750. /** Z axis */
  8751. static Z: Vector3;
  8752. }
  8753. /**
  8754. * Defines cartesian components.
  8755. */
  8756. export enum Coordinate {
  8757. /** X axis */
  8758. X = 0,
  8759. /** Y axis */
  8760. Y = 1,
  8761. /** Z axis */
  8762. Z = 2
  8763. }
  8764. }
  8765. declare module "babylonjs/Lights/shadowLight" {
  8766. import { Camera } from "babylonjs/Cameras/camera";
  8767. import { Scene } from "babylonjs/scene";
  8768. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8770. import { Light } from "babylonjs/Lights/light";
  8771. /**
  8772. * Interface describing all the common properties and methods a shadow light needs to implement.
  8773. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8774. * as well as binding the different shadow properties to the effects.
  8775. */
  8776. export interface IShadowLight extends Light {
  8777. /**
  8778. * The light id in the scene (used in scene.findLighById for instance)
  8779. */
  8780. id: string;
  8781. /**
  8782. * The position the shdow will be casted from.
  8783. */
  8784. position: Vector3;
  8785. /**
  8786. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8787. */
  8788. direction: Vector3;
  8789. /**
  8790. * The transformed position. Position of the light in world space taking parenting in account.
  8791. */
  8792. transformedPosition: Vector3;
  8793. /**
  8794. * The transformed direction. Direction of the light in world space taking parenting in account.
  8795. */
  8796. transformedDirection: Vector3;
  8797. /**
  8798. * The friendly name of the light in the scene.
  8799. */
  8800. name: string;
  8801. /**
  8802. * Defines the shadow projection clipping minimum z value.
  8803. */
  8804. shadowMinZ: number;
  8805. /**
  8806. * Defines the shadow projection clipping maximum z value.
  8807. */
  8808. shadowMaxZ: number;
  8809. /**
  8810. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8811. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8812. */
  8813. computeTransformedInformation(): boolean;
  8814. /**
  8815. * Gets the scene the light belongs to.
  8816. * @returns The scene
  8817. */
  8818. getScene(): Scene;
  8819. /**
  8820. * Callback defining a custom Projection Matrix Builder.
  8821. * This can be used to override the default projection matrix computation.
  8822. */
  8823. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8824. /**
  8825. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8826. * @param matrix The materix to updated with the projection information
  8827. * @param viewMatrix The transform matrix of the light
  8828. * @param renderList The list of mesh to render in the map
  8829. * @returns The current light
  8830. */
  8831. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8832. /**
  8833. * Gets the current depth scale used in ESM.
  8834. * @returns The scale
  8835. */
  8836. getDepthScale(): number;
  8837. /**
  8838. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8839. * @returns true if a cube texture needs to be use
  8840. */
  8841. needCube(): boolean;
  8842. /**
  8843. * Detects if the projection matrix requires to be recomputed this frame.
  8844. * @returns true if it requires to be recomputed otherwise, false.
  8845. */
  8846. needProjectionMatrixCompute(): boolean;
  8847. /**
  8848. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8849. */
  8850. forceProjectionMatrixCompute(): void;
  8851. /**
  8852. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8853. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8854. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8855. */
  8856. getShadowDirection(faceIndex?: number): Vector3;
  8857. /**
  8858. * Gets the minZ used for shadow according to both the scene and the light.
  8859. * @param activeCamera The camera we are returning the min for
  8860. * @returns the depth min z
  8861. */
  8862. getDepthMinZ(activeCamera: Camera): number;
  8863. /**
  8864. * Gets the maxZ used for shadow according to both the scene and the light.
  8865. * @param activeCamera The camera we are returning the max for
  8866. * @returns the depth max z
  8867. */
  8868. getDepthMaxZ(activeCamera: Camera): number;
  8869. }
  8870. /**
  8871. * Base implementation IShadowLight
  8872. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8873. */
  8874. export abstract class ShadowLight extends Light implements IShadowLight {
  8875. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8876. protected _position: Vector3;
  8877. protected _setPosition(value: Vector3): void;
  8878. /**
  8879. * Sets the position the shadow will be casted from. Also use as the light position for both
  8880. * point and spot lights.
  8881. */
  8882. get position(): Vector3;
  8883. /**
  8884. * Sets the position the shadow will be casted from. Also use as the light position for both
  8885. * point and spot lights.
  8886. */
  8887. set position(value: Vector3);
  8888. protected _direction: Vector3;
  8889. protected _setDirection(value: Vector3): void;
  8890. /**
  8891. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8892. * Also use as the light direction on spot and directional lights.
  8893. */
  8894. get direction(): Vector3;
  8895. /**
  8896. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8897. * Also use as the light direction on spot and directional lights.
  8898. */
  8899. set direction(value: Vector3);
  8900. protected _shadowMinZ: number;
  8901. /**
  8902. * Gets the shadow projection clipping minimum z value.
  8903. */
  8904. get shadowMinZ(): number;
  8905. /**
  8906. * Sets the shadow projection clipping minimum z value.
  8907. */
  8908. set shadowMinZ(value: number);
  8909. protected _shadowMaxZ: number;
  8910. /**
  8911. * Sets the shadow projection clipping maximum z value.
  8912. */
  8913. get shadowMaxZ(): number;
  8914. /**
  8915. * Gets the shadow projection clipping maximum z value.
  8916. */
  8917. set shadowMaxZ(value: number);
  8918. /**
  8919. * Callback defining a custom Projection Matrix Builder.
  8920. * This can be used to override the default projection matrix computation.
  8921. */
  8922. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8923. /**
  8924. * The transformed position. Position of the light in world space taking parenting in account.
  8925. */
  8926. transformedPosition: Vector3;
  8927. /**
  8928. * The transformed direction. Direction of the light in world space taking parenting in account.
  8929. */
  8930. transformedDirection: Vector3;
  8931. private _needProjectionMatrixCompute;
  8932. /**
  8933. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8934. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8935. */
  8936. computeTransformedInformation(): boolean;
  8937. /**
  8938. * Return the depth scale used for the shadow map.
  8939. * @returns the depth scale.
  8940. */
  8941. getDepthScale(): number;
  8942. /**
  8943. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8944. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8945. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8946. */
  8947. getShadowDirection(faceIndex?: number): Vector3;
  8948. /**
  8949. * Returns the ShadowLight absolute position in the World.
  8950. * @returns the position vector in world space
  8951. */
  8952. getAbsolutePosition(): Vector3;
  8953. /**
  8954. * Sets the ShadowLight direction toward the passed target.
  8955. * @param target The point to target in local space
  8956. * @returns the updated ShadowLight direction
  8957. */
  8958. setDirectionToTarget(target: Vector3): Vector3;
  8959. /**
  8960. * Returns the light rotation in euler definition.
  8961. * @returns the x y z rotation in local space.
  8962. */
  8963. getRotation(): Vector3;
  8964. /**
  8965. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8966. * @returns true if a cube texture needs to be use
  8967. */
  8968. needCube(): boolean;
  8969. /**
  8970. * Detects if the projection matrix requires to be recomputed this frame.
  8971. * @returns true if it requires to be recomputed otherwise, false.
  8972. */
  8973. needProjectionMatrixCompute(): boolean;
  8974. /**
  8975. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8976. */
  8977. forceProjectionMatrixCompute(): void;
  8978. /** @hidden */
  8979. _initCache(): void;
  8980. /** @hidden */
  8981. _isSynchronized(): boolean;
  8982. /**
  8983. * Computes the world matrix of the node
  8984. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8985. * @returns the world matrix
  8986. */
  8987. computeWorldMatrix(force?: boolean): Matrix;
  8988. /**
  8989. * Gets the minZ used for shadow according to both the scene and the light.
  8990. * @param activeCamera The camera we are returning the min for
  8991. * @returns the depth min z
  8992. */
  8993. getDepthMinZ(activeCamera: Camera): number;
  8994. /**
  8995. * Gets the maxZ used for shadow according to both the scene and the light.
  8996. * @param activeCamera The camera we are returning the max for
  8997. * @returns the depth max z
  8998. */
  8999. getDepthMaxZ(activeCamera: Camera): number;
  9000. /**
  9001. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9002. * @param matrix The materix to updated with the projection information
  9003. * @param viewMatrix The transform matrix of the light
  9004. * @param renderList The list of mesh to render in the map
  9005. * @returns The current light
  9006. */
  9007. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9008. }
  9009. }
  9010. declare module "babylonjs/Materials/prePassConfiguration" {
  9011. import { Matrix } from "babylonjs/Maths/math.vector";
  9012. import { Mesh } from "babylonjs/Meshes/mesh";
  9013. import { Scene } from "babylonjs/scene";
  9014. import { Effect } from "babylonjs/Materials/effect";
  9015. /**
  9016. * Configuration needed for prepass-capable materials
  9017. */
  9018. export class PrePassConfiguration {
  9019. /**
  9020. * Previous world matrices of meshes carrying this material
  9021. * Used for computing velocity
  9022. */
  9023. previousWorldMatrices: {
  9024. [index: number]: Matrix;
  9025. };
  9026. /**
  9027. * Previous view project matrix
  9028. * Used for computing velocity
  9029. */
  9030. previousViewProjection: Matrix;
  9031. /**
  9032. * Previous bones of meshes carrying this material
  9033. * Used for computing velocity
  9034. */
  9035. previousBones: {
  9036. [index: number]: Float32Array;
  9037. };
  9038. /**
  9039. * Add the required uniforms to the current list.
  9040. * @param uniforms defines the current uniform list.
  9041. */
  9042. static AddUniforms(uniforms: string[]): void;
  9043. /**
  9044. * Add the required samplers to the current list.
  9045. * @param samplers defines the current sampler list.
  9046. */
  9047. static AddSamplers(samplers: string[]): void;
  9048. /**
  9049. * Binds the material data.
  9050. * @param effect defines the effect to update
  9051. * @param scene defines the scene the material belongs to.
  9052. * @param mesh The mesh
  9053. * @param world World matrix of this mesh
  9054. * @param isFrozen Is the material frozen
  9055. */
  9056. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  9057. }
  9058. }
  9059. declare module "babylonjs/Cameras/targetCamera" {
  9060. import { Nullable } from "babylonjs/types";
  9061. import { Camera } from "babylonjs/Cameras/camera";
  9062. import { Scene } from "babylonjs/scene";
  9063. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9064. /**
  9065. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9066. * This is the base of the follow, arc rotate cameras and Free camera
  9067. * @see https://doc.babylonjs.com/features/cameras
  9068. */
  9069. export class TargetCamera extends Camera {
  9070. private static _RigCamTransformMatrix;
  9071. private static _TargetTransformMatrix;
  9072. private static _TargetFocalPoint;
  9073. private _tmpUpVector;
  9074. private _tmpTargetVector;
  9075. /**
  9076. * Define the current direction the camera is moving to
  9077. */
  9078. cameraDirection: Vector3;
  9079. /**
  9080. * Define the current rotation the camera is rotating to
  9081. */
  9082. cameraRotation: Vector2;
  9083. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  9084. ignoreParentScaling: boolean;
  9085. /**
  9086. * When set, the up vector of the camera will be updated by the rotation of the camera
  9087. */
  9088. updateUpVectorFromRotation: boolean;
  9089. private _tmpQuaternion;
  9090. /**
  9091. * Define the current rotation of the camera
  9092. */
  9093. rotation: Vector3;
  9094. /**
  9095. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9096. */
  9097. rotationQuaternion: Quaternion;
  9098. /**
  9099. * Define the current speed of the camera
  9100. */
  9101. speed: number;
  9102. /**
  9103. * Add constraint to the camera to prevent it to move freely in all directions and
  9104. * around all axis.
  9105. */
  9106. noRotationConstraint: boolean;
  9107. /**
  9108. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9109. * panning
  9110. */
  9111. invertRotation: boolean;
  9112. /**
  9113. * Speed multiplier for inverse camera panning
  9114. */
  9115. inverseRotationSpeed: number;
  9116. /**
  9117. * Define the current target of the camera as an object or a position.
  9118. */
  9119. lockedTarget: any;
  9120. /** @hidden */
  9121. _currentTarget: Vector3;
  9122. /** @hidden */
  9123. _initialFocalDistance: number;
  9124. /** @hidden */
  9125. _viewMatrix: Matrix;
  9126. /** @hidden */
  9127. _camMatrix: Matrix;
  9128. /** @hidden */
  9129. _cameraTransformMatrix: Matrix;
  9130. /** @hidden */
  9131. _cameraRotationMatrix: Matrix;
  9132. /** @hidden */
  9133. _referencePoint: Vector3;
  9134. /** @hidden */
  9135. _transformedReferencePoint: Vector3;
  9136. /** @hidden */
  9137. _reset: () => void;
  9138. private _defaultUp;
  9139. /**
  9140. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9141. * This is the base of the follow, arc rotate cameras and Free camera
  9142. * @see https://doc.babylonjs.com/features/cameras
  9143. * @param name Defines the name of the camera in the scene
  9144. * @param position Defines the start position of the camera in the scene
  9145. * @param scene Defines the scene the camera belongs to
  9146. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9147. */
  9148. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9149. /**
  9150. * Gets the position in front of the camera at a given distance.
  9151. * @param distance The distance from the camera we want the position to be
  9152. * @returns the position
  9153. */
  9154. getFrontPosition(distance: number): Vector3;
  9155. /** @hidden */
  9156. _getLockedTargetPosition(): Nullable<Vector3>;
  9157. private _storedPosition;
  9158. private _storedRotation;
  9159. private _storedRotationQuaternion;
  9160. /**
  9161. * Store current camera state of the camera (fov, position, rotation, etc..)
  9162. * @returns the camera
  9163. */
  9164. storeState(): Camera;
  9165. /**
  9166. * Restored camera state. You must call storeState() first
  9167. * @returns whether it was successful or not
  9168. * @hidden
  9169. */
  9170. _restoreStateValues(): boolean;
  9171. /** @hidden */
  9172. _initCache(): void;
  9173. /** @hidden */
  9174. _updateCache(ignoreParentClass?: boolean): void;
  9175. /** @hidden */
  9176. _isSynchronizedViewMatrix(): boolean;
  9177. /** @hidden */
  9178. _computeLocalCameraSpeed(): number;
  9179. /**
  9180. * Defines the target the camera should look at.
  9181. * @param target Defines the new target as a Vector or a mesh
  9182. */
  9183. setTarget(target: Vector3): void;
  9184. /**
  9185. * Defines the target point of the camera.
  9186. * The camera looks towards it form the radius distance.
  9187. */
  9188. get target(): Vector3;
  9189. set target(value: Vector3);
  9190. /**
  9191. * Return the current target position of the camera. This value is expressed in local space.
  9192. * @returns the target position
  9193. */
  9194. getTarget(): Vector3;
  9195. /** @hidden */
  9196. _decideIfNeedsToMove(): boolean;
  9197. /** @hidden */
  9198. _updatePosition(): void;
  9199. /** @hidden */
  9200. _checkInputs(): void;
  9201. protected _updateCameraRotationMatrix(): void;
  9202. /**
  9203. * 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)
  9204. * @returns the current camera
  9205. */
  9206. private _rotateUpVectorWithCameraRotationMatrix;
  9207. private _cachedRotationZ;
  9208. private _cachedQuaternionRotationZ;
  9209. /** @hidden */
  9210. _getViewMatrix(): Matrix;
  9211. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9212. /**
  9213. * @hidden
  9214. */
  9215. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9216. /**
  9217. * @hidden
  9218. */
  9219. _updateRigCameras(): void;
  9220. private _getRigCamPositionAndTarget;
  9221. /**
  9222. * Gets the current object class name.
  9223. * @return the class name
  9224. */
  9225. getClassName(): string;
  9226. }
  9227. }
  9228. declare module "babylonjs/Cameras/cameraInputsManager" {
  9229. import { Nullable } from "babylonjs/types";
  9230. import { Camera } from "babylonjs/Cameras/camera";
  9231. /**
  9232. * @ignore
  9233. * This is a list of all the different input types that are available in the application.
  9234. * Fo instance: ArcRotateCameraGamepadInput...
  9235. */
  9236. export var CameraInputTypes: {};
  9237. /**
  9238. * This is the contract to implement in order to create a new input class.
  9239. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9240. */
  9241. export interface ICameraInput<TCamera extends Camera> {
  9242. /**
  9243. * Defines the camera the input is attached to.
  9244. */
  9245. camera: Nullable<TCamera>;
  9246. /**
  9247. * Gets the class name of the current intput.
  9248. * @returns the class name
  9249. */
  9250. getClassName(): string;
  9251. /**
  9252. * Get the friendly name associated with the input class.
  9253. * @returns the input friendly name
  9254. */
  9255. getSimpleName(): string;
  9256. /**
  9257. * Attach the input controls to a specific dom element to get the input from.
  9258. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9259. */
  9260. attachControl(noPreventDefault?: boolean): void;
  9261. /**
  9262. * Detach the current controls from the specified dom element.
  9263. */
  9264. detachControl(): void;
  9265. /**
  9266. * Update the current camera state depending on the inputs that have been used this frame.
  9267. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9268. */
  9269. checkInputs?: () => void;
  9270. }
  9271. /**
  9272. * Represents a map of input types to input instance or input index to input instance.
  9273. */
  9274. export interface CameraInputsMap<TCamera extends Camera> {
  9275. /**
  9276. * Accessor to the input by input type.
  9277. */
  9278. [name: string]: ICameraInput<TCamera>;
  9279. /**
  9280. * Accessor to the input by input index.
  9281. */
  9282. [idx: number]: ICameraInput<TCamera>;
  9283. }
  9284. /**
  9285. * This represents the input manager used within a camera.
  9286. * It helps dealing with all the different kind of input attached to a camera.
  9287. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9288. */
  9289. export class CameraInputsManager<TCamera extends Camera> {
  9290. /**
  9291. * Defines the list of inputs attahed to the camera.
  9292. */
  9293. attached: CameraInputsMap<TCamera>;
  9294. /**
  9295. * Defines the dom element the camera is collecting inputs from.
  9296. * This is null if the controls have not been attached.
  9297. */
  9298. attachedToElement: boolean;
  9299. /**
  9300. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9301. */
  9302. noPreventDefault: boolean;
  9303. /**
  9304. * Defined the camera the input manager belongs to.
  9305. */
  9306. camera: TCamera;
  9307. /**
  9308. * Update the current camera state depending on the inputs that have been used this frame.
  9309. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9310. */
  9311. checkInputs: () => void;
  9312. /**
  9313. * Instantiate a new Camera Input Manager.
  9314. * @param camera Defines the camera the input manager blongs to
  9315. */
  9316. constructor(camera: TCamera);
  9317. /**
  9318. * Add an input method to a camera
  9319. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9320. * @param input camera input method
  9321. */
  9322. add(input: ICameraInput<TCamera>): void;
  9323. /**
  9324. * Remove a specific input method from a camera
  9325. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9326. * @param inputToRemove camera input method
  9327. */
  9328. remove(inputToRemove: ICameraInput<TCamera>): void;
  9329. /**
  9330. * Remove a specific input type from a camera
  9331. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9332. * @param inputType the type of the input to remove
  9333. */
  9334. removeByType(inputType: string): void;
  9335. private _addCheckInputs;
  9336. /**
  9337. * Attach the input controls to the currently attached dom element to listen the events from.
  9338. * @param input Defines the input to attach
  9339. */
  9340. attachInput(input: ICameraInput<TCamera>): void;
  9341. /**
  9342. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9343. * @param element Defines the dom element to collect the events from
  9344. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9345. */
  9346. attachElement(noPreventDefault?: boolean): void;
  9347. /**
  9348. * Detach the current manager inputs controls from a specific dom element.
  9349. * @param element Defines the dom element to collect the events from
  9350. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9351. */
  9352. detachElement(disconnect?: boolean): void;
  9353. /**
  9354. * Rebuild the dynamic inputCheck function from the current list of
  9355. * defined inputs in the manager.
  9356. */
  9357. rebuildInputCheck(): void;
  9358. /**
  9359. * Remove all attached input methods from a camera
  9360. */
  9361. clear(): void;
  9362. /**
  9363. * Serialize the current input manager attached to a camera.
  9364. * This ensures than once parsed,
  9365. * the input associated to the camera will be identical to the current ones
  9366. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9367. */
  9368. serialize(serializedCamera: any): void;
  9369. /**
  9370. * Parses an input manager serialized JSON to restore the previous list of inputs
  9371. * and states associated to a camera.
  9372. * @param parsedCamera Defines the JSON to parse
  9373. */
  9374. parse(parsedCamera: any): void;
  9375. }
  9376. }
  9377. declare module "babylonjs/Events/keyboardEvents" {
  9378. /**
  9379. * Gather the list of keyboard event types as constants.
  9380. */
  9381. export class KeyboardEventTypes {
  9382. /**
  9383. * The keydown event is fired when a key becomes active (pressed).
  9384. */
  9385. static readonly KEYDOWN: number;
  9386. /**
  9387. * The keyup event is fired when a key has been released.
  9388. */
  9389. static readonly KEYUP: number;
  9390. }
  9391. /**
  9392. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9393. */
  9394. export class KeyboardInfo {
  9395. /**
  9396. * Defines the type of event (KeyboardEventTypes)
  9397. */
  9398. type: number;
  9399. /**
  9400. * Defines the related dom event
  9401. */
  9402. event: KeyboardEvent;
  9403. /**
  9404. * Instantiates a new keyboard info.
  9405. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9406. * @param type Defines the type of event (KeyboardEventTypes)
  9407. * @param event Defines the related dom event
  9408. */
  9409. constructor(
  9410. /**
  9411. * Defines the type of event (KeyboardEventTypes)
  9412. */
  9413. type: number,
  9414. /**
  9415. * Defines the related dom event
  9416. */
  9417. event: KeyboardEvent);
  9418. }
  9419. /**
  9420. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9421. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9422. */
  9423. export class KeyboardInfoPre extends KeyboardInfo {
  9424. /**
  9425. * Defines the type of event (KeyboardEventTypes)
  9426. */
  9427. type: number;
  9428. /**
  9429. * Defines the related dom event
  9430. */
  9431. event: KeyboardEvent;
  9432. /**
  9433. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9434. */
  9435. skipOnPointerObservable: boolean;
  9436. /**
  9437. * Instantiates a new keyboard pre info.
  9438. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9439. * @param type Defines the type of event (KeyboardEventTypes)
  9440. * @param event Defines the related dom event
  9441. */
  9442. constructor(
  9443. /**
  9444. * Defines the type of event (KeyboardEventTypes)
  9445. */
  9446. type: number,
  9447. /**
  9448. * Defines the related dom event
  9449. */
  9450. event: KeyboardEvent);
  9451. }
  9452. }
  9453. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  9454. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  9455. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  9456. /**
  9457. * Manage the keyboard inputs to control the movement of a free camera.
  9458. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9459. */
  9460. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9461. /**
  9462. * Defines the camera the input is attached to.
  9463. */
  9464. camera: FreeCamera;
  9465. /**
  9466. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9467. */
  9468. keysUp: number[];
  9469. /**
  9470. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  9471. */
  9472. keysUpward: number[];
  9473. /**
  9474. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9475. */
  9476. keysDown: number[];
  9477. /**
  9478. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  9479. */
  9480. keysDownward: number[];
  9481. /**
  9482. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9483. */
  9484. keysLeft: number[];
  9485. /**
  9486. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9487. */
  9488. keysRight: number[];
  9489. private _keys;
  9490. private _onCanvasBlurObserver;
  9491. private _onKeyboardObserver;
  9492. private _engine;
  9493. private _scene;
  9494. /**
  9495. * Attach the input controls to a specific dom element to get the input from.
  9496. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9497. */
  9498. attachControl(noPreventDefault?: boolean): void;
  9499. /**
  9500. * Detach the current controls from the specified dom element.
  9501. */
  9502. detachControl(): void;
  9503. /**
  9504. * Update the current camera state depending on the inputs that have been used this frame.
  9505. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9506. */
  9507. checkInputs(): void;
  9508. /**
  9509. * Gets the class name of the current intput.
  9510. * @returns the class name
  9511. */
  9512. getClassName(): string;
  9513. /** @hidden */
  9514. _onLostFocus(): void;
  9515. /**
  9516. * Get the friendly name associated with the input class.
  9517. * @returns the input friendly name
  9518. */
  9519. getSimpleName(): string;
  9520. }
  9521. }
  9522. declare module "babylonjs/Actions/action" {
  9523. import { Observable } from "babylonjs/Misc/observable";
  9524. import { Condition } from "babylonjs/Actions/condition";
  9525. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9526. import { Nullable } from "babylonjs/types";
  9527. import { Scene } from "babylonjs/scene";
  9528. import { ActionManager } from "babylonjs/Actions/actionManager";
  9529. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9530. import { Node } from "babylonjs/node";
  9531. /**
  9532. * Interface used to define Action
  9533. */
  9534. export interface IAction {
  9535. /**
  9536. * Trigger for the action
  9537. */
  9538. trigger: number;
  9539. /** Options of the trigger */
  9540. triggerOptions: any;
  9541. /**
  9542. * Gets the trigger parameters
  9543. * @returns the trigger parameters
  9544. */
  9545. getTriggerParameter(): any;
  9546. /**
  9547. * Internal only - executes current action event
  9548. * @hidden
  9549. */
  9550. _executeCurrent(evt?: ActionEvent): void;
  9551. /**
  9552. * Serialize placeholder for child classes
  9553. * @param parent of child
  9554. * @returns the serialized object
  9555. */
  9556. serialize(parent: any): any;
  9557. /**
  9558. * Internal only
  9559. * @hidden
  9560. */
  9561. _prepare(): void;
  9562. /**
  9563. * Internal only - manager for action
  9564. * @hidden
  9565. */
  9566. _actionManager: Nullable<AbstractActionManager>;
  9567. /**
  9568. * Adds action to chain of actions, may be a DoNothingAction
  9569. * @param action defines the next action to execute
  9570. * @returns The action passed in
  9571. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9572. */
  9573. then(action: IAction): IAction;
  9574. }
  9575. /**
  9576. * The action to be carried out following a trigger
  9577. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9578. */
  9579. export class Action implements IAction {
  9580. /** the trigger, with or without parameters, for the action */
  9581. triggerOptions: any;
  9582. /**
  9583. * Trigger for the action
  9584. */
  9585. trigger: number;
  9586. /**
  9587. * Internal only - manager for action
  9588. * @hidden
  9589. */
  9590. _actionManager: ActionManager;
  9591. private _nextActiveAction;
  9592. private _child;
  9593. private _condition?;
  9594. private _triggerParameter;
  9595. /**
  9596. * An event triggered prior to action being executed.
  9597. */
  9598. onBeforeExecuteObservable: Observable<Action>;
  9599. /**
  9600. * Creates a new Action
  9601. * @param triggerOptions the trigger, with or without parameters, for the action
  9602. * @param condition an optional determinant of action
  9603. */
  9604. constructor(
  9605. /** the trigger, with or without parameters, for the action */
  9606. triggerOptions: any, condition?: Condition);
  9607. /**
  9608. * Internal only
  9609. * @hidden
  9610. */
  9611. _prepare(): void;
  9612. /**
  9613. * Gets the trigger parameters
  9614. * @returns the trigger parameters
  9615. */
  9616. getTriggerParameter(): any;
  9617. /**
  9618. * Internal only - executes current action event
  9619. * @hidden
  9620. */
  9621. _executeCurrent(evt?: ActionEvent): void;
  9622. /**
  9623. * Execute placeholder for child classes
  9624. * @param evt optional action event
  9625. */
  9626. execute(evt?: ActionEvent): void;
  9627. /**
  9628. * Skips to next active action
  9629. */
  9630. skipToNextActiveAction(): void;
  9631. /**
  9632. * Adds action to chain of actions, may be a DoNothingAction
  9633. * @param action defines the next action to execute
  9634. * @returns The action passed in
  9635. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9636. */
  9637. then(action: Action): Action;
  9638. /**
  9639. * Internal only
  9640. * @hidden
  9641. */
  9642. _getProperty(propertyPath: string): string;
  9643. /**
  9644. * Internal only
  9645. * @hidden
  9646. */
  9647. _getEffectiveTarget(target: any, propertyPath: string): any;
  9648. /**
  9649. * Serialize placeholder for child classes
  9650. * @param parent of child
  9651. * @returns the serialized object
  9652. */
  9653. serialize(parent: any): any;
  9654. /**
  9655. * Internal only called by serialize
  9656. * @hidden
  9657. */
  9658. protected _serialize(serializedAction: any, parent?: any): any;
  9659. /**
  9660. * Internal only
  9661. * @hidden
  9662. */
  9663. static _SerializeValueAsString: (value: any) => string;
  9664. /**
  9665. * Internal only
  9666. * @hidden
  9667. */
  9668. static _GetTargetProperty: (target: Scene | Node) => {
  9669. name: string;
  9670. targetType: string;
  9671. value: string;
  9672. };
  9673. }
  9674. }
  9675. declare module "babylonjs/Actions/condition" {
  9676. import { ActionManager } from "babylonjs/Actions/actionManager";
  9677. /**
  9678. * A Condition applied to an Action
  9679. */
  9680. export class Condition {
  9681. /**
  9682. * Internal only - manager for action
  9683. * @hidden
  9684. */
  9685. _actionManager: ActionManager;
  9686. /**
  9687. * Internal only
  9688. * @hidden
  9689. */
  9690. _evaluationId: number;
  9691. /**
  9692. * Internal only
  9693. * @hidden
  9694. */
  9695. _currentResult: boolean;
  9696. /**
  9697. * Creates a new Condition
  9698. * @param actionManager the manager of the action the condition is applied to
  9699. */
  9700. constructor(actionManager: ActionManager);
  9701. /**
  9702. * Check if the current condition is valid
  9703. * @returns a boolean
  9704. */
  9705. isValid(): boolean;
  9706. /**
  9707. * Internal only
  9708. * @hidden
  9709. */
  9710. _getProperty(propertyPath: string): string;
  9711. /**
  9712. * Internal only
  9713. * @hidden
  9714. */
  9715. _getEffectiveTarget(target: any, propertyPath: string): any;
  9716. /**
  9717. * Serialize placeholder for child classes
  9718. * @returns the serialized object
  9719. */
  9720. serialize(): any;
  9721. /**
  9722. * Internal only
  9723. * @hidden
  9724. */
  9725. protected _serialize(serializedCondition: any): any;
  9726. }
  9727. /**
  9728. * Defines specific conditional operators as extensions of Condition
  9729. */
  9730. export class ValueCondition extends Condition {
  9731. /** path to specify the property of the target the conditional operator uses */
  9732. propertyPath: string;
  9733. /** the value compared by the conditional operator against the current value of the property */
  9734. value: any;
  9735. /** the conditional operator, default ValueCondition.IsEqual */
  9736. operator: number;
  9737. /**
  9738. * Internal only
  9739. * @hidden
  9740. */
  9741. private static _IsEqual;
  9742. /**
  9743. * Internal only
  9744. * @hidden
  9745. */
  9746. private static _IsDifferent;
  9747. /**
  9748. * Internal only
  9749. * @hidden
  9750. */
  9751. private static _IsGreater;
  9752. /**
  9753. * Internal only
  9754. * @hidden
  9755. */
  9756. private static _IsLesser;
  9757. /**
  9758. * returns the number for IsEqual
  9759. */
  9760. static get IsEqual(): number;
  9761. /**
  9762. * Returns the number for IsDifferent
  9763. */
  9764. static get IsDifferent(): number;
  9765. /**
  9766. * Returns the number for IsGreater
  9767. */
  9768. static get IsGreater(): number;
  9769. /**
  9770. * Returns the number for IsLesser
  9771. */
  9772. static get IsLesser(): number;
  9773. /**
  9774. * Internal only The action manager for the condition
  9775. * @hidden
  9776. */
  9777. _actionManager: ActionManager;
  9778. /**
  9779. * Internal only
  9780. * @hidden
  9781. */
  9782. private _target;
  9783. /**
  9784. * Internal only
  9785. * @hidden
  9786. */
  9787. private _effectiveTarget;
  9788. /**
  9789. * Internal only
  9790. * @hidden
  9791. */
  9792. private _property;
  9793. /**
  9794. * Creates a new ValueCondition
  9795. * @param actionManager manager for the action the condition applies to
  9796. * @param target for the action
  9797. * @param propertyPath path to specify the property of the target the conditional operator uses
  9798. * @param value the value compared by the conditional operator against the current value of the property
  9799. * @param operator the conditional operator, default ValueCondition.IsEqual
  9800. */
  9801. constructor(actionManager: ActionManager, target: any,
  9802. /** path to specify the property of the target the conditional operator uses */
  9803. propertyPath: string,
  9804. /** the value compared by the conditional operator against the current value of the property */
  9805. value: any,
  9806. /** the conditional operator, default ValueCondition.IsEqual */
  9807. operator?: number);
  9808. /**
  9809. * Compares the given value with the property value for the specified conditional operator
  9810. * @returns the result of the comparison
  9811. */
  9812. isValid(): boolean;
  9813. /**
  9814. * Serialize the ValueCondition into a JSON compatible object
  9815. * @returns serialization object
  9816. */
  9817. serialize(): any;
  9818. /**
  9819. * Gets the name of the conditional operator for the ValueCondition
  9820. * @param operator the conditional operator
  9821. * @returns the name
  9822. */
  9823. static GetOperatorName(operator: number): string;
  9824. }
  9825. /**
  9826. * Defines a predicate condition as an extension of Condition
  9827. */
  9828. export class PredicateCondition extends Condition {
  9829. /** defines the predicate function used to validate the condition */
  9830. predicate: () => boolean;
  9831. /**
  9832. * Internal only - manager for action
  9833. * @hidden
  9834. */
  9835. _actionManager: ActionManager;
  9836. /**
  9837. * Creates a new PredicateCondition
  9838. * @param actionManager manager for the action the condition applies to
  9839. * @param predicate defines the predicate function used to validate the condition
  9840. */
  9841. constructor(actionManager: ActionManager,
  9842. /** defines the predicate function used to validate the condition */
  9843. predicate: () => boolean);
  9844. /**
  9845. * @returns the validity of the predicate condition
  9846. */
  9847. isValid(): boolean;
  9848. }
  9849. /**
  9850. * Defines a state condition as an extension of Condition
  9851. */
  9852. export class StateCondition extends Condition {
  9853. /** Value to compare with target state */
  9854. value: string;
  9855. /**
  9856. * Internal only - manager for action
  9857. * @hidden
  9858. */
  9859. _actionManager: ActionManager;
  9860. /**
  9861. * Internal only
  9862. * @hidden
  9863. */
  9864. private _target;
  9865. /**
  9866. * Creates a new StateCondition
  9867. * @param actionManager manager for the action the condition applies to
  9868. * @param target of the condition
  9869. * @param value to compare with target state
  9870. */
  9871. constructor(actionManager: ActionManager, target: any,
  9872. /** Value to compare with target state */
  9873. value: string);
  9874. /**
  9875. * Gets a boolean indicating if the current condition is met
  9876. * @returns the validity of the state
  9877. */
  9878. isValid(): boolean;
  9879. /**
  9880. * Serialize the StateCondition into a JSON compatible object
  9881. * @returns serialization object
  9882. */
  9883. serialize(): any;
  9884. }
  9885. }
  9886. declare module "babylonjs/Actions/directActions" {
  9887. import { Action } from "babylonjs/Actions/action";
  9888. import { Condition } from "babylonjs/Actions/condition";
  9889. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9890. /**
  9891. * This defines an action responsible to toggle a boolean once triggered.
  9892. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9893. */
  9894. export class SwitchBooleanAction extends Action {
  9895. /**
  9896. * The path to the boolean property in the target object
  9897. */
  9898. propertyPath: string;
  9899. private _target;
  9900. private _effectiveTarget;
  9901. private _property;
  9902. /**
  9903. * Instantiate the action
  9904. * @param triggerOptions defines the trigger options
  9905. * @param target defines the object containing the boolean
  9906. * @param propertyPath defines the path to the boolean property in the target object
  9907. * @param condition defines the trigger related conditions
  9908. */
  9909. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9910. /** @hidden */
  9911. _prepare(): void;
  9912. /**
  9913. * Execute the action toggle the boolean value.
  9914. */
  9915. execute(): void;
  9916. /**
  9917. * Serializes the actions and its related information.
  9918. * @param parent defines the object to serialize in
  9919. * @returns the serialized object
  9920. */
  9921. serialize(parent: any): any;
  9922. }
  9923. /**
  9924. * This defines an action responsible to set a the state field of the target
  9925. * to a desired value once triggered.
  9926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9927. */
  9928. export class SetStateAction extends Action {
  9929. /**
  9930. * The value to store in the state field.
  9931. */
  9932. value: string;
  9933. private _target;
  9934. /**
  9935. * Instantiate the action
  9936. * @param triggerOptions defines the trigger options
  9937. * @param target defines the object containing the state property
  9938. * @param value defines the value to store in the state field
  9939. * @param condition defines the trigger related conditions
  9940. */
  9941. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9942. /**
  9943. * Execute the action and store the value on the target state property.
  9944. */
  9945. execute(): void;
  9946. /**
  9947. * Serializes the actions and its related information.
  9948. * @param parent defines the object to serialize in
  9949. * @returns the serialized object
  9950. */
  9951. serialize(parent: any): any;
  9952. }
  9953. /**
  9954. * This defines an action responsible to set a property of the target
  9955. * to a desired value once triggered.
  9956. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9957. */
  9958. export class SetValueAction extends Action {
  9959. /**
  9960. * The path of the property to set in the target.
  9961. */
  9962. propertyPath: string;
  9963. /**
  9964. * The value to set in the property
  9965. */
  9966. value: any;
  9967. private _target;
  9968. private _effectiveTarget;
  9969. private _property;
  9970. /**
  9971. * Instantiate the action
  9972. * @param triggerOptions defines the trigger options
  9973. * @param target defines the object containing the property
  9974. * @param propertyPath defines the path of the property to set in the target
  9975. * @param value defines the value to set in the property
  9976. * @param condition defines the trigger related conditions
  9977. */
  9978. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9979. /** @hidden */
  9980. _prepare(): void;
  9981. /**
  9982. * Execute the action and set the targetted property to the desired value.
  9983. */
  9984. execute(): void;
  9985. /**
  9986. * Serializes the actions and its related information.
  9987. * @param parent defines the object to serialize in
  9988. * @returns the serialized object
  9989. */
  9990. serialize(parent: any): any;
  9991. }
  9992. /**
  9993. * This defines an action responsible to increment the target value
  9994. * to a desired value once triggered.
  9995. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9996. */
  9997. export class IncrementValueAction extends Action {
  9998. /**
  9999. * The path of the property to increment in the target.
  10000. */
  10001. propertyPath: string;
  10002. /**
  10003. * The value we should increment the property by.
  10004. */
  10005. value: any;
  10006. private _target;
  10007. private _effectiveTarget;
  10008. private _property;
  10009. /**
  10010. * Instantiate the action
  10011. * @param triggerOptions defines the trigger options
  10012. * @param target defines the object containing the property
  10013. * @param propertyPath defines the path of the property to increment in the target
  10014. * @param value defines the value value we should increment the property by
  10015. * @param condition defines the trigger related conditions
  10016. */
  10017. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10018. /** @hidden */
  10019. _prepare(): void;
  10020. /**
  10021. * Execute the action and increment the target of the value amount.
  10022. */
  10023. execute(): void;
  10024. /**
  10025. * Serializes the actions and its related information.
  10026. * @param parent defines the object to serialize in
  10027. * @returns the serialized object
  10028. */
  10029. serialize(parent: any): any;
  10030. }
  10031. /**
  10032. * This defines an action responsible to start an animation once triggered.
  10033. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10034. */
  10035. export class PlayAnimationAction extends Action {
  10036. /**
  10037. * Where the animation should start (animation frame)
  10038. */
  10039. from: number;
  10040. /**
  10041. * Where the animation should stop (animation frame)
  10042. */
  10043. to: number;
  10044. /**
  10045. * Define if the animation should loop or stop after the first play.
  10046. */
  10047. loop?: boolean;
  10048. private _target;
  10049. /**
  10050. * Instantiate the action
  10051. * @param triggerOptions defines the trigger options
  10052. * @param target defines the target animation or animation name
  10053. * @param from defines from where the animation should start (animation frame)
  10054. * @param end defines where the animation should stop (animation frame)
  10055. * @param loop defines if the animation should loop or stop after the first play
  10056. * @param condition defines the trigger related conditions
  10057. */
  10058. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10059. /** @hidden */
  10060. _prepare(): void;
  10061. /**
  10062. * Execute the action and play the animation.
  10063. */
  10064. execute(): void;
  10065. /**
  10066. * Serializes the actions and its related information.
  10067. * @param parent defines the object to serialize in
  10068. * @returns the serialized object
  10069. */
  10070. serialize(parent: any): any;
  10071. }
  10072. /**
  10073. * This defines an action responsible to stop an animation once triggered.
  10074. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10075. */
  10076. export class StopAnimationAction extends Action {
  10077. private _target;
  10078. /**
  10079. * Instantiate the action
  10080. * @param triggerOptions defines the trigger options
  10081. * @param target defines the target animation or animation name
  10082. * @param condition defines the trigger related conditions
  10083. */
  10084. constructor(triggerOptions: any, target: any, condition?: Condition);
  10085. /** @hidden */
  10086. _prepare(): void;
  10087. /**
  10088. * Execute the action and stop the animation.
  10089. */
  10090. execute(): void;
  10091. /**
  10092. * Serializes the actions and its related information.
  10093. * @param parent defines the object to serialize in
  10094. * @returns the serialized object
  10095. */
  10096. serialize(parent: any): any;
  10097. }
  10098. /**
  10099. * This defines an action responsible that does nothing once triggered.
  10100. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10101. */
  10102. export class DoNothingAction extends Action {
  10103. /**
  10104. * Instantiate the action
  10105. * @param triggerOptions defines the trigger options
  10106. * @param condition defines the trigger related conditions
  10107. */
  10108. constructor(triggerOptions?: any, condition?: Condition);
  10109. /**
  10110. * Execute the action and do nothing.
  10111. */
  10112. execute(): void;
  10113. /**
  10114. * Serializes the actions and its related information.
  10115. * @param parent defines the object to serialize in
  10116. * @returns the serialized object
  10117. */
  10118. serialize(parent: any): any;
  10119. }
  10120. /**
  10121. * This defines an action responsible to trigger several actions once triggered.
  10122. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10123. */
  10124. export class CombineAction extends Action {
  10125. /**
  10126. * The list of aggregated animations to run.
  10127. */
  10128. children: Action[];
  10129. /**
  10130. * Instantiate the action
  10131. * @param triggerOptions defines the trigger options
  10132. * @param children defines the list of aggregated animations to run
  10133. * @param condition defines the trigger related conditions
  10134. */
  10135. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10136. /** @hidden */
  10137. _prepare(): void;
  10138. /**
  10139. * Execute the action and executes all the aggregated actions.
  10140. */
  10141. execute(evt: ActionEvent): 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 run code (external event) once triggered.
  10151. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10152. */
  10153. export class ExecuteCodeAction extends Action {
  10154. /**
  10155. * The callback function to run.
  10156. */
  10157. func: (evt: ActionEvent) => void;
  10158. /**
  10159. * Instantiate the action
  10160. * @param triggerOptions defines the trigger options
  10161. * @param func defines the callback function to run
  10162. * @param condition defines the trigger related conditions
  10163. */
  10164. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10165. /**
  10166. * Execute the action and run the attached code.
  10167. */
  10168. execute(evt: ActionEvent): void;
  10169. }
  10170. /**
  10171. * This defines an action responsible to set the parent property of the target once triggered.
  10172. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10173. */
  10174. export class SetParentAction extends Action {
  10175. private _parent;
  10176. private _target;
  10177. /**
  10178. * Instantiate the action
  10179. * @param triggerOptions defines the trigger options
  10180. * @param target defines the target containing the parent property
  10181. * @param parent defines from where the animation should start (animation frame)
  10182. * @param condition defines the trigger related conditions
  10183. */
  10184. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10185. /** @hidden */
  10186. _prepare(): void;
  10187. /**
  10188. * Execute the action and set the parent property.
  10189. */
  10190. execute(): void;
  10191. /**
  10192. * Serializes the actions and its related information.
  10193. * @param parent defines the object to serialize in
  10194. * @returns the serialized object
  10195. */
  10196. serialize(parent: any): any;
  10197. }
  10198. }
  10199. declare module "babylonjs/Actions/actionManager" {
  10200. import { Nullable } from "babylonjs/types";
  10201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10202. import { Scene } from "babylonjs/scene";
  10203. import { IAction } from "babylonjs/Actions/action";
  10204. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10205. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10206. /**
  10207. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10208. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10209. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10210. */
  10211. export class ActionManager extends AbstractActionManager {
  10212. /**
  10213. * Nothing
  10214. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10215. */
  10216. static readonly NothingTrigger: number;
  10217. /**
  10218. * On pick
  10219. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10220. */
  10221. static readonly OnPickTrigger: number;
  10222. /**
  10223. * On left pick
  10224. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10225. */
  10226. static readonly OnLeftPickTrigger: number;
  10227. /**
  10228. * On right pick
  10229. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10230. */
  10231. static readonly OnRightPickTrigger: number;
  10232. /**
  10233. * On center pick
  10234. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10235. */
  10236. static readonly OnCenterPickTrigger: number;
  10237. /**
  10238. * On pick down
  10239. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10240. */
  10241. static readonly OnPickDownTrigger: number;
  10242. /**
  10243. * On double pick
  10244. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10245. */
  10246. static readonly OnDoublePickTrigger: number;
  10247. /**
  10248. * On pick up
  10249. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10250. */
  10251. static readonly OnPickUpTrigger: number;
  10252. /**
  10253. * On pick out.
  10254. * This trigger will only be raised if you also declared a OnPickDown
  10255. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10256. */
  10257. static readonly OnPickOutTrigger: number;
  10258. /**
  10259. * On long press
  10260. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10261. */
  10262. static readonly OnLongPressTrigger: number;
  10263. /**
  10264. * On pointer over
  10265. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10266. */
  10267. static readonly OnPointerOverTrigger: number;
  10268. /**
  10269. * On pointer out
  10270. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10271. */
  10272. static readonly OnPointerOutTrigger: number;
  10273. /**
  10274. * On every frame
  10275. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10276. */
  10277. static readonly OnEveryFrameTrigger: number;
  10278. /**
  10279. * On intersection enter
  10280. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10281. */
  10282. static readonly OnIntersectionEnterTrigger: number;
  10283. /**
  10284. * On intersection exit
  10285. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10286. */
  10287. static readonly OnIntersectionExitTrigger: number;
  10288. /**
  10289. * On key down
  10290. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10291. */
  10292. static readonly OnKeyDownTrigger: number;
  10293. /**
  10294. * On key up
  10295. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10296. */
  10297. static readonly OnKeyUpTrigger: number;
  10298. private _scene;
  10299. /**
  10300. * Creates a new action manager
  10301. * @param scene defines the hosting scene
  10302. */
  10303. constructor(scene: Scene);
  10304. /**
  10305. * Releases all associated resources
  10306. */
  10307. dispose(): void;
  10308. /**
  10309. * Gets hosting scene
  10310. * @returns the hosting scene
  10311. */
  10312. getScene(): Scene;
  10313. /**
  10314. * Does this action manager handles actions of any of the given triggers
  10315. * @param triggers defines the triggers to be tested
  10316. * @return a boolean indicating whether one (or more) of the triggers is handled
  10317. */
  10318. hasSpecificTriggers(triggers: number[]): boolean;
  10319. /**
  10320. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10321. * speed.
  10322. * @param triggerA defines the trigger to be tested
  10323. * @param triggerB defines the trigger to be tested
  10324. * @return a boolean indicating whether one (or more) of the triggers is handled
  10325. */
  10326. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10327. /**
  10328. * Does this action manager handles actions of a given trigger
  10329. * @param trigger defines the trigger to be tested
  10330. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10331. * @return whether the trigger is handled
  10332. */
  10333. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10334. /**
  10335. * Does this action manager has pointer triggers
  10336. */
  10337. get hasPointerTriggers(): boolean;
  10338. /**
  10339. * Does this action manager has pick triggers
  10340. */
  10341. get hasPickTriggers(): boolean;
  10342. /**
  10343. * Registers an action to this action manager
  10344. * @param action defines the action to be registered
  10345. * @return the action amended (prepared) after registration
  10346. */
  10347. registerAction(action: IAction): Nullable<IAction>;
  10348. /**
  10349. * Unregisters an action to this action manager
  10350. * @param action defines the action to be unregistered
  10351. * @return a boolean indicating whether the action has been unregistered
  10352. */
  10353. unregisterAction(action: IAction): Boolean;
  10354. /**
  10355. * Process a specific trigger
  10356. * @param trigger defines the trigger to process
  10357. * @param evt defines the event details to be processed
  10358. */
  10359. processTrigger(trigger: number, evt?: IActionEvent): void;
  10360. /** @hidden */
  10361. _getEffectiveTarget(target: any, propertyPath: string): any;
  10362. /** @hidden */
  10363. _getProperty(propertyPath: string): string;
  10364. /**
  10365. * Serialize this manager to a JSON object
  10366. * @param name defines the property name to store this manager
  10367. * @returns a JSON representation of this manager
  10368. */
  10369. serialize(name: string): any;
  10370. /**
  10371. * Creates a new ActionManager from a JSON data
  10372. * @param parsedActions defines the JSON data to read from
  10373. * @param object defines the hosting mesh
  10374. * @param scene defines the hosting scene
  10375. */
  10376. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10377. /**
  10378. * Get a trigger name by index
  10379. * @param trigger defines the trigger index
  10380. * @returns a trigger name
  10381. */
  10382. static GetTriggerName(trigger: number): string;
  10383. }
  10384. }
  10385. declare module "babylonjs/Culling/ray" {
  10386. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10387. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10389. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10390. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10391. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10392. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10393. import { Plane } from "babylonjs/Maths/math.plane";
  10394. /**
  10395. * Class representing a ray with position and direction
  10396. */
  10397. export class Ray {
  10398. /** origin point */
  10399. origin: Vector3;
  10400. /** direction */
  10401. direction: Vector3;
  10402. /** length of the ray */
  10403. length: number;
  10404. private static readonly _TmpVector3;
  10405. private _tmpRay;
  10406. /**
  10407. * Creates a new ray
  10408. * @param origin origin point
  10409. * @param direction direction
  10410. * @param length length of the ray
  10411. */
  10412. constructor(
  10413. /** origin point */
  10414. origin: Vector3,
  10415. /** direction */
  10416. direction: Vector3,
  10417. /** length of the ray */
  10418. length?: number);
  10419. /**
  10420. * Checks if the ray intersects a box
  10421. * This does not account for the ray lenght by design to improve perfs.
  10422. * @param minimum bound of the box
  10423. * @param maximum bound of the box
  10424. * @param intersectionTreshold extra extend to be added to the box in all direction
  10425. * @returns if the box was hit
  10426. */
  10427. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10428. /**
  10429. * Checks if the ray intersects a box
  10430. * This does not account for the ray lenght by design to improve perfs.
  10431. * @param box the bounding box to check
  10432. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10433. * @returns if the box was hit
  10434. */
  10435. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10436. /**
  10437. * If the ray hits a sphere
  10438. * @param sphere the bounding sphere to check
  10439. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10440. * @returns true if it hits the sphere
  10441. */
  10442. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10443. /**
  10444. * If the ray hits a triange
  10445. * @param vertex0 triangle vertex
  10446. * @param vertex1 triangle vertex
  10447. * @param vertex2 triangle vertex
  10448. * @returns intersection information if hit
  10449. */
  10450. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10451. /**
  10452. * Checks if ray intersects a plane
  10453. * @param plane the plane to check
  10454. * @returns the distance away it was hit
  10455. */
  10456. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10457. /**
  10458. * Calculate the intercept of a ray on a given axis
  10459. * @param axis to check 'x' | 'y' | 'z'
  10460. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10461. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10462. */
  10463. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10464. /**
  10465. * Checks if ray intersects a mesh
  10466. * @param mesh the mesh to check
  10467. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10468. * @returns picking info of the intersecton
  10469. */
  10470. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10471. /**
  10472. * Checks if ray intersects a mesh
  10473. * @param meshes the meshes to check
  10474. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10475. * @param results array to store result in
  10476. * @returns Array of picking infos
  10477. */
  10478. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10479. private _comparePickingInfo;
  10480. private static smallnum;
  10481. private static rayl;
  10482. /**
  10483. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10484. * @param sega the first point of the segment to test the intersection against
  10485. * @param segb the second point of the segment to test the intersection against
  10486. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10487. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10488. */
  10489. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10490. /**
  10491. * Update the ray from viewport position
  10492. * @param x position
  10493. * @param y y position
  10494. * @param viewportWidth viewport width
  10495. * @param viewportHeight viewport height
  10496. * @param world world matrix
  10497. * @param view view matrix
  10498. * @param projection projection matrix
  10499. * @returns this ray updated
  10500. */
  10501. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10502. /**
  10503. * Creates a ray with origin and direction of 0,0,0
  10504. * @returns the new ray
  10505. */
  10506. static Zero(): Ray;
  10507. /**
  10508. * Creates a new ray from screen space and viewport
  10509. * @param x position
  10510. * @param y y position
  10511. * @param viewportWidth viewport width
  10512. * @param viewportHeight viewport height
  10513. * @param world world matrix
  10514. * @param view view matrix
  10515. * @param projection projection matrix
  10516. * @returns new ray
  10517. */
  10518. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10519. /**
  10520. * 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
  10521. * transformed to the given world matrix.
  10522. * @param origin The origin point
  10523. * @param end The end point
  10524. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10525. * @returns the new ray
  10526. */
  10527. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10528. /**
  10529. * Transforms a ray by a matrix
  10530. * @param ray ray to transform
  10531. * @param matrix matrix to apply
  10532. * @returns the resulting new ray
  10533. */
  10534. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10535. /**
  10536. * Transforms a ray by a matrix
  10537. * @param ray ray to transform
  10538. * @param matrix matrix to apply
  10539. * @param result ray to store result in
  10540. */
  10541. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10542. /**
  10543. * Unproject a ray from screen space to object space
  10544. * @param sourceX defines the screen space x coordinate to use
  10545. * @param sourceY defines the screen space y coordinate to use
  10546. * @param viewportWidth defines the current width of the viewport
  10547. * @param viewportHeight defines the current height of the viewport
  10548. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10549. * @param view defines the view matrix to use
  10550. * @param projection defines the projection matrix to use
  10551. */
  10552. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10553. }
  10554. /**
  10555. * Type used to define predicate used to select faces when a mesh intersection is detected
  10556. */
  10557. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10558. module "babylonjs/scene" {
  10559. interface Scene {
  10560. /** @hidden */
  10561. _tempPickingRay: Nullable<Ray>;
  10562. /** @hidden */
  10563. _cachedRayForTransform: Ray;
  10564. /** @hidden */
  10565. _pickWithRayInverseMatrix: Matrix;
  10566. /** @hidden */
  10567. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10568. /** @hidden */
  10569. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10570. /** @hidden */
  10571. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  10572. }
  10573. }
  10574. }
  10575. declare module "babylonjs/sceneComponent" {
  10576. import { Scene } from "babylonjs/scene";
  10577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10578. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10579. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10580. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10581. import { Nullable } from "babylonjs/types";
  10582. import { Camera } from "babylonjs/Cameras/camera";
  10583. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10584. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10585. import { AbstractScene } from "babylonjs/abstractScene";
  10586. import { Mesh } from "babylonjs/Meshes/mesh";
  10587. /**
  10588. * Groups all the scene component constants in one place to ease maintenance.
  10589. * @hidden
  10590. */
  10591. export class SceneComponentConstants {
  10592. static readonly NAME_EFFECTLAYER: string;
  10593. static readonly NAME_LAYER: string;
  10594. static readonly NAME_LENSFLARESYSTEM: string;
  10595. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10596. static readonly NAME_PARTICLESYSTEM: string;
  10597. static readonly NAME_GAMEPAD: string;
  10598. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10599. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10600. static readonly NAME_PREPASSRENDERER: string;
  10601. static readonly NAME_DEPTHRENDERER: string;
  10602. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10603. static readonly NAME_SPRITE: string;
  10604. static readonly NAME_SUBSURFACE: string;
  10605. static readonly NAME_OUTLINERENDERER: string;
  10606. static readonly NAME_PROCEDURALTEXTURE: string;
  10607. static readonly NAME_SHADOWGENERATOR: string;
  10608. static readonly NAME_OCTREE: string;
  10609. static readonly NAME_PHYSICSENGINE: string;
  10610. static readonly NAME_AUDIO: string;
  10611. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10612. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10613. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10614. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10615. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10616. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10617. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10618. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10619. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10620. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10621. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10622. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10623. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10624. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10625. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10626. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10627. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10628. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10629. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10630. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10631. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10632. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10633. static readonly STEP_AFTERRENDER_AUDIO: number;
  10634. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10635. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10636. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10637. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10638. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10639. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10640. static readonly STEP_POINTERMOVE_SPRITE: number;
  10641. static readonly STEP_POINTERDOWN_SPRITE: number;
  10642. static readonly STEP_POINTERUP_SPRITE: number;
  10643. }
  10644. /**
  10645. * This represents a scene component.
  10646. *
  10647. * This is used to decouple the dependency the scene is having on the different workloads like
  10648. * layers, post processes...
  10649. */
  10650. export interface ISceneComponent {
  10651. /**
  10652. * The name of the component. Each component must have a unique name.
  10653. */
  10654. name: string;
  10655. /**
  10656. * The scene the component belongs to.
  10657. */
  10658. scene: Scene;
  10659. /**
  10660. * Register the component to one instance of a scene.
  10661. */
  10662. register(): void;
  10663. /**
  10664. * Rebuilds the elements related to this component in case of
  10665. * context lost for instance.
  10666. */
  10667. rebuild(): void;
  10668. /**
  10669. * Disposes the component and the associated ressources.
  10670. */
  10671. dispose(): void;
  10672. }
  10673. /**
  10674. * This represents a SERIALIZABLE scene component.
  10675. *
  10676. * This extends Scene Component to add Serialization methods on top.
  10677. */
  10678. export interface ISceneSerializableComponent extends ISceneComponent {
  10679. /**
  10680. * Adds all the elements from the container to the scene
  10681. * @param container the container holding the elements
  10682. */
  10683. addFromContainer(container: AbstractScene): void;
  10684. /**
  10685. * Removes all the elements in the container from the scene
  10686. * @param container contains the elements to remove
  10687. * @param dispose if the removed element should be disposed (default: false)
  10688. */
  10689. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10690. /**
  10691. * Serializes the component data to the specified json object
  10692. * @param serializationObject The object to serialize to
  10693. */
  10694. serialize(serializationObject: any): void;
  10695. }
  10696. /**
  10697. * Strong typing of a Mesh related stage step action
  10698. */
  10699. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10700. /**
  10701. * Strong typing of a Evaluate Sub Mesh related stage step action
  10702. */
  10703. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10704. /**
  10705. * Strong typing of a pre active Mesh related stage step action
  10706. */
  10707. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  10708. /**
  10709. * Strong typing of a Camera related stage step action
  10710. */
  10711. export type CameraStageAction = (camera: Camera) => void;
  10712. /**
  10713. * Strong typing of a Camera Frame buffer related stage step action
  10714. */
  10715. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10716. /**
  10717. * Strong typing of a Render Target related stage step action
  10718. */
  10719. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10720. /**
  10721. * Strong typing of a RenderingGroup related stage step action
  10722. */
  10723. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10724. /**
  10725. * Strong typing of a Mesh Render related stage step action
  10726. */
  10727. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10728. /**
  10729. * Strong typing of a simple stage step action
  10730. */
  10731. export type SimpleStageAction = () => void;
  10732. /**
  10733. * Strong typing of a render target action.
  10734. */
  10735. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10736. /**
  10737. * Strong typing of a pointer move action.
  10738. */
  10739. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10740. /**
  10741. * Strong typing of a pointer up/down action.
  10742. */
  10743. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10744. /**
  10745. * Representation of a stage in the scene (Basically a list of ordered steps)
  10746. * @hidden
  10747. */
  10748. export class Stage<T extends Function> extends Array<{
  10749. index: number;
  10750. component: ISceneComponent;
  10751. action: T;
  10752. }> {
  10753. /**
  10754. * Hide ctor from the rest of the world.
  10755. * @param items The items to add.
  10756. */
  10757. private constructor();
  10758. /**
  10759. * Creates a new Stage.
  10760. * @returns A new instance of a Stage
  10761. */
  10762. static Create<T extends Function>(): Stage<T>;
  10763. /**
  10764. * Registers a step in an ordered way in the targeted stage.
  10765. * @param index Defines the position to register the step in
  10766. * @param component Defines the component attached to the step
  10767. * @param action Defines the action to launch during the step
  10768. */
  10769. registerStep(index: number, component: ISceneComponent, action: T): void;
  10770. /**
  10771. * Clears all the steps from the stage.
  10772. */
  10773. clear(): void;
  10774. }
  10775. }
  10776. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10777. import { Nullable } from "babylonjs/types";
  10778. import { Observable } from "babylonjs/Misc/observable";
  10779. import { Scene } from "babylonjs/scene";
  10780. import { Sprite } from "babylonjs/Sprites/sprite";
  10781. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10782. import { Ray } from "babylonjs/Culling/ray";
  10783. import { Camera } from "babylonjs/Cameras/camera";
  10784. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10785. import { ISceneComponent } from "babylonjs/sceneComponent";
  10786. module "babylonjs/scene" {
  10787. interface Scene {
  10788. /** @hidden */
  10789. _pointerOverSprite: Nullable<Sprite>;
  10790. /** @hidden */
  10791. _pickedDownSprite: Nullable<Sprite>;
  10792. /** @hidden */
  10793. _tempSpritePickingRay: Nullable<Ray>;
  10794. /**
  10795. * All of the sprite managers added to this scene
  10796. * @see https://doc.babylonjs.com/babylon101/sprites
  10797. */
  10798. spriteManagers: Array<ISpriteManager>;
  10799. /**
  10800. * An event triggered when sprites rendering is about to start
  10801. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10802. */
  10803. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10804. /**
  10805. * An event triggered when sprites rendering is done
  10806. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10807. */
  10808. onAfterSpritesRenderingObservable: Observable<Scene>;
  10809. /** @hidden */
  10810. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10811. /** Launch a ray to try to pick a sprite in the scene
  10812. * @param x position on screen
  10813. * @param y position on screen
  10814. * @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
  10815. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10816. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10817. * @returns a PickingInfo
  10818. */
  10819. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10820. /** Use the given ray to pick a sprite in the scene
  10821. * @param ray The ray (in world space) to use to pick meshes
  10822. * @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
  10823. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10824. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10825. * @returns a PickingInfo
  10826. */
  10827. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10828. /** @hidden */
  10829. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10830. /** Launch a ray to try to pick sprites in the scene
  10831. * @param x position on screen
  10832. * @param y position on screen
  10833. * @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
  10834. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10835. * @returns a PickingInfo array
  10836. */
  10837. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10838. /** Use the given ray to pick sprites in the scene
  10839. * @param ray The ray (in world space) to use to pick meshes
  10840. * @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
  10841. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10842. * @returns a PickingInfo array
  10843. */
  10844. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10845. /**
  10846. * Force the sprite under the pointer
  10847. * @param sprite defines the sprite to use
  10848. */
  10849. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10850. /**
  10851. * Gets the sprite under the pointer
  10852. * @returns a Sprite or null if no sprite is under the pointer
  10853. */
  10854. getPointerOverSprite(): Nullable<Sprite>;
  10855. }
  10856. }
  10857. /**
  10858. * Defines the sprite scene component responsible to manage sprites
  10859. * in a given scene.
  10860. */
  10861. export class SpriteSceneComponent implements ISceneComponent {
  10862. /**
  10863. * The component name helpfull to identify the component in the list of scene components.
  10864. */
  10865. readonly name: string;
  10866. /**
  10867. * The scene the component belongs to.
  10868. */
  10869. scene: Scene;
  10870. /** @hidden */
  10871. private _spritePredicate;
  10872. /**
  10873. * Creates a new instance of the component for the given scene
  10874. * @param scene Defines the scene to register the component in
  10875. */
  10876. constructor(scene: Scene);
  10877. /**
  10878. * Registers the component in a given scene
  10879. */
  10880. register(): void;
  10881. /**
  10882. * Rebuilds the elements related to this component in case of
  10883. * context lost for instance.
  10884. */
  10885. rebuild(): void;
  10886. /**
  10887. * Disposes the component and the associated ressources.
  10888. */
  10889. dispose(): void;
  10890. private _pickSpriteButKeepRay;
  10891. private _pointerMove;
  10892. private _pointerDown;
  10893. private _pointerUp;
  10894. }
  10895. }
  10896. declare module "babylonjs/Misc/timingTools" {
  10897. /**
  10898. * Class used to provide helper for timing
  10899. */
  10900. export class TimingTools {
  10901. /**
  10902. * Polyfill for setImmediate
  10903. * @param action defines the action to execute after the current execution block
  10904. */
  10905. static SetImmediate(action: () => void): void;
  10906. }
  10907. }
  10908. declare module "babylonjs/Misc/instantiationTools" {
  10909. /**
  10910. * Class used to enable instatition of objects by class name
  10911. */
  10912. export class InstantiationTools {
  10913. /**
  10914. * Use this object to register external classes like custom textures or material
  10915. * to allow the laoders to instantiate them
  10916. */
  10917. static RegisteredExternalClasses: {
  10918. [key: string]: Object;
  10919. };
  10920. /**
  10921. * Tries to instantiate a new object from a given class name
  10922. * @param className defines the class name to instantiate
  10923. * @returns the new object or null if the system was not able to do the instantiation
  10924. */
  10925. static Instantiate(className: string): any;
  10926. }
  10927. }
  10928. declare module "babylonjs/Misc/copyTools" {
  10929. import { Nullable } from "babylonjs/types";
  10930. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  10931. /**
  10932. * Class used to host copy specific utilities
  10933. */
  10934. export class CopyTools {
  10935. /**
  10936. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  10937. * @param texture defines the texture to read pixels from
  10938. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  10939. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  10940. * @returns The base64 encoded string or null
  10941. */
  10942. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  10943. }
  10944. }
  10945. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  10946. /**
  10947. * Define options used to create a depth texture
  10948. */
  10949. export class DepthTextureCreationOptions {
  10950. /** Specifies whether or not a stencil should be allocated in the texture */
  10951. generateStencil?: boolean;
  10952. /** Specifies whether or not bilinear filtering is enable on the texture */
  10953. bilinearFiltering?: boolean;
  10954. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  10955. comparisonFunction?: number;
  10956. /** Specifies if the created texture is a cube texture */
  10957. isCube?: boolean;
  10958. }
  10959. }
  10960. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  10961. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10962. import { Nullable } from "babylonjs/types";
  10963. import { Scene } from "babylonjs/scene";
  10964. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  10965. module "babylonjs/Engines/thinEngine" {
  10966. interface ThinEngine {
  10967. /**
  10968. * Creates a depth stencil cube texture.
  10969. * This is only available in WebGL 2.
  10970. * @param size The size of face edge in the cube texture.
  10971. * @param options The options defining the cube texture.
  10972. * @returns The cube texture
  10973. */
  10974. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  10975. /**
  10976. * Creates a cube texture
  10977. * @param rootUrl defines the url where the files to load is located
  10978. * @param scene defines the current scene
  10979. * @param files defines the list of files to load (1 per face)
  10980. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10981. * @param onLoad defines an optional callback raised when the texture is loaded
  10982. * @param onError defines an optional callback raised if there is an issue to load the texture
  10983. * @param format defines the format of the data
  10984. * @param forcedExtension defines the extension to use to pick the right loader
  10985. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10986. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10987. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10988. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  10989. * @param loaderOptions options to be passed to the loader
  10990. * @returns the cube texture as an InternalTexture
  10991. */
  10992. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any): InternalTexture;
  10993. /**
  10994. * Creates a cube texture
  10995. * @param rootUrl defines the url where the files to load is located
  10996. * @param scene defines the current scene
  10997. * @param files defines the list of files to load (1 per face)
  10998. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10999. * @param onLoad defines an optional callback raised when the texture is loaded
  11000. * @param onError defines an optional callback raised if there is an issue to load the texture
  11001. * @param format defines the format of the data
  11002. * @param forcedExtension defines the extension to use to pick the right loader
  11003. * @returns the cube texture as an InternalTexture
  11004. */
  11005. 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;
  11006. /**
  11007. * Creates a cube texture
  11008. * @param rootUrl defines the url where the files to load is located
  11009. * @param scene defines the current scene
  11010. * @param files defines the list of files to load (1 per face)
  11011. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11012. * @param onLoad defines an optional callback raised when the texture is loaded
  11013. * @param onError defines an optional callback raised if there is an issue to load the texture
  11014. * @param format defines the format of the data
  11015. * @param forcedExtension defines the extension to use to pick the right loader
  11016. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11017. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11018. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11019. * @returns the cube texture as an InternalTexture
  11020. */
  11021. 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;
  11022. /** @hidden */
  11023. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  11024. /** @hidden */
  11025. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  11026. /** @hidden */
  11027. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11028. /** @hidden */
  11029. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11030. /**
  11031. * @hidden
  11032. */
  11033. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  11034. }
  11035. }
  11036. }
  11037. declare module "babylonjs/Materials/Textures/cubeTexture" {
  11038. import { Nullable } from "babylonjs/types";
  11039. import { Scene } from "babylonjs/scene";
  11040. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11041. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11042. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11043. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  11044. import { Observable } from "babylonjs/Misc/observable";
  11045. /**
  11046. * Class for creating a cube texture
  11047. */
  11048. export class CubeTexture extends BaseTexture {
  11049. private _delayedOnLoad;
  11050. /**
  11051. * Observable triggered once the texture has been loaded.
  11052. */
  11053. onLoadObservable: Observable<CubeTexture>;
  11054. /**
  11055. * The url of the texture
  11056. */
  11057. url: string;
  11058. /**
  11059. * Gets or sets the center of the bounding box associated with the cube texture.
  11060. * It must define where the camera used to render the texture was set
  11061. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11062. */
  11063. boundingBoxPosition: Vector3;
  11064. private _boundingBoxSize;
  11065. /**
  11066. * Gets or sets the size of the bounding box associated with the cube texture
  11067. * When defined, the cubemap will switch to local mode
  11068. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  11069. * @example https://www.babylonjs-playground.com/#RNASML
  11070. */
  11071. set boundingBoxSize(value: Vector3);
  11072. /**
  11073. * Returns the bounding box size
  11074. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11075. */
  11076. get boundingBoxSize(): Vector3;
  11077. protected _rotationY: number;
  11078. /**
  11079. * Sets texture matrix rotation angle around Y axis in radians.
  11080. */
  11081. set rotationY(value: number);
  11082. /**
  11083. * Gets texture matrix rotation angle around Y axis radians.
  11084. */
  11085. get rotationY(): number;
  11086. /**
  11087. * Are mip maps generated for this texture or not.
  11088. */
  11089. get noMipmap(): boolean;
  11090. private _noMipmap;
  11091. private _files;
  11092. protected _forcedExtension: Nullable<string>;
  11093. private _extensions;
  11094. private _textureMatrix;
  11095. private _format;
  11096. private _createPolynomials;
  11097. private _loaderOptions;
  11098. /**
  11099. * Creates a cube texture from an array of image urls
  11100. * @param files defines an array of image urls
  11101. * @param scene defines the hosting scene
  11102. * @param noMipmap specifies if mip maps are not used
  11103. * @returns a cube texture
  11104. */
  11105. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11106. /**
  11107. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11108. * @param url defines the url of the prefiltered texture
  11109. * @param scene defines the scene the texture is attached to
  11110. * @param forcedExtension defines the extension of the file if different from the url
  11111. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11112. * @return the prefiltered texture
  11113. */
  11114. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11115. /**
  11116. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11117. * as prefiltered data.
  11118. * @param rootUrl defines the url of the texture or the root name of the six images
  11119. * @param null defines the scene or engine the texture is attached to
  11120. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11121. * @param noMipmap defines if mipmaps should be created or not
  11122. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11123. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  11124. * @param onError defines a callback triggered in case of error during load
  11125. * @param format defines the internal format to use for the texture once loaded
  11126. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11127. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11128. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11129. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11130. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11131. * @param loaderOptions options to be passed to the loader
  11132. * @return the cube texture
  11133. */
  11134. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, loaderOptions?: any);
  11135. /**
  11136. * Get the current class name of the texture useful for serialization or dynamic coding.
  11137. * @returns "CubeTexture"
  11138. */
  11139. getClassName(): string;
  11140. /**
  11141. * Update the url (and optional buffer) of this texture if url was null during construction.
  11142. * @param url the url of the texture
  11143. * @param forcedExtension defines the extension to use
  11144. * @param onLoad callback called when the texture is loaded (defaults to null)
  11145. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11146. */
  11147. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11148. /**
  11149. * Delays loading of the cube texture
  11150. * @param forcedExtension defines the extension to use
  11151. */
  11152. delayLoad(forcedExtension?: string): void;
  11153. /**
  11154. * Returns the reflection texture matrix
  11155. * @returns the reflection texture matrix
  11156. */
  11157. getReflectionTextureMatrix(): Matrix;
  11158. /**
  11159. * Sets the reflection texture matrix
  11160. * @param value Reflection texture matrix
  11161. */
  11162. setReflectionTextureMatrix(value: Matrix): void;
  11163. /**
  11164. * Parses text to create a cube texture
  11165. * @param parsedTexture define the serialized text to read from
  11166. * @param scene defines the hosting scene
  11167. * @param rootUrl defines the root url of the cube texture
  11168. * @returns a cube texture
  11169. */
  11170. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11171. /**
  11172. * Makes a clone, or deep copy, of the cube texture
  11173. * @returns a new cube texture
  11174. */
  11175. clone(): CubeTexture;
  11176. }
  11177. }
  11178. declare module "babylonjs/Materials/colorCurves" {
  11179. import { Effect } from "babylonjs/Materials/effect";
  11180. /**
  11181. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11182. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11183. * 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;
  11184. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11185. */
  11186. export class ColorCurves {
  11187. private _dirty;
  11188. private _tempColor;
  11189. private _globalCurve;
  11190. private _highlightsCurve;
  11191. private _midtonesCurve;
  11192. private _shadowsCurve;
  11193. private _positiveCurve;
  11194. private _negativeCurve;
  11195. private _globalHue;
  11196. private _globalDensity;
  11197. private _globalSaturation;
  11198. private _globalExposure;
  11199. /**
  11200. * Gets the global Hue value.
  11201. * 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).
  11202. */
  11203. get globalHue(): number;
  11204. /**
  11205. * Sets the global Hue value.
  11206. * 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).
  11207. */
  11208. set globalHue(value: number);
  11209. /**
  11210. * Gets the global Density value.
  11211. * 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.
  11212. * Values less than zero provide a filter of opposite hue.
  11213. */
  11214. get globalDensity(): number;
  11215. /**
  11216. * Sets the global Density value.
  11217. * 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.
  11218. * Values less than zero provide a filter of opposite hue.
  11219. */
  11220. set globalDensity(value: number);
  11221. /**
  11222. * Gets the global Saturation value.
  11223. * 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.
  11224. */
  11225. get globalSaturation(): number;
  11226. /**
  11227. * Sets the global Saturation value.
  11228. * 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.
  11229. */
  11230. set globalSaturation(value: number);
  11231. /**
  11232. * Gets the global Exposure value.
  11233. * 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.
  11234. */
  11235. get globalExposure(): number;
  11236. /**
  11237. * Sets the global Exposure value.
  11238. * 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.
  11239. */
  11240. set globalExposure(value: number);
  11241. private _highlightsHue;
  11242. private _highlightsDensity;
  11243. private _highlightsSaturation;
  11244. private _highlightsExposure;
  11245. /**
  11246. * Gets the highlights Hue value.
  11247. * 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).
  11248. */
  11249. get highlightsHue(): number;
  11250. /**
  11251. * Sets the highlights Hue value.
  11252. * 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).
  11253. */
  11254. set highlightsHue(value: number);
  11255. /**
  11256. * Gets the highlights Density value.
  11257. * 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.
  11258. * Values less than zero provide a filter of opposite hue.
  11259. */
  11260. get highlightsDensity(): number;
  11261. /**
  11262. * Sets the highlights Density value.
  11263. * 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.
  11264. * Values less than zero provide a filter of opposite hue.
  11265. */
  11266. set highlightsDensity(value: number);
  11267. /**
  11268. * Gets the highlights Saturation value.
  11269. * 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.
  11270. */
  11271. get highlightsSaturation(): number;
  11272. /**
  11273. * Sets the highlights Saturation value.
  11274. * 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.
  11275. */
  11276. set highlightsSaturation(value: number);
  11277. /**
  11278. * Gets the highlights Exposure value.
  11279. * 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.
  11280. */
  11281. get highlightsExposure(): number;
  11282. /**
  11283. * Sets the highlights Exposure value.
  11284. * 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.
  11285. */
  11286. set highlightsExposure(value: number);
  11287. private _midtonesHue;
  11288. private _midtonesDensity;
  11289. private _midtonesSaturation;
  11290. private _midtonesExposure;
  11291. /**
  11292. * Gets the midtones Hue value.
  11293. * 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).
  11294. */
  11295. get midtonesHue(): number;
  11296. /**
  11297. * Sets the midtones Hue value.
  11298. * 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).
  11299. */
  11300. set midtonesHue(value: number);
  11301. /**
  11302. * Gets the midtones Density value.
  11303. * 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.
  11304. * Values less than zero provide a filter of opposite hue.
  11305. */
  11306. get midtonesDensity(): number;
  11307. /**
  11308. * Sets the midtones Density value.
  11309. * 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.
  11310. * Values less than zero provide a filter of opposite hue.
  11311. */
  11312. set midtonesDensity(value: number);
  11313. /**
  11314. * Gets the midtones Saturation value.
  11315. * 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.
  11316. */
  11317. get midtonesSaturation(): number;
  11318. /**
  11319. * Sets the midtones Saturation value.
  11320. * 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.
  11321. */
  11322. set midtonesSaturation(value: number);
  11323. /**
  11324. * Gets the midtones Exposure value.
  11325. * 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.
  11326. */
  11327. get midtonesExposure(): number;
  11328. /**
  11329. * Sets the midtones Exposure value.
  11330. * 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.
  11331. */
  11332. set midtonesExposure(value: number);
  11333. private _shadowsHue;
  11334. private _shadowsDensity;
  11335. private _shadowsSaturation;
  11336. private _shadowsExposure;
  11337. /**
  11338. * Gets the shadows Hue value.
  11339. * 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).
  11340. */
  11341. get shadowsHue(): number;
  11342. /**
  11343. * Sets the shadows Hue value.
  11344. * 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).
  11345. */
  11346. set shadowsHue(value: number);
  11347. /**
  11348. * Gets the shadows Density value.
  11349. * 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.
  11350. * Values less than zero provide a filter of opposite hue.
  11351. */
  11352. get shadowsDensity(): number;
  11353. /**
  11354. * Sets the shadows Density value.
  11355. * 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.
  11356. * Values less than zero provide a filter of opposite hue.
  11357. */
  11358. set shadowsDensity(value: number);
  11359. /**
  11360. * Gets the shadows Saturation value.
  11361. * 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.
  11362. */
  11363. get shadowsSaturation(): number;
  11364. /**
  11365. * Sets the shadows Saturation value.
  11366. * 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.
  11367. */
  11368. set shadowsSaturation(value: number);
  11369. /**
  11370. * Gets the shadows Exposure value.
  11371. * 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.
  11372. */
  11373. get shadowsExposure(): number;
  11374. /**
  11375. * Sets the shadows Exposure value.
  11376. * 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.
  11377. */
  11378. set shadowsExposure(value: number);
  11379. /**
  11380. * Returns the class name
  11381. * @returns The class name
  11382. */
  11383. getClassName(): string;
  11384. /**
  11385. * Binds the color curves to the shader.
  11386. * @param colorCurves The color curve to bind
  11387. * @param effect The effect to bind to
  11388. * @param positiveUniform The positive uniform shader parameter
  11389. * @param neutralUniform The neutral uniform shader parameter
  11390. * @param negativeUniform The negative uniform shader parameter
  11391. */
  11392. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11393. /**
  11394. * Prepare the list of uniforms associated with the ColorCurves effects.
  11395. * @param uniformsList The list of uniforms used in the effect
  11396. */
  11397. static PrepareUniforms(uniformsList: string[]): void;
  11398. /**
  11399. * Returns color grading data based on a hue, density, saturation and exposure value.
  11400. * @param filterHue The hue of the color filter.
  11401. * @param filterDensity The density of the color filter.
  11402. * @param saturation The saturation.
  11403. * @param exposure The exposure.
  11404. * @param result The result data container.
  11405. */
  11406. private getColorGradingDataToRef;
  11407. /**
  11408. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11409. * @param value The input slider value in range [-100,100].
  11410. * @returns Adjusted value.
  11411. */
  11412. private static applyColorGradingSliderNonlinear;
  11413. /**
  11414. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11415. * @param hue The hue (H) input.
  11416. * @param saturation The saturation (S) input.
  11417. * @param brightness The brightness (B) input.
  11418. * @result An RGBA color represented as Vector4.
  11419. */
  11420. private static fromHSBToRef;
  11421. /**
  11422. * Returns a value clamped between min and max
  11423. * @param value The value to clamp
  11424. * @param min The minimum of value
  11425. * @param max The maximum of value
  11426. * @returns The clamped value.
  11427. */
  11428. private static clamp;
  11429. /**
  11430. * Clones the current color curve instance.
  11431. * @return The cloned curves
  11432. */
  11433. clone(): ColorCurves;
  11434. /**
  11435. * Serializes the current color curve instance to a json representation.
  11436. * @return a JSON representation
  11437. */
  11438. serialize(): any;
  11439. /**
  11440. * Parses the color curve from a json representation.
  11441. * @param source the JSON source to parse
  11442. * @return The parsed curves
  11443. */
  11444. static Parse(source: any): ColorCurves;
  11445. }
  11446. }
  11447. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  11448. import { Observable } from "babylonjs/Misc/observable";
  11449. import { Nullable } from "babylonjs/types";
  11450. import { Color4 } from "babylonjs/Maths/math.color";
  11451. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11452. import { Effect } from "babylonjs/Materials/effect";
  11453. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11454. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  11455. /**
  11456. * Interface to follow in your material defines to integrate easily the
  11457. * Image proccessing functions.
  11458. * @hidden
  11459. */
  11460. export interface IImageProcessingConfigurationDefines {
  11461. IMAGEPROCESSING: boolean;
  11462. VIGNETTE: boolean;
  11463. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11464. VIGNETTEBLENDMODEOPAQUE: boolean;
  11465. TONEMAPPING: boolean;
  11466. TONEMAPPING_ACES: boolean;
  11467. CONTRAST: boolean;
  11468. EXPOSURE: boolean;
  11469. COLORCURVES: boolean;
  11470. COLORGRADING: boolean;
  11471. COLORGRADING3D: boolean;
  11472. SAMPLER3DGREENDEPTH: boolean;
  11473. SAMPLER3DBGRMAP: boolean;
  11474. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11475. }
  11476. /**
  11477. * @hidden
  11478. */
  11479. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11480. IMAGEPROCESSING: boolean;
  11481. VIGNETTE: boolean;
  11482. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11483. VIGNETTEBLENDMODEOPAQUE: boolean;
  11484. TONEMAPPING: boolean;
  11485. TONEMAPPING_ACES: boolean;
  11486. CONTRAST: boolean;
  11487. COLORCURVES: boolean;
  11488. COLORGRADING: boolean;
  11489. COLORGRADING3D: boolean;
  11490. SAMPLER3DGREENDEPTH: boolean;
  11491. SAMPLER3DBGRMAP: boolean;
  11492. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11493. EXPOSURE: boolean;
  11494. constructor();
  11495. }
  11496. /**
  11497. * This groups together the common properties used for image processing either in direct forward pass
  11498. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11499. * or not.
  11500. */
  11501. export class ImageProcessingConfiguration {
  11502. /**
  11503. * Default tone mapping applied in BabylonJS.
  11504. */
  11505. static readonly TONEMAPPING_STANDARD: number;
  11506. /**
  11507. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11508. * to other engines rendering to increase portability.
  11509. */
  11510. static readonly TONEMAPPING_ACES: number;
  11511. /**
  11512. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11513. */
  11514. colorCurves: Nullable<ColorCurves>;
  11515. private _colorCurvesEnabled;
  11516. /**
  11517. * Gets wether the color curves effect is enabled.
  11518. */
  11519. get colorCurvesEnabled(): boolean;
  11520. /**
  11521. * Sets wether the color curves effect is enabled.
  11522. */
  11523. set colorCurvesEnabled(value: boolean);
  11524. private _colorGradingTexture;
  11525. /**
  11526. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11527. */
  11528. get colorGradingTexture(): Nullable<BaseTexture>;
  11529. /**
  11530. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11531. */
  11532. set colorGradingTexture(value: Nullable<BaseTexture>);
  11533. private _colorGradingEnabled;
  11534. /**
  11535. * Gets wether the color grading effect is enabled.
  11536. */
  11537. get colorGradingEnabled(): boolean;
  11538. /**
  11539. * Sets wether the color grading effect is enabled.
  11540. */
  11541. set colorGradingEnabled(value: boolean);
  11542. private _colorGradingWithGreenDepth;
  11543. /**
  11544. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11545. */
  11546. get colorGradingWithGreenDepth(): boolean;
  11547. /**
  11548. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11549. */
  11550. set colorGradingWithGreenDepth(value: boolean);
  11551. private _colorGradingBGR;
  11552. /**
  11553. * Gets wether the color grading texture contains BGR values.
  11554. */
  11555. get colorGradingBGR(): boolean;
  11556. /**
  11557. * Sets wether the color grading texture contains BGR values.
  11558. */
  11559. set colorGradingBGR(value: boolean);
  11560. /** @hidden */
  11561. _exposure: number;
  11562. /**
  11563. * Gets the Exposure used in the effect.
  11564. */
  11565. get exposure(): number;
  11566. /**
  11567. * Sets the Exposure used in the effect.
  11568. */
  11569. set exposure(value: number);
  11570. private _toneMappingEnabled;
  11571. /**
  11572. * Gets wether the tone mapping effect is enabled.
  11573. */
  11574. get toneMappingEnabled(): boolean;
  11575. /**
  11576. * Sets wether the tone mapping effect is enabled.
  11577. */
  11578. set toneMappingEnabled(value: boolean);
  11579. private _toneMappingType;
  11580. /**
  11581. * Gets the type of tone mapping effect.
  11582. */
  11583. get toneMappingType(): number;
  11584. /**
  11585. * Sets the type of tone mapping effect used in BabylonJS.
  11586. */
  11587. set toneMappingType(value: number);
  11588. protected _contrast: number;
  11589. /**
  11590. * Gets the contrast used in the effect.
  11591. */
  11592. get contrast(): number;
  11593. /**
  11594. * Sets the contrast used in the effect.
  11595. */
  11596. set contrast(value: number);
  11597. /**
  11598. * Vignette stretch size.
  11599. */
  11600. vignetteStretch: number;
  11601. /**
  11602. * Vignette centre X Offset.
  11603. */
  11604. vignetteCentreX: number;
  11605. /**
  11606. * Vignette centre Y Offset.
  11607. */
  11608. vignetteCentreY: number;
  11609. /**
  11610. * Vignette weight or intensity of the vignette effect.
  11611. */
  11612. vignetteWeight: number;
  11613. /**
  11614. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  11615. * if vignetteEnabled is set to true.
  11616. */
  11617. vignetteColor: Color4;
  11618. /**
  11619. * Camera field of view used by the Vignette effect.
  11620. */
  11621. vignetteCameraFov: number;
  11622. private _vignetteBlendMode;
  11623. /**
  11624. * Gets the vignette blend mode allowing different kind of effect.
  11625. */
  11626. get vignetteBlendMode(): number;
  11627. /**
  11628. * Sets the vignette blend mode allowing different kind of effect.
  11629. */
  11630. set vignetteBlendMode(value: number);
  11631. private _vignetteEnabled;
  11632. /**
  11633. * Gets wether the vignette effect is enabled.
  11634. */
  11635. get vignetteEnabled(): boolean;
  11636. /**
  11637. * Sets wether the vignette effect is enabled.
  11638. */
  11639. set vignetteEnabled(value: boolean);
  11640. private _applyByPostProcess;
  11641. /**
  11642. * Gets wether the image processing is applied through a post process or not.
  11643. */
  11644. get applyByPostProcess(): boolean;
  11645. /**
  11646. * Sets wether the image processing is applied through a post process or not.
  11647. */
  11648. set applyByPostProcess(value: boolean);
  11649. private _isEnabled;
  11650. /**
  11651. * Gets wether the image processing is enabled or not.
  11652. */
  11653. get isEnabled(): boolean;
  11654. /**
  11655. * Sets wether the image processing is enabled or not.
  11656. */
  11657. set isEnabled(value: boolean);
  11658. /**
  11659. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  11660. */
  11661. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  11662. /**
  11663. * Method called each time the image processing information changes requires to recompile the effect.
  11664. */
  11665. protected _updateParameters(): void;
  11666. /**
  11667. * Gets the current class name.
  11668. * @return "ImageProcessingConfiguration"
  11669. */
  11670. getClassName(): string;
  11671. /**
  11672. * Prepare the list of uniforms associated with the Image Processing effects.
  11673. * @param uniforms The list of uniforms used in the effect
  11674. * @param defines the list of defines currently in use
  11675. */
  11676. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  11677. /**
  11678. * Prepare the list of samplers associated with the Image Processing effects.
  11679. * @param samplersList The list of uniforms used in the effect
  11680. * @param defines the list of defines currently in use
  11681. */
  11682. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  11683. /**
  11684. * Prepare the list of defines associated to the shader.
  11685. * @param defines the list of defines to complete
  11686. * @param forPostProcess Define if we are currently in post process mode or not
  11687. */
  11688. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  11689. /**
  11690. * Returns true if all the image processing information are ready.
  11691. * @returns True if ready, otherwise, false
  11692. */
  11693. isReady(): boolean;
  11694. /**
  11695. * Binds the image processing to the shader.
  11696. * @param effect The effect to bind to
  11697. * @param overrideAspectRatio Override the aspect ratio of the effect
  11698. */
  11699. bind(effect: Effect, overrideAspectRatio?: number): void;
  11700. /**
  11701. * Clones the current image processing instance.
  11702. * @return The cloned image processing
  11703. */
  11704. clone(): ImageProcessingConfiguration;
  11705. /**
  11706. * Serializes the current image processing instance to a json representation.
  11707. * @return a JSON representation
  11708. */
  11709. serialize(): any;
  11710. /**
  11711. * Parses the image processing from a json representation.
  11712. * @param source the JSON source to parse
  11713. * @return The parsed image processing
  11714. */
  11715. static Parse(source: any): ImageProcessingConfiguration;
  11716. private static _VIGNETTEMODE_MULTIPLY;
  11717. private static _VIGNETTEMODE_OPAQUE;
  11718. /**
  11719. * Used to apply the vignette as a mix with the pixel color.
  11720. */
  11721. static get VIGNETTEMODE_MULTIPLY(): number;
  11722. /**
  11723. * Used to apply the vignette as a replacement of the pixel color.
  11724. */
  11725. static get VIGNETTEMODE_OPAQUE(): number;
  11726. }
  11727. }
  11728. declare module "babylonjs/Shaders/postprocess.vertex" {
  11729. /** @hidden */
  11730. export var postprocessVertexShader: {
  11731. name: string;
  11732. shader: string;
  11733. };
  11734. }
  11735. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  11736. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11737. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11738. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  11739. /**
  11740. * Type used to define a render target texture size (either with a number or with a rect width and height)
  11741. */
  11742. export type RenderTargetTextureSize = number | {
  11743. width: number;
  11744. height: number;
  11745. layers?: number;
  11746. };
  11747. module "babylonjs/Engines/thinEngine" {
  11748. interface ThinEngine {
  11749. /**
  11750. * Creates a new render target texture
  11751. * @param size defines the size of the texture
  11752. * @param options defines the options used to create the texture
  11753. * @returns a new render target texture stored in an InternalTexture
  11754. */
  11755. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11756. /**
  11757. * Creates a depth stencil texture.
  11758. * This is only available in WebGL 2 or with the depth texture extension available.
  11759. * @param size The size of face edge in the texture.
  11760. * @param options The options defining the texture.
  11761. * @returns The texture
  11762. */
  11763. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11764. /** @hidden */
  11765. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11766. }
  11767. }
  11768. }
  11769. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  11770. /**
  11771. * Defines the kind of connection point for node based material
  11772. */
  11773. export enum NodeMaterialBlockConnectionPointTypes {
  11774. /** Float */
  11775. Float = 1,
  11776. /** Int */
  11777. Int = 2,
  11778. /** Vector2 */
  11779. Vector2 = 4,
  11780. /** Vector3 */
  11781. Vector3 = 8,
  11782. /** Vector4 */
  11783. Vector4 = 16,
  11784. /** Color3 */
  11785. Color3 = 32,
  11786. /** Color4 */
  11787. Color4 = 64,
  11788. /** Matrix */
  11789. Matrix = 128,
  11790. /** Custom object */
  11791. Object = 256,
  11792. /** Detect type based on connection */
  11793. AutoDetect = 1024,
  11794. /** Output type that will be defined by input type */
  11795. BasedOnInput = 2048
  11796. }
  11797. }
  11798. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  11799. /**
  11800. * Enum used to define the target of a block
  11801. */
  11802. export enum NodeMaterialBlockTargets {
  11803. /** Vertex shader */
  11804. Vertex = 1,
  11805. /** Fragment shader */
  11806. Fragment = 2,
  11807. /** Neutral */
  11808. Neutral = 4,
  11809. /** Vertex and Fragment */
  11810. VertexAndFragment = 3
  11811. }
  11812. }
  11813. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  11814. /**
  11815. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  11816. */
  11817. export enum NodeMaterialBlockConnectionPointMode {
  11818. /** Value is an uniform */
  11819. Uniform = 0,
  11820. /** Value is a mesh attribute */
  11821. Attribute = 1,
  11822. /** Value is a varying between vertex and fragment shaders */
  11823. Varying = 2,
  11824. /** Mode is undefined */
  11825. Undefined = 3
  11826. }
  11827. }
  11828. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  11829. /**
  11830. * Enum used to define system values e.g. values automatically provided by the system
  11831. */
  11832. export enum NodeMaterialSystemValues {
  11833. /** World */
  11834. World = 1,
  11835. /** View */
  11836. View = 2,
  11837. /** Projection */
  11838. Projection = 3,
  11839. /** ViewProjection */
  11840. ViewProjection = 4,
  11841. /** WorldView */
  11842. WorldView = 5,
  11843. /** WorldViewProjection */
  11844. WorldViewProjection = 6,
  11845. /** CameraPosition */
  11846. CameraPosition = 7,
  11847. /** Fog Color */
  11848. FogColor = 8,
  11849. /** Delta time */
  11850. DeltaTime = 9
  11851. }
  11852. }
  11853. declare module "babylonjs/Maths/math.frustum" {
  11854. import { Matrix } from "babylonjs/Maths/math.vector";
  11855. import { DeepImmutable } from "babylonjs/types";
  11856. import { Plane } from "babylonjs/Maths/math.plane";
  11857. /**
  11858. * Represents a camera frustum
  11859. */
  11860. export class Frustum {
  11861. /**
  11862. * Gets the planes representing the frustum
  11863. * @param transform matrix to be applied to the returned planes
  11864. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  11865. */
  11866. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  11867. /**
  11868. * Gets the near frustum plane transformed by the transform matrix
  11869. * @param transform transformation matrix to be applied to the resulting frustum plane
  11870. * @param frustumPlane the resuling frustum plane
  11871. */
  11872. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11873. /**
  11874. * Gets the far frustum plane transformed by the transform matrix
  11875. * @param transform transformation matrix to be applied to the resulting frustum plane
  11876. * @param frustumPlane the resuling frustum plane
  11877. */
  11878. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11879. /**
  11880. * Gets the left frustum plane transformed by the transform matrix
  11881. * @param transform transformation matrix to be applied to the resulting frustum plane
  11882. * @param frustumPlane the resuling frustum plane
  11883. */
  11884. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11885. /**
  11886. * Gets the right frustum plane transformed by the transform matrix
  11887. * @param transform transformation matrix to be applied to the resulting frustum plane
  11888. * @param frustumPlane the resuling frustum plane
  11889. */
  11890. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11891. /**
  11892. * Gets the top frustum plane transformed by the transform matrix
  11893. * @param transform transformation matrix to be applied to the resulting frustum plane
  11894. * @param frustumPlane the resuling frustum plane
  11895. */
  11896. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11897. /**
  11898. * Gets the bottom frustum plane transformed by the transform matrix
  11899. * @param transform transformation matrix to be applied to the resulting frustum plane
  11900. * @param frustumPlane the resuling frustum plane
  11901. */
  11902. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11903. /**
  11904. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  11905. * @param transform transformation matrix to be applied to the resulting frustum planes
  11906. * @param frustumPlanes the resuling frustum planes
  11907. */
  11908. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  11909. }
  11910. }
  11911. declare module "babylonjs/Maths/math.vertexFormat" {
  11912. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11913. /**
  11914. * Contains position and normal vectors for a vertex
  11915. */
  11916. export class PositionNormalVertex {
  11917. /** the position of the vertex (defaut: 0,0,0) */
  11918. position: Vector3;
  11919. /** the normal of the vertex (defaut: 0,1,0) */
  11920. normal: Vector3;
  11921. /**
  11922. * Creates a PositionNormalVertex
  11923. * @param position the position of the vertex (defaut: 0,0,0)
  11924. * @param normal the normal of the vertex (defaut: 0,1,0)
  11925. */
  11926. constructor(
  11927. /** the position of the vertex (defaut: 0,0,0) */
  11928. position?: Vector3,
  11929. /** the normal of the vertex (defaut: 0,1,0) */
  11930. normal?: Vector3);
  11931. /**
  11932. * Clones the PositionNormalVertex
  11933. * @returns the cloned PositionNormalVertex
  11934. */
  11935. clone(): PositionNormalVertex;
  11936. }
  11937. /**
  11938. * Contains position, normal and uv vectors for a vertex
  11939. */
  11940. export class PositionNormalTextureVertex {
  11941. /** the position of the vertex (defaut: 0,0,0) */
  11942. position: Vector3;
  11943. /** the normal of the vertex (defaut: 0,1,0) */
  11944. normal: Vector3;
  11945. /** the uv of the vertex (default: 0,0) */
  11946. uv: Vector2;
  11947. /**
  11948. * Creates a PositionNormalTextureVertex
  11949. * @param position the position of the vertex (defaut: 0,0,0)
  11950. * @param normal the normal of the vertex (defaut: 0,1,0)
  11951. * @param uv the uv of the vertex (default: 0,0)
  11952. */
  11953. constructor(
  11954. /** the position of the vertex (defaut: 0,0,0) */
  11955. position?: Vector3,
  11956. /** the normal of the vertex (defaut: 0,1,0) */
  11957. normal?: Vector3,
  11958. /** the uv of the vertex (default: 0,0) */
  11959. uv?: Vector2);
  11960. /**
  11961. * Clones the PositionNormalTextureVertex
  11962. * @returns the cloned PositionNormalTextureVertex
  11963. */
  11964. clone(): PositionNormalTextureVertex;
  11965. }
  11966. }
  11967. declare module "babylonjs/Maths/math" {
  11968. export * from "babylonjs/Maths/math.axis";
  11969. export * from "babylonjs/Maths/math.color";
  11970. export * from "babylonjs/Maths/math.constants";
  11971. export * from "babylonjs/Maths/math.frustum";
  11972. export * from "babylonjs/Maths/math.path";
  11973. export * from "babylonjs/Maths/math.plane";
  11974. export * from "babylonjs/Maths/math.size";
  11975. export * from "babylonjs/Maths/math.vector";
  11976. export * from "babylonjs/Maths/math.vertexFormat";
  11977. export * from "babylonjs/Maths/math.viewport";
  11978. }
  11979. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  11980. /**
  11981. * Enum defining the type of animations supported by InputBlock
  11982. */
  11983. export enum AnimatedInputBlockTypes {
  11984. /** No animation */
  11985. None = 0,
  11986. /** Time based animation. Will only work for floats */
  11987. Time = 1
  11988. }
  11989. }
  11990. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  11991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  11992. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  11993. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  11994. import { Nullable } from "babylonjs/types";
  11995. import { Effect } from "babylonjs/Materials/effect";
  11996. import { Matrix } from "babylonjs/Maths/math.vector";
  11997. import { Scene } from "babylonjs/scene";
  11998. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  11999. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12000. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12001. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  12002. import { Observable } from "babylonjs/Misc/observable";
  12003. /**
  12004. * Block used to expose an input value
  12005. */
  12006. export class InputBlock extends NodeMaterialBlock {
  12007. private _mode;
  12008. private _associatedVariableName;
  12009. private _storedValue;
  12010. private _valueCallback;
  12011. private _type;
  12012. private _animationType;
  12013. /** Gets or set a value used to limit the range of float values */
  12014. min: number;
  12015. /** Gets or set a value used to limit the range of float values */
  12016. max: number;
  12017. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12018. isBoolean: boolean;
  12019. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12020. matrixMode: number;
  12021. /** @hidden */
  12022. _systemValue: Nullable<NodeMaterialSystemValues>;
  12023. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12024. isConstant: boolean;
  12025. /** Gets or sets the group to use to display this block in the Inspector */
  12026. groupInInspector: string;
  12027. /** Gets an observable raised when the value is changed */
  12028. onValueChangedObservable: Observable<InputBlock>;
  12029. /**
  12030. * Gets or sets the connection point type (default is float)
  12031. */
  12032. get type(): NodeMaterialBlockConnectionPointTypes;
  12033. /**
  12034. * Creates a new InputBlock
  12035. * @param name defines the block name
  12036. * @param target defines the target of that block (Vertex by default)
  12037. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12038. */
  12039. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12040. /**
  12041. * Validates if a name is a reserve word.
  12042. * @param newName the new name to be given to the node.
  12043. * @returns false if the name is a reserve word, else true.
  12044. */
  12045. validateBlockName(newName: string): boolean;
  12046. /**
  12047. * Gets the output component
  12048. */
  12049. get output(): NodeMaterialConnectionPoint;
  12050. /**
  12051. * Set the source of this connection point to a vertex attribute
  12052. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12053. * @returns the current connection point
  12054. */
  12055. setAsAttribute(attributeName?: string): InputBlock;
  12056. /**
  12057. * Set the source of this connection point to a system value
  12058. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12059. * @returns the current connection point
  12060. */
  12061. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12062. /**
  12063. * Gets or sets the value of that point.
  12064. * Please note that this value will be ignored if valueCallback is defined
  12065. */
  12066. get value(): any;
  12067. set value(value: any);
  12068. /**
  12069. * Gets or sets a callback used to get the value of that point.
  12070. * Please note that setting this value will force the connection point to ignore the value property
  12071. */
  12072. get valueCallback(): () => any;
  12073. set valueCallback(value: () => any);
  12074. /**
  12075. * Gets or sets the associated variable name in the shader
  12076. */
  12077. get associatedVariableName(): string;
  12078. set associatedVariableName(value: string);
  12079. /** Gets or sets the type of animation applied to the input */
  12080. get animationType(): AnimatedInputBlockTypes;
  12081. set animationType(value: AnimatedInputBlockTypes);
  12082. /**
  12083. * Gets a boolean indicating that this connection point not defined yet
  12084. */
  12085. get isUndefined(): boolean;
  12086. /**
  12087. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12088. * In this case the connection point name must be the name of the uniform to use.
  12089. * Can only be set on inputs
  12090. */
  12091. get isUniform(): boolean;
  12092. set isUniform(value: boolean);
  12093. /**
  12094. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12095. * In this case the connection point name must be the name of the attribute to use
  12096. * Can only be set on inputs
  12097. */
  12098. get isAttribute(): boolean;
  12099. set isAttribute(value: boolean);
  12100. /**
  12101. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12102. * Can only be set on exit points
  12103. */
  12104. get isVarying(): boolean;
  12105. set isVarying(value: boolean);
  12106. /**
  12107. * Gets a boolean indicating that the current connection point is a system value
  12108. */
  12109. get isSystemValue(): boolean;
  12110. /**
  12111. * Gets or sets the current well known value or null if not defined as a system value
  12112. */
  12113. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12114. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12115. /**
  12116. * Gets the current class name
  12117. * @returns the class name
  12118. */
  12119. getClassName(): string;
  12120. /**
  12121. * Animate the input if animationType !== None
  12122. * @param scene defines the rendering scene
  12123. */
  12124. animate(scene: Scene): void;
  12125. private _emitDefine;
  12126. initialize(state: NodeMaterialBuildState): void;
  12127. /**
  12128. * Set the input block to its default value (based on its type)
  12129. */
  12130. setDefaultValue(): void;
  12131. private _emitConstant;
  12132. /** @hidden */
  12133. get _noContextSwitch(): boolean;
  12134. private _emit;
  12135. /** @hidden */
  12136. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12137. /** @hidden */
  12138. _transmit(effect: Effect, scene: Scene): void;
  12139. protected _buildBlock(state: NodeMaterialBuildState): void;
  12140. protected _dumpPropertiesCode(): string;
  12141. dispose(): void;
  12142. serialize(): any;
  12143. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12144. }
  12145. }
  12146. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  12147. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  12148. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12149. import { Nullable } from "babylonjs/types";
  12150. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  12151. import { Observable } from "babylonjs/Misc/observable";
  12152. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12153. /**
  12154. * Enum used to define the compatibility state between two connection points
  12155. */
  12156. export enum NodeMaterialConnectionPointCompatibilityStates {
  12157. /** Points are compatibles */
  12158. Compatible = 0,
  12159. /** Points are incompatible because of their types */
  12160. TypeIncompatible = 1,
  12161. /** Points are incompatible because of their targets (vertex vs fragment) */
  12162. TargetIncompatible = 2
  12163. }
  12164. /**
  12165. * Defines the direction of a connection point
  12166. */
  12167. export enum NodeMaterialConnectionPointDirection {
  12168. /** Input */
  12169. Input = 0,
  12170. /** Output */
  12171. Output = 1
  12172. }
  12173. /**
  12174. * Defines a connection point for a block
  12175. */
  12176. export class NodeMaterialConnectionPoint {
  12177. /**
  12178. * Checks if two types are equivalent
  12179. * @param type1 type 1 to check
  12180. * @param type2 type 2 to check
  12181. * @returns true if both types are equivalent, else false
  12182. */
  12183. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12184. /** @hidden */
  12185. _ownerBlock: NodeMaterialBlock;
  12186. /** @hidden */
  12187. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12188. private _endpoints;
  12189. private _associatedVariableName;
  12190. private _direction;
  12191. /** @hidden */
  12192. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12193. /** @hidden */
  12194. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12195. /** @hidden */
  12196. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12197. private _type;
  12198. /** @hidden */
  12199. _enforceAssociatedVariableName: boolean;
  12200. /** Gets the direction of the point */
  12201. get direction(): NodeMaterialConnectionPointDirection;
  12202. /** Indicates that this connection point needs dual validation before being connected to another point */
  12203. needDualDirectionValidation: boolean;
  12204. /**
  12205. * Gets or sets the additional types supported by this connection point
  12206. */
  12207. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12208. /**
  12209. * Gets or sets the additional types excluded by this connection point
  12210. */
  12211. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12212. /**
  12213. * Observable triggered when this point is connected
  12214. */
  12215. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12216. /**
  12217. * Gets or sets the associated variable name in the shader
  12218. */
  12219. get associatedVariableName(): string;
  12220. set associatedVariableName(value: string);
  12221. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12222. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12223. /**
  12224. * Gets or sets the connection point type (default is float)
  12225. */
  12226. get type(): NodeMaterialBlockConnectionPointTypes;
  12227. set type(value: NodeMaterialBlockConnectionPointTypes);
  12228. /**
  12229. * Gets or sets the connection point name
  12230. */
  12231. name: string;
  12232. /**
  12233. * Gets or sets the connection point name
  12234. */
  12235. displayName: string;
  12236. /**
  12237. * Gets or sets a boolean indicating that this connection point can be omitted
  12238. */
  12239. isOptional: boolean;
  12240. /**
  12241. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12242. */
  12243. isExposedOnFrame: boolean;
  12244. /**
  12245. * Gets or sets number indicating the position that the port is exposed to on a frame
  12246. */
  12247. exposedPortPosition: number;
  12248. /**
  12249. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12250. */
  12251. define: string;
  12252. /** @hidden */
  12253. _prioritizeVertex: boolean;
  12254. private _target;
  12255. /** Gets or sets the target of that connection point */
  12256. get target(): NodeMaterialBlockTargets;
  12257. set target(value: NodeMaterialBlockTargets);
  12258. /**
  12259. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12260. */
  12261. get isConnected(): boolean;
  12262. /**
  12263. * Gets a boolean indicating that the current point is connected to an input block
  12264. */
  12265. get isConnectedToInputBlock(): boolean;
  12266. /**
  12267. * Gets a the connected input block (if any)
  12268. */
  12269. get connectInputBlock(): Nullable<InputBlock>;
  12270. /** Get the other side of the connection (if any) */
  12271. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12272. /** Get the block that owns this connection point */
  12273. get ownerBlock(): NodeMaterialBlock;
  12274. /** Get the block connected on the other side of this connection (if any) */
  12275. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12276. /** Get the block connected on the endpoints of this connection (if any) */
  12277. get connectedBlocks(): Array<NodeMaterialBlock>;
  12278. /** Gets the list of connected endpoints */
  12279. get endpoints(): NodeMaterialConnectionPoint[];
  12280. /** Gets a boolean indicating if that output point is connected to at least one input */
  12281. get hasEndpoints(): boolean;
  12282. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12283. get isConnectedInVertexShader(): boolean;
  12284. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12285. get isConnectedInFragmentShader(): boolean;
  12286. /**
  12287. * Creates a block suitable to be used as an input for this input point.
  12288. * If null is returned, a block based on the point type will be created.
  12289. * @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
  12290. */
  12291. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12292. /**
  12293. * Creates a new connection point
  12294. * @param name defines the connection point name
  12295. * @param ownerBlock defines the block hosting this connection point
  12296. * @param direction defines the direction of the connection point
  12297. */
  12298. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12299. /**
  12300. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12301. * @returns the class name
  12302. */
  12303. getClassName(): string;
  12304. /**
  12305. * Gets a boolean indicating if the current point can be connected to another point
  12306. * @param connectionPoint defines the other connection point
  12307. * @returns a boolean
  12308. */
  12309. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12310. /**
  12311. * Gets a number indicating if the current point can be connected to another point
  12312. * @param connectionPoint defines the other connection point
  12313. * @returns a number defining the compatibility state
  12314. */
  12315. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12316. /**
  12317. * Connect this point to another connection point
  12318. * @param connectionPoint defines the other connection point
  12319. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12320. * @returns the current connection point
  12321. */
  12322. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12323. /**
  12324. * Disconnect this point from one of his endpoint
  12325. * @param endpoint defines the other connection point
  12326. * @returns the current connection point
  12327. */
  12328. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12329. /**
  12330. * Serializes this point in a JSON representation
  12331. * @param isInput defines if the connection point is an input (default is true)
  12332. * @returns the serialized point object
  12333. */
  12334. serialize(isInput?: boolean): any;
  12335. /**
  12336. * Release resources
  12337. */
  12338. dispose(): void;
  12339. }
  12340. }
  12341. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  12342. /**
  12343. * Enum used to define the material modes
  12344. */
  12345. export enum NodeMaterialModes {
  12346. /** Regular material */
  12347. Material = 0,
  12348. /** For post process */
  12349. PostProcess = 1,
  12350. /** For particle system */
  12351. Particle = 2,
  12352. /** For procedural texture */
  12353. ProceduralTexture = 3
  12354. }
  12355. }
  12356. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  12357. /** @hidden */
  12358. export var helperFunctions: {
  12359. name: string;
  12360. shader: string;
  12361. };
  12362. }
  12363. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  12364. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12365. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12366. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12367. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12369. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12370. import { Effect } from "babylonjs/Materials/effect";
  12371. import { Mesh } from "babylonjs/Meshes/mesh";
  12372. import { Nullable } from "babylonjs/types";
  12373. import { Texture } from "babylonjs/Materials/Textures/texture";
  12374. import { Scene } from "babylonjs/scene";
  12375. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12376. /**
  12377. * Block used to read a texture from a sampler
  12378. */
  12379. export class TextureBlock extends NodeMaterialBlock {
  12380. private _defineName;
  12381. private _linearDefineName;
  12382. private _gammaDefineName;
  12383. private _tempTextureRead;
  12384. private _samplerName;
  12385. private _transformedUVName;
  12386. private _textureTransformName;
  12387. private _textureInfoName;
  12388. private _mainUVName;
  12389. private _mainUVDefineName;
  12390. private _fragmentOnly;
  12391. /**
  12392. * Gets or sets the texture associated with the node
  12393. */
  12394. texture: Nullable<Texture>;
  12395. /**
  12396. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12397. */
  12398. convertToGammaSpace: boolean;
  12399. /**
  12400. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12401. */
  12402. convertToLinearSpace: boolean;
  12403. /**
  12404. * Create a new TextureBlock
  12405. * @param name defines the block name
  12406. */
  12407. constructor(name: string, fragmentOnly?: boolean);
  12408. /**
  12409. * Gets the current class name
  12410. * @returns the class name
  12411. */
  12412. getClassName(): string;
  12413. /**
  12414. * Gets the uv input component
  12415. */
  12416. get uv(): NodeMaterialConnectionPoint;
  12417. /**
  12418. * Gets the rgba output component
  12419. */
  12420. get rgba(): NodeMaterialConnectionPoint;
  12421. /**
  12422. * Gets the rgb output component
  12423. */
  12424. get rgb(): NodeMaterialConnectionPoint;
  12425. /**
  12426. * Gets the r output component
  12427. */
  12428. get r(): NodeMaterialConnectionPoint;
  12429. /**
  12430. * Gets the g output component
  12431. */
  12432. get g(): NodeMaterialConnectionPoint;
  12433. /**
  12434. * Gets the b output component
  12435. */
  12436. get b(): NodeMaterialConnectionPoint;
  12437. /**
  12438. * Gets the a output component
  12439. */
  12440. get a(): NodeMaterialConnectionPoint;
  12441. get target(): NodeMaterialBlockTargets;
  12442. autoConfigure(material: NodeMaterial): void;
  12443. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12444. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12445. isReady(): boolean;
  12446. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12447. private get _isMixed();
  12448. private _injectVertexCode;
  12449. private _writeTextureRead;
  12450. private _writeOutput;
  12451. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12452. protected _dumpPropertiesCode(): string;
  12453. serialize(): any;
  12454. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12455. }
  12456. }
  12457. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  12458. /** @hidden */
  12459. export var reflectionFunction: {
  12460. name: string;
  12461. shader: string;
  12462. };
  12463. }
  12464. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  12465. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12466. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12467. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12468. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12470. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12471. import { Effect } from "babylonjs/Materials/effect";
  12472. import { Mesh } from "babylonjs/Meshes/mesh";
  12473. import { Nullable } from "babylonjs/types";
  12474. import { Scene } from "babylonjs/scene";
  12475. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  12476. /**
  12477. * Base block used to read a reflection texture from a sampler
  12478. */
  12479. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12480. /** @hidden */
  12481. _define3DName: string;
  12482. /** @hidden */
  12483. _defineCubicName: string;
  12484. /** @hidden */
  12485. _defineExplicitName: string;
  12486. /** @hidden */
  12487. _defineProjectionName: string;
  12488. /** @hidden */
  12489. _defineLocalCubicName: string;
  12490. /** @hidden */
  12491. _defineSphericalName: string;
  12492. /** @hidden */
  12493. _definePlanarName: string;
  12494. /** @hidden */
  12495. _defineEquirectangularName: string;
  12496. /** @hidden */
  12497. _defineMirroredEquirectangularFixedName: string;
  12498. /** @hidden */
  12499. _defineEquirectangularFixedName: string;
  12500. /** @hidden */
  12501. _defineSkyboxName: string;
  12502. /** @hidden */
  12503. _defineOppositeZ: string;
  12504. /** @hidden */
  12505. _cubeSamplerName: string;
  12506. /** @hidden */
  12507. _2DSamplerName: string;
  12508. protected _positionUVWName: string;
  12509. protected _directionWName: string;
  12510. protected _reflectionVectorName: string;
  12511. /** @hidden */
  12512. _reflectionCoordsName: string;
  12513. /** @hidden */
  12514. _reflectionMatrixName: string;
  12515. protected _reflectionColorName: string;
  12516. /**
  12517. * Gets or sets the texture associated with the node
  12518. */
  12519. texture: Nullable<BaseTexture>;
  12520. /**
  12521. * Create a new ReflectionTextureBaseBlock
  12522. * @param name defines the block name
  12523. */
  12524. constructor(name: string);
  12525. /**
  12526. * Gets the current class name
  12527. * @returns the class name
  12528. */
  12529. getClassName(): string;
  12530. /**
  12531. * Gets the world position input component
  12532. */
  12533. abstract get position(): NodeMaterialConnectionPoint;
  12534. /**
  12535. * Gets the world position input component
  12536. */
  12537. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12538. /**
  12539. * Gets the world normal input component
  12540. */
  12541. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12542. /**
  12543. * Gets the world input component
  12544. */
  12545. abstract get world(): NodeMaterialConnectionPoint;
  12546. /**
  12547. * Gets the camera (or eye) position component
  12548. */
  12549. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12550. /**
  12551. * Gets the view input component
  12552. */
  12553. abstract get view(): NodeMaterialConnectionPoint;
  12554. protected _getTexture(): Nullable<BaseTexture>;
  12555. autoConfigure(material: NodeMaterial): void;
  12556. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12557. isReady(): boolean;
  12558. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12559. /**
  12560. * Gets the code to inject in the vertex shader
  12561. * @param state current state of the node material building
  12562. * @returns the shader code
  12563. */
  12564. handleVertexSide(state: NodeMaterialBuildState): string;
  12565. /**
  12566. * Handles the inits for the fragment code path
  12567. * @param state node material build state
  12568. */
  12569. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12570. /**
  12571. * Generates the reflection coords code for the fragment code path
  12572. * @param worldNormalVarName name of the world normal variable
  12573. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  12574. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  12575. * @returns the shader code
  12576. */
  12577. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  12578. /**
  12579. * Generates the reflection color code for the fragment code path
  12580. * @param lodVarName name of the lod variable
  12581. * @param swizzleLookupTexture swizzle to use for the final color variable
  12582. * @returns the shader code
  12583. */
  12584. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  12585. /**
  12586. * Generates the code corresponding to the connected output points
  12587. * @param state node material build state
  12588. * @param varName name of the variable to output
  12589. * @returns the shader code
  12590. */
  12591. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  12592. protected _buildBlock(state: NodeMaterialBuildState): this;
  12593. protected _dumpPropertiesCode(): string;
  12594. serialize(): any;
  12595. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12596. }
  12597. }
  12598. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  12599. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12600. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12601. import { Nullable } from "babylonjs/types";
  12602. /**
  12603. * Defines a connection point to be used for points with a custom object type
  12604. */
  12605. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  12606. private _blockType;
  12607. private _blockName;
  12608. private _nameForCheking?;
  12609. /**
  12610. * Creates a new connection point
  12611. * @param name defines the connection point name
  12612. * @param ownerBlock defines the block hosting this connection point
  12613. * @param direction defines the direction of the connection point
  12614. */
  12615. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  12616. /**
  12617. * Gets a number indicating if the current point can be connected to another point
  12618. * @param connectionPoint defines the other connection point
  12619. * @returns a number defining the compatibility state
  12620. */
  12621. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12622. /**
  12623. * Creates a block suitable to be used as an input for this input point.
  12624. * If null is returned, a block based on the point type will be created.
  12625. * @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
  12626. */
  12627. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12628. }
  12629. }
  12630. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  12631. /**
  12632. * Enum defining the type of properties that can be edited in the property pages in the NME
  12633. */
  12634. export enum PropertyTypeForEdition {
  12635. /** property is a boolean */
  12636. Boolean = 0,
  12637. /** property is a float */
  12638. Float = 1,
  12639. /** property is a Vector2 */
  12640. Vector2 = 2,
  12641. /** property is a list of values */
  12642. List = 3
  12643. }
  12644. /**
  12645. * Interface that defines an option in a variable of type list
  12646. */
  12647. export interface IEditablePropertyListOption {
  12648. /** label of the option */
  12649. "label": string;
  12650. /** value of the option */
  12651. "value": number;
  12652. }
  12653. /**
  12654. * Interface that defines the options available for an editable property
  12655. */
  12656. export interface IEditablePropertyOption {
  12657. /** min value */
  12658. "min"?: number;
  12659. /** max value */
  12660. "max"?: number;
  12661. /** notifiers: indicates which actions to take when the property is changed */
  12662. "notifiers"?: {
  12663. /** the material should be rebuilt */
  12664. "rebuild"?: boolean;
  12665. /** the preview should be updated */
  12666. "update"?: boolean;
  12667. };
  12668. /** list of the options for a variable of type list */
  12669. "options"?: IEditablePropertyListOption[];
  12670. }
  12671. /**
  12672. * Interface that describes an editable property
  12673. */
  12674. export interface IPropertyDescriptionForEdition {
  12675. /** name of the property */
  12676. "propertyName": string;
  12677. /** display name of the property */
  12678. "displayName": string;
  12679. /** type of the property */
  12680. "type": PropertyTypeForEdition;
  12681. /** group of the property - all properties with the same group value will be displayed in a specific section */
  12682. "groupName": string;
  12683. /** options for the property */
  12684. "options": IEditablePropertyOption;
  12685. }
  12686. /**
  12687. * Decorator that flags a property in a node material block as being editable
  12688. */
  12689. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  12690. }
  12691. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  12692. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12693. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12694. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12696. import { Nullable } from "babylonjs/types";
  12697. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12698. import { Mesh } from "babylonjs/Meshes/mesh";
  12699. import { SubMesh } from "babylonjs/Meshes/subMesh";
  12700. import { Effect } from "babylonjs/Materials/effect";
  12701. import { Scene } from "babylonjs/scene";
  12702. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12703. /**
  12704. * Block used to implement the refraction part of the sub surface module of the PBR material
  12705. */
  12706. export class RefractionBlock extends NodeMaterialBlock {
  12707. /** @hidden */
  12708. _define3DName: string;
  12709. /** @hidden */
  12710. _refractionMatrixName: string;
  12711. /** @hidden */
  12712. _defineLODRefractionAlpha: string;
  12713. /** @hidden */
  12714. _defineLinearSpecularRefraction: string;
  12715. /** @hidden */
  12716. _defineOppositeZ: string;
  12717. /** @hidden */
  12718. _cubeSamplerName: string;
  12719. /** @hidden */
  12720. _2DSamplerName: string;
  12721. /** @hidden */
  12722. _vRefractionMicrosurfaceInfosName: string;
  12723. /** @hidden */
  12724. _vRefractionInfosName: string;
  12725. private _scene;
  12726. /**
  12727. * The properties below are set by the main PBR block prior to calling methods of this class.
  12728. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  12729. * It's less burden on the user side in the editor part.
  12730. */
  12731. /** @hidden */
  12732. viewConnectionPoint: NodeMaterialConnectionPoint;
  12733. /** @hidden */
  12734. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  12735. /**
  12736. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  12737. * Materials half opaque for instance using refraction could benefit from this control.
  12738. */
  12739. linkRefractionWithTransparency: boolean;
  12740. /**
  12741. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  12742. */
  12743. invertRefractionY: boolean;
  12744. /**
  12745. * Gets or sets the texture associated with the node
  12746. */
  12747. texture: Nullable<BaseTexture>;
  12748. /**
  12749. * Create a new RefractionBlock
  12750. * @param name defines the block name
  12751. */
  12752. constructor(name: string);
  12753. /**
  12754. * Gets the current class name
  12755. * @returns the class name
  12756. */
  12757. getClassName(): string;
  12758. /**
  12759. * Gets the intensity input component
  12760. */
  12761. get intensity(): NodeMaterialConnectionPoint;
  12762. /**
  12763. * Gets the tint at distance input component
  12764. */
  12765. get tintAtDistance(): NodeMaterialConnectionPoint;
  12766. /**
  12767. * Gets the view input component
  12768. */
  12769. get view(): NodeMaterialConnectionPoint;
  12770. /**
  12771. * Gets the refraction object output component
  12772. */
  12773. get refraction(): NodeMaterialConnectionPoint;
  12774. /**
  12775. * Returns true if the block has a texture
  12776. */
  12777. get hasTexture(): boolean;
  12778. protected _getTexture(): Nullable<BaseTexture>;
  12779. autoConfigure(material: NodeMaterial): void;
  12780. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12781. isReady(): boolean;
  12782. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  12783. /**
  12784. * Gets the main code of the block (fragment side)
  12785. * @param state current state of the node material building
  12786. * @returns the shader code
  12787. */
  12788. getCode(state: NodeMaterialBuildState): string;
  12789. protected _buildBlock(state: NodeMaterialBuildState): this;
  12790. protected _dumpPropertiesCode(): string;
  12791. serialize(): any;
  12792. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12793. }
  12794. }
  12795. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  12796. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12797. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12798. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12799. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12801. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12802. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12803. import { Nullable } from "babylonjs/types";
  12804. import { Scene } from "babylonjs/scene";
  12805. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  12806. /**
  12807. * Base block used as input for post process
  12808. */
  12809. export class CurrentScreenBlock extends NodeMaterialBlock {
  12810. private _samplerName;
  12811. private _linearDefineName;
  12812. private _gammaDefineName;
  12813. private _mainUVName;
  12814. private _tempTextureRead;
  12815. /**
  12816. * Gets or sets the texture associated with the node
  12817. */
  12818. texture: Nullable<BaseTexture>;
  12819. /**
  12820. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12821. */
  12822. convertToGammaSpace: boolean;
  12823. /**
  12824. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12825. */
  12826. convertToLinearSpace: boolean;
  12827. /**
  12828. * Create a new CurrentScreenBlock
  12829. * @param name defines the block name
  12830. */
  12831. constructor(name: string);
  12832. /**
  12833. * Gets the current class name
  12834. * @returns the class name
  12835. */
  12836. getClassName(): string;
  12837. /**
  12838. * Gets the uv input component
  12839. */
  12840. get uv(): NodeMaterialConnectionPoint;
  12841. /**
  12842. * Gets the rgba output component
  12843. */
  12844. get rgba(): NodeMaterialConnectionPoint;
  12845. /**
  12846. * Gets the rgb output component
  12847. */
  12848. get rgb(): NodeMaterialConnectionPoint;
  12849. /**
  12850. * Gets the r output component
  12851. */
  12852. get r(): NodeMaterialConnectionPoint;
  12853. /**
  12854. * Gets the g output component
  12855. */
  12856. get g(): NodeMaterialConnectionPoint;
  12857. /**
  12858. * Gets the b output component
  12859. */
  12860. get b(): NodeMaterialConnectionPoint;
  12861. /**
  12862. * Gets the a output component
  12863. */
  12864. get a(): NodeMaterialConnectionPoint;
  12865. /**
  12866. * Initialize the block and prepare the context for build
  12867. * @param state defines the state that will be used for the build
  12868. */
  12869. initialize(state: NodeMaterialBuildState): void;
  12870. get target(): NodeMaterialBlockTargets;
  12871. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12872. isReady(): boolean;
  12873. private _injectVertexCode;
  12874. private _writeTextureRead;
  12875. private _writeOutput;
  12876. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12877. serialize(): any;
  12878. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12879. }
  12880. }
  12881. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  12882. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12883. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12884. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12886. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12887. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12888. import { Nullable } from "babylonjs/types";
  12889. import { Scene } from "babylonjs/scene";
  12890. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  12891. /**
  12892. * Base block used for the particle texture
  12893. */
  12894. export class ParticleTextureBlock extends NodeMaterialBlock {
  12895. private _samplerName;
  12896. private _linearDefineName;
  12897. private _gammaDefineName;
  12898. private _tempTextureRead;
  12899. /**
  12900. * Gets or sets the texture associated with the node
  12901. */
  12902. texture: Nullable<BaseTexture>;
  12903. /**
  12904. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12905. */
  12906. convertToGammaSpace: boolean;
  12907. /**
  12908. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12909. */
  12910. convertToLinearSpace: boolean;
  12911. /**
  12912. * Create a new ParticleTextureBlock
  12913. * @param name defines the block name
  12914. */
  12915. constructor(name: string);
  12916. /**
  12917. * Gets the current class name
  12918. * @returns the class name
  12919. */
  12920. getClassName(): string;
  12921. /**
  12922. * Gets the uv input component
  12923. */
  12924. get uv(): NodeMaterialConnectionPoint;
  12925. /**
  12926. * Gets the rgba output component
  12927. */
  12928. get rgba(): NodeMaterialConnectionPoint;
  12929. /**
  12930. * Gets the rgb output component
  12931. */
  12932. get rgb(): NodeMaterialConnectionPoint;
  12933. /**
  12934. * Gets the r output component
  12935. */
  12936. get r(): NodeMaterialConnectionPoint;
  12937. /**
  12938. * Gets the g output component
  12939. */
  12940. get g(): NodeMaterialConnectionPoint;
  12941. /**
  12942. * Gets the b output component
  12943. */
  12944. get b(): NodeMaterialConnectionPoint;
  12945. /**
  12946. * Gets the a output component
  12947. */
  12948. get a(): NodeMaterialConnectionPoint;
  12949. /**
  12950. * Initialize the block and prepare the context for build
  12951. * @param state defines the state that will be used for the build
  12952. */
  12953. initialize(state: NodeMaterialBuildState): void;
  12954. autoConfigure(material: NodeMaterial): void;
  12955. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12956. isReady(): boolean;
  12957. private _writeOutput;
  12958. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12959. serialize(): any;
  12960. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12961. }
  12962. }
  12963. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  12964. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12965. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12966. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  12967. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  12968. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  12969. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  12970. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  12971. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  12972. import { Scene } from "babylonjs/scene";
  12973. /**
  12974. * Class used to store shared data between 2 NodeMaterialBuildState
  12975. */
  12976. export class NodeMaterialBuildStateSharedData {
  12977. /**
  12978. * Gets the list of emitted varyings
  12979. */
  12980. temps: string[];
  12981. /**
  12982. * Gets the list of emitted varyings
  12983. */
  12984. varyings: string[];
  12985. /**
  12986. * Gets the varying declaration string
  12987. */
  12988. varyingDeclaration: string;
  12989. /**
  12990. * Input blocks
  12991. */
  12992. inputBlocks: InputBlock[];
  12993. /**
  12994. * Input blocks
  12995. */
  12996. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  12997. /**
  12998. * Bindable blocks (Blocks that need to set data to the effect)
  12999. */
  13000. bindableBlocks: NodeMaterialBlock[];
  13001. /**
  13002. * List of blocks that can provide a compilation fallback
  13003. */
  13004. blocksWithFallbacks: NodeMaterialBlock[];
  13005. /**
  13006. * List of blocks that can provide a define update
  13007. */
  13008. blocksWithDefines: NodeMaterialBlock[];
  13009. /**
  13010. * List of blocks that can provide a repeatable content
  13011. */
  13012. repeatableContentBlocks: NodeMaterialBlock[];
  13013. /**
  13014. * List of blocks that can provide a dynamic list of uniforms
  13015. */
  13016. dynamicUniformBlocks: NodeMaterialBlock[];
  13017. /**
  13018. * List of blocks that can block the isReady function for the material
  13019. */
  13020. blockingBlocks: NodeMaterialBlock[];
  13021. /**
  13022. * Gets the list of animated inputs
  13023. */
  13024. animatedInputs: InputBlock[];
  13025. /**
  13026. * Build Id used to avoid multiple recompilations
  13027. */
  13028. buildId: number;
  13029. /** List of emitted variables */
  13030. variableNames: {
  13031. [key: string]: number;
  13032. };
  13033. /** List of emitted defines */
  13034. defineNames: {
  13035. [key: string]: number;
  13036. };
  13037. /** Should emit comments? */
  13038. emitComments: boolean;
  13039. /** Emit build activity */
  13040. verbose: boolean;
  13041. /** Gets or sets the hosting scene */
  13042. scene: Scene;
  13043. /**
  13044. * Gets the compilation hints emitted at compilation time
  13045. */
  13046. hints: {
  13047. needWorldViewMatrix: boolean;
  13048. needWorldViewProjectionMatrix: boolean;
  13049. needAlphaBlending: boolean;
  13050. needAlphaTesting: boolean;
  13051. };
  13052. /**
  13053. * List of compilation checks
  13054. */
  13055. checks: {
  13056. emitVertex: boolean;
  13057. emitFragment: boolean;
  13058. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13059. };
  13060. /**
  13061. * Is vertex program allowed to be empty?
  13062. */
  13063. allowEmptyVertexProgram: boolean;
  13064. /** Creates a new shared data */
  13065. constructor();
  13066. /**
  13067. * Emits console errors and exceptions if there is a failing check
  13068. */
  13069. emitErrors(): void;
  13070. }
  13071. }
  13072. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  13073. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  13074. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13075. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  13076. /**
  13077. * Class used to store node based material build state
  13078. */
  13079. export class NodeMaterialBuildState {
  13080. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13081. supportUniformBuffers: boolean;
  13082. /**
  13083. * Gets the list of emitted attributes
  13084. */
  13085. attributes: string[];
  13086. /**
  13087. * Gets the list of emitted uniforms
  13088. */
  13089. uniforms: string[];
  13090. /**
  13091. * Gets the list of emitted constants
  13092. */
  13093. constants: string[];
  13094. /**
  13095. * Gets the list of emitted samplers
  13096. */
  13097. samplers: string[];
  13098. /**
  13099. * Gets the list of emitted functions
  13100. */
  13101. functions: {
  13102. [key: string]: string;
  13103. };
  13104. /**
  13105. * Gets the list of emitted extensions
  13106. */
  13107. extensions: {
  13108. [key: string]: string;
  13109. };
  13110. /**
  13111. * Gets the target of the compilation state
  13112. */
  13113. target: NodeMaterialBlockTargets;
  13114. /**
  13115. * Gets the list of emitted counters
  13116. */
  13117. counters: {
  13118. [key: string]: number;
  13119. };
  13120. /**
  13121. * Shared data between multiple NodeMaterialBuildState instances
  13122. */
  13123. sharedData: NodeMaterialBuildStateSharedData;
  13124. /** @hidden */
  13125. _vertexState: NodeMaterialBuildState;
  13126. /** @hidden */
  13127. _attributeDeclaration: string;
  13128. /** @hidden */
  13129. _uniformDeclaration: string;
  13130. /** @hidden */
  13131. _constantDeclaration: string;
  13132. /** @hidden */
  13133. _samplerDeclaration: string;
  13134. /** @hidden */
  13135. _varyingTransfer: string;
  13136. /** @hidden */
  13137. _injectAtEnd: string;
  13138. private _repeatableContentAnchorIndex;
  13139. /** @hidden */
  13140. _builtCompilationString: string;
  13141. /**
  13142. * Gets the emitted compilation strings
  13143. */
  13144. compilationString: string;
  13145. /**
  13146. * Finalize the compilation strings
  13147. * @param state defines the current compilation state
  13148. */
  13149. finalize(state: NodeMaterialBuildState): void;
  13150. /** @hidden */
  13151. get _repeatableContentAnchor(): string;
  13152. /** @hidden */
  13153. _getFreeVariableName(prefix: string): string;
  13154. /** @hidden */
  13155. _getFreeDefineName(prefix: string): string;
  13156. /** @hidden */
  13157. _excludeVariableName(name: string): void;
  13158. /** @hidden */
  13159. _emit2DSampler(name: string): void;
  13160. /** @hidden */
  13161. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13162. /** @hidden */
  13163. _emitExtension(name: string, extension: string, define?: string): void;
  13164. /** @hidden */
  13165. _emitFunction(name: string, code: string, comments: string): void;
  13166. /** @hidden */
  13167. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13168. replaceStrings?: {
  13169. search: RegExp;
  13170. replace: string;
  13171. }[];
  13172. repeatKey?: string;
  13173. }): string;
  13174. /** @hidden */
  13175. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13176. repeatKey?: string;
  13177. removeAttributes?: boolean;
  13178. removeUniforms?: boolean;
  13179. removeVaryings?: boolean;
  13180. removeIfDef?: boolean;
  13181. replaceStrings?: {
  13182. search: RegExp;
  13183. replace: string;
  13184. }[];
  13185. }, storeKey?: string): void;
  13186. /** @hidden */
  13187. _registerTempVariable(name: string): boolean;
  13188. /** @hidden */
  13189. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13190. /** @hidden */
  13191. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13192. /** @hidden */
  13193. _emitFloat(value: number): string;
  13194. }
  13195. }
  13196. declare module "babylonjs/Misc/uniqueIdGenerator" {
  13197. /**
  13198. * Helper class used to generate session unique ID
  13199. */
  13200. export class UniqueIdGenerator {
  13201. private static _UniqueIdCounter;
  13202. /**
  13203. * Gets an unique (relatively to the current scene) Id
  13204. */
  13205. static get UniqueId(): number;
  13206. }
  13207. }
  13208. declare module "babylonjs/Materials/effectFallbacks" {
  13209. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  13210. import { Effect } from "babylonjs/Materials/effect";
  13211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13212. /**
  13213. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13214. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13215. */
  13216. export class EffectFallbacks implements IEffectFallbacks {
  13217. private _defines;
  13218. private _currentRank;
  13219. private _maxRank;
  13220. private _mesh;
  13221. /**
  13222. * Removes the fallback from the bound mesh.
  13223. */
  13224. unBindMesh(): void;
  13225. /**
  13226. * Adds a fallback on the specified property.
  13227. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13228. * @param define The name of the define in the shader
  13229. */
  13230. addFallback(rank: number, define: string): void;
  13231. /**
  13232. * Sets the mesh to use CPU skinning when needing to fallback.
  13233. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13234. * @param mesh The mesh to use the fallbacks.
  13235. */
  13236. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13237. /**
  13238. * Checks to see if more fallbacks are still availible.
  13239. */
  13240. get hasMoreFallbacks(): boolean;
  13241. /**
  13242. * Removes the defines that should be removed when falling back.
  13243. * @param currentDefines defines the current define statements for the shader.
  13244. * @param effect defines the current effect we try to compile
  13245. * @returns The resulting defines with defines of the current rank removed.
  13246. */
  13247. reduce(currentDefines: string, effect: Effect): string;
  13248. }
  13249. }
  13250. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  13251. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  13252. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13253. import { Nullable } from "babylonjs/types";
  13254. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13255. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13256. import { Effect } from "babylonjs/Materials/effect";
  13257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13258. import { Mesh } from "babylonjs/Meshes/mesh";
  13259. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13260. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13261. import { Scene } from "babylonjs/scene";
  13262. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  13263. /**
  13264. * Defines a block that can be used inside a node based material
  13265. */
  13266. export class NodeMaterialBlock {
  13267. private _buildId;
  13268. private _buildTarget;
  13269. private _target;
  13270. private _isFinalMerger;
  13271. private _isInput;
  13272. private _name;
  13273. protected _isUnique: boolean;
  13274. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13275. inputsAreExclusive: boolean;
  13276. /** @hidden */
  13277. _codeVariableName: string;
  13278. /** @hidden */
  13279. _inputs: NodeMaterialConnectionPoint[];
  13280. /** @hidden */
  13281. _outputs: NodeMaterialConnectionPoint[];
  13282. /** @hidden */
  13283. _preparationId: number;
  13284. /**
  13285. * Gets the name of the block
  13286. */
  13287. get name(): string;
  13288. /**
  13289. * Sets the name of the block. Will check if the name is valid.
  13290. */
  13291. set name(newName: string);
  13292. /**
  13293. * Gets or sets the unique id of the node
  13294. */
  13295. uniqueId: number;
  13296. /**
  13297. * Gets or sets the comments associated with this block
  13298. */
  13299. comments: string;
  13300. /**
  13301. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13302. */
  13303. get isUnique(): boolean;
  13304. /**
  13305. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13306. */
  13307. get isFinalMerger(): boolean;
  13308. /**
  13309. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13310. */
  13311. get isInput(): boolean;
  13312. /**
  13313. * Gets or sets the build Id
  13314. */
  13315. get buildId(): number;
  13316. set buildId(value: number);
  13317. /**
  13318. * Gets or sets the target of the block
  13319. */
  13320. get target(): NodeMaterialBlockTargets;
  13321. set target(value: NodeMaterialBlockTargets);
  13322. /**
  13323. * Gets the list of input points
  13324. */
  13325. get inputs(): NodeMaterialConnectionPoint[];
  13326. /** Gets the list of output points */
  13327. get outputs(): NodeMaterialConnectionPoint[];
  13328. /**
  13329. * Find an input by its name
  13330. * @param name defines the name of the input to look for
  13331. * @returns the input or null if not found
  13332. */
  13333. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13334. /**
  13335. * Find an output by its name
  13336. * @param name defines the name of the outputto look for
  13337. * @returns the output or null if not found
  13338. */
  13339. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13340. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13341. visibleInInspector: boolean;
  13342. /**
  13343. * Creates a new NodeMaterialBlock
  13344. * @param name defines the block name
  13345. * @param target defines the target of that block (Vertex by default)
  13346. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13347. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13348. */
  13349. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13350. /**
  13351. * Initialize the block and prepare the context for build
  13352. * @param state defines the state that will be used for the build
  13353. */
  13354. initialize(state: NodeMaterialBuildState): void;
  13355. /**
  13356. * Bind data to effect. Will only be called for blocks with isBindable === true
  13357. * @param effect defines the effect to bind data to
  13358. * @param nodeMaterial defines the hosting NodeMaterial
  13359. * @param mesh defines the mesh that will be rendered
  13360. * @param subMesh defines the submesh that will be rendered
  13361. */
  13362. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13363. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13364. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13365. protected _writeFloat(value: number): string;
  13366. /**
  13367. * Gets the current class name e.g. "NodeMaterialBlock"
  13368. * @returns the class name
  13369. */
  13370. getClassName(): string;
  13371. /**
  13372. * Register a new input. Must be called inside a block constructor
  13373. * @param name defines the connection point name
  13374. * @param type defines the connection point type
  13375. * @param isOptional defines a boolean indicating that this input can be omitted
  13376. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13377. * @param point an already created connection point. If not provided, create a new one
  13378. * @returns the current block
  13379. */
  13380. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13381. /**
  13382. * Register a new output. Must be called inside a block constructor
  13383. * @param name defines the connection point name
  13384. * @param type defines the connection point type
  13385. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13386. * @param point an already created connection point. If not provided, create a new one
  13387. * @returns the current block
  13388. */
  13389. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13390. /**
  13391. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13392. * @param forOutput defines an optional connection point to check compatibility with
  13393. * @returns the first available input or null
  13394. */
  13395. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13396. /**
  13397. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13398. * @param forBlock defines an optional block to check compatibility with
  13399. * @returns the first available input or null
  13400. */
  13401. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13402. /**
  13403. * Gets the sibling of the given output
  13404. * @param current defines the current output
  13405. * @returns the next output in the list or null
  13406. */
  13407. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13408. /**
  13409. * Connect current block with another block
  13410. * @param other defines the block to connect with
  13411. * @param options define the various options to help pick the right connections
  13412. * @returns the current block
  13413. */
  13414. connectTo(other: NodeMaterialBlock, options?: {
  13415. input?: string;
  13416. output?: string;
  13417. outputSwizzle?: string;
  13418. }): this | undefined;
  13419. protected _buildBlock(state: NodeMaterialBuildState): void;
  13420. /**
  13421. * Add uniforms, samplers and uniform buffers at compilation time
  13422. * @param state defines the state to update
  13423. * @param nodeMaterial defines the node material requesting the update
  13424. * @param defines defines the material defines to update
  13425. * @param uniformBuffers defines the list of uniform buffer names
  13426. */
  13427. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13428. /**
  13429. * Add potential fallbacks if shader compilation fails
  13430. * @param mesh defines the mesh to be rendered
  13431. * @param fallbacks defines the current prioritized list of fallbacks
  13432. */
  13433. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13434. /**
  13435. * Initialize defines for shader compilation
  13436. * @param mesh defines the mesh to be rendered
  13437. * @param nodeMaterial defines the node material requesting the update
  13438. * @param defines defines the material defines to update
  13439. * @param useInstances specifies that instances should be used
  13440. */
  13441. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13442. /**
  13443. * Update defines for shader compilation
  13444. * @param mesh defines the mesh to be rendered
  13445. * @param nodeMaterial defines the node material requesting the update
  13446. * @param defines defines the material defines to update
  13447. * @param useInstances specifies that instances should be used
  13448. * @param subMesh defines which submesh to render
  13449. */
  13450. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13451. /**
  13452. * Lets the block try to connect some inputs automatically
  13453. * @param material defines the hosting NodeMaterial
  13454. */
  13455. autoConfigure(material: NodeMaterial): void;
  13456. /**
  13457. * Function called when a block is declared as repeatable content generator
  13458. * @param vertexShaderState defines the current compilation state for the vertex shader
  13459. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13460. * @param mesh defines the mesh to be rendered
  13461. * @param defines defines the material defines to update
  13462. */
  13463. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13464. /**
  13465. * Checks if the block is ready
  13466. * @param mesh defines the mesh to be rendered
  13467. * @param nodeMaterial defines the node material requesting the update
  13468. * @param defines defines the material defines to update
  13469. * @param useInstances specifies that instances should be used
  13470. * @returns true if the block is ready
  13471. */
  13472. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13473. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13474. private _processBuild;
  13475. /**
  13476. * Validates the new name for the block node.
  13477. * @param newName the new name to be given to the node.
  13478. * @returns false if the name is a reserve word, else true.
  13479. */
  13480. validateBlockName(newName: string): boolean;
  13481. /**
  13482. * Compile the current node and generate the shader code
  13483. * @param state defines the current compilation state (uniforms, samplers, current string)
  13484. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13485. * @returns true if already built
  13486. */
  13487. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13488. protected _inputRename(name: string): string;
  13489. protected _outputRename(name: string): string;
  13490. protected _dumpPropertiesCode(): string;
  13491. /** @hidden */
  13492. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13493. /** @hidden */
  13494. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13495. /**
  13496. * Clone the current block to a new identical block
  13497. * @param scene defines the hosting scene
  13498. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13499. * @returns a copy of the current block
  13500. */
  13501. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13502. /**
  13503. * Serializes this block in a JSON representation
  13504. * @returns the serialized block object
  13505. */
  13506. serialize(): any;
  13507. /** @hidden */
  13508. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13509. private _deserializePortDisplayNamesAndExposedOnFrame;
  13510. /**
  13511. * Release resources
  13512. */
  13513. dispose(): void;
  13514. }
  13515. }
  13516. declare module "babylonjs/Materials/pushMaterial" {
  13517. import { Nullable } from "babylonjs/types";
  13518. import { Scene } from "babylonjs/scene";
  13519. import { Matrix } from "babylonjs/Maths/math.vector";
  13520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13521. import { Mesh } from "babylonjs/Meshes/mesh";
  13522. import { Material } from "babylonjs/Materials/material";
  13523. import { Effect } from "babylonjs/Materials/effect";
  13524. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13525. /**
  13526. * Base class of materials working in push mode in babylon JS
  13527. * @hidden
  13528. */
  13529. export class PushMaterial extends Material {
  13530. protected _activeEffect: Effect;
  13531. protected _normalMatrix: Matrix;
  13532. constructor(name: string, scene: Scene);
  13533. getEffect(): Effect;
  13534. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13535. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13536. /**
  13537. * Binds the given world matrix to the active effect
  13538. *
  13539. * @param world the matrix to bind
  13540. */
  13541. bindOnlyWorldMatrix(world: Matrix): void;
  13542. /**
  13543. * Binds the given normal matrix to the active effect
  13544. *
  13545. * @param normalMatrix the matrix to bind
  13546. */
  13547. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13548. bind(world: Matrix, mesh?: Mesh): void;
  13549. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13550. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13551. }
  13552. }
  13553. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  13554. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13555. /**
  13556. * Root class for all node material optimizers
  13557. */
  13558. export class NodeMaterialOptimizer {
  13559. /**
  13560. * Function used to optimize a NodeMaterial graph
  13561. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13562. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13563. */
  13564. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13565. }
  13566. }
  13567. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  13568. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13569. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13570. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13571. import { Scene } from "babylonjs/scene";
  13572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13573. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13574. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13575. /**
  13576. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13577. */
  13578. export class TransformBlock extends NodeMaterialBlock {
  13579. /**
  13580. * Defines the value to use to complement W value to transform it to a Vector4
  13581. */
  13582. complementW: number;
  13583. /**
  13584. * Defines the value to use to complement z value to transform it to a Vector4
  13585. */
  13586. complementZ: number;
  13587. /**
  13588. * Creates a new TransformBlock
  13589. * @param name defines the block name
  13590. */
  13591. constructor(name: string);
  13592. /**
  13593. * Gets the current class name
  13594. * @returns the class name
  13595. */
  13596. getClassName(): string;
  13597. /**
  13598. * Gets the vector input
  13599. */
  13600. get vector(): NodeMaterialConnectionPoint;
  13601. /**
  13602. * Gets the output component
  13603. */
  13604. get output(): NodeMaterialConnectionPoint;
  13605. /**
  13606. * Gets the xyz output component
  13607. */
  13608. get xyz(): NodeMaterialConnectionPoint;
  13609. /**
  13610. * Gets the matrix transform input
  13611. */
  13612. get transform(): NodeMaterialConnectionPoint;
  13613. protected _buildBlock(state: NodeMaterialBuildState): this;
  13614. /**
  13615. * Update defines for shader compilation
  13616. * @param mesh defines the mesh to be rendered
  13617. * @param nodeMaterial defines the node material requesting the update
  13618. * @param defines defines the material defines to update
  13619. * @param useInstances specifies that instances should be used
  13620. * @param subMesh defines which submesh to render
  13621. */
  13622. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13623. serialize(): any;
  13624. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13625. protected _dumpPropertiesCode(): string;
  13626. }
  13627. }
  13628. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  13629. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13630. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13631. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13632. /**
  13633. * Block used to output the vertex position
  13634. */
  13635. export class VertexOutputBlock extends NodeMaterialBlock {
  13636. /**
  13637. * Creates a new VertexOutputBlock
  13638. * @param name defines the block name
  13639. */
  13640. constructor(name: string);
  13641. /**
  13642. * Gets the current class name
  13643. * @returns the class name
  13644. */
  13645. getClassName(): string;
  13646. /**
  13647. * Gets the vector input component
  13648. */
  13649. get vector(): NodeMaterialConnectionPoint;
  13650. protected _buildBlock(state: NodeMaterialBuildState): this;
  13651. }
  13652. }
  13653. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  13654. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13655. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13656. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13657. /**
  13658. * Block used to output the final color
  13659. */
  13660. export class FragmentOutputBlock extends NodeMaterialBlock {
  13661. /**
  13662. * Create a new FragmentOutputBlock
  13663. * @param name defines the block name
  13664. */
  13665. constructor(name: string);
  13666. /**
  13667. * Gets the current class name
  13668. * @returns the class name
  13669. */
  13670. getClassName(): string;
  13671. /**
  13672. * Gets the rgba input component
  13673. */
  13674. get rgba(): NodeMaterialConnectionPoint;
  13675. /**
  13676. * Gets the rgb input component
  13677. */
  13678. get rgb(): NodeMaterialConnectionPoint;
  13679. /**
  13680. * Gets the a input component
  13681. */
  13682. get a(): NodeMaterialConnectionPoint;
  13683. protected _buildBlock(state: NodeMaterialBuildState): this;
  13684. }
  13685. }
  13686. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  13687. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13688. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13689. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13690. /**
  13691. * Block used for the particle ramp gradient section
  13692. */
  13693. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  13694. /**
  13695. * Create a new ParticleRampGradientBlock
  13696. * @param name defines the block name
  13697. */
  13698. constructor(name: string);
  13699. /**
  13700. * Gets the current class name
  13701. * @returns the class name
  13702. */
  13703. getClassName(): string;
  13704. /**
  13705. * Gets the color input component
  13706. */
  13707. get color(): NodeMaterialConnectionPoint;
  13708. /**
  13709. * Gets the rampColor output component
  13710. */
  13711. get rampColor(): NodeMaterialConnectionPoint;
  13712. /**
  13713. * Initialize the block and prepare the context for build
  13714. * @param state defines the state that will be used for the build
  13715. */
  13716. initialize(state: NodeMaterialBuildState): void;
  13717. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13718. }
  13719. }
  13720. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  13721. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13722. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13723. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13724. /**
  13725. * Block used for the particle blend multiply section
  13726. */
  13727. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  13728. /**
  13729. * Create a new ParticleBlendMultiplyBlock
  13730. * @param name defines the block name
  13731. */
  13732. constructor(name: string);
  13733. /**
  13734. * Gets the current class name
  13735. * @returns the class name
  13736. */
  13737. getClassName(): string;
  13738. /**
  13739. * Gets the color input component
  13740. */
  13741. get color(): NodeMaterialConnectionPoint;
  13742. /**
  13743. * Gets the alphaTexture input component
  13744. */
  13745. get alphaTexture(): NodeMaterialConnectionPoint;
  13746. /**
  13747. * Gets the alphaColor input component
  13748. */
  13749. get alphaColor(): NodeMaterialConnectionPoint;
  13750. /**
  13751. * Gets the blendColor output component
  13752. */
  13753. get blendColor(): NodeMaterialConnectionPoint;
  13754. /**
  13755. * Initialize the block and prepare the context for build
  13756. * @param state defines the state that will be used for the build
  13757. */
  13758. initialize(state: NodeMaterialBuildState): void;
  13759. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13760. }
  13761. }
  13762. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  13763. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13764. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13765. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13766. /**
  13767. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  13768. */
  13769. export class VectorMergerBlock extends NodeMaterialBlock {
  13770. /**
  13771. * Create a new VectorMergerBlock
  13772. * @param name defines the block name
  13773. */
  13774. constructor(name: string);
  13775. /**
  13776. * Gets the current class name
  13777. * @returns the class name
  13778. */
  13779. getClassName(): string;
  13780. /**
  13781. * Gets the xyz component (input)
  13782. */
  13783. get xyzIn(): NodeMaterialConnectionPoint;
  13784. /**
  13785. * Gets the xy component (input)
  13786. */
  13787. get xyIn(): NodeMaterialConnectionPoint;
  13788. /**
  13789. * Gets the x component (input)
  13790. */
  13791. get x(): NodeMaterialConnectionPoint;
  13792. /**
  13793. * Gets the y component (input)
  13794. */
  13795. get y(): NodeMaterialConnectionPoint;
  13796. /**
  13797. * Gets the z component (input)
  13798. */
  13799. get z(): NodeMaterialConnectionPoint;
  13800. /**
  13801. * Gets the w component (input)
  13802. */
  13803. get w(): NodeMaterialConnectionPoint;
  13804. /**
  13805. * Gets the xyzw component (output)
  13806. */
  13807. get xyzw(): NodeMaterialConnectionPoint;
  13808. /**
  13809. * Gets the xyz component (output)
  13810. */
  13811. get xyzOut(): NodeMaterialConnectionPoint;
  13812. /**
  13813. * Gets the xy component (output)
  13814. */
  13815. get xyOut(): NodeMaterialConnectionPoint;
  13816. /**
  13817. * Gets the xy component (output)
  13818. * @deprecated Please use xyOut instead.
  13819. */
  13820. get xy(): NodeMaterialConnectionPoint;
  13821. /**
  13822. * Gets the xyz component (output)
  13823. * @deprecated Please use xyzOut instead.
  13824. */
  13825. get xyz(): NodeMaterialConnectionPoint;
  13826. protected _buildBlock(state: NodeMaterialBuildState): this;
  13827. }
  13828. }
  13829. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  13830. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13831. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13832. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13833. import { Vector2 } from "babylonjs/Maths/math.vector";
  13834. import { Scene } from "babylonjs/scene";
  13835. /**
  13836. * Block used to remap a float from a range to a new one
  13837. */
  13838. export class RemapBlock extends NodeMaterialBlock {
  13839. /**
  13840. * Gets or sets the source range
  13841. */
  13842. sourceRange: Vector2;
  13843. /**
  13844. * Gets or sets the target range
  13845. */
  13846. targetRange: Vector2;
  13847. /**
  13848. * Creates a new RemapBlock
  13849. * @param name defines the block name
  13850. */
  13851. constructor(name: string);
  13852. /**
  13853. * Gets the current class name
  13854. * @returns the class name
  13855. */
  13856. getClassName(): string;
  13857. /**
  13858. * Gets the input component
  13859. */
  13860. get input(): NodeMaterialConnectionPoint;
  13861. /**
  13862. * Gets the source min input component
  13863. */
  13864. get sourceMin(): NodeMaterialConnectionPoint;
  13865. /**
  13866. * Gets the source max input component
  13867. */
  13868. get sourceMax(): NodeMaterialConnectionPoint;
  13869. /**
  13870. * Gets the target min input component
  13871. */
  13872. get targetMin(): NodeMaterialConnectionPoint;
  13873. /**
  13874. * Gets the target max input component
  13875. */
  13876. get targetMax(): NodeMaterialConnectionPoint;
  13877. /**
  13878. * Gets the output component
  13879. */
  13880. get output(): NodeMaterialConnectionPoint;
  13881. protected _buildBlock(state: NodeMaterialBuildState): this;
  13882. protected _dumpPropertiesCode(): string;
  13883. serialize(): any;
  13884. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13885. }
  13886. }
  13887. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  13888. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13889. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13890. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13891. /**
  13892. * Block used to multiply 2 values
  13893. */
  13894. export class MultiplyBlock extends NodeMaterialBlock {
  13895. /**
  13896. * Creates a new MultiplyBlock
  13897. * @param name defines the block name
  13898. */
  13899. constructor(name: string);
  13900. /**
  13901. * Gets the current class name
  13902. * @returns the class name
  13903. */
  13904. getClassName(): string;
  13905. /**
  13906. * Gets the left operand input component
  13907. */
  13908. get left(): NodeMaterialConnectionPoint;
  13909. /**
  13910. * Gets the right operand input component
  13911. */
  13912. get right(): NodeMaterialConnectionPoint;
  13913. /**
  13914. * Gets the output component
  13915. */
  13916. get output(): NodeMaterialConnectionPoint;
  13917. protected _buildBlock(state: NodeMaterialBuildState): this;
  13918. }
  13919. }
  13920. declare module "babylonjs/Misc/gradients" {
  13921. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13922. /** Interface used by value gradients (color, factor, ...) */
  13923. export interface IValueGradient {
  13924. /**
  13925. * Gets or sets the gradient value (between 0 and 1)
  13926. */
  13927. gradient: number;
  13928. }
  13929. /** Class used to store color4 gradient */
  13930. export class ColorGradient implements IValueGradient {
  13931. /**
  13932. * Gets or sets the gradient value (between 0 and 1)
  13933. */
  13934. gradient: number;
  13935. /**
  13936. * Gets or sets first associated color
  13937. */
  13938. color1: Color4;
  13939. /**
  13940. * Gets or sets second associated color
  13941. */
  13942. color2?: Color4 | undefined;
  13943. /**
  13944. * Creates a new color4 gradient
  13945. * @param gradient gets or sets the gradient value (between 0 and 1)
  13946. * @param color1 gets or sets first associated color
  13947. * @param color2 gets or sets first second color
  13948. */
  13949. constructor(
  13950. /**
  13951. * Gets or sets the gradient value (between 0 and 1)
  13952. */
  13953. gradient: number,
  13954. /**
  13955. * Gets or sets first associated color
  13956. */
  13957. color1: Color4,
  13958. /**
  13959. * Gets or sets second associated color
  13960. */
  13961. color2?: Color4 | undefined);
  13962. /**
  13963. * Will get a color picked randomly between color1 and color2.
  13964. * If color2 is undefined then color1 will be used
  13965. * @param result defines the target Color4 to store the result in
  13966. */
  13967. getColorToRef(result: Color4): void;
  13968. }
  13969. /** Class used to store color 3 gradient */
  13970. export class Color3Gradient implements IValueGradient {
  13971. /**
  13972. * Gets or sets the gradient value (between 0 and 1)
  13973. */
  13974. gradient: number;
  13975. /**
  13976. * Gets or sets the associated color
  13977. */
  13978. color: Color3;
  13979. /**
  13980. * Creates a new color3 gradient
  13981. * @param gradient gets or sets the gradient value (between 0 and 1)
  13982. * @param color gets or sets associated color
  13983. */
  13984. constructor(
  13985. /**
  13986. * Gets or sets the gradient value (between 0 and 1)
  13987. */
  13988. gradient: number,
  13989. /**
  13990. * Gets or sets the associated color
  13991. */
  13992. color: Color3);
  13993. }
  13994. /** Class used to store factor gradient */
  13995. export class FactorGradient implements IValueGradient {
  13996. /**
  13997. * Gets or sets the gradient value (between 0 and 1)
  13998. */
  13999. gradient: number;
  14000. /**
  14001. * Gets or sets first associated factor
  14002. */
  14003. factor1: number;
  14004. /**
  14005. * Gets or sets second associated factor
  14006. */
  14007. factor2?: number | undefined;
  14008. /**
  14009. * Creates a new factor gradient
  14010. * @param gradient gets or sets the gradient value (between 0 and 1)
  14011. * @param factor1 gets or sets first associated factor
  14012. * @param factor2 gets or sets second associated factor
  14013. */
  14014. constructor(
  14015. /**
  14016. * Gets or sets the gradient value (between 0 and 1)
  14017. */
  14018. gradient: number,
  14019. /**
  14020. * Gets or sets first associated factor
  14021. */
  14022. factor1: number,
  14023. /**
  14024. * Gets or sets second associated factor
  14025. */
  14026. factor2?: number | undefined);
  14027. /**
  14028. * Will get a number picked randomly between factor1 and factor2.
  14029. * If factor2 is undefined then factor1 will be used
  14030. * @returns the picked number
  14031. */
  14032. getFactor(): number;
  14033. }
  14034. /**
  14035. * Helper used to simplify some generic gradient tasks
  14036. */
  14037. export class GradientHelper {
  14038. /**
  14039. * Gets the current gradient from an array of IValueGradient
  14040. * @param ratio defines the current ratio to get
  14041. * @param gradients defines the array of IValueGradient
  14042. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14043. */
  14044. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14045. }
  14046. }
  14047. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  14048. import { Nullable } from "babylonjs/types";
  14049. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14050. import { Scene } from "babylonjs/scene";
  14051. module "babylonjs/Engines/thinEngine" {
  14052. interface ThinEngine {
  14053. /**
  14054. * Creates a raw texture
  14055. * @param data defines the data to store in the texture
  14056. * @param width defines the width of the texture
  14057. * @param height defines the height of the texture
  14058. * @param format defines the format of the data
  14059. * @param generateMipMaps defines if the engine should generate the mip levels
  14060. * @param invertY defines if data must be stored with Y axis inverted
  14061. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14062. * @param compression defines the compression used (null by default)
  14063. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14064. * @returns the raw texture inside an InternalTexture
  14065. */
  14066. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14067. /**
  14068. * Update a raw texture
  14069. * @param texture defines the texture to update
  14070. * @param data defines the data to store in the texture
  14071. * @param format defines the format of the data
  14072. * @param invertY defines if data must be stored with Y axis inverted
  14073. */
  14074. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14075. /**
  14076. * Update a raw texture
  14077. * @param texture defines the texture to update
  14078. * @param data defines the data to store in the texture
  14079. * @param format defines the format of the data
  14080. * @param invertY defines if data must be stored with Y axis inverted
  14081. * @param compression defines the compression used (null by default)
  14082. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14083. */
  14084. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14085. /**
  14086. * Creates a new raw cube texture
  14087. * @param data defines the array of data to use to create each face
  14088. * @param size defines the size of the textures
  14089. * @param format defines the format of the data
  14090. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14091. * @param generateMipMaps defines if the engine should generate the mip levels
  14092. * @param invertY defines if data must be stored with Y axis inverted
  14093. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14094. * @param compression defines the compression used (null by default)
  14095. * @returns the cube texture as an InternalTexture
  14096. */
  14097. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14098. /**
  14099. * Update a raw cube texture
  14100. * @param texture defines the texture to udpdate
  14101. * @param data defines the data to store
  14102. * @param format defines the data format
  14103. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14104. * @param invertY defines if data must be stored with Y axis inverted
  14105. */
  14106. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14107. /**
  14108. * Update a raw cube texture
  14109. * @param texture defines the texture to udpdate
  14110. * @param data defines the data to store
  14111. * @param format defines the data format
  14112. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14113. * @param invertY defines if data must be stored with Y axis inverted
  14114. * @param compression defines the compression used (null by default)
  14115. */
  14116. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14117. /**
  14118. * Update a raw cube texture
  14119. * @param texture defines the texture to udpdate
  14120. * @param data defines the data to store
  14121. * @param format defines the data format
  14122. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14123. * @param invertY defines if data must be stored with Y axis inverted
  14124. * @param compression defines the compression used (null by default)
  14125. * @param level defines which level of the texture to update
  14126. */
  14127. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14128. /**
  14129. * Creates a new raw cube texture from a specified url
  14130. * @param url defines the url where the data is located
  14131. * @param scene defines the current scene
  14132. * @param size defines the size of the textures
  14133. * @param format defines the format of the data
  14134. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14135. * @param noMipmap defines if the engine should avoid generating the mip levels
  14136. * @param callback defines a callback used to extract texture data from loaded data
  14137. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14138. * @param onLoad defines a callback called when texture is loaded
  14139. * @param onError defines a callback called if there is an error
  14140. * @returns the cube texture as an InternalTexture
  14141. */
  14142. 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;
  14143. /**
  14144. * Creates a new raw cube texture from a specified url
  14145. * @param url defines the url where the data is located
  14146. * @param scene defines the current scene
  14147. * @param size defines the size of the textures
  14148. * @param format defines the format of the data
  14149. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14150. * @param noMipmap defines if the engine should avoid generating the mip levels
  14151. * @param callback defines a callback used to extract texture data from loaded data
  14152. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14153. * @param onLoad defines a callback called when texture is loaded
  14154. * @param onError defines a callback called if there is an error
  14155. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14156. * @param invertY defines if data must be stored with Y axis inverted
  14157. * @returns the cube texture as an InternalTexture
  14158. */
  14159. 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;
  14160. /**
  14161. * Creates a new raw 3D texture
  14162. * @param data defines the data used to create the texture
  14163. * @param width defines the width of the texture
  14164. * @param height defines the height of the texture
  14165. * @param depth defines the depth of the texture
  14166. * @param format defines the format of the texture
  14167. * @param generateMipMaps defines if the engine must generate mip levels
  14168. * @param invertY defines if data must be stored with Y axis inverted
  14169. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14170. * @param compression defines the compressed used (can be null)
  14171. * @param textureType defines the compressed used (can be null)
  14172. * @returns a new raw 3D texture (stored in an InternalTexture)
  14173. */
  14174. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14175. /**
  14176. * Update a raw 3D texture
  14177. * @param texture defines the texture to update
  14178. * @param data defines the data to store
  14179. * @param format defines the data format
  14180. * @param invertY defines if data must be stored with Y axis inverted
  14181. */
  14182. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14183. /**
  14184. * Update a raw 3D texture
  14185. * @param texture defines the texture to update
  14186. * @param data defines the data to store
  14187. * @param format defines the data format
  14188. * @param invertY defines if data must be stored with Y axis inverted
  14189. * @param compression defines the used compression (can be null)
  14190. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14191. */
  14192. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14193. /**
  14194. * Creates a new raw 2D array texture
  14195. * @param data defines the data used to create the texture
  14196. * @param width defines the width of the texture
  14197. * @param height defines the height of the texture
  14198. * @param depth defines the number of layers of the texture
  14199. * @param format defines the format of the texture
  14200. * @param generateMipMaps defines if the engine must generate mip levels
  14201. * @param invertY defines if data must be stored with Y axis inverted
  14202. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14203. * @param compression defines the compressed used (can be null)
  14204. * @param textureType defines the compressed used (can be null)
  14205. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14206. */
  14207. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14208. /**
  14209. * Update a raw 2D array texture
  14210. * @param texture defines the texture to update
  14211. * @param data defines the data to store
  14212. * @param format defines the data format
  14213. * @param invertY defines if data must be stored with Y axis inverted
  14214. */
  14215. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14216. /**
  14217. * Update a raw 2D array texture
  14218. * @param texture defines the texture to update
  14219. * @param data defines the data to store
  14220. * @param format defines the data format
  14221. * @param invertY defines if data must be stored with Y axis inverted
  14222. * @param compression defines the used compression (can be null)
  14223. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14224. */
  14225. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14226. }
  14227. }
  14228. }
  14229. declare module "babylonjs/Materials/Textures/rawTexture" {
  14230. import { Texture } from "babylonjs/Materials/Textures/texture";
  14231. import "babylonjs/Engines/Extensions/engine.rawTexture";
  14232. import { Nullable } from "babylonjs/types";
  14233. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  14234. import { Scene } from "babylonjs/scene";
  14235. /**
  14236. * Raw texture can help creating a texture directly from an array of data.
  14237. * This can be super useful if you either get the data from an uncompressed source or
  14238. * if you wish to create your texture pixel by pixel.
  14239. */
  14240. export class RawTexture extends Texture {
  14241. /**
  14242. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14243. */
  14244. format: number;
  14245. /**
  14246. * Instantiates a new RawTexture.
  14247. * Raw texture can help creating a texture directly from an array of data.
  14248. * This can be super useful if you either get the data from an uncompressed source or
  14249. * if you wish to create your texture pixel by pixel.
  14250. * @param data define the array of data to use to create the texture
  14251. * @param width define the width of the texture
  14252. * @param height define the height of the texture
  14253. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14254. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14255. * @param generateMipMaps define whether mip maps should be generated or not
  14256. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14257. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14258. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14259. */
  14260. constructor(data: ArrayBufferView, width: number, height: number,
  14261. /**
  14262. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14263. */
  14264. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14265. /**
  14266. * Updates the texture underlying data.
  14267. * @param data Define the new data of the texture
  14268. */
  14269. update(data: ArrayBufferView): void;
  14270. /**
  14271. * Creates a luminance texture from some data.
  14272. * @param data Define the texture data
  14273. * @param width Define the width of the texture
  14274. * @param height Define the height of the texture
  14275. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14276. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14277. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14278. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14279. * @returns the luminance texture
  14280. */
  14281. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14282. /**
  14283. * Creates a luminance alpha texture from some data.
  14284. * @param data Define the texture data
  14285. * @param width Define the width of the texture
  14286. * @param height Define the height of the texture
  14287. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14288. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14289. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14290. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14291. * @returns the luminance alpha texture
  14292. */
  14293. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14294. /**
  14295. * Creates an alpha texture from some data.
  14296. * @param data Define the texture data
  14297. * @param width Define the width of the texture
  14298. * @param height Define the height of the texture
  14299. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14300. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14301. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14302. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14303. * @returns the alpha texture
  14304. */
  14305. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14306. /**
  14307. * Creates a RGB texture from some data.
  14308. * @param data Define the texture data
  14309. * @param width Define the width of the texture
  14310. * @param height Define the height of the texture
  14311. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14312. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14313. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14314. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14315. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14316. * @returns the RGB alpha texture
  14317. */
  14318. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14319. /**
  14320. * Creates a RGBA texture from some data.
  14321. * @param data Define the texture data
  14322. * @param width Define the width of the texture
  14323. * @param height Define the height of the texture
  14324. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14325. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14326. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14327. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14328. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14329. * @returns the RGBA texture
  14330. */
  14331. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14332. /**
  14333. * Creates a R texture from some data.
  14334. * @param data Define the texture data
  14335. * @param width Define the width of the texture
  14336. * @param height Define the height of the texture
  14337. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14338. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14339. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14340. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14341. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14342. * @returns the R texture
  14343. */
  14344. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14345. }
  14346. }
  14347. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  14348. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  14349. import { IndicesArray, DataArray } from "babylonjs/types";
  14350. module "babylonjs/Engines/thinEngine" {
  14351. interface ThinEngine {
  14352. /**
  14353. * Update a dynamic index buffer
  14354. * @param indexBuffer defines the target index buffer
  14355. * @param indices defines the data to update
  14356. * @param offset defines the offset in the target index buffer where update should start
  14357. */
  14358. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14359. /**
  14360. * Updates a dynamic vertex buffer.
  14361. * @param vertexBuffer the vertex buffer to update
  14362. * @param data the data used to update the vertex buffer
  14363. * @param byteOffset the byte offset of the data
  14364. * @param byteLength the byte length of the data
  14365. */
  14366. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14367. }
  14368. }
  14369. }
  14370. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14371. import { Scene } from "babylonjs/scene";
  14372. import { ISceneComponent } from "babylonjs/sceneComponent";
  14373. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14374. module "babylonjs/abstractScene" {
  14375. interface AbstractScene {
  14376. /**
  14377. * The list of procedural textures added to the scene
  14378. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14379. */
  14380. proceduralTextures: Array<ProceduralTexture>;
  14381. }
  14382. }
  14383. /**
  14384. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14385. * in a given scene.
  14386. */
  14387. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14388. /**
  14389. * The component name helpfull to identify the component in the list of scene components.
  14390. */
  14391. readonly name: string;
  14392. /**
  14393. * The scene the component belongs to.
  14394. */
  14395. scene: Scene;
  14396. /**
  14397. * Creates a new instance of the component for the given scene
  14398. * @param scene Defines the scene to register the component in
  14399. */
  14400. constructor(scene: Scene);
  14401. /**
  14402. * Registers the component in a given scene
  14403. */
  14404. register(): void;
  14405. /**
  14406. * Rebuilds the elements related to this component in case of
  14407. * context lost for instance.
  14408. */
  14409. rebuild(): void;
  14410. /**
  14411. * Disposes the component and the associated ressources.
  14412. */
  14413. dispose(): void;
  14414. private _beforeClear;
  14415. }
  14416. }
  14417. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  14418. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14419. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  14420. module "babylonjs/Engines/thinEngine" {
  14421. interface ThinEngine {
  14422. /**
  14423. * Creates a new render target cube texture
  14424. * @param size defines the size of the texture
  14425. * @param options defines the options used to create the texture
  14426. * @returns a new render target cube texture stored in an InternalTexture
  14427. */
  14428. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14429. }
  14430. }
  14431. }
  14432. declare module "babylonjs/Shaders/procedural.vertex" {
  14433. /** @hidden */
  14434. export var proceduralVertexShader: {
  14435. name: string;
  14436. shader: string;
  14437. };
  14438. }
  14439. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14440. import { Observable } from "babylonjs/Misc/observable";
  14441. import { Nullable } from "babylonjs/types";
  14442. import { Scene } from "babylonjs/scene";
  14443. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  14444. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  14445. import { Effect } from "babylonjs/Materials/effect";
  14446. import { Texture } from "babylonjs/Materials/Textures/texture";
  14447. import "babylonjs/Engines/Extensions/engine.renderTarget";
  14448. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  14449. import "babylonjs/Shaders/procedural.vertex";
  14450. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  14451. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  14452. /**
  14453. * 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.
  14454. * This is the base class of any Procedural texture and contains most of the shareable code.
  14455. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14456. */
  14457. export class ProceduralTexture extends Texture {
  14458. /**
  14459. * Define if the texture is enabled or not (disabled texture will not render)
  14460. */
  14461. isEnabled: boolean;
  14462. /**
  14463. * Define if the texture must be cleared before rendering (default is true)
  14464. */
  14465. autoClear: boolean;
  14466. /**
  14467. * Callback called when the texture is generated
  14468. */
  14469. onGenerated: () => void;
  14470. /**
  14471. * Event raised when the texture is generated
  14472. */
  14473. onGeneratedObservable: Observable<ProceduralTexture>;
  14474. /**
  14475. * Event raised before the texture is generated
  14476. */
  14477. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14478. /**
  14479. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14480. */
  14481. nodeMaterialSource: Nullable<NodeMaterial>;
  14482. /** @hidden */
  14483. _generateMipMaps: boolean;
  14484. /** @hidden **/
  14485. _effect: Effect;
  14486. /** @hidden */
  14487. _textures: {
  14488. [key: string]: Texture;
  14489. };
  14490. /** @hidden */
  14491. protected _fallbackTexture: Nullable<Texture>;
  14492. private _size;
  14493. private _currentRefreshId;
  14494. private _frameId;
  14495. private _refreshRate;
  14496. private _vertexBuffers;
  14497. private _indexBuffer;
  14498. private _uniforms;
  14499. private _samplers;
  14500. private _fragment;
  14501. private _floats;
  14502. private _ints;
  14503. private _floatsArrays;
  14504. private _colors3;
  14505. private _colors4;
  14506. private _vectors2;
  14507. private _vectors3;
  14508. private _matrices;
  14509. private _fallbackTextureUsed;
  14510. private _fullEngine;
  14511. private _cachedDefines;
  14512. private _contentUpdateId;
  14513. private _contentData;
  14514. /**
  14515. * Instantiates a new procedural texture.
  14516. * 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.
  14517. * This is the base class of any Procedural texture and contains most of the shareable code.
  14518. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14519. * @param name Define the name of the texture
  14520. * @param size Define the size of the texture to create
  14521. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14522. * @param scene Define the scene the texture belongs to
  14523. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14524. * @param generateMipMaps Define if the texture should creates mip maps or not
  14525. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14526. * @param textureType The FBO internal texture type
  14527. */
  14528. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14529. /**
  14530. * The effect that is created when initializing the post process.
  14531. * @returns The created effect corresponding the the postprocess.
  14532. */
  14533. getEffect(): Effect;
  14534. /**
  14535. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14536. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14537. */
  14538. getContent(): Nullable<ArrayBufferView>;
  14539. private _createIndexBuffer;
  14540. /** @hidden */
  14541. _rebuild(): void;
  14542. /**
  14543. * Resets the texture in order to recreate its associated resources.
  14544. * This can be called in case of context loss
  14545. */
  14546. reset(): void;
  14547. protected _getDefines(): string;
  14548. /**
  14549. * Is the texture ready to be used ? (rendered at least once)
  14550. * @returns true if ready, otherwise, false.
  14551. */
  14552. isReady(): boolean;
  14553. /**
  14554. * Resets the refresh counter of the texture and start bak from scratch.
  14555. * Could be useful to regenerate the texture if it is setup to render only once.
  14556. */
  14557. resetRefreshCounter(): void;
  14558. /**
  14559. * Set the fragment shader to use in order to render the texture.
  14560. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14561. */
  14562. setFragment(fragment: any): void;
  14563. /**
  14564. * Define the refresh rate of the texture or the rendering frequency.
  14565. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14566. */
  14567. get refreshRate(): number;
  14568. set refreshRate(value: number);
  14569. /** @hidden */
  14570. _shouldRender(): boolean;
  14571. /**
  14572. * Get the size the texture is rendering at.
  14573. * @returns the size (on cube texture it is always squared)
  14574. */
  14575. getRenderSize(): RenderTargetTextureSize;
  14576. /**
  14577. * Resize the texture to new value.
  14578. * @param size Define the new size the texture should have
  14579. * @param generateMipMaps Define whether the new texture should create mip maps
  14580. */
  14581. resize(size: number, generateMipMaps: boolean): void;
  14582. private _checkUniform;
  14583. /**
  14584. * Set a texture in the shader program used to render.
  14585. * @param name Define the name of the uniform samplers as defined in the shader
  14586. * @param texture Define the texture to bind to this sampler
  14587. * @return the texture itself allowing "fluent" like uniform updates
  14588. */
  14589. setTexture(name: string, texture: Texture): ProceduralTexture;
  14590. /**
  14591. * Set a float in the shader.
  14592. * @param name Define the name of the uniform as defined in the shader
  14593. * @param value Define the value to give to the uniform
  14594. * @return the texture itself allowing "fluent" like uniform updates
  14595. */
  14596. setFloat(name: string, value: number): ProceduralTexture;
  14597. /**
  14598. * Set a int in the shader.
  14599. * @param name Define the name of the uniform as defined in the shader
  14600. * @param value Define the value to give to the uniform
  14601. * @return the texture itself allowing "fluent" like uniform updates
  14602. */
  14603. setInt(name: string, value: number): ProceduralTexture;
  14604. /**
  14605. * Set an array of floats in the shader.
  14606. * @param name Define the name of the uniform as defined in the shader
  14607. * @param value Define the value to give to the uniform
  14608. * @return the texture itself allowing "fluent" like uniform updates
  14609. */
  14610. setFloats(name: string, value: number[]): ProceduralTexture;
  14611. /**
  14612. * Set a vec3 in the shader from a Color3.
  14613. * @param name Define the name of the uniform as defined in the shader
  14614. * @param value Define the value to give to the uniform
  14615. * @return the texture itself allowing "fluent" like uniform updates
  14616. */
  14617. setColor3(name: string, value: Color3): ProceduralTexture;
  14618. /**
  14619. * Set a vec4 in the shader from a Color4.
  14620. * @param name Define the name of the uniform as defined in the shader
  14621. * @param value Define the value to give to the uniform
  14622. * @return the texture itself allowing "fluent" like uniform updates
  14623. */
  14624. setColor4(name: string, value: Color4): ProceduralTexture;
  14625. /**
  14626. * Set a vec2 in the shader from a Vector2.
  14627. * @param name Define the name of the uniform as defined in the shader
  14628. * @param value Define the value to give to the uniform
  14629. * @return the texture itself allowing "fluent" like uniform updates
  14630. */
  14631. setVector2(name: string, value: Vector2): ProceduralTexture;
  14632. /**
  14633. * Set a vec3 in the shader from a Vector3.
  14634. * @param name Define the name of the uniform as defined in the shader
  14635. * @param value Define the value to give to the uniform
  14636. * @return the texture itself allowing "fluent" like uniform updates
  14637. */
  14638. setVector3(name: string, value: Vector3): ProceduralTexture;
  14639. /**
  14640. * Set a mat4 in the shader from a MAtrix.
  14641. * @param name Define the name of the uniform as defined in the shader
  14642. * @param value Define the value to give to the uniform
  14643. * @return the texture itself allowing "fluent" like uniform updates
  14644. */
  14645. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14646. /**
  14647. * Render the texture to its associated render target.
  14648. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14649. */
  14650. render(useCameraPostProcess?: boolean): void;
  14651. /**
  14652. * Clone the texture.
  14653. * @returns the cloned texture
  14654. */
  14655. clone(): ProceduralTexture;
  14656. /**
  14657. * Dispose the texture and release its asoociated resources.
  14658. */
  14659. dispose(): void;
  14660. }
  14661. }
  14662. declare module "babylonjs/Particles/baseParticleSystem" {
  14663. import { Nullable } from "babylonjs/types";
  14664. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14665. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14666. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14667. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  14668. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14669. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14670. import { Color4 } from "babylonjs/Maths/math.color";
  14671. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  14672. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  14673. import { Animation } from "babylonjs/Animations/animation";
  14674. import { Scene } from "babylonjs/scene";
  14675. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14676. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14677. /**
  14678. * This represents the base class for particle system in Babylon.
  14679. * 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.
  14680. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14681. * @example https://doc.babylonjs.com/babylon101/particles
  14682. */
  14683. export class BaseParticleSystem {
  14684. /**
  14685. * Source color is added to the destination color without alpha affecting the result
  14686. */
  14687. static BLENDMODE_ONEONE: number;
  14688. /**
  14689. * Blend current color and particle color using particle’s alpha
  14690. */
  14691. static BLENDMODE_STANDARD: number;
  14692. /**
  14693. * Add current color and particle color multiplied by particle’s alpha
  14694. */
  14695. static BLENDMODE_ADD: number;
  14696. /**
  14697. * Multiply current color with particle color
  14698. */
  14699. static BLENDMODE_MULTIPLY: number;
  14700. /**
  14701. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14702. */
  14703. static BLENDMODE_MULTIPLYADD: number;
  14704. /**
  14705. * List of animations used by the particle system.
  14706. */
  14707. animations: Animation[];
  14708. /**
  14709. * Gets or sets the unique id of the particle system
  14710. */
  14711. uniqueId: number;
  14712. /**
  14713. * The id of the Particle system.
  14714. */
  14715. id: string;
  14716. /**
  14717. * The friendly name of the Particle system.
  14718. */
  14719. name: string;
  14720. /**
  14721. * Snippet ID if the particle system was created from the snippet server
  14722. */
  14723. snippetId: string;
  14724. /**
  14725. * The rendering group used by the Particle system to chose when to render.
  14726. */
  14727. renderingGroupId: number;
  14728. /**
  14729. * The emitter represents the Mesh or position we are attaching the particle system to.
  14730. */
  14731. emitter: Nullable<AbstractMesh | Vector3>;
  14732. /**
  14733. * The maximum number of particles to emit per frame
  14734. */
  14735. emitRate: number;
  14736. /**
  14737. * If you want to launch only a few particles at once, that can be done, as well.
  14738. */
  14739. manualEmitCount: number;
  14740. /**
  14741. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14742. */
  14743. updateSpeed: number;
  14744. /**
  14745. * The amount of time the particle system is running (depends of the overall update speed).
  14746. */
  14747. targetStopDuration: number;
  14748. /**
  14749. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14750. */
  14751. disposeOnStop: boolean;
  14752. /**
  14753. * Minimum power of emitting particles.
  14754. */
  14755. minEmitPower: number;
  14756. /**
  14757. * Maximum power of emitting particles.
  14758. */
  14759. maxEmitPower: number;
  14760. /**
  14761. * Minimum life time of emitting particles.
  14762. */
  14763. minLifeTime: number;
  14764. /**
  14765. * Maximum life time of emitting particles.
  14766. */
  14767. maxLifeTime: number;
  14768. /**
  14769. * Minimum Size of emitting particles.
  14770. */
  14771. minSize: number;
  14772. /**
  14773. * Maximum Size of emitting particles.
  14774. */
  14775. maxSize: number;
  14776. /**
  14777. * Minimum scale of emitting particles on X axis.
  14778. */
  14779. minScaleX: number;
  14780. /**
  14781. * Maximum scale of emitting particles on X axis.
  14782. */
  14783. maxScaleX: number;
  14784. /**
  14785. * Minimum scale of emitting particles on Y axis.
  14786. */
  14787. minScaleY: number;
  14788. /**
  14789. * Maximum scale of emitting particles on Y axis.
  14790. */
  14791. maxScaleY: number;
  14792. /**
  14793. * Gets or sets the minimal initial rotation in radians.
  14794. */
  14795. minInitialRotation: number;
  14796. /**
  14797. * Gets or sets the maximal initial rotation in radians.
  14798. */
  14799. maxInitialRotation: number;
  14800. /**
  14801. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14802. */
  14803. minAngularSpeed: number;
  14804. /**
  14805. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14806. */
  14807. maxAngularSpeed: number;
  14808. /**
  14809. * The texture used to render each particle. (this can be a spritesheet)
  14810. */
  14811. particleTexture: Nullable<BaseTexture>;
  14812. /**
  14813. * The layer mask we are rendering the particles through.
  14814. */
  14815. layerMask: number;
  14816. /**
  14817. * This can help using your own shader to render the particle system.
  14818. * The according effect will be created
  14819. */
  14820. customShader: any;
  14821. /**
  14822. * By default particle system starts as soon as they are created. This prevents the
  14823. * automatic start to happen and let you decide when to start emitting particles.
  14824. */
  14825. preventAutoStart: boolean;
  14826. private _noiseTexture;
  14827. /**
  14828. * Gets or sets a texture used to add random noise to particle positions
  14829. */
  14830. get noiseTexture(): Nullable<ProceduralTexture>;
  14831. set noiseTexture(value: Nullable<ProceduralTexture>);
  14832. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14833. noiseStrength: Vector3;
  14834. /**
  14835. * Callback triggered when the particle animation is ending.
  14836. */
  14837. onAnimationEnd: Nullable<() => void>;
  14838. /**
  14839. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14840. */
  14841. blendMode: number;
  14842. /**
  14843. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14844. * to override the particles.
  14845. */
  14846. forceDepthWrite: boolean;
  14847. /** 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 */
  14848. preWarmCycles: number;
  14849. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14850. preWarmStepOffset: number;
  14851. /**
  14852. * 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)
  14853. */
  14854. spriteCellChangeSpeed: number;
  14855. /**
  14856. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14857. */
  14858. startSpriteCellID: number;
  14859. /**
  14860. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14861. */
  14862. endSpriteCellID: number;
  14863. /**
  14864. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14865. */
  14866. spriteCellWidth: number;
  14867. /**
  14868. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14869. */
  14870. spriteCellHeight: number;
  14871. /**
  14872. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14873. */
  14874. spriteRandomStartCell: boolean;
  14875. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14876. translationPivot: Vector2;
  14877. /** @hidden */
  14878. protected _isAnimationSheetEnabled: boolean;
  14879. /**
  14880. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14881. */
  14882. beginAnimationOnStart: boolean;
  14883. /**
  14884. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14885. */
  14886. beginAnimationFrom: number;
  14887. /**
  14888. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14889. */
  14890. beginAnimationTo: number;
  14891. /**
  14892. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14893. */
  14894. beginAnimationLoop: boolean;
  14895. /**
  14896. * Gets or sets a world offset applied to all particles
  14897. */
  14898. worldOffset: Vector3;
  14899. /**
  14900. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14901. */
  14902. get isAnimationSheetEnabled(): boolean;
  14903. set isAnimationSheetEnabled(value: boolean);
  14904. /**
  14905. * Get hosting scene
  14906. * @returns the scene
  14907. */
  14908. getScene(): Nullable<Scene>;
  14909. /**
  14910. * You can use gravity if you want to give an orientation to your particles.
  14911. */
  14912. gravity: Vector3;
  14913. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14914. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14915. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14916. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14917. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14918. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14919. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14920. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14921. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14922. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14923. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14924. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14925. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14926. /**
  14927. * Defines the delay in milliseconds before starting the system (0 by default)
  14928. */
  14929. startDelay: number;
  14930. /**
  14931. * Gets the current list of drag gradients.
  14932. * You must use addDragGradient and removeDragGradient to udpate this list
  14933. * @returns the list of drag gradients
  14934. */
  14935. getDragGradients(): Nullable<Array<FactorGradient>>;
  14936. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14937. limitVelocityDamping: number;
  14938. /**
  14939. * Gets the current list of limit velocity gradients.
  14940. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14941. * @returns the list of limit velocity gradients
  14942. */
  14943. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14944. /**
  14945. * Gets the current list of color gradients.
  14946. * You must use addColorGradient and removeColorGradient to udpate this list
  14947. * @returns the list of color gradients
  14948. */
  14949. getColorGradients(): Nullable<Array<ColorGradient>>;
  14950. /**
  14951. * Gets the current list of size gradients.
  14952. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14953. * @returns the list of size gradients
  14954. */
  14955. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14956. /**
  14957. * Gets the current list of color remap gradients.
  14958. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14959. * @returns the list of color remap gradients
  14960. */
  14961. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14962. /**
  14963. * Gets the current list of alpha remap gradients.
  14964. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14965. * @returns the list of alpha remap gradients
  14966. */
  14967. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14968. /**
  14969. * Gets the current list of life time gradients.
  14970. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14971. * @returns the list of life time gradients
  14972. */
  14973. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14974. /**
  14975. * Gets the current list of angular speed gradients.
  14976. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14977. * @returns the list of angular speed gradients
  14978. */
  14979. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14980. /**
  14981. * Gets the current list of velocity gradients.
  14982. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14983. * @returns the list of velocity gradients
  14984. */
  14985. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14986. /**
  14987. * Gets the current list of start size gradients.
  14988. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14989. * @returns the list of start size gradients
  14990. */
  14991. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14992. /**
  14993. * Gets the current list of emit rate gradients.
  14994. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14995. * @returns the list of emit rate gradients
  14996. */
  14997. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14998. /**
  14999. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15000. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15001. */
  15002. get direction1(): Vector3;
  15003. set direction1(value: Vector3);
  15004. /**
  15005. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15006. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15007. */
  15008. get direction2(): Vector3;
  15009. set direction2(value: Vector3);
  15010. /**
  15011. * 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.
  15012. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15013. */
  15014. get minEmitBox(): Vector3;
  15015. set minEmitBox(value: Vector3);
  15016. /**
  15017. * 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.
  15018. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15019. */
  15020. get maxEmitBox(): Vector3;
  15021. set maxEmitBox(value: Vector3);
  15022. /**
  15023. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15024. */
  15025. color1: Color4;
  15026. /**
  15027. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15028. */
  15029. color2: Color4;
  15030. /**
  15031. * Color the particle will have at the end of its lifetime
  15032. */
  15033. colorDead: Color4;
  15034. /**
  15035. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15036. */
  15037. textureMask: Color4;
  15038. /**
  15039. * The particle emitter type defines the emitter used by the particle system.
  15040. * It can be for example box, sphere, or cone...
  15041. */
  15042. particleEmitterType: IParticleEmitterType;
  15043. /** @hidden */
  15044. _isSubEmitter: boolean;
  15045. /**
  15046. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15047. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15048. */
  15049. billboardMode: number;
  15050. protected _isBillboardBased: boolean;
  15051. /**
  15052. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15053. */
  15054. get isBillboardBased(): boolean;
  15055. set isBillboardBased(value: boolean);
  15056. /**
  15057. * The scene the particle system belongs to.
  15058. */
  15059. protected _scene: Nullable<Scene>;
  15060. /**
  15061. * The engine the particle system belongs to.
  15062. */
  15063. protected _engine: ThinEngine;
  15064. /**
  15065. * Local cache of defines for image processing.
  15066. */
  15067. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15068. /**
  15069. * Default configuration related to image processing available in the standard Material.
  15070. */
  15071. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15072. /**
  15073. * Gets the image processing configuration used either in this material.
  15074. */
  15075. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15076. /**
  15077. * Sets the Default image processing configuration used either in the this material.
  15078. *
  15079. * If sets to null, the scene one is in use.
  15080. */
  15081. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15082. /**
  15083. * Attaches a new image processing configuration to the Standard Material.
  15084. * @param configuration
  15085. */
  15086. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15087. /** @hidden */
  15088. protected _reset(): void;
  15089. /** @hidden */
  15090. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15091. /**
  15092. * Instantiates a particle system.
  15093. * 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.
  15094. * @param name The name of the particle system
  15095. */
  15096. constructor(name: string);
  15097. /**
  15098. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15099. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15100. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15101. * @returns the emitter
  15102. */
  15103. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15104. /**
  15105. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15106. * @param radius The radius of the hemisphere to emit from
  15107. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15108. * @returns the emitter
  15109. */
  15110. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15111. /**
  15112. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15113. * @param radius The radius of the sphere to emit from
  15114. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15115. * @returns the emitter
  15116. */
  15117. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15118. /**
  15119. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15120. * @param radius The radius of the sphere to emit from
  15121. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15122. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15123. * @returns the emitter
  15124. */
  15125. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15126. /**
  15127. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15128. * @param radius The radius of the emission cylinder
  15129. * @param height The height of the emission cylinder
  15130. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15131. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15132. * @returns the emitter
  15133. */
  15134. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15135. /**
  15136. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15137. * @param radius The radius of the cylinder to emit from
  15138. * @param height The height of the emission cylinder
  15139. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15140. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15141. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15142. * @returns the emitter
  15143. */
  15144. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15145. /**
  15146. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15147. * @param radius The radius of the cone to emit from
  15148. * @param angle The base angle of the cone
  15149. * @returns the emitter
  15150. */
  15151. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15152. /**
  15153. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15154. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15155. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15156. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15157. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15158. * @returns the emitter
  15159. */
  15160. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15161. }
  15162. }
  15163. declare module "babylonjs/Particles/subEmitter" {
  15164. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15165. import { Scene } from "babylonjs/scene";
  15166. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15167. /**
  15168. * Type of sub emitter
  15169. */
  15170. export enum SubEmitterType {
  15171. /**
  15172. * Attached to the particle over it's lifetime
  15173. */
  15174. ATTACHED = 0,
  15175. /**
  15176. * Created when the particle dies
  15177. */
  15178. END = 1
  15179. }
  15180. /**
  15181. * Sub emitter class used to emit particles from an existing particle
  15182. */
  15183. export class SubEmitter {
  15184. /**
  15185. * the particle system to be used by the sub emitter
  15186. */
  15187. particleSystem: ParticleSystem;
  15188. /**
  15189. * Type of the submitter (Default: END)
  15190. */
  15191. type: SubEmitterType;
  15192. /**
  15193. * 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)
  15194. * Note: This only is supported when using an emitter of type Mesh
  15195. */
  15196. inheritDirection: boolean;
  15197. /**
  15198. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15199. */
  15200. inheritedVelocityAmount: number;
  15201. /**
  15202. * Creates a sub emitter
  15203. * @param particleSystem the particle system to be used by the sub emitter
  15204. */
  15205. constructor(
  15206. /**
  15207. * the particle system to be used by the sub emitter
  15208. */
  15209. particleSystem: ParticleSystem);
  15210. /**
  15211. * Clones the sub emitter
  15212. * @returns the cloned sub emitter
  15213. */
  15214. clone(): SubEmitter;
  15215. /**
  15216. * Serialize current object to a JSON object
  15217. * @returns the serialized object
  15218. */
  15219. serialize(): any;
  15220. /** @hidden */
  15221. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15222. /**
  15223. * Creates a new SubEmitter from a serialized JSON version
  15224. * @param serializationObject defines the JSON object to read from
  15225. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15226. * @param rootUrl defines the rootUrl for data loading
  15227. * @returns a new SubEmitter
  15228. */
  15229. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15230. /** Release associated resources */
  15231. dispose(): void;
  15232. }
  15233. }
  15234. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15235. /** @hidden */
  15236. export var clipPlaneFragmentDeclaration: {
  15237. name: string;
  15238. shader: string;
  15239. };
  15240. }
  15241. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15242. /** @hidden */
  15243. export var imageProcessingDeclaration: {
  15244. name: string;
  15245. shader: string;
  15246. };
  15247. }
  15248. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15249. /** @hidden */
  15250. export var imageProcessingFunctions: {
  15251. name: string;
  15252. shader: string;
  15253. };
  15254. }
  15255. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15256. /** @hidden */
  15257. export var clipPlaneFragment: {
  15258. name: string;
  15259. shader: string;
  15260. };
  15261. }
  15262. declare module "babylonjs/Shaders/particles.fragment" {
  15263. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15264. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15265. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15266. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15267. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15268. /** @hidden */
  15269. export var particlesPixelShader: {
  15270. name: string;
  15271. shader: string;
  15272. };
  15273. }
  15274. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15275. /** @hidden */
  15276. export var clipPlaneVertexDeclaration: {
  15277. name: string;
  15278. shader: string;
  15279. };
  15280. }
  15281. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15282. /** @hidden */
  15283. export var clipPlaneVertex: {
  15284. name: string;
  15285. shader: string;
  15286. };
  15287. }
  15288. declare module "babylonjs/Shaders/particles.vertex" {
  15289. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15290. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15291. /** @hidden */
  15292. export var particlesVertexShader: {
  15293. name: string;
  15294. shader: string;
  15295. };
  15296. }
  15297. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  15298. import { Nullable } from "babylonjs/types";
  15299. import { Plane } from "babylonjs/Maths/math";
  15300. /**
  15301. * Interface used to define entities containing multiple clip planes
  15302. */
  15303. export interface IClipPlanesHolder {
  15304. /**
  15305. * Gets or sets the active clipplane 1
  15306. */
  15307. clipPlane: Nullable<Plane>;
  15308. /**
  15309. * Gets or sets the active clipplane 2
  15310. */
  15311. clipPlane2: Nullable<Plane>;
  15312. /**
  15313. * Gets or sets the active clipplane 3
  15314. */
  15315. clipPlane3: Nullable<Plane>;
  15316. /**
  15317. * Gets or sets the active clipplane 4
  15318. */
  15319. clipPlane4: Nullable<Plane>;
  15320. /**
  15321. * Gets or sets the active clipplane 5
  15322. */
  15323. clipPlane5: Nullable<Plane>;
  15324. /**
  15325. * Gets or sets the active clipplane 6
  15326. */
  15327. clipPlane6: Nullable<Plane>;
  15328. }
  15329. }
  15330. declare module "babylonjs/Materials/thinMaterialHelper" {
  15331. import { Effect } from "babylonjs/Materials/effect";
  15332. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  15333. /**
  15334. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  15335. *
  15336. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  15337. *
  15338. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  15339. */
  15340. export class ThinMaterialHelper {
  15341. /**
  15342. * Binds the clip plane information from the holder to the effect.
  15343. * @param effect The effect we are binding the data to
  15344. * @param holder The entity containing the clip plane information
  15345. */
  15346. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  15347. }
  15348. }
  15349. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  15350. module "babylonjs/Engines/thinEngine" {
  15351. interface ThinEngine {
  15352. /**
  15353. * Sets alpha constants used by some alpha blending modes
  15354. * @param r defines the red component
  15355. * @param g defines the green component
  15356. * @param b defines the blue component
  15357. * @param a defines the alpha component
  15358. */
  15359. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  15360. /**
  15361. * Sets the current alpha mode
  15362. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  15363. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  15364. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15365. */
  15366. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  15367. /**
  15368. * Gets the current alpha mode
  15369. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15370. * @returns the current alpha mode
  15371. */
  15372. getAlphaMode(): number;
  15373. /**
  15374. * Sets the current alpha equation
  15375. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  15376. */
  15377. setAlphaEquation(equation: number): void;
  15378. /**
  15379. * Gets the current alpha equation.
  15380. * @returns the current alpha equation
  15381. */
  15382. getAlphaEquation(): number;
  15383. }
  15384. }
  15385. }
  15386. declare module "babylonjs/Particles/particleSystem" {
  15387. import { Nullable } from "babylonjs/types";
  15388. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  15389. import { Observable } from "babylonjs/Misc/observable";
  15390. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15391. import { Effect } from "babylonjs/Materials/effect";
  15392. import { IDisposable } from "babylonjs/scene";
  15393. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15394. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15395. import { Particle } from "babylonjs/Particles/particle";
  15396. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15397. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15398. import "babylonjs/Shaders/particles.fragment";
  15399. import "babylonjs/Shaders/particles.vertex";
  15400. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  15401. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15402. import "babylonjs/Engines/Extensions/engine.alpha";
  15403. import { Scene } from "babylonjs/scene";
  15404. /**
  15405. * This represents a particle system in Babylon.
  15406. * 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.
  15407. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15408. * @example https://doc.babylonjs.com/babylon101/particles
  15409. */
  15410. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15411. /**
  15412. * Billboard mode will only apply to Y axis
  15413. */
  15414. static readonly BILLBOARDMODE_Y: number;
  15415. /**
  15416. * Billboard mode will apply to all axes
  15417. */
  15418. static readonly BILLBOARDMODE_ALL: number;
  15419. /**
  15420. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15421. */
  15422. static readonly BILLBOARDMODE_STRETCHED: number;
  15423. /**
  15424. * This function can be defined to provide custom update for active particles.
  15425. * This function will be called instead of regular update (age, position, color, etc.).
  15426. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15427. */
  15428. updateFunction: (particles: Particle[]) => void;
  15429. private _emitterWorldMatrix;
  15430. /**
  15431. * This function can be defined to specify initial direction for every new particle.
  15432. * It by default use the emitterType defined function
  15433. */
  15434. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15435. /**
  15436. * This function can be defined to specify initial position for every new particle.
  15437. * It by default use the emitterType defined function
  15438. */
  15439. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15440. /**
  15441. * @hidden
  15442. */
  15443. _inheritedVelocityOffset: Vector3;
  15444. /**
  15445. * An event triggered when the system is disposed
  15446. */
  15447. onDisposeObservable: Observable<IParticleSystem>;
  15448. /**
  15449. * An event triggered when the system is stopped
  15450. */
  15451. onStoppedObservable: Observable<IParticleSystem>;
  15452. private _onDisposeObserver;
  15453. /**
  15454. * Sets a callback that will be triggered when the system is disposed
  15455. */
  15456. set onDispose(callback: () => void);
  15457. private _particles;
  15458. private _epsilon;
  15459. private _capacity;
  15460. private _stockParticles;
  15461. private _newPartsExcess;
  15462. private _vertexData;
  15463. private _vertexBuffer;
  15464. private _vertexBuffers;
  15465. private _spriteBuffer;
  15466. private _indexBuffer;
  15467. private _effect;
  15468. private _customEffect;
  15469. private _cachedDefines;
  15470. private _scaledColorStep;
  15471. private _colorDiff;
  15472. private _scaledDirection;
  15473. private _scaledGravity;
  15474. private _currentRenderId;
  15475. private _alive;
  15476. private _useInstancing;
  15477. private _vertexArrayObject;
  15478. private _started;
  15479. private _stopped;
  15480. private _actualFrame;
  15481. private _scaledUpdateSpeed;
  15482. private _vertexBufferSize;
  15483. /** @hidden */
  15484. _currentEmitRateGradient: Nullable<FactorGradient>;
  15485. /** @hidden */
  15486. _currentEmitRate1: number;
  15487. /** @hidden */
  15488. _currentEmitRate2: number;
  15489. /** @hidden */
  15490. _currentStartSizeGradient: Nullable<FactorGradient>;
  15491. /** @hidden */
  15492. _currentStartSize1: number;
  15493. /** @hidden */
  15494. _currentStartSize2: number;
  15495. private readonly _rawTextureWidth;
  15496. private _rampGradientsTexture;
  15497. private _useRampGradients;
  15498. /** Gets or sets a matrix to use to compute projection */
  15499. defaultProjectionMatrix: Matrix;
  15500. /** Gets or sets a matrix to use to compute view */
  15501. defaultViewMatrix: Matrix;
  15502. /** Gets or sets a boolean indicating that ramp gradients must be used
  15503. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15504. */
  15505. get useRampGradients(): boolean;
  15506. set useRampGradients(value: boolean);
  15507. /**
  15508. * 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.
  15509. * 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: [])
  15510. */
  15511. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15512. private _subEmitters;
  15513. /**
  15514. * @hidden
  15515. * If the particle systems emitter should be disposed when the particle system is disposed
  15516. */
  15517. _disposeEmitterOnDispose: boolean;
  15518. /**
  15519. * The current active Sub-systems, this property is used by the root particle system only.
  15520. */
  15521. activeSubSystems: Array<ParticleSystem>;
  15522. /**
  15523. * Specifies if the particles are updated in emitter local space or world space
  15524. */
  15525. isLocal: boolean;
  15526. private _rootParticleSystem;
  15527. /**
  15528. * Gets the current list of active particles
  15529. */
  15530. get particles(): Particle[];
  15531. /**
  15532. * Gets the number of particles active at the same time.
  15533. * @returns The number of active particles.
  15534. */
  15535. getActiveCount(): number;
  15536. /**
  15537. * Returns the string "ParticleSystem"
  15538. * @returns a string containing the class name
  15539. */
  15540. getClassName(): string;
  15541. /**
  15542. * Gets a boolean indicating that the system is stopping
  15543. * @returns true if the system is currently stopping
  15544. */
  15545. isStopping(): boolean;
  15546. /**
  15547. * Gets the custom effect used to render the particles
  15548. * @param blendMode Blend mode for which the effect should be retrieved
  15549. * @returns The effect
  15550. */
  15551. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15552. /**
  15553. * Sets the custom effect used to render the particles
  15554. * @param effect The effect to set
  15555. * @param blendMode Blend mode for which the effect should be set
  15556. */
  15557. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15558. /** @hidden */
  15559. private _onBeforeDrawParticlesObservable;
  15560. /**
  15561. * Observable that will be called just before the particles are drawn
  15562. */
  15563. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15564. /**
  15565. * Gets the name of the particle vertex shader
  15566. */
  15567. get vertexShaderName(): string;
  15568. /**
  15569. * Instantiates a particle system.
  15570. * 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.
  15571. * @param name The name of the particle system
  15572. * @param capacity The max number of particles alive at the same time
  15573. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15574. * @param customEffect a custom effect used to change the way particles are rendered by default
  15575. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15576. * @param epsilon Offset used to render the particles
  15577. */
  15578. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15579. private _addFactorGradient;
  15580. private _removeFactorGradient;
  15581. /**
  15582. * Adds a new life time gradient
  15583. * @param gradient defines the gradient to use (between 0 and 1)
  15584. * @param factor defines the life time factor to affect to the specified gradient
  15585. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15586. * @returns the current particle system
  15587. */
  15588. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15589. /**
  15590. * Remove a specific life time gradient
  15591. * @param gradient defines the gradient to remove
  15592. * @returns the current particle system
  15593. */
  15594. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15595. /**
  15596. * Adds a new size gradient
  15597. * @param gradient defines the gradient to use (between 0 and 1)
  15598. * @param factor defines the size factor to affect to the specified gradient
  15599. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15600. * @returns the current particle system
  15601. */
  15602. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15603. /**
  15604. * Remove a specific size gradient
  15605. * @param gradient defines the gradient to remove
  15606. * @returns the current particle system
  15607. */
  15608. removeSizeGradient(gradient: number): IParticleSystem;
  15609. /**
  15610. * Adds a new color remap gradient
  15611. * @param gradient defines the gradient to use (between 0 and 1)
  15612. * @param min defines the color remap minimal range
  15613. * @param max defines the color remap maximal range
  15614. * @returns the current particle system
  15615. */
  15616. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15617. /**
  15618. * Remove a specific color remap gradient
  15619. * @param gradient defines the gradient to remove
  15620. * @returns the current particle system
  15621. */
  15622. removeColorRemapGradient(gradient: number): IParticleSystem;
  15623. /**
  15624. * Adds a new alpha remap gradient
  15625. * @param gradient defines the gradient to use (between 0 and 1)
  15626. * @param min defines the alpha remap minimal range
  15627. * @param max defines the alpha remap maximal range
  15628. * @returns the current particle system
  15629. */
  15630. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15631. /**
  15632. * Remove a specific alpha remap gradient
  15633. * @param gradient defines the gradient to remove
  15634. * @returns the current particle system
  15635. */
  15636. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15637. /**
  15638. * Adds a new angular speed gradient
  15639. * @param gradient defines the gradient to use (between 0 and 1)
  15640. * @param factor defines the angular speed to affect to the specified gradient
  15641. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15642. * @returns the current particle system
  15643. */
  15644. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15645. /**
  15646. * Remove a specific angular speed gradient
  15647. * @param gradient defines the gradient to remove
  15648. * @returns the current particle system
  15649. */
  15650. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15651. /**
  15652. * Adds a new velocity gradient
  15653. * @param gradient defines the gradient to use (between 0 and 1)
  15654. * @param factor defines the velocity to affect to the specified gradient
  15655. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15656. * @returns the current particle system
  15657. */
  15658. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15659. /**
  15660. * Remove a specific velocity gradient
  15661. * @param gradient defines the gradient to remove
  15662. * @returns the current particle system
  15663. */
  15664. removeVelocityGradient(gradient: number): IParticleSystem;
  15665. /**
  15666. * Adds a new limit velocity gradient
  15667. * @param gradient defines the gradient to use (between 0 and 1)
  15668. * @param factor defines the limit velocity value to affect to the specified gradient
  15669. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15670. * @returns the current particle system
  15671. */
  15672. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15673. /**
  15674. * Remove a specific limit velocity gradient
  15675. * @param gradient defines the gradient to remove
  15676. * @returns the current particle system
  15677. */
  15678. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15679. /**
  15680. * Adds a new drag gradient
  15681. * @param gradient defines the gradient to use (between 0 and 1)
  15682. * @param factor defines the drag value to affect to the specified gradient
  15683. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15684. * @returns the current particle system
  15685. */
  15686. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15687. /**
  15688. * Remove a specific drag gradient
  15689. * @param gradient defines the gradient to remove
  15690. * @returns the current particle system
  15691. */
  15692. removeDragGradient(gradient: number): IParticleSystem;
  15693. /**
  15694. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15695. * @param gradient defines the gradient to use (between 0 and 1)
  15696. * @param factor defines the emit rate value to affect to the specified gradient
  15697. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15698. * @returns the current particle system
  15699. */
  15700. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15701. /**
  15702. * Remove a specific emit rate gradient
  15703. * @param gradient defines the gradient to remove
  15704. * @returns the current particle system
  15705. */
  15706. removeEmitRateGradient(gradient: number): IParticleSystem;
  15707. /**
  15708. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15709. * @param gradient defines the gradient to use (between 0 and 1)
  15710. * @param factor defines the start size value to affect to the specified gradient
  15711. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15712. * @returns the current particle system
  15713. */
  15714. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15715. /**
  15716. * Remove a specific start size gradient
  15717. * @param gradient defines the gradient to remove
  15718. * @returns the current particle system
  15719. */
  15720. removeStartSizeGradient(gradient: number): IParticleSystem;
  15721. private _createRampGradientTexture;
  15722. /**
  15723. * Gets the current list of ramp gradients.
  15724. * You must use addRampGradient and removeRampGradient to udpate this list
  15725. * @returns the list of ramp gradients
  15726. */
  15727. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15728. /** Force the system to rebuild all gradients that need to be resync */
  15729. forceRefreshGradients(): void;
  15730. private _syncRampGradientTexture;
  15731. /**
  15732. * Adds a new ramp gradient used to remap particle colors
  15733. * @param gradient defines the gradient to use (between 0 and 1)
  15734. * @param color defines the color to affect to the specified gradient
  15735. * @returns the current particle system
  15736. */
  15737. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15738. /**
  15739. * Remove a specific ramp gradient
  15740. * @param gradient defines the gradient to remove
  15741. * @returns the current particle system
  15742. */
  15743. removeRampGradient(gradient: number): ParticleSystem;
  15744. /**
  15745. * Adds a new color gradient
  15746. * @param gradient defines the gradient to use (between 0 and 1)
  15747. * @param color1 defines the color to affect to the specified gradient
  15748. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15749. * @returns this particle system
  15750. */
  15751. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15752. /**
  15753. * Remove a specific color gradient
  15754. * @param gradient defines the gradient to remove
  15755. * @returns this particle system
  15756. */
  15757. removeColorGradient(gradient: number): IParticleSystem;
  15758. private _fetchR;
  15759. protected _reset(): void;
  15760. private _resetEffect;
  15761. private _createVertexBuffers;
  15762. private _createIndexBuffer;
  15763. /**
  15764. * Gets the maximum number of particles active at the same time.
  15765. * @returns The max number of active particles.
  15766. */
  15767. getCapacity(): number;
  15768. /**
  15769. * Gets whether there are still active particles in the system.
  15770. * @returns True if it is alive, otherwise false.
  15771. */
  15772. isAlive(): boolean;
  15773. /**
  15774. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15775. * @returns True if it has been started, otherwise false.
  15776. */
  15777. isStarted(): boolean;
  15778. private _prepareSubEmitterInternalArray;
  15779. /**
  15780. * Starts the particle system and begins to emit
  15781. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15782. */
  15783. start(delay?: number): void;
  15784. /**
  15785. * Stops the particle system.
  15786. * @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.
  15787. */
  15788. stop(stopSubEmitters?: boolean): void;
  15789. /**
  15790. * Remove all active particles
  15791. */
  15792. reset(): void;
  15793. /**
  15794. * @hidden (for internal use only)
  15795. */
  15796. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15797. /**
  15798. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15799. * Its lifetime will start back at 0.
  15800. */
  15801. recycleParticle: (particle: Particle) => void;
  15802. private _stopSubEmitters;
  15803. private _createParticle;
  15804. private _removeFromRoot;
  15805. private _emitFromParticle;
  15806. private _update;
  15807. /** @hidden */
  15808. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15809. /** @hidden */
  15810. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15811. /**
  15812. * Fill the defines array according to the current settings of the particle system
  15813. * @param defines Array to be updated
  15814. * @param blendMode blend mode to take into account when updating the array
  15815. */
  15816. fillDefines(defines: Array<string>, blendMode: number): void;
  15817. /**
  15818. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  15819. * @param uniforms Uniforms array to fill
  15820. * @param attributes Attributes array to fill
  15821. * @param samplers Samplers array to fill
  15822. */
  15823. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  15824. /** @hidden */
  15825. private _getEffect;
  15826. /**
  15827. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15828. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15829. */
  15830. animate(preWarmOnly?: boolean): void;
  15831. private _appendParticleVertices;
  15832. /**
  15833. * Rebuilds the particle system.
  15834. */
  15835. rebuild(): void;
  15836. /**
  15837. * Is this system ready to be used/rendered
  15838. * @return true if the system is ready
  15839. */
  15840. isReady(): boolean;
  15841. private _render;
  15842. /**
  15843. * Renders the particle system in its current state.
  15844. * @returns the current number of particles
  15845. */
  15846. render(): number;
  15847. /**
  15848. * Disposes the particle system and free the associated resources
  15849. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15850. */
  15851. dispose(disposeTexture?: boolean): void;
  15852. /**
  15853. * Clones the particle system.
  15854. * @param name The name of the cloned object
  15855. * @param newEmitter The new emitter to use
  15856. * @returns the cloned particle system
  15857. */
  15858. clone(name: string, newEmitter: any): ParticleSystem;
  15859. /**
  15860. * Serializes the particle system to a JSON object
  15861. * @param serializeTexture defines if the texture must be serialized as well
  15862. * @returns the JSON object
  15863. */
  15864. serialize(serializeTexture?: boolean): any;
  15865. /** @hidden */
  15866. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  15867. /** @hidden */
  15868. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  15869. /**
  15870. * Parses a JSON object to create a particle system.
  15871. * @param parsedParticleSystem The JSON object to parse
  15872. * @param sceneOrEngine The scene or the engine to create the particle system in
  15873. * @param rootUrl The root url to use to load external dependencies like texture
  15874. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15875. * @returns the Parsed particle system
  15876. */
  15877. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15878. }
  15879. }
  15880. declare module "babylonjs/Particles/particle" {
  15881. import { Nullable } from "babylonjs/types";
  15882. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  15883. import { Color4 } from "babylonjs/Maths/math.color";
  15884. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15885. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15886. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  15887. /**
  15888. * A particle represents one of the element emitted by a particle system.
  15889. * This is mainly define by its coordinates, direction, velocity and age.
  15890. */
  15891. export class Particle {
  15892. /**
  15893. * The particle system the particle belongs to.
  15894. */
  15895. particleSystem: ParticleSystem;
  15896. private static _Count;
  15897. /**
  15898. * Unique ID of the particle
  15899. */
  15900. id: number;
  15901. /**
  15902. * The world position of the particle in the scene.
  15903. */
  15904. position: Vector3;
  15905. /**
  15906. * The world direction of the particle in the scene.
  15907. */
  15908. direction: Vector3;
  15909. /**
  15910. * The color of the particle.
  15911. */
  15912. color: Color4;
  15913. /**
  15914. * The color change of the particle per step.
  15915. */
  15916. colorStep: Color4;
  15917. /**
  15918. * Defines how long will the life of the particle be.
  15919. */
  15920. lifeTime: number;
  15921. /**
  15922. * The current age of the particle.
  15923. */
  15924. age: number;
  15925. /**
  15926. * The current size of the particle.
  15927. */
  15928. size: number;
  15929. /**
  15930. * The current scale of the particle.
  15931. */
  15932. scale: Vector2;
  15933. /**
  15934. * The current angle of the particle.
  15935. */
  15936. angle: number;
  15937. /**
  15938. * Defines how fast is the angle changing.
  15939. */
  15940. angularSpeed: number;
  15941. /**
  15942. * Defines the cell index used by the particle to be rendered from a sprite.
  15943. */
  15944. cellIndex: number;
  15945. /**
  15946. * The information required to support color remapping
  15947. */
  15948. remapData: Vector4;
  15949. /** @hidden */
  15950. _randomCellOffset?: number;
  15951. /** @hidden */
  15952. _initialDirection: Nullable<Vector3>;
  15953. /** @hidden */
  15954. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15955. /** @hidden */
  15956. _initialStartSpriteCellID: number;
  15957. /** @hidden */
  15958. _initialEndSpriteCellID: number;
  15959. /** @hidden */
  15960. _currentColorGradient: Nullable<ColorGradient>;
  15961. /** @hidden */
  15962. _currentColor1: Color4;
  15963. /** @hidden */
  15964. _currentColor2: Color4;
  15965. /** @hidden */
  15966. _currentSizeGradient: Nullable<FactorGradient>;
  15967. /** @hidden */
  15968. _currentSize1: number;
  15969. /** @hidden */
  15970. _currentSize2: number;
  15971. /** @hidden */
  15972. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15973. /** @hidden */
  15974. _currentAngularSpeed1: number;
  15975. /** @hidden */
  15976. _currentAngularSpeed2: number;
  15977. /** @hidden */
  15978. _currentVelocityGradient: Nullable<FactorGradient>;
  15979. /** @hidden */
  15980. _currentVelocity1: number;
  15981. /** @hidden */
  15982. _currentVelocity2: number;
  15983. /** @hidden */
  15984. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15985. /** @hidden */
  15986. _currentLimitVelocity1: number;
  15987. /** @hidden */
  15988. _currentLimitVelocity2: number;
  15989. /** @hidden */
  15990. _currentDragGradient: Nullable<FactorGradient>;
  15991. /** @hidden */
  15992. _currentDrag1: number;
  15993. /** @hidden */
  15994. _currentDrag2: number;
  15995. /** @hidden */
  15996. _randomNoiseCoordinates1: Vector3;
  15997. /** @hidden */
  15998. _randomNoiseCoordinates2: Vector3;
  15999. /** @hidden */
  16000. _localPosition?: Vector3;
  16001. /**
  16002. * Creates a new instance Particle
  16003. * @param particleSystem the particle system the particle belongs to
  16004. */
  16005. constructor(
  16006. /**
  16007. * The particle system the particle belongs to.
  16008. */
  16009. particleSystem: ParticleSystem);
  16010. private updateCellInfoFromSystem;
  16011. /**
  16012. * Defines how the sprite cell index is updated for the particle
  16013. */
  16014. updateCellIndex(): void;
  16015. /** @hidden */
  16016. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16017. /** @hidden */
  16018. _inheritParticleInfoToSubEmitters(): void;
  16019. /** @hidden */
  16020. _reset(): void;
  16021. /**
  16022. * Copy the properties of particle to another one.
  16023. * @param other the particle to copy the information to.
  16024. */
  16025. copyTo(other: Particle): void;
  16026. }
  16027. }
  16028. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  16029. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16030. import { Effect } from "babylonjs/Materials/effect";
  16031. import { Particle } from "babylonjs/Particles/particle";
  16032. import { Nullable } from "babylonjs/types";
  16033. import { Scene } from "babylonjs/scene";
  16034. /**
  16035. * Particle emitter represents a volume emitting particles.
  16036. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16037. */
  16038. export interface IParticleEmitterType {
  16039. /**
  16040. * Called by the particle System when the direction is computed for the created particle.
  16041. * @param worldMatrix is the world matrix of the particle system
  16042. * @param directionToUpdate is the direction vector to update with the result
  16043. * @param particle is the particle we are computed the direction for
  16044. * @param isLocal defines if the direction should be set in local space
  16045. */
  16046. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16047. /**
  16048. * Called by the particle System when the position is computed for the created particle.
  16049. * @param worldMatrix is the world matrix of the particle system
  16050. * @param positionToUpdate is the position vector to update with the result
  16051. * @param particle is the particle we are computed the position for
  16052. * @param isLocal defines if the position should be set in local space
  16053. */
  16054. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16055. /**
  16056. * Clones the current emitter and returns a copy of it
  16057. * @returns the new emitter
  16058. */
  16059. clone(): IParticleEmitterType;
  16060. /**
  16061. * Called by the GPUParticleSystem to setup the update shader
  16062. * @param effect defines the update shader
  16063. */
  16064. applyToShader(effect: Effect): void;
  16065. /**
  16066. * Returns a string to use to update the GPU particles update shader
  16067. * @returns the effect defines string
  16068. */
  16069. getEffectDefines(): string;
  16070. /**
  16071. * Returns a string representing the class name
  16072. * @returns a string containing the class name
  16073. */
  16074. getClassName(): string;
  16075. /**
  16076. * Serializes the particle system to a JSON object.
  16077. * @returns the JSON object
  16078. */
  16079. serialize(): any;
  16080. /**
  16081. * Parse properties from a JSON object
  16082. * @param serializationObject defines the JSON object
  16083. * @param scene defines the hosting scene
  16084. */
  16085. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16086. }
  16087. }
  16088. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  16089. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16090. import { Effect } from "babylonjs/Materials/effect";
  16091. import { Particle } from "babylonjs/Particles/particle";
  16092. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16093. /**
  16094. * Particle emitter emitting particles from the inside of a box.
  16095. * It emits the particles randomly between 2 given directions.
  16096. */
  16097. export class BoxParticleEmitter implements IParticleEmitterType {
  16098. /**
  16099. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16100. */
  16101. direction1: Vector3;
  16102. /**
  16103. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16104. */
  16105. direction2: Vector3;
  16106. /**
  16107. * 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.
  16108. */
  16109. minEmitBox: Vector3;
  16110. /**
  16111. * 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.
  16112. */
  16113. maxEmitBox: Vector3;
  16114. /**
  16115. * Creates a new instance BoxParticleEmitter
  16116. */
  16117. constructor();
  16118. /**
  16119. * Called by the particle System when the direction is computed for the created particle.
  16120. * @param worldMatrix is the world matrix of the particle system
  16121. * @param directionToUpdate is the direction vector to update with the result
  16122. * @param particle is the particle we are computed the direction for
  16123. * @param isLocal defines if the direction should be set in local space
  16124. */
  16125. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16126. /**
  16127. * Called by the particle System when the position is computed for the created particle.
  16128. * @param worldMatrix is the world matrix of the particle system
  16129. * @param positionToUpdate is the position vector to update with the result
  16130. * @param particle is the particle we are computed the position for
  16131. * @param isLocal defines if the position should be set in local space
  16132. */
  16133. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16134. /**
  16135. * Clones the current emitter and returns a copy of it
  16136. * @returns the new emitter
  16137. */
  16138. clone(): BoxParticleEmitter;
  16139. /**
  16140. * Called by the GPUParticleSystem to setup the update shader
  16141. * @param effect defines the update shader
  16142. */
  16143. applyToShader(effect: Effect): void;
  16144. /**
  16145. * Returns a string to use to update the GPU particles update shader
  16146. * @returns a string containng the defines string
  16147. */
  16148. getEffectDefines(): string;
  16149. /**
  16150. * Returns the string "BoxParticleEmitter"
  16151. * @returns a string containing the class name
  16152. */
  16153. getClassName(): string;
  16154. /**
  16155. * Serializes the particle system to a JSON object.
  16156. * @returns the JSON object
  16157. */
  16158. serialize(): any;
  16159. /**
  16160. * Parse properties from a JSON object
  16161. * @param serializationObject defines the JSON object
  16162. */
  16163. parse(serializationObject: any): void;
  16164. }
  16165. }
  16166. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  16167. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16168. import { Effect } from "babylonjs/Materials/effect";
  16169. import { Particle } from "babylonjs/Particles/particle";
  16170. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16171. /**
  16172. * Particle emitter emitting particles from the inside of a cone.
  16173. * It emits the particles alongside the cone volume from the base to the particle.
  16174. * The emission direction might be randomized.
  16175. */
  16176. export class ConeParticleEmitter implements IParticleEmitterType {
  16177. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16178. directionRandomizer: number;
  16179. private _radius;
  16180. private _angle;
  16181. private _height;
  16182. /**
  16183. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16184. */
  16185. radiusRange: number;
  16186. /**
  16187. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16188. */
  16189. heightRange: number;
  16190. /**
  16191. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16192. */
  16193. emitFromSpawnPointOnly: boolean;
  16194. /**
  16195. * Gets or sets the radius of the emission cone
  16196. */
  16197. get radius(): number;
  16198. set radius(value: number);
  16199. /**
  16200. * Gets or sets the angle of the emission cone
  16201. */
  16202. get angle(): number;
  16203. set angle(value: number);
  16204. private _buildHeight;
  16205. /**
  16206. * Creates a new instance ConeParticleEmitter
  16207. * @param radius the radius of the emission cone (1 by default)
  16208. * @param angle the cone base angle (PI by default)
  16209. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16210. */
  16211. constructor(radius?: number, angle?: number,
  16212. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16213. directionRandomizer?: number);
  16214. /**
  16215. * Called by the particle System when the direction is computed for the created particle.
  16216. * @param worldMatrix is the world matrix of the particle system
  16217. * @param directionToUpdate is the direction vector to update with the result
  16218. * @param particle is the particle we are computed the direction for
  16219. * @param isLocal defines if the direction should be set in local space
  16220. */
  16221. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16222. /**
  16223. * Called by the particle System when the position is computed for the created particle.
  16224. * @param worldMatrix is the world matrix of the particle system
  16225. * @param positionToUpdate is the position vector to update with the result
  16226. * @param particle is the particle we are computed the position for
  16227. * @param isLocal defines if the position should be set in local space
  16228. */
  16229. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16230. /**
  16231. * Clones the current emitter and returns a copy of it
  16232. * @returns the new emitter
  16233. */
  16234. clone(): ConeParticleEmitter;
  16235. /**
  16236. * Called by the GPUParticleSystem to setup the update shader
  16237. * @param effect defines the update shader
  16238. */
  16239. applyToShader(effect: Effect): void;
  16240. /**
  16241. * Returns a string to use to update the GPU particles update shader
  16242. * @returns a string containng the defines string
  16243. */
  16244. getEffectDefines(): string;
  16245. /**
  16246. * Returns the string "ConeParticleEmitter"
  16247. * @returns a string containing the class name
  16248. */
  16249. getClassName(): string;
  16250. /**
  16251. * Serializes the particle system to a JSON object.
  16252. * @returns the JSON object
  16253. */
  16254. serialize(): any;
  16255. /**
  16256. * Parse properties from a JSON object
  16257. * @param serializationObject defines the JSON object
  16258. */
  16259. parse(serializationObject: any): void;
  16260. }
  16261. }
  16262. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16263. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16264. import { Effect } from "babylonjs/Materials/effect";
  16265. import { Particle } from "babylonjs/Particles/particle";
  16266. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16267. /**
  16268. * Particle emitter emitting particles from the inside of a cylinder.
  16269. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16270. */
  16271. export class CylinderParticleEmitter implements IParticleEmitterType {
  16272. /**
  16273. * The radius of the emission cylinder.
  16274. */
  16275. radius: number;
  16276. /**
  16277. * The height of the emission cylinder.
  16278. */
  16279. height: number;
  16280. /**
  16281. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16282. */
  16283. radiusRange: number;
  16284. /**
  16285. * How much to randomize the particle direction [0-1].
  16286. */
  16287. directionRandomizer: number;
  16288. /**
  16289. * Creates a new instance CylinderParticleEmitter
  16290. * @param radius the radius of the emission cylinder (1 by default)
  16291. * @param height the height of the emission cylinder (1 by default)
  16292. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16293. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16294. */
  16295. constructor(
  16296. /**
  16297. * The radius of the emission cylinder.
  16298. */
  16299. radius?: number,
  16300. /**
  16301. * The height of the emission cylinder.
  16302. */
  16303. height?: number,
  16304. /**
  16305. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16306. */
  16307. radiusRange?: number,
  16308. /**
  16309. * How much to randomize the particle direction [0-1].
  16310. */
  16311. directionRandomizer?: number);
  16312. /**
  16313. * Called by the particle System when the direction is computed for the created particle.
  16314. * @param worldMatrix is the world matrix of the particle system
  16315. * @param directionToUpdate is the direction vector to update with the result
  16316. * @param particle is the particle we are computed the direction for
  16317. * @param isLocal defines if the direction should be set in local space
  16318. */
  16319. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16320. /**
  16321. * Called by the particle System when the position is computed for the created particle.
  16322. * @param worldMatrix is the world matrix of the particle system
  16323. * @param positionToUpdate is the position vector to update with the result
  16324. * @param particle is the particle we are computed the position for
  16325. * @param isLocal defines if the position should be set in local space
  16326. */
  16327. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16328. /**
  16329. * Clones the current emitter and returns a copy of it
  16330. * @returns the new emitter
  16331. */
  16332. clone(): CylinderParticleEmitter;
  16333. /**
  16334. * Called by the GPUParticleSystem to setup the update shader
  16335. * @param effect defines the update shader
  16336. */
  16337. applyToShader(effect: Effect): void;
  16338. /**
  16339. * Returns a string to use to update the GPU particles update shader
  16340. * @returns a string containng the defines string
  16341. */
  16342. getEffectDefines(): string;
  16343. /**
  16344. * Returns the string "CylinderParticleEmitter"
  16345. * @returns a string containing the class name
  16346. */
  16347. getClassName(): string;
  16348. /**
  16349. * Serializes the particle system to a JSON object.
  16350. * @returns the JSON object
  16351. */
  16352. serialize(): any;
  16353. /**
  16354. * Parse properties from a JSON object
  16355. * @param serializationObject defines the JSON object
  16356. */
  16357. parse(serializationObject: any): void;
  16358. }
  16359. /**
  16360. * Particle emitter emitting particles from the inside of a cylinder.
  16361. * It emits the particles randomly between two vectors.
  16362. */
  16363. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16364. /**
  16365. * The min limit of the emission direction.
  16366. */
  16367. direction1: Vector3;
  16368. /**
  16369. * The max limit of the emission direction.
  16370. */
  16371. direction2: Vector3;
  16372. /**
  16373. * Creates a new instance CylinderDirectedParticleEmitter
  16374. * @param radius the radius of the emission cylinder (1 by default)
  16375. * @param height the height of the emission cylinder (1 by default)
  16376. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16377. * @param direction1 the min limit of the emission direction (up vector by default)
  16378. * @param direction2 the max limit of the emission direction (up vector by default)
  16379. */
  16380. constructor(radius?: number, height?: number, radiusRange?: number,
  16381. /**
  16382. * The min limit of the emission direction.
  16383. */
  16384. direction1?: Vector3,
  16385. /**
  16386. * The max limit of the emission direction.
  16387. */
  16388. direction2?: Vector3);
  16389. /**
  16390. * Called by the particle System when the direction is computed for the created particle.
  16391. * @param worldMatrix is the world matrix of the particle system
  16392. * @param directionToUpdate is the direction vector to update with the result
  16393. * @param particle is the particle we are computed the direction for
  16394. */
  16395. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16396. /**
  16397. * Clones the current emitter and returns a copy of it
  16398. * @returns the new emitter
  16399. */
  16400. clone(): CylinderDirectedParticleEmitter;
  16401. /**
  16402. * Called by the GPUParticleSystem to setup the update shader
  16403. * @param effect defines the update shader
  16404. */
  16405. applyToShader(effect: Effect): void;
  16406. /**
  16407. * Returns a string to use to update the GPU particles update shader
  16408. * @returns a string containng the defines string
  16409. */
  16410. getEffectDefines(): string;
  16411. /**
  16412. * Returns the string "CylinderDirectedParticleEmitter"
  16413. * @returns a string containing the class name
  16414. */
  16415. getClassName(): string;
  16416. /**
  16417. * Serializes the particle system to a JSON object.
  16418. * @returns the JSON object
  16419. */
  16420. serialize(): any;
  16421. /**
  16422. * Parse properties from a JSON object
  16423. * @param serializationObject defines the JSON object
  16424. */
  16425. parse(serializationObject: any): void;
  16426. }
  16427. }
  16428. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16429. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16430. import { Effect } from "babylonjs/Materials/effect";
  16431. import { Particle } from "babylonjs/Particles/particle";
  16432. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16433. /**
  16434. * Particle emitter emitting particles from the inside of a hemisphere.
  16435. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16436. */
  16437. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16438. /**
  16439. * The radius of the emission hemisphere.
  16440. */
  16441. radius: number;
  16442. /**
  16443. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16444. */
  16445. radiusRange: number;
  16446. /**
  16447. * How much to randomize the particle direction [0-1].
  16448. */
  16449. directionRandomizer: number;
  16450. /**
  16451. * Creates a new instance HemisphericParticleEmitter
  16452. * @param radius the radius of the emission hemisphere (1 by default)
  16453. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16454. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16455. */
  16456. constructor(
  16457. /**
  16458. * The radius of the emission hemisphere.
  16459. */
  16460. radius?: number,
  16461. /**
  16462. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16463. */
  16464. radiusRange?: number,
  16465. /**
  16466. * How much to randomize the particle direction [0-1].
  16467. */
  16468. directionRandomizer?: number);
  16469. /**
  16470. * Called by the particle System when the direction is computed for the created particle.
  16471. * @param worldMatrix is the world matrix of the particle system
  16472. * @param directionToUpdate is the direction vector to update with the result
  16473. * @param particle is the particle we are computed the direction for
  16474. * @param isLocal defines if the direction should be set in local space
  16475. */
  16476. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16477. /**
  16478. * Called by the particle System when the position is computed for the created particle.
  16479. * @param worldMatrix is the world matrix of the particle system
  16480. * @param positionToUpdate is the position vector to update with the result
  16481. * @param particle is the particle we are computed the position for
  16482. * @param isLocal defines if the position should be set in local space
  16483. */
  16484. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16485. /**
  16486. * Clones the current emitter and returns a copy of it
  16487. * @returns the new emitter
  16488. */
  16489. clone(): HemisphericParticleEmitter;
  16490. /**
  16491. * Called by the GPUParticleSystem to setup the update shader
  16492. * @param effect defines the update shader
  16493. */
  16494. applyToShader(effect: Effect): void;
  16495. /**
  16496. * Returns a string to use to update the GPU particles update shader
  16497. * @returns a string containng the defines string
  16498. */
  16499. getEffectDefines(): string;
  16500. /**
  16501. * Returns the string "HemisphericParticleEmitter"
  16502. * @returns a string containing the class name
  16503. */
  16504. getClassName(): string;
  16505. /**
  16506. * Serializes the particle system to a JSON object.
  16507. * @returns the JSON object
  16508. */
  16509. serialize(): any;
  16510. /**
  16511. * Parse properties from a JSON object
  16512. * @param serializationObject defines the JSON object
  16513. */
  16514. parse(serializationObject: any): void;
  16515. }
  16516. }
  16517. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16518. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16519. import { Effect } from "babylonjs/Materials/effect";
  16520. import { Particle } from "babylonjs/Particles/particle";
  16521. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16522. /**
  16523. * Particle emitter emitting particles from a point.
  16524. * It emits the particles randomly between 2 given directions.
  16525. */
  16526. export class PointParticleEmitter implements IParticleEmitterType {
  16527. /**
  16528. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16529. */
  16530. direction1: Vector3;
  16531. /**
  16532. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16533. */
  16534. direction2: Vector3;
  16535. /**
  16536. * Creates a new instance PointParticleEmitter
  16537. */
  16538. constructor();
  16539. /**
  16540. * Called by the particle System when the direction is computed for the created particle.
  16541. * @param worldMatrix is the world matrix of the particle system
  16542. * @param directionToUpdate is the direction vector to update with the result
  16543. * @param particle is the particle we are computed the direction for
  16544. * @param isLocal defines if the direction should be set in local space
  16545. */
  16546. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16547. /**
  16548. * Called by the particle System when the position is computed for the created particle.
  16549. * @param worldMatrix is the world matrix of the particle system
  16550. * @param positionToUpdate is the position vector to update with the result
  16551. * @param particle is the particle we are computed the position for
  16552. * @param isLocal defines if the position should be set in local space
  16553. */
  16554. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16555. /**
  16556. * Clones the current emitter and returns a copy of it
  16557. * @returns the new emitter
  16558. */
  16559. clone(): PointParticleEmitter;
  16560. /**
  16561. * Called by the GPUParticleSystem to setup the update shader
  16562. * @param effect defines the update shader
  16563. */
  16564. applyToShader(effect: Effect): void;
  16565. /**
  16566. * Returns a string to use to update the GPU particles update shader
  16567. * @returns a string containng the defines string
  16568. */
  16569. getEffectDefines(): string;
  16570. /**
  16571. * Returns the string "PointParticleEmitter"
  16572. * @returns a string containing the class name
  16573. */
  16574. getClassName(): string;
  16575. /**
  16576. * Serializes the particle system to a JSON object.
  16577. * @returns the JSON object
  16578. */
  16579. serialize(): any;
  16580. /**
  16581. * Parse properties from a JSON object
  16582. * @param serializationObject defines the JSON object
  16583. */
  16584. parse(serializationObject: any): void;
  16585. }
  16586. }
  16587. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16588. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16589. import { Effect } from "babylonjs/Materials/effect";
  16590. import { Particle } from "babylonjs/Particles/particle";
  16591. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16592. /**
  16593. * Particle emitter emitting particles from the inside of a sphere.
  16594. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16595. */
  16596. export class SphereParticleEmitter implements IParticleEmitterType {
  16597. /**
  16598. * The radius of the emission sphere.
  16599. */
  16600. radius: number;
  16601. /**
  16602. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16603. */
  16604. radiusRange: number;
  16605. /**
  16606. * How much to randomize the particle direction [0-1].
  16607. */
  16608. directionRandomizer: number;
  16609. /**
  16610. * Creates a new instance SphereParticleEmitter
  16611. * @param radius the radius of the emission sphere (1 by default)
  16612. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16613. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16614. */
  16615. constructor(
  16616. /**
  16617. * The radius of the emission sphere.
  16618. */
  16619. radius?: number,
  16620. /**
  16621. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16622. */
  16623. radiusRange?: number,
  16624. /**
  16625. * How much to randomize the particle direction [0-1].
  16626. */
  16627. directionRandomizer?: number);
  16628. /**
  16629. * Called by the particle System when the direction is computed for the created particle.
  16630. * @param worldMatrix is the world matrix of the particle system
  16631. * @param directionToUpdate is the direction vector to update with the result
  16632. * @param particle is the particle we are computed the direction for
  16633. * @param isLocal defines if the direction should be set in local space
  16634. */
  16635. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16636. /**
  16637. * Called by the particle System when the position is computed for the created particle.
  16638. * @param worldMatrix is the world matrix of the particle system
  16639. * @param positionToUpdate is the position vector to update with the result
  16640. * @param particle is the particle we are computed the position for
  16641. * @param isLocal defines if the position should be set in local space
  16642. */
  16643. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16644. /**
  16645. * Clones the current emitter and returns a copy of it
  16646. * @returns the new emitter
  16647. */
  16648. clone(): SphereParticleEmitter;
  16649. /**
  16650. * Called by the GPUParticleSystem to setup the update shader
  16651. * @param effect defines the update shader
  16652. */
  16653. applyToShader(effect: Effect): void;
  16654. /**
  16655. * Returns a string to use to update the GPU particles update shader
  16656. * @returns a string containng the defines string
  16657. */
  16658. getEffectDefines(): string;
  16659. /**
  16660. * Returns the string "SphereParticleEmitter"
  16661. * @returns a string containing the class name
  16662. */
  16663. getClassName(): string;
  16664. /**
  16665. * Serializes the particle system to a JSON object.
  16666. * @returns the JSON object
  16667. */
  16668. serialize(): any;
  16669. /**
  16670. * Parse properties from a JSON object
  16671. * @param serializationObject defines the JSON object
  16672. */
  16673. parse(serializationObject: any): void;
  16674. }
  16675. /**
  16676. * Particle emitter emitting particles from the inside of a sphere.
  16677. * It emits the particles randomly between two vectors.
  16678. */
  16679. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16680. /**
  16681. * The min limit of the emission direction.
  16682. */
  16683. direction1: Vector3;
  16684. /**
  16685. * The max limit of the emission direction.
  16686. */
  16687. direction2: Vector3;
  16688. /**
  16689. * Creates a new instance SphereDirectedParticleEmitter
  16690. * @param radius the radius of the emission sphere (1 by default)
  16691. * @param direction1 the min limit of the emission direction (up vector by default)
  16692. * @param direction2 the max limit of the emission direction (up vector by default)
  16693. */
  16694. constructor(radius?: number,
  16695. /**
  16696. * The min limit of the emission direction.
  16697. */
  16698. direction1?: Vector3,
  16699. /**
  16700. * The max limit of the emission direction.
  16701. */
  16702. direction2?: Vector3);
  16703. /**
  16704. * Called by the particle System when the direction is computed for the created particle.
  16705. * @param worldMatrix is the world matrix of the particle system
  16706. * @param directionToUpdate is the direction vector to update with the result
  16707. * @param particle is the particle we are computed the direction for
  16708. */
  16709. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16710. /**
  16711. * Clones the current emitter and returns a copy of it
  16712. * @returns the new emitter
  16713. */
  16714. clone(): SphereDirectedParticleEmitter;
  16715. /**
  16716. * Called by the GPUParticleSystem to setup the update shader
  16717. * @param effect defines the update shader
  16718. */
  16719. applyToShader(effect: Effect): void;
  16720. /**
  16721. * Returns a string to use to update the GPU particles update shader
  16722. * @returns a string containng the defines string
  16723. */
  16724. getEffectDefines(): string;
  16725. /**
  16726. * Returns the string "SphereDirectedParticleEmitter"
  16727. * @returns a string containing the class name
  16728. */
  16729. getClassName(): string;
  16730. /**
  16731. * Serializes the particle system to a JSON object.
  16732. * @returns the JSON object
  16733. */
  16734. serialize(): any;
  16735. /**
  16736. * Parse properties from a JSON object
  16737. * @param serializationObject defines the JSON object
  16738. */
  16739. parse(serializationObject: any): void;
  16740. }
  16741. }
  16742. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  16743. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16744. import { Effect } from "babylonjs/Materials/effect";
  16745. import { Particle } from "babylonjs/Particles/particle";
  16746. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16747. import { Nullable } from "babylonjs/types";
  16748. /**
  16749. * Particle emitter emitting particles from a custom list of positions.
  16750. */
  16751. export class CustomParticleEmitter implements IParticleEmitterType {
  16752. /**
  16753. * Gets or sets the position generator that will create the inital position of each particle.
  16754. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16755. */
  16756. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16757. /**
  16758. * Gets or sets the destination generator that will create the final destination of each particle.
  16759. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16760. */
  16761. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16762. /**
  16763. * Creates a new instance CustomParticleEmitter
  16764. */
  16765. constructor();
  16766. /**
  16767. * Called by the particle System when the direction is computed for the created particle.
  16768. * @param worldMatrix is the world matrix of the particle system
  16769. * @param directionToUpdate is the direction vector to update with the result
  16770. * @param particle is the particle we are computed the direction for
  16771. * @param isLocal defines if the direction should be set in local space
  16772. */
  16773. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16774. /**
  16775. * Called by the particle System when the position is computed for the created particle.
  16776. * @param worldMatrix is the world matrix of the particle system
  16777. * @param positionToUpdate is the position vector to update with the result
  16778. * @param particle is the particle we are computed the position for
  16779. * @param isLocal defines if the position should be set in local space
  16780. */
  16781. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16782. /**
  16783. * Clones the current emitter and returns a copy of it
  16784. * @returns the new emitter
  16785. */
  16786. clone(): CustomParticleEmitter;
  16787. /**
  16788. * Called by the GPUParticleSystem to setup the update shader
  16789. * @param effect defines the update shader
  16790. */
  16791. applyToShader(effect: Effect): void;
  16792. /**
  16793. * Returns a string to use to update the GPU particles update shader
  16794. * @returns a string containng the defines string
  16795. */
  16796. getEffectDefines(): string;
  16797. /**
  16798. * Returns the string "PointParticleEmitter"
  16799. * @returns a string containing the class name
  16800. */
  16801. getClassName(): string;
  16802. /**
  16803. * Serializes the particle system to a JSON object.
  16804. * @returns the JSON object
  16805. */
  16806. serialize(): any;
  16807. /**
  16808. * Parse properties from a JSON object
  16809. * @param serializationObject defines the JSON object
  16810. */
  16811. parse(serializationObject: any): void;
  16812. }
  16813. }
  16814. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  16815. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16816. import { Effect } from "babylonjs/Materials/effect";
  16817. import { Particle } from "babylonjs/Particles/particle";
  16818. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16819. import { Nullable } from "babylonjs/types";
  16820. import { Scene } from "babylonjs/scene";
  16821. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16822. /**
  16823. * Particle emitter emitting particles from the inside of a box.
  16824. * It emits the particles randomly between 2 given directions.
  16825. */
  16826. export class MeshParticleEmitter implements IParticleEmitterType {
  16827. private _indices;
  16828. private _positions;
  16829. private _normals;
  16830. private _storedNormal;
  16831. private _mesh;
  16832. /**
  16833. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16834. */
  16835. direction1: Vector3;
  16836. /**
  16837. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16838. */
  16839. direction2: Vector3;
  16840. /**
  16841. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  16842. */
  16843. useMeshNormalsForDirection: boolean;
  16844. /** Defines the mesh to use as source */
  16845. get mesh(): Nullable<AbstractMesh>;
  16846. set mesh(value: Nullable<AbstractMesh>);
  16847. /**
  16848. * Creates a new instance MeshParticleEmitter
  16849. * @param mesh defines the mesh to use as source
  16850. */
  16851. constructor(mesh?: Nullable<AbstractMesh>);
  16852. /**
  16853. * Called by the particle System when the direction is computed for the created particle.
  16854. * @param worldMatrix is the world matrix of the particle system
  16855. * @param directionToUpdate is the direction vector to update with the result
  16856. * @param particle is the particle we are computed the direction for
  16857. * @param isLocal defines if the direction should be set in local space
  16858. */
  16859. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16860. /**
  16861. * Called by the particle System when the position is computed for the created particle.
  16862. * @param worldMatrix is the world matrix of the particle system
  16863. * @param positionToUpdate is the position vector to update with the result
  16864. * @param particle is the particle we are computed the position for
  16865. * @param isLocal defines if the position should be set in local space
  16866. */
  16867. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16868. /**
  16869. * Clones the current emitter and returns a copy of it
  16870. * @returns the new emitter
  16871. */
  16872. clone(): MeshParticleEmitter;
  16873. /**
  16874. * Called by the GPUParticleSystem to setup the update shader
  16875. * @param effect defines the update shader
  16876. */
  16877. applyToShader(effect: Effect): void;
  16878. /**
  16879. * Returns a string to use to update the GPU particles update shader
  16880. * @returns a string containng the defines string
  16881. */
  16882. getEffectDefines(): string;
  16883. /**
  16884. * Returns the string "BoxParticleEmitter"
  16885. * @returns a string containing the class name
  16886. */
  16887. getClassName(): string;
  16888. /**
  16889. * Serializes the particle system to a JSON object.
  16890. * @returns the JSON object
  16891. */
  16892. serialize(): any;
  16893. /**
  16894. * Parse properties from a JSON object
  16895. * @param serializationObject defines the JSON object
  16896. * @param scene defines the hosting scene
  16897. */
  16898. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16899. }
  16900. }
  16901. declare module "babylonjs/Particles/EmitterTypes/index" {
  16902. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16903. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16904. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16905. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16906. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16907. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16908. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16909. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  16910. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  16911. }
  16912. declare module "babylonjs/Particles/IParticleSystem" {
  16913. import { Nullable } from "babylonjs/types";
  16914. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16915. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16916. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16917. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16918. import { Scene } from "babylonjs/scene";
  16919. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  16920. import { Effect } from "babylonjs/Materials/effect";
  16921. import { Observable } from "babylonjs/Misc/observable";
  16922. import { Animation } from "babylonjs/Animations/animation";
  16923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16924. /**
  16925. * Interface representing a particle system in Babylon.js.
  16926. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16927. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16928. */
  16929. export interface IParticleSystem {
  16930. /**
  16931. * List of animations used by the particle system.
  16932. */
  16933. animations: Animation[];
  16934. /**
  16935. * The id of the Particle system.
  16936. */
  16937. id: string;
  16938. /**
  16939. * The name of the Particle system.
  16940. */
  16941. name: string;
  16942. /**
  16943. * The emitter represents the Mesh or position we are attaching the particle system to.
  16944. */
  16945. emitter: Nullable<AbstractMesh | Vector3>;
  16946. /**
  16947. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16948. */
  16949. isBillboardBased: boolean;
  16950. /**
  16951. * The rendering group used by the Particle system to chose when to render.
  16952. */
  16953. renderingGroupId: number;
  16954. /**
  16955. * The layer mask we are rendering the particles through.
  16956. */
  16957. layerMask: number;
  16958. /**
  16959. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16960. */
  16961. updateSpeed: number;
  16962. /**
  16963. * The amount of time the particle system is running (depends of the overall update speed).
  16964. */
  16965. targetStopDuration: number;
  16966. /**
  16967. * The texture used to render each particle. (this can be a spritesheet)
  16968. */
  16969. particleTexture: Nullable<BaseTexture>;
  16970. /**
  16971. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16972. */
  16973. blendMode: number;
  16974. /**
  16975. * Minimum life time of emitting particles.
  16976. */
  16977. minLifeTime: number;
  16978. /**
  16979. * Maximum life time of emitting particles.
  16980. */
  16981. maxLifeTime: number;
  16982. /**
  16983. * Minimum Size of emitting particles.
  16984. */
  16985. minSize: number;
  16986. /**
  16987. * Maximum Size of emitting particles.
  16988. */
  16989. maxSize: number;
  16990. /**
  16991. * Minimum scale of emitting particles on X axis.
  16992. */
  16993. minScaleX: number;
  16994. /**
  16995. * Maximum scale of emitting particles on X axis.
  16996. */
  16997. maxScaleX: number;
  16998. /**
  16999. * Minimum scale of emitting particles on Y axis.
  17000. */
  17001. minScaleY: number;
  17002. /**
  17003. * Maximum scale of emitting particles on Y axis.
  17004. */
  17005. maxScaleY: number;
  17006. /**
  17007. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17008. */
  17009. color1: Color4;
  17010. /**
  17011. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17012. */
  17013. color2: Color4;
  17014. /**
  17015. * Color the particle will have at the end of its lifetime.
  17016. */
  17017. colorDead: Color4;
  17018. /**
  17019. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17020. */
  17021. emitRate: number;
  17022. /**
  17023. * You can use gravity if you want to give an orientation to your particles.
  17024. */
  17025. gravity: Vector3;
  17026. /**
  17027. * Minimum power of emitting particles.
  17028. */
  17029. minEmitPower: number;
  17030. /**
  17031. * Maximum power of emitting particles.
  17032. */
  17033. maxEmitPower: number;
  17034. /**
  17035. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17036. */
  17037. minAngularSpeed: number;
  17038. /**
  17039. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17040. */
  17041. maxAngularSpeed: number;
  17042. /**
  17043. * Gets or sets the minimal initial rotation in radians.
  17044. */
  17045. minInitialRotation: number;
  17046. /**
  17047. * Gets or sets the maximal initial rotation in radians.
  17048. */
  17049. maxInitialRotation: number;
  17050. /**
  17051. * The particle emitter type defines the emitter used by the particle system.
  17052. * It can be for example box, sphere, or cone...
  17053. */
  17054. particleEmitterType: Nullable<IParticleEmitterType>;
  17055. /**
  17056. * Defines the delay in milliseconds before starting the system (0 by default)
  17057. */
  17058. startDelay: number;
  17059. /**
  17060. * 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
  17061. */
  17062. preWarmCycles: number;
  17063. /**
  17064. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17065. */
  17066. preWarmStepOffset: number;
  17067. /**
  17068. * 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)
  17069. */
  17070. spriteCellChangeSpeed: number;
  17071. /**
  17072. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17073. */
  17074. startSpriteCellID: number;
  17075. /**
  17076. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17077. */
  17078. endSpriteCellID: number;
  17079. /**
  17080. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17081. */
  17082. spriteCellWidth: number;
  17083. /**
  17084. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17085. */
  17086. spriteCellHeight: number;
  17087. /**
  17088. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17089. */
  17090. spriteRandomStartCell: boolean;
  17091. /**
  17092. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17093. */
  17094. isAnimationSheetEnabled: boolean;
  17095. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17096. translationPivot: Vector2;
  17097. /**
  17098. * Gets or sets a texture used to add random noise to particle positions
  17099. */
  17100. noiseTexture: Nullable<BaseTexture>;
  17101. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17102. noiseStrength: Vector3;
  17103. /**
  17104. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17105. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17106. */
  17107. billboardMode: number;
  17108. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17109. limitVelocityDamping: number;
  17110. /**
  17111. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17112. */
  17113. beginAnimationOnStart: boolean;
  17114. /**
  17115. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17116. */
  17117. beginAnimationFrom: number;
  17118. /**
  17119. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17120. */
  17121. beginAnimationTo: number;
  17122. /**
  17123. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17124. */
  17125. beginAnimationLoop: boolean;
  17126. /**
  17127. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17128. */
  17129. disposeOnStop: boolean;
  17130. /**
  17131. * Specifies if the particles are updated in emitter local space or world space
  17132. */
  17133. isLocal: boolean;
  17134. /** Snippet ID if the particle system was created from the snippet server */
  17135. snippetId: string;
  17136. /** Gets or sets a matrix to use to compute projection */
  17137. defaultProjectionMatrix: Matrix;
  17138. /**
  17139. * Gets the maximum number of particles active at the same time.
  17140. * @returns The max number of active particles.
  17141. */
  17142. getCapacity(): number;
  17143. /**
  17144. * Gets the number of particles active at the same time.
  17145. * @returns The number of active particles.
  17146. */
  17147. getActiveCount(): number;
  17148. /**
  17149. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17150. * @returns True if it has been started, otherwise false.
  17151. */
  17152. isStarted(): boolean;
  17153. /**
  17154. * Animates the particle system for this frame.
  17155. */
  17156. animate(): void;
  17157. /**
  17158. * Renders the particle system in its current state.
  17159. * @returns the current number of particles
  17160. */
  17161. render(): number;
  17162. /**
  17163. * Dispose the particle system and frees its associated resources.
  17164. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17165. */
  17166. dispose(disposeTexture?: boolean): void;
  17167. /**
  17168. * An event triggered when the system is disposed
  17169. */
  17170. onDisposeObservable: Observable<IParticleSystem>;
  17171. /**
  17172. * An event triggered when the system is stopped
  17173. */
  17174. onStoppedObservable: Observable<IParticleSystem>;
  17175. /**
  17176. * Clones the particle system.
  17177. * @param name The name of the cloned object
  17178. * @param newEmitter The new emitter to use
  17179. * @returns the cloned particle system
  17180. */
  17181. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17182. /**
  17183. * Serializes the particle system to a JSON object
  17184. * @param serializeTexture defines if the texture must be serialized as well
  17185. * @returns the JSON object
  17186. */
  17187. serialize(serializeTexture: boolean): any;
  17188. /**
  17189. * Rebuild the particle system
  17190. */
  17191. rebuild(): void;
  17192. /** Force the system to rebuild all gradients that need to be resync */
  17193. forceRefreshGradients(): void;
  17194. /**
  17195. * Starts the particle system and begins to emit
  17196. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17197. */
  17198. start(delay?: number): void;
  17199. /**
  17200. * Stops the particle system.
  17201. */
  17202. stop(): void;
  17203. /**
  17204. * Remove all active particles
  17205. */
  17206. reset(): void;
  17207. /**
  17208. * Gets a boolean indicating that the system is stopping
  17209. * @returns true if the system is currently stopping
  17210. */
  17211. isStopping(): boolean;
  17212. /**
  17213. * Is this system ready to be used/rendered
  17214. * @return true if the system is ready
  17215. */
  17216. isReady(): boolean;
  17217. /**
  17218. * Returns the string "ParticleSystem"
  17219. * @returns a string containing the class name
  17220. */
  17221. getClassName(): string;
  17222. /**
  17223. * Gets the custom effect used to render the particles
  17224. * @param blendMode Blend mode for which the effect should be retrieved
  17225. * @returns The effect
  17226. */
  17227. getCustomEffect(blendMode: number): Nullable<Effect>;
  17228. /**
  17229. * Sets the custom effect used to render the particles
  17230. * @param effect The effect to set
  17231. * @param blendMode Blend mode for which the effect should be set
  17232. */
  17233. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17234. /**
  17235. * Fill the defines array according to the current settings of the particle system
  17236. * @param defines Array to be updated
  17237. * @param blendMode blend mode to take into account when updating the array
  17238. */
  17239. fillDefines(defines: Array<string>, blendMode: number): void;
  17240. /**
  17241. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17242. * @param uniforms Uniforms array to fill
  17243. * @param attributes Attributes array to fill
  17244. * @param samplers Samplers array to fill
  17245. */
  17246. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17247. /**
  17248. * Observable that will be called just before the particles are drawn
  17249. */
  17250. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17251. /**
  17252. * Gets the name of the particle vertex shader
  17253. */
  17254. vertexShaderName: string;
  17255. /**
  17256. * Adds a new color gradient
  17257. * @param gradient defines the gradient to use (between 0 and 1)
  17258. * @param color1 defines the color to affect to the specified gradient
  17259. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17260. * @returns the current particle system
  17261. */
  17262. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17263. /**
  17264. * Remove a specific color gradient
  17265. * @param gradient defines the gradient to remove
  17266. * @returns the current particle system
  17267. */
  17268. removeColorGradient(gradient: number): IParticleSystem;
  17269. /**
  17270. * Adds a new size gradient
  17271. * @param gradient defines the gradient to use (between 0 and 1)
  17272. * @param factor defines the size factor to affect to the specified gradient
  17273. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17274. * @returns the current particle system
  17275. */
  17276. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17277. /**
  17278. * Remove a specific size gradient
  17279. * @param gradient defines the gradient to remove
  17280. * @returns the current particle system
  17281. */
  17282. removeSizeGradient(gradient: number): IParticleSystem;
  17283. /**
  17284. * Gets the current list of color gradients.
  17285. * You must use addColorGradient and removeColorGradient to udpate this list
  17286. * @returns the list of color gradients
  17287. */
  17288. getColorGradients(): Nullable<Array<ColorGradient>>;
  17289. /**
  17290. * Gets the current list of size gradients.
  17291. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17292. * @returns the list of size gradients
  17293. */
  17294. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17295. /**
  17296. * Gets the current list of angular speed gradients.
  17297. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17298. * @returns the list of angular speed gradients
  17299. */
  17300. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17301. /**
  17302. * Adds a new angular speed gradient
  17303. * @param gradient defines the gradient to use (between 0 and 1)
  17304. * @param factor defines the angular speed to affect to the specified gradient
  17305. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17306. * @returns the current particle system
  17307. */
  17308. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17309. /**
  17310. * Remove a specific angular speed gradient
  17311. * @param gradient defines the gradient to remove
  17312. * @returns the current particle system
  17313. */
  17314. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17315. /**
  17316. * Gets the current list of velocity gradients.
  17317. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17318. * @returns the list of velocity gradients
  17319. */
  17320. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17321. /**
  17322. * Adds a new velocity gradient
  17323. * @param gradient defines the gradient to use (between 0 and 1)
  17324. * @param factor defines the velocity to affect to the specified gradient
  17325. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17326. * @returns the current particle system
  17327. */
  17328. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17329. /**
  17330. * Remove a specific velocity gradient
  17331. * @param gradient defines the gradient to remove
  17332. * @returns the current particle system
  17333. */
  17334. removeVelocityGradient(gradient: number): IParticleSystem;
  17335. /**
  17336. * Gets the current list of limit velocity gradients.
  17337. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17338. * @returns the list of limit velocity gradients
  17339. */
  17340. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17341. /**
  17342. * Adds a new limit velocity gradient
  17343. * @param gradient defines the gradient to use (between 0 and 1)
  17344. * @param factor defines the limit velocity to affect to the specified gradient
  17345. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17346. * @returns the current particle system
  17347. */
  17348. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17349. /**
  17350. * Remove a specific limit velocity gradient
  17351. * @param gradient defines the gradient to remove
  17352. * @returns the current particle system
  17353. */
  17354. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17355. /**
  17356. * Adds a new drag gradient
  17357. * @param gradient defines the gradient to use (between 0 and 1)
  17358. * @param factor defines the drag to affect to the specified gradient
  17359. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17360. * @returns the current particle system
  17361. */
  17362. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17363. /**
  17364. * Remove a specific drag gradient
  17365. * @param gradient defines the gradient to remove
  17366. * @returns the current particle system
  17367. */
  17368. removeDragGradient(gradient: number): IParticleSystem;
  17369. /**
  17370. * Gets the current list of drag gradients.
  17371. * You must use addDragGradient and removeDragGradient to udpate this list
  17372. * @returns the list of drag gradients
  17373. */
  17374. getDragGradients(): Nullable<Array<FactorGradient>>;
  17375. /**
  17376. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17377. * @param gradient defines the gradient to use (between 0 and 1)
  17378. * @param factor defines the emit rate to affect to the specified gradient
  17379. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17380. * @returns the current particle system
  17381. */
  17382. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17383. /**
  17384. * Remove a specific emit rate gradient
  17385. * @param gradient defines the gradient to remove
  17386. * @returns the current particle system
  17387. */
  17388. removeEmitRateGradient(gradient: number): IParticleSystem;
  17389. /**
  17390. * Gets the current list of emit rate gradients.
  17391. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17392. * @returns the list of emit rate gradients
  17393. */
  17394. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17395. /**
  17396. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17397. * @param gradient defines the gradient to use (between 0 and 1)
  17398. * @param factor defines the start size to affect to the specified gradient
  17399. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17400. * @returns the current particle system
  17401. */
  17402. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17403. /**
  17404. * Remove a specific start size gradient
  17405. * @param gradient defines the gradient to remove
  17406. * @returns the current particle system
  17407. */
  17408. removeStartSizeGradient(gradient: number): IParticleSystem;
  17409. /**
  17410. * Gets the current list of start size gradients.
  17411. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17412. * @returns the list of start size gradients
  17413. */
  17414. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17415. /**
  17416. * Adds a new life time gradient
  17417. * @param gradient defines the gradient to use (between 0 and 1)
  17418. * @param factor defines the life time factor to affect to the specified gradient
  17419. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17420. * @returns the current particle system
  17421. */
  17422. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17423. /**
  17424. * Remove a specific life time gradient
  17425. * @param gradient defines the gradient to remove
  17426. * @returns the current particle system
  17427. */
  17428. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17429. /**
  17430. * Gets the current list of life time gradients.
  17431. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17432. * @returns the list of life time gradients
  17433. */
  17434. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17435. /**
  17436. * Gets the current list of color gradients.
  17437. * You must use addColorGradient and removeColorGradient to udpate this list
  17438. * @returns the list of color gradients
  17439. */
  17440. getColorGradients(): Nullable<Array<ColorGradient>>;
  17441. /**
  17442. * Adds a new ramp gradient used to remap particle colors
  17443. * @param gradient defines the gradient to use (between 0 and 1)
  17444. * @param color defines the color to affect to the specified gradient
  17445. * @returns the current particle system
  17446. */
  17447. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17448. /**
  17449. * Gets the current list of ramp gradients.
  17450. * You must use addRampGradient and removeRampGradient to udpate this list
  17451. * @returns the list of ramp gradients
  17452. */
  17453. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17454. /** Gets or sets a boolean indicating that ramp gradients must be used
  17455. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17456. */
  17457. useRampGradients: boolean;
  17458. /**
  17459. * Adds a new color remap gradient
  17460. * @param gradient defines the gradient to use (between 0 and 1)
  17461. * @param min defines the color remap minimal range
  17462. * @param max defines the color remap maximal range
  17463. * @returns the current particle system
  17464. */
  17465. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17466. /**
  17467. * Gets the current list of color remap gradients.
  17468. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17469. * @returns the list of color remap gradients
  17470. */
  17471. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17472. /**
  17473. * Adds a new alpha remap gradient
  17474. * @param gradient defines the gradient to use (between 0 and 1)
  17475. * @param min defines the alpha remap minimal range
  17476. * @param max defines the alpha remap maximal range
  17477. * @returns the current particle system
  17478. */
  17479. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17480. /**
  17481. * Gets the current list of alpha remap gradients.
  17482. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17483. * @returns the list of alpha remap gradients
  17484. */
  17485. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17486. /**
  17487. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17488. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17489. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17490. * @returns the emitter
  17491. */
  17492. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17493. /**
  17494. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17495. * @param radius The radius of the hemisphere to emit from
  17496. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17497. * @returns the emitter
  17498. */
  17499. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17500. /**
  17501. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17502. * @param radius The radius of the sphere to emit from
  17503. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17504. * @returns the emitter
  17505. */
  17506. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17507. /**
  17508. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17509. * @param radius The radius of the sphere to emit from
  17510. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17511. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17512. * @returns the emitter
  17513. */
  17514. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17515. /**
  17516. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17517. * @param radius The radius of the emission cylinder
  17518. * @param height The height of the emission cylinder
  17519. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17520. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17521. * @returns the emitter
  17522. */
  17523. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17524. /**
  17525. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17526. * @param radius The radius of the cylinder to emit from
  17527. * @param height The height of the emission cylinder
  17528. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17529. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17530. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17531. * @returns the emitter
  17532. */
  17533. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17534. /**
  17535. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17536. * @param radius The radius of the cone to emit from
  17537. * @param angle The base angle of the cone
  17538. * @returns the emitter
  17539. */
  17540. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17541. /**
  17542. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17543. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17544. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17545. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17546. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17547. * @returns the emitter
  17548. */
  17549. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17550. /**
  17551. * Get hosting scene
  17552. * @returns the scene
  17553. */
  17554. getScene(): Nullable<Scene>;
  17555. }
  17556. }
  17557. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  17558. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  17559. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  17560. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  17561. /**
  17562. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17563. */
  17564. export class ColorSplitterBlock extends NodeMaterialBlock {
  17565. /**
  17566. * Create a new ColorSplitterBlock
  17567. * @param name defines the block name
  17568. */
  17569. constructor(name: string);
  17570. /**
  17571. * Gets the current class name
  17572. * @returns the class name
  17573. */
  17574. getClassName(): string;
  17575. /**
  17576. * Gets the rgba component (input)
  17577. */
  17578. get rgba(): NodeMaterialConnectionPoint;
  17579. /**
  17580. * Gets the rgb component (input)
  17581. */
  17582. get rgbIn(): NodeMaterialConnectionPoint;
  17583. /**
  17584. * Gets the rgb component (output)
  17585. */
  17586. get rgbOut(): NodeMaterialConnectionPoint;
  17587. /**
  17588. * Gets the r component (output)
  17589. */
  17590. get r(): NodeMaterialConnectionPoint;
  17591. /**
  17592. * Gets the g component (output)
  17593. */
  17594. get g(): NodeMaterialConnectionPoint;
  17595. /**
  17596. * Gets the b component (output)
  17597. */
  17598. get b(): NodeMaterialConnectionPoint;
  17599. /**
  17600. * Gets the a component (output)
  17601. */
  17602. get a(): NodeMaterialConnectionPoint;
  17603. protected _inputRename(name: string): string;
  17604. protected _outputRename(name: string): string;
  17605. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17606. }
  17607. }
  17608. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  17609. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  17610. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  17611. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  17612. import { Scene } from "babylonjs/scene";
  17613. /**
  17614. * Operations supported by the Trigonometry block
  17615. */
  17616. export enum TrigonometryBlockOperations {
  17617. /** Cos */
  17618. Cos = 0,
  17619. /** Sin */
  17620. Sin = 1,
  17621. /** Abs */
  17622. Abs = 2,
  17623. /** Exp */
  17624. Exp = 3,
  17625. /** Exp2 */
  17626. Exp2 = 4,
  17627. /** Round */
  17628. Round = 5,
  17629. /** Floor */
  17630. Floor = 6,
  17631. /** Ceiling */
  17632. Ceiling = 7,
  17633. /** Square root */
  17634. Sqrt = 8,
  17635. /** Log */
  17636. Log = 9,
  17637. /** Tangent */
  17638. Tan = 10,
  17639. /** Arc tangent */
  17640. ArcTan = 11,
  17641. /** Arc cosinus */
  17642. ArcCos = 12,
  17643. /** Arc sinus */
  17644. ArcSin = 13,
  17645. /** Fraction */
  17646. Fract = 14,
  17647. /** Sign */
  17648. Sign = 15,
  17649. /** To radians (from degrees) */
  17650. Radians = 16,
  17651. /** To degrees (from radians) */
  17652. Degrees = 17
  17653. }
  17654. /**
  17655. * Block used to apply trigonometry operation to floats
  17656. */
  17657. export class TrigonometryBlock extends NodeMaterialBlock {
  17658. /**
  17659. * Gets or sets the operation applied by the block
  17660. */
  17661. operation: TrigonometryBlockOperations;
  17662. /**
  17663. * Creates a new TrigonometryBlock
  17664. * @param name defines the block name
  17665. */
  17666. constructor(name: string);
  17667. /**
  17668. * Gets the current class name
  17669. * @returns the class name
  17670. */
  17671. getClassName(): string;
  17672. /**
  17673. * Gets the input component
  17674. */
  17675. get input(): NodeMaterialConnectionPoint;
  17676. /**
  17677. * Gets the output component
  17678. */
  17679. get output(): NodeMaterialConnectionPoint;
  17680. protected _buildBlock(state: NodeMaterialBuildState): this;
  17681. serialize(): any;
  17682. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17683. protected _dumpPropertiesCode(): string;
  17684. }
  17685. }
  17686. declare module "babylonjs/Materials/Node/nodeMaterial" {
  17687. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  17688. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  17689. import { Scene } from "babylonjs/scene";
  17690. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17691. import { Matrix } from "babylonjs/Maths/math.vector";
  17692. import { Mesh } from "babylonjs/Meshes/mesh";
  17693. import { Engine } from "babylonjs/Engines/engine";
  17694. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17695. import { Observable } from "babylonjs/Misc/observable";
  17696. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17697. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17698. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  17699. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17700. import { Nullable } from "babylonjs/types";
  17701. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  17702. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  17703. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  17704. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  17705. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  17706. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  17707. import { Effect } from "babylonjs/Materials/effect";
  17708. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  17709. import { Camera } from "babylonjs/Cameras/camera";
  17710. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  17711. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17712. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17713. /**
  17714. * Interface used to configure the node material editor
  17715. */
  17716. export interface INodeMaterialEditorOptions {
  17717. /** Define the URl to load node editor script */
  17718. editorURL?: string;
  17719. }
  17720. /** @hidden */
  17721. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17722. NORMAL: boolean;
  17723. TANGENT: boolean;
  17724. UV1: boolean;
  17725. /** BONES */
  17726. NUM_BONE_INFLUENCERS: number;
  17727. BonesPerMesh: number;
  17728. BONETEXTURE: boolean;
  17729. /** MORPH TARGETS */
  17730. MORPHTARGETS: boolean;
  17731. MORPHTARGETS_NORMAL: boolean;
  17732. MORPHTARGETS_TANGENT: boolean;
  17733. MORPHTARGETS_UV: boolean;
  17734. NUM_MORPH_INFLUENCERS: number;
  17735. /** IMAGE PROCESSING */
  17736. IMAGEPROCESSING: boolean;
  17737. VIGNETTE: boolean;
  17738. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17739. VIGNETTEBLENDMODEOPAQUE: boolean;
  17740. TONEMAPPING: boolean;
  17741. TONEMAPPING_ACES: boolean;
  17742. CONTRAST: boolean;
  17743. EXPOSURE: boolean;
  17744. COLORCURVES: boolean;
  17745. COLORGRADING: boolean;
  17746. COLORGRADING3D: boolean;
  17747. SAMPLER3DGREENDEPTH: boolean;
  17748. SAMPLER3DBGRMAP: boolean;
  17749. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17750. /** MISC. */
  17751. BUMPDIRECTUV: number;
  17752. constructor();
  17753. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17754. }
  17755. /**
  17756. * Class used to configure NodeMaterial
  17757. */
  17758. export interface INodeMaterialOptions {
  17759. /**
  17760. * Defines if blocks should emit comments
  17761. */
  17762. emitComments: boolean;
  17763. }
  17764. /**
  17765. * Class used to create a node based material built by assembling shader blocks
  17766. */
  17767. export class NodeMaterial extends PushMaterial {
  17768. private static _BuildIdGenerator;
  17769. private _options;
  17770. private _vertexCompilationState;
  17771. private _fragmentCompilationState;
  17772. private _sharedData;
  17773. private _buildId;
  17774. private _buildWasSuccessful;
  17775. private _cachedWorldViewMatrix;
  17776. private _cachedWorldViewProjectionMatrix;
  17777. private _optimizers;
  17778. private _animationFrame;
  17779. /** Define the Url to load node editor script */
  17780. static EditorURL: string;
  17781. /** Define the Url to load snippets */
  17782. static SnippetUrl: string;
  17783. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17784. static IgnoreTexturesAtLoadTime: boolean;
  17785. private BJSNODEMATERIALEDITOR;
  17786. /** Get the inspector from bundle or global */
  17787. private _getGlobalNodeMaterialEditor;
  17788. /**
  17789. * Snippet ID if the material was created from the snippet server
  17790. */
  17791. snippetId: string;
  17792. /**
  17793. * Gets or sets data used by visual editor
  17794. * @see https://nme.babylonjs.com
  17795. */
  17796. editorData: any;
  17797. /**
  17798. * 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)
  17799. */
  17800. ignoreAlpha: boolean;
  17801. /**
  17802. * Defines the maximum number of lights that can be used in the material
  17803. */
  17804. maxSimultaneousLights: number;
  17805. /**
  17806. * Observable raised when the material is built
  17807. */
  17808. onBuildObservable: Observable<NodeMaterial>;
  17809. /**
  17810. * Gets or sets the root nodes of the material vertex shader
  17811. */
  17812. _vertexOutputNodes: NodeMaterialBlock[];
  17813. /**
  17814. * Gets or sets the root nodes of the material fragment (pixel) shader
  17815. */
  17816. _fragmentOutputNodes: NodeMaterialBlock[];
  17817. /** Gets or sets options to control the node material overall behavior */
  17818. get options(): INodeMaterialOptions;
  17819. set options(options: INodeMaterialOptions);
  17820. /**
  17821. * Default configuration related to image processing available in the standard Material.
  17822. */
  17823. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17824. /**
  17825. * Gets the image processing configuration used either in this material.
  17826. */
  17827. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17828. /**
  17829. * Sets the Default image processing configuration used either in the this material.
  17830. *
  17831. * If sets to null, the scene one is in use.
  17832. */
  17833. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17834. /**
  17835. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17836. */
  17837. attachedBlocks: NodeMaterialBlock[];
  17838. /**
  17839. * Specifies the mode of the node material
  17840. * @hidden
  17841. */
  17842. _mode: NodeMaterialModes;
  17843. /**
  17844. * Gets the mode property
  17845. */
  17846. get mode(): NodeMaterialModes;
  17847. /**
  17848. * A free comment about the material
  17849. */
  17850. comment: string;
  17851. /**
  17852. * Create a new node based material
  17853. * @param name defines the material name
  17854. * @param scene defines the hosting scene
  17855. * @param options defines creation option
  17856. */
  17857. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  17858. /**
  17859. * Gets the current class name of the material e.g. "NodeMaterial"
  17860. * @returns the class name
  17861. */
  17862. getClassName(): string;
  17863. /**
  17864. * Keep track of the image processing observer to allow dispose and replace.
  17865. */
  17866. private _imageProcessingObserver;
  17867. /**
  17868. * Attaches a new image processing configuration to the Standard Material.
  17869. * @param configuration
  17870. */
  17871. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17872. /**
  17873. * Get a block by its name
  17874. * @param name defines the name of the block to retrieve
  17875. * @returns the required block or null if not found
  17876. */
  17877. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  17878. /**
  17879. * Get a block by its name
  17880. * @param predicate defines the predicate used to find the good candidate
  17881. * @returns the required block or null if not found
  17882. */
  17883. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  17884. /**
  17885. * Get an input block by its name
  17886. * @param predicate defines the predicate used to find the good candidate
  17887. * @returns the required input block or null if not found
  17888. */
  17889. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  17890. /**
  17891. * Gets the list of input blocks attached to this material
  17892. * @returns an array of InputBlocks
  17893. */
  17894. getInputBlocks(): InputBlock[];
  17895. /**
  17896. * Adds a new optimizer to the list of optimizers
  17897. * @param optimizer defines the optimizers to add
  17898. * @returns the current material
  17899. */
  17900. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17901. /**
  17902. * Remove an optimizer from the list of optimizers
  17903. * @param optimizer defines the optimizers to remove
  17904. * @returns the current material
  17905. */
  17906. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17907. /**
  17908. * Add a new block to the list of output nodes
  17909. * @param node defines the node to add
  17910. * @returns the current material
  17911. */
  17912. addOutputNode(node: NodeMaterialBlock): this;
  17913. /**
  17914. * Remove a block from the list of root nodes
  17915. * @param node defines the node to remove
  17916. * @returns the current material
  17917. */
  17918. removeOutputNode(node: NodeMaterialBlock): this;
  17919. private _addVertexOutputNode;
  17920. private _removeVertexOutputNode;
  17921. private _addFragmentOutputNode;
  17922. private _removeFragmentOutputNode;
  17923. /**
  17924. * Specifies if the material will require alpha blending
  17925. * @returns a boolean specifying if alpha blending is needed
  17926. */
  17927. needAlphaBlending(): boolean;
  17928. /**
  17929. * Specifies if this material should be rendered in alpha test mode
  17930. * @returns a boolean specifying if an alpha test is needed.
  17931. */
  17932. needAlphaTesting(): boolean;
  17933. private _initializeBlock;
  17934. private _resetDualBlocks;
  17935. /**
  17936. * Remove a block from the current node material
  17937. * @param block defines the block to remove
  17938. */
  17939. removeBlock(block: NodeMaterialBlock): void;
  17940. /**
  17941. * Build the material and generates the inner effect
  17942. * @param verbose defines if the build should log activity
  17943. */
  17944. build(verbose?: boolean): void;
  17945. /**
  17946. * Runs an otpimization phase to try to improve the shader code
  17947. */
  17948. optimize(): void;
  17949. private _prepareDefinesForAttributes;
  17950. /**
  17951. * Create a post process from the material
  17952. * @param camera The camera to apply the render pass to.
  17953. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  17954. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  17955. * @param engine The engine which the post process will be applied. (default: current engine)
  17956. * @param reusable If the post process can be reused on the same frame. (default: false)
  17957. * @param textureType Type of textures used when performing the post process. (default: 0)
  17958. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  17959. * @returns the post process created
  17960. */
  17961. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  17962. /**
  17963. * Create the post process effect from the material
  17964. * @param postProcess The post process to create the effect for
  17965. */
  17966. createEffectForPostProcess(postProcess: PostProcess): void;
  17967. private _createEffectForPostProcess;
  17968. /**
  17969. * Create a new procedural texture based on this node material
  17970. * @param size defines the size of the texture
  17971. * @param scene defines the hosting scene
  17972. * @returns the new procedural texture attached to this node material
  17973. */
  17974. createProceduralTexture(size: number | {
  17975. width: number;
  17976. height: number;
  17977. layers?: number;
  17978. }, scene: Scene): Nullable<ProceduralTexture>;
  17979. private _createEffectForParticles;
  17980. private _checkInternals;
  17981. /**
  17982. * Create the effect to be used as the custom effect for a particle system
  17983. * @param particleSystem Particle system to create the effect for
  17984. * @param onCompiled defines a function to call when the effect creation is successful
  17985. * @param onError defines a function to call when the effect creation has failed
  17986. */
  17987. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  17988. private _processDefines;
  17989. /**
  17990. * Get if the submesh is ready to be used and all its information available.
  17991. * Child classes can use it to update shaders
  17992. * @param mesh defines the mesh to check
  17993. * @param subMesh defines which submesh to check
  17994. * @param useInstances specifies that instances should be used
  17995. * @returns a boolean indicating that the submesh is ready or not
  17996. */
  17997. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17998. /**
  17999. * Get a string representing the shaders built by the current node graph
  18000. */
  18001. get compiledShaders(): string;
  18002. /**
  18003. * Binds the world matrix to the material
  18004. * @param world defines the world transformation matrix
  18005. */
  18006. bindOnlyWorldMatrix(world: Matrix): void;
  18007. /**
  18008. * Binds the submesh to this material by preparing the effect and shader to draw
  18009. * @param world defines the world transformation matrix
  18010. * @param mesh defines the mesh containing the submesh
  18011. * @param subMesh defines the submesh to bind the material to
  18012. */
  18013. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18014. /**
  18015. * Gets the active textures from the material
  18016. * @returns an array of textures
  18017. */
  18018. getActiveTextures(): BaseTexture[];
  18019. /**
  18020. * Gets the list of texture blocks
  18021. * @returns an array of texture blocks
  18022. */
  18023. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18024. /**
  18025. * Specifies if the material uses a texture
  18026. * @param texture defines the texture to check against the material
  18027. * @returns a boolean specifying if the material uses the texture
  18028. */
  18029. hasTexture(texture: BaseTexture): boolean;
  18030. /**
  18031. * Disposes the material
  18032. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18033. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18034. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18035. */
  18036. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18037. /** Creates the node editor window. */
  18038. private _createNodeEditor;
  18039. /**
  18040. * Launch the node material editor
  18041. * @param config Define the configuration of the editor
  18042. * @return a promise fulfilled when the node editor is visible
  18043. */
  18044. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18045. /**
  18046. * Clear the current material
  18047. */
  18048. clear(): void;
  18049. /**
  18050. * Clear the current material and set it to a default state
  18051. */
  18052. setToDefault(): void;
  18053. /**
  18054. * Clear the current material and set it to a default state for post process
  18055. */
  18056. setToDefaultPostProcess(): void;
  18057. /**
  18058. * Clear the current material and set it to a default state for procedural texture
  18059. */
  18060. setToDefaultProceduralTexture(): void;
  18061. /**
  18062. * Clear the current material and set it to a default state for particle
  18063. */
  18064. setToDefaultParticle(): void;
  18065. /**
  18066. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18067. * @param url defines the url to load from
  18068. * @returns a promise that will fullfil when the material is fully loaded
  18069. */
  18070. loadAsync(url: string): Promise<void>;
  18071. private _gatherBlocks;
  18072. /**
  18073. * Generate a string containing the code declaration required to create an equivalent of this material
  18074. * @returns a string
  18075. */
  18076. generateCode(): string;
  18077. /**
  18078. * Serializes this material in a JSON representation
  18079. * @returns the serialized material object
  18080. */
  18081. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18082. private _restoreConnections;
  18083. /**
  18084. * Clear the current graph and load a new one from a serialization object
  18085. * @param source defines the JSON representation of the material
  18086. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18087. * @param merge defines whether or not the source must be merged or replace the current content
  18088. */
  18089. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18090. /**
  18091. * Makes a duplicate of the current material.
  18092. * @param name - name to use for the new material.
  18093. */
  18094. clone(name: string): NodeMaterial;
  18095. /**
  18096. * Creates a node material from parsed material data
  18097. * @param source defines the JSON representation of the material
  18098. * @param scene defines the hosting scene
  18099. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18100. * @returns a new node material
  18101. */
  18102. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18103. /**
  18104. * Creates a node material from a snippet saved in a remote file
  18105. * @param name defines the name of the material to create
  18106. * @param url defines the url to load from
  18107. * @param scene defines the hosting scene
  18108. * @returns a promise that will resolve to the new node material
  18109. */
  18110. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18111. /**
  18112. * Creates a node material from a snippet saved by the node material editor
  18113. * @param snippetId defines the snippet to load
  18114. * @param scene defines the hosting scene
  18115. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18116. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18117. * @returns a promise that will resolve to the new node material
  18118. */
  18119. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18120. /**
  18121. * Creates a new node material set to default basic configuration
  18122. * @param name defines the name of the material
  18123. * @param scene defines the hosting scene
  18124. * @returns a new NodeMaterial
  18125. */
  18126. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18127. }
  18128. }
  18129. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  18130. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18131. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  18132. import { Nullable } from "babylonjs/types";
  18133. module "babylonjs/Engines/thinEngine" {
  18134. interface ThinEngine {
  18135. /**
  18136. * Unbind a list of render target textures from the webGL context
  18137. * This is used only when drawBuffer extension or webGL2 are active
  18138. * @param textures defines the render target textures to unbind
  18139. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18140. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18141. */
  18142. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18143. /**
  18144. * Create a multi render target texture
  18145. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18146. * @param size defines the size of the texture
  18147. * @param options defines the creation options
  18148. * @returns the cube texture as an InternalTexture
  18149. */
  18150. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  18151. /**
  18152. * Update the sample count for a given multiple render target texture
  18153. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18154. * @param textures defines the textures to update
  18155. * @param samples defines the sample count to set
  18156. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18157. */
  18158. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  18159. /**
  18160. * Select a subsets of attachments to draw to.
  18161. * @param attachments gl attachments
  18162. */
  18163. bindAttachments(attachments: number[]): void;
  18164. /**
  18165. * Creates a layout object to draw/clear on specific textures in a MRT
  18166. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18167. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18168. */
  18169. buildTextureLayout(textureStatus: boolean[]): number[];
  18170. /**
  18171. * Restores the webgl state to only draw on the main color attachment
  18172. */
  18173. restoreSingleAttachment(): void;
  18174. }
  18175. }
  18176. }
  18177. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  18178. import { Scene } from "babylonjs/scene";
  18179. import { Engine } from "babylonjs/Engines/engine";
  18180. import { Texture } from "babylonjs/Materials/Textures/texture";
  18181. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18182. import "babylonjs/Engines/Extensions/engine.multiRender";
  18183. /**
  18184. * Creation options of the multi render target texture.
  18185. */
  18186. export interface IMultiRenderTargetOptions {
  18187. /**
  18188. * Define if the texture needs to create mip maps after render.
  18189. */
  18190. generateMipMaps?: boolean;
  18191. /**
  18192. * Define the types of all the draw buffers we want to create
  18193. */
  18194. types?: number[];
  18195. /**
  18196. * Define the sampling modes of all the draw buffers we want to create
  18197. */
  18198. samplingModes?: number[];
  18199. /**
  18200. * Define if a depth buffer is required
  18201. */
  18202. generateDepthBuffer?: boolean;
  18203. /**
  18204. * Define if a stencil buffer is required
  18205. */
  18206. generateStencilBuffer?: boolean;
  18207. /**
  18208. * Define if a depth texture is required instead of a depth buffer
  18209. */
  18210. generateDepthTexture?: boolean;
  18211. /**
  18212. * Define the number of desired draw buffers
  18213. */
  18214. textureCount?: number;
  18215. /**
  18216. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18217. */
  18218. doNotChangeAspectRatio?: boolean;
  18219. /**
  18220. * Define the default type of the buffers we are creating
  18221. */
  18222. defaultType?: number;
  18223. }
  18224. /**
  18225. * A multi render target, like a render target provides the ability to render to a texture.
  18226. * Unlike the render target, it can render to several draw buffers in one draw.
  18227. * This is specially interesting in deferred rendering or for any effects requiring more than
  18228. * just one color from a single pass.
  18229. */
  18230. export class MultiRenderTarget extends RenderTargetTexture {
  18231. private _internalTextures;
  18232. private _textures;
  18233. private _multiRenderTargetOptions;
  18234. private _count;
  18235. /**
  18236. * Get if draw buffers are currently supported by the used hardware and browser.
  18237. */
  18238. get isSupported(): boolean;
  18239. /**
  18240. * Get the list of textures generated by the multi render target.
  18241. */
  18242. get textures(): Texture[];
  18243. /**
  18244. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18245. */
  18246. get count(): number;
  18247. /**
  18248. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18249. */
  18250. get depthTexture(): Texture;
  18251. /**
  18252. * Set the wrapping mode on U of all the textures we are rendering to.
  18253. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18254. */
  18255. set wrapU(wrap: number);
  18256. /**
  18257. * Set the wrapping mode on V of all the textures we are rendering to.
  18258. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18259. */
  18260. set wrapV(wrap: number);
  18261. /**
  18262. * Instantiate a new multi render target texture.
  18263. * A multi render target, like a render target provides the ability to render to a texture.
  18264. * Unlike the render target, it can render to several draw buffers in one draw.
  18265. * This is specially interesting in deferred rendering or for any effects requiring more than
  18266. * just one color from a single pass.
  18267. * @param name Define the name of the texture
  18268. * @param size Define the size of the buffers to render to
  18269. * @param count Define the number of target we are rendering into
  18270. * @param scene Define the scene the texture belongs to
  18271. * @param options Define the options used to create the multi render target
  18272. */
  18273. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18274. private _initTypes;
  18275. /** @hidden */
  18276. _rebuild(forceFullRebuild?: boolean): void;
  18277. private _createInternalTextures;
  18278. private _createTextures;
  18279. /**
  18280. * Replaces a texture within the MRT.
  18281. * @param texture The new texture to insert in the MRT
  18282. * @param index The index of the texture to replace
  18283. */
  18284. replaceTexture(texture: Texture, index: number): void;
  18285. /**
  18286. * Define the number of samples used if MSAA is enabled.
  18287. */
  18288. get samples(): number;
  18289. set samples(value: number);
  18290. /**
  18291. * Resize all the textures in the multi render target.
  18292. * Be careful as it will recreate all the data in the new texture.
  18293. * @param size Define the new size
  18294. */
  18295. resize(size: any): void;
  18296. /**
  18297. * Changes the number of render targets in this MRT
  18298. * Be careful as it will recreate all the data in the new texture.
  18299. * @param count new texture count
  18300. * @param options Specifies texture types and sampling modes for new textures
  18301. */
  18302. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18303. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18304. /**
  18305. * Dispose the render targets and their associated resources
  18306. */
  18307. dispose(): void;
  18308. /**
  18309. * Release all the underlying texture used as draw buffers.
  18310. */
  18311. releaseInternalTextures(): void;
  18312. }
  18313. }
  18314. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  18315. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  18316. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  18317. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  18318. /** @hidden */
  18319. export var imageProcessingPixelShader: {
  18320. name: string;
  18321. shader: string;
  18322. };
  18323. }
  18324. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  18325. import { Nullable } from "babylonjs/types";
  18326. import { Color4 } from "babylonjs/Maths/math.color";
  18327. import { Camera } from "babylonjs/Cameras/camera";
  18328. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18329. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  18330. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  18331. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18332. import { Engine } from "babylonjs/Engines/engine";
  18333. import "babylonjs/Shaders/imageProcessing.fragment";
  18334. import "babylonjs/Shaders/postprocess.vertex";
  18335. /**
  18336. * ImageProcessingPostProcess
  18337. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18338. */
  18339. export class ImageProcessingPostProcess extends PostProcess {
  18340. /**
  18341. * Default configuration related to image processing available in the PBR Material.
  18342. */
  18343. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18344. /**
  18345. * Gets the image processing configuration used either in this material.
  18346. */
  18347. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18348. /**
  18349. * Sets the Default image processing configuration used either in the this material.
  18350. *
  18351. * If sets to null, the scene one is in use.
  18352. */
  18353. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18354. /**
  18355. * Keep track of the image processing observer to allow dispose and replace.
  18356. */
  18357. private _imageProcessingObserver;
  18358. /**
  18359. * Attaches a new image processing configuration to the PBR Material.
  18360. * @param configuration
  18361. */
  18362. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18363. /**
  18364. * If the post process is supported.
  18365. */
  18366. get isSupported(): boolean;
  18367. /**
  18368. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18369. */
  18370. get colorCurves(): Nullable<ColorCurves>;
  18371. /**
  18372. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18373. */
  18374. set colorCurves(value: Nullable<ColorCurves>);
  18375. /**
  18376. * Gets wether the color curves effect is enabled.
  18377. */
  18378. get colorCurvesEnabled(): boolean;
  18379. /**
  18380. * Sets wether the color curves effect is enabled.
  18381. */
  18382. set colorCurvesEnabled(value: boolean);
  18383. /**
  18384. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18385. */
  18386. get colorGradingTexture(): Nullable<BaseTexture>;
  18387. /**
  18388. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18389. */
  18390. set colorGradingTexture(value: Nullable<BaseTexture>);
  18391. /**
  18392. * Gets wether the color grading effect is enabled.
  18393. */
  18394. get colorGradingEnabled(): boolean;
  18395. /**
  18396. * Gets wether the color grading effect is enabled.
  18397. */
  18398. set colorGradingEnabled(value: boolean);
  18399. /**
  18400. * Gets exposure used in the effect.
  18401. */
  18402. get exposure(): number;
  18403. /**
  18404. * Sets exposure used in the effect.
  18405. */
  18406. set exposure(value: number);
  18407. /**
  18408. * Gets wether tonemapping is enabled or not.
  18409. */
  18410. get toneMappingEnabled(): boolean;
  18411. /**
  18412. * Sets wether tonemapping is enabled or not
  18413. */
  18414. set toneMappingEnabled(value: boolean);
  18415. /**
  18416. * Gets the type of tone mapping effect.
  18417. */
  18418. get toneMappingType(): number;
  18419. /**
  18420. * Sets the type of tone mapping effect.
  18421. */
  18422. set toneMappingType(value: number);
  18423. /**
  18424. * Gets contrast used in the effect.
  18425. */
  18426. get contrast(): number;
  18427. /**
  18428. * Sets contrast used in the effect.
  18429. */
  18430. set contrast(value: number);
  18431. /**
  18432. * Gets Vignette stretch size.
  18433. */
  18434. get vignetteStretch(): number;
  18435. /**
  18436. * Sets Vignette stretch size.
  18437. */
  18438. set vignetteStretch(value: number);
  18439. /**
  18440. * Gets Vignette centre X Offset.
  18441. */
  18442. get vignetteCentreX(): number;
  18443. /**
  18444. * Sets Vignette centre X Offset.
  18445. */
  18446. set vignetteCentreX(value: number);
  18447. /**
  18448. * Gets Vignette centre Y Offset.
  18449. */
  18450. get vignetteCentreY(): number;
  18451. /**
  18452. * Sets Vignette centre Y Offset.
  18453. */
  18454. set vignetteCentreY(value: number);
  18455. /**
  18456. * Gets Vignette weight or intensity of the vignette effect.
  18457. */
  18458. get vignetteWeight(): number;
  18459. /**
  18460. * Sets Vignette weight or intensity of the vignette effect.
  18461. */
  18462. set vignetteWeight(value: number);
  18463. /**
  18464. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18465. * if vignetteEnabled is set to true.
  18466. */
  18467. get vignetteColor(): Color4;
  18468. /**
  18469. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18470. * if vignetteEnabled is set to true.
  18471. */
  18472. set vignetteColor(value: Color4);
  18473. /**
  18474. * Gets Camera field of view used by the Vignette effect.
  18475. */
  18476. get vignetteCameraFov(): number;
  18477. /**
  18478. * Sets Camera field of view used by the Vignette effect.
  18479. */
  18480. set vignetteCameraFov(value: number);
  18481. /**
  18482. * Gets the vignette blend mode allowing different kind of effect.
  18483. */
  18484. get vignetteBlendMode(): number;
  18485. /**
  18486. * Sets the vignette blend mode allowing different kind of effect.
  18487. */
  18488. set vignetteBlendMode(value: number);
  18489. /**
  18490. * Gets wether the vignette effect is enabled.
  18491. */
  18492. get vignetteEnabled(): boolean;
  18493. /**
  18494. * Sets wether the vignette effect is enabled.
  18495. */
  18496. set vignetteEnabled(value: boolean);
  18497. private _fromLinearSpace;
  18498. /**
  18499. * Gets wether the input of the processing is in Gamma or Linear Space.
  18500. */
  18501. get fromLinearSpace(): boolean;
  18502. /**
  18503. * Sets wether the input of the processing is in Gamma or Linear Space.
  18504. */
  18505. set fromLinearSpace(value: boolean);
  18506. /**
  18507. * Defines cache preventing GC.
  18508. */
  18509. private _defines;
  18510. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  18511. /**
  18512. * "ImageProcessingPostProcess"
  18513. * @returns "ImageProcessingPostProcess"
  18514. */
  18515. getClassName(): string;
  18516. /**
  18517. * @hidden
  18518. */
  18519. _updateParameters(): void;
  18520. dispose(camera?: Camera): void;
  18521. }
  18522. }
  18523. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  18524. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18525. /**
  18526. * Interface for defining prepass effects in the prepass post-process pipeline
  18527. */
  18528. export interface PrePassEffectConfiguration {
  18529. /**
  18530. * Name of the effect
  18531. */
  18532. name: string;
  18533. /**
  18534. * Post process to attach for this effect
  18535. */
  18536. postProcess?: PostProcess;
  18537. /**
  18538. * Textures required in the MRT
  18539. */
  18540. texturesRequired: number[];
  18541. /**
  18542. * Is the effect enabled
  18543. */
  18544. enabled: boolean;
  18545. /**
  18546. * Disposes the effect configuration
  18547. */
  18548. dispose?: () => void;
  18549. /**
  18550. * Creates the associated post process
  18551. */
  18552. createPostProcess?: () => PostProcess;
  18553. }
  18554. }
  18555. declare module "babylonjs/Materials/fresnelParameters" {
  18556. import { DeepImmutable } from "babylonjs/types";
  18557. import { Color3 } from "babylonjs/Maths/math.color";
  18558. /**
  18559. * Options to be used when creating a FresnelParameters.
  18560. */
  18561. export type IFresnelParametersCreationOptions = {
  18562. /**
  18563. * Define the color used on edges (grazing angle)
  18564. */
  18565. leftColor?: Color3;
  18566. /**
  18567. * Define the color used on center
  18568. */
  18569. rightColor?: Color3;
  18570. /**
  18571. * Define bias applied to computed fresnel term
  18572. */
  18573. bias?: number;
  18574. /**
  18575. * Defined the power exponent applied to fresnel term
  18576. */
  18577. power?: number;
  18578. /**
  18579. * Define if the fresnel effect is enable or not.
  18580. */
  18581. isEnabled?: boolean;
  18582. };
  18583. /**
  18584. * Serialized format for FresnelParameters.
  18585. */
  18586. export type IFresnelParametersSerialized = {
  18587. /**
  18588. * Define the color used on edges (grazing angle) [as an array]
  18589. */
  18590. leftColor: number[];
  18591. /**
  18592. * Define the color used on center [as an array]
  18593. */
  18594. rightColor: number[];
  18595. /**
  18596. * Define bias applied to computed fresnel term
  18597. */
  18598. bias: number;
  18599. /**
  18600. * Defined the power exponent applied to fresnel term
  18601. */
  18602. power?: number;
  18603. /**
  18604. * Define if the fresnel effect is enable or not.
  18605. */
  18606. isEnabled: boolean;
  18607. };
  18608. /**
  18609. * This represents all the required information to add a fresnel effect on a material:
  18610. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18611. */
  18612. export class FresnelParameters {
  18613. private _isEnabled;
  18614. /**
  18615. * Define if the fresnel effect is enable or not.
  18616. */
  18617. get isEnabled(): boolean;
  18618. set isEnabled(value: boolean);
  18619. /**
  18620. * Define the color used on edges (grazing angle)
  18621. */
  18622. leftColor: Color3;
  18623. /**
  18624. * Define the color used on center
  18625. */
  18626. rightColor: Color3;
  18627. /**
  18628. * Define bias applied to computed fresnel term
  18629. */
  18630. bias: number;
  18631. /**
  18632. * Defined the power exponent applied to fresnel term
  18633. */
  18634. power: number;
  18635. /**
  18636. * Creates a new FresnelParameters object.
  18637. *
  18638. * @param options provide your own settings to optionally to override defaults
  18639. */
  18640. constructor(options?: IFresnelParametersCreationOptions);
  18641. /**
  18642. * Clones the current fresnel and its valuues
  18643. * @returns a clone fresnel configuration
  18644. */
  18645. clone(): FresnelParameters;
  18646. /**
  18647. * Determines equality between FresnelParameters objects
  18648. * @param otherFresnelParameters defines the second operand
  18649. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18650. */
  18651. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18652. /**
  18653. * Serializes the current fresnel parameters to a JSON representation.
  18654. * @return the JSON serialization
  18655. */
  18656. serialize(): IFresnelParametersSerialized;
  18657. /**
  18658. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18659. * @param parsedFresnelParameters Define the JSON representation
  18660. * @returns the parsed parameters
  18661. */
  18662. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18663. }
  18664. }
  18665. declare module "babylonjs/Materials/materialFlags" {
  18666. /**
  18667. * This groups all the flags used to control the materials channel.
  18668. */
  18669. export class MaterialFlags {
  18670. private static _DiffuseTextureEnabled;
  18671. /**
  18672. * Are diffuse textures enabled in the application.
  18673. */
  18674. static get DiffuseTextureEnabled(): boolean;
  18675. static set DiffuseTextureEnabled(value: boolean);
  18676. private static _DetailTextureEnabled;
  18677. /**
  18678. * Are detail textures enabled in the application.
  18679. */
  18680. static get DetailTextureEnabled(): boolean;
  18681. static set DetailTextureEnabled(value: boolean);
  18682. private static _AmbientTextureEnabled;
  18683. /**
  18684. * Are ambient textures enabled in the application.
  18685. */
  18686. static get AmbientTextureEnabled(): boolean;
  18687. static set AmbientTextureEnabled(value: boolean);
  18688. private static _OpacityTextureEnabled;
  18689. /**
  18690. * Are opacity textures enabled in the application.
  18691. */
  18692. static get OpacityTextureEnabled(): boolean;
  18693. static set OpacityTextureEnabled(value: boolean);
  18694. private static _ReflectionTextureEnabled;
  18695. /**
  18696. * Are reflection textures enabled in the application.
  18697. */
  18698. static get ReflectionTextureEnabled(): boolean;
  18699. static set ReflectionTextureEnabled(value: boolean);
  18700. private static _EmissiveTextureEnabled;
  18701. /**
  18702. * Are emissive textures enabled in the application.
  18703. */
  18704. static get EmissiveTextureEnabled(): boolean;
  18705. static set EmissiveTextureEnabled(value: boolean);
  18706. private static _SpecularTextureEnabled;
  18707. /**
  18708. * Are specular textures enabled in the application.
  18709. */
  18710. static get SpecularTextureEnabled(): boolean;
  18711. static set SpecularTextureEnabled(value: boolean);
  18712. private static _BumpTextureEnabled;
  18713. /**
  18714. * Are bump textures enabled in the application.
  18715. */
  18716. static get BumpTextureEnabled(): boolean;
  18717. static set BumpTextureEnabled(value: boolean);
  18718. private static _LightmapTextureEnabled;
  18719. /**
  18720. * Are lightmap textures enabled in the application.
  18721. */
  18722. static get LightmapTextureEnabled(): boolean;
  18723. static set LightmapTextureEnabled(value: boolean);
  18724. private static _RefractionTextureEnabled;
  18725. /**
  18726. * Are refraction textures enabled in the application.
  18727. */
  18728. static get RefractionTextureEnabled(): boolean;
  18729. static set RefractionTextureEnabled(value: boolean);
  18730. private static _ColorGradingTextureEnabled;
  18731. /**
  18732. * Are color grading textures enabled in the application.
  18733. */
  18734. static get ColorGradingTextureEnabled(): boolean;
  18735. static set ColorGradingTextureEnabled(value: boolean);
  18736. private static _FresnelEnabled;
  18737. /**
  18738. * Are fresnels enabled in the application.
  18739. */
  18740. static get FresnelEnabled(): boolean;
  18741. static set FresnelEnabled(value: boolean);
  18742. private static _ClearCoatTextureEnabled;
  18743. /**
  18744. * Are clear coat textures enabled in the application.
  18745. */
  18746. static get ClearCoatTextureEnabled(): boolean;
  18747. static set ClearCoatTextureEnabled(value: boolean);
  18748. private static _ClearCoatBumpTextureEnabled;
  18749. /**
  18750. * Are clear coat bump textures enabled in the application.
  18751. */
  18752. static get ClearCoatBumpTextureEnabled(): boolean;
  18753. static set ClearCoatBumpTextureEnabled(value: boolean);
  18754. private static _ClearCoatTintTextureEnabled;
  18755. /**
  18756. * Are clear coat tint textures enabled in the application.
  18757. */
  18758. static get ClearCoatTintTextureEnabled(): boolean;
  18759. static set ClearCoatTintTextureEnabled(value: boolean);
  18760. private static _SheenTextureEnabled;
  18761. /**
  18762. * Are sheen textures enabled in the application.
  18763. */
  18764. static get SheenTextureEnabled(): boolean;
  18765. static set SheenTextureEnabled(value: boolean);
  18766. private static _AnisotropicTextureEnabled;
  18767. /**
  18768. * Are anisotropic textures enabled in the application.
  18769. */
  18770. static get AnisotropicTextureEnabled(): boolean;
  18771. static set AnisotropicTextureEnabled(value: boolean);
  18772. private static _ThicknessTextureEnabled;
  18773. /**
  18774. * Are thickness textures enabled in the application.
  18775. */
  18776. static get ThicknessTextureEnabled(): boolean;
  18777. static set ThicknessTextureEnabled(value: boolean);
  18778. }
  18779. }
  18780. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  18781. /** @hidden */
  18782. export var defaultFragmentDeclaration: {
  18783. name: string;
  18784. shader: string;
  18785. };
  18786. }
  18787. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  18788. /** @hidden */
  18789. export var defaultUboDeclaration: {
  18790. name: string;
  18791. shader: string;
  18792. };
  18793. }
  18794. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  18795. /** @hidden */
  18796. export var prePassDeclaration: {
  18797. name: string;
  18798. shader: string;
  18799. };
  18800. }
  18801. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  18802. /** @hidden */
  18803. export var lightFragmentDeclaration: {
  18804. name: string;
  18805. shader: string;
  18806. };
  18807. }
  18808. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  18809. /** @hidden */
  18810. export var lightUboDeclaration: {
  18811. name: string;
  18812. shader: string;
  18813. };
  18814. }
  18815. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  18816. /** @hidden */
  18817. export var lightsFragmentFunctions: {
  18818. name: string;
  18819. shader: string;
  18820. };
  18821. }
  18822. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  18823. /** @hidden */
  18824. export var shadowsFragmentFunctions: {
  18825. name: string;
  18826. shader: string;
  18827. };
  18828. }
  18829. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  18830. /** @hidden */
  18831. export var fresnelFunction: {
  18832. name: string;
  18833. shader: string;
  18834. };
  18835. }
  18836. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  18837. /** @hidden */
  18838. export var bumpFragmentMainFunctions: {
  18839. name: string;
  18840. shader: string;
  18841. };
  18842. }
  18843. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  18844. /** @hidden */
  18845. export var bumpFragmentFunctions: {
  18846. name: string;
  18847. shader: string;
  18848. };
  18849. }
  18850. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  18851. /** @hidden */
  18852. export var logDepthDeclaration: {
  18853. name: string;
  18854. shader: string;
  18855. };
  18856. }
  18857. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  18858. /** @hidden */
  18859. export var fogFragmentDeclaration: {
  18860. name: string;
  18861. shader: string;
  18862. };
  18863. }
  18864. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  18865. /** @hidden */
  18866. export var bumpFragment: {
  18867. name: string;
  18868. shader: string;
  18869. };
  18870. }
  18871. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  18872. /** @hidden */
  18873. export var depthPrePass: {
  18874. name: string;
  18875. shader: string;
  18876. };
  18877. }
  18878. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  18879. /** @hidden */
  18880. export var lightFragment: {
  18881. name: string;
  18882. shader: string;
  18883. };
  18884. }
  18885. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  18886. /** @hidden */
  18887. export var logDepthFragment: {
  18888. name: string;
  18889. shader: string;
  18890. };
  18891. }
  18892. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  18893. /** @hidden */
  18894. export var fogFragment: {
  18895. name: string;
  18896. shader: string;
  18897. };
  18898. }
  18899. declare module "babylonjs/Shaders/default.fragment" {
  18900. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  18901. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  18902. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  18903. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  18904. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  18905. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  18906. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  18907. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  18908. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  18909. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  18910. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  18911. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  18912. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  18913. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  18914. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  18915. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  18916. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  18917. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  18918. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  18919. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  18920. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  18921. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  18922. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  18923. /** @hidden */
  18924. export var defaultPixelShader: {
  18925. name: string;
  18926. shader: string;
  18927. };
  18928. }
  18929. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  18930. /** @hidden */
  18931. export var defaultVertexDeclaration: {
  18932. name: string;
  18933. shader: string;
  18934. };
  18935. }
  18936. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  18937. /** @hidden */
  18938. export var bonesDeclaration: {
  18939. name: string;
  18940. shader: string;
  18941. };
  18942. }
  18943. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  18944. /** @hidden */
  18945. export var instancesDeclaration: {
  18946. name: string;
  18947. shader: string;
  18948. };
  18949. }
  18950. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  18951. /** @hidden */
  18952. export var prePassVertexDeclaration: {
  18953. name: string;
  18954. shader: string;
  18955. };
  18956. }
  18957. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  18958. /** @hidden */
  18959. export var bumpVertexDeclaration: {
  18960. name: string;
  18961. shader: string;
  18962. };
  18963. }
  18964. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  18965. /** @hidden */
  18966. export var fogVertexDeclaration: {
  18967. name: string;
  18968. shader: string;
  18969. };
  18970. }
  18971. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  18972. /** @hidden */
  18973. export var morphTargetsVertexGlobalDeclaration: {
  18974. name: string;
  18975. shader: string;
  18976. };
  18977. }
  18978. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  18979. /** @hidden */
  18980. export var morphTargetsVertexDeclaration: {
  18981. name: string;
  18982. shader: string;
  18983. };
  18984. }
  18985. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  18986. /** @hidden */
  18987. export var morphTargetsVertex: {
  18988. name: string;
  18989. shader: string;
  18990. };
  18991. }
  18992. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  18993. /** @hidden */
  18994. export var instancesVertex: {
  18995. name: string;
  18996. shader: string;
  18997. };
  18998. }
  18999. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  19000. /** @hidden */
  19001. export var bonesVertex: {
  19002. name: string;
  19003. shader: string;
  19004. };
  19005. }
  19006. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  19007. /** @hidden */
  19008. export var prePassVertex: {
  19009. name: string;
  19010. shader: string;
  19011. };
  19012. }
  19013. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  19014. /** @hidden */
  19015. export var bumpVertex: {
  19016. name: string;
  19017. shader: string;
  19018. };
  19019. }
  19020. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  19021. /** @hidden */
  19022. export var fogVertex: {
  19023. name: string;
  19024. shader: string;
  19025. };
  19026. }
  19027. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  19028. /** @hidden */
  19029. export var shadowsVertex: {
  19030. name: string;
  19031. shader: string;
  19032. };
  19033. }
  19034. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  19035. /** @hidden */
  19036. export var pointCloudVertex: {
  19037. name: string;
  19038. shader: string;
  19039. };
  19040. }
  19041. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  19042. /** @hidden */
  19043. export var logDepthVertex: {
  19044. name: string;
  19045. shader: string;
  19046. };
  19047. }
  19048. declare module "babylonjs/Shaders/default.vertex" {
  19049. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  19050. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  19051. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19052. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19053. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19054. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  19055. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  19056. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19057. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  19058. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  19059. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  19060. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  19061. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  19062. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  19063. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  19064. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19065. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19066. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  19067. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  19068. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19069. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  19070. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  19071. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  19072. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  19073. /** @hidden */
  19074. export var defaultVertexShader: {
  19075. name: string;
  19076. shader: string;
  19077. };
  19078. }
  19079. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  19080. import { Nullable } from "babylonjs/types";
  19081. import { Scene } from "babylonjs/scene";
  19082. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19083. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19084. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19085. /**
  19086. * @hidden
  19087. */
  19088. export interface IMaterialDetailMapDefines {
  19089. DETAIL: boolean;
  19090. DETAILDIRECTUV: number;
  19091. DETAIL_NORMALBLENDMETHOD: number;
  19092. /** @hidden */
  19093. _areTexturesDirty: boolean;
  19094. }
  19095. /**
  19096. * Define the code related to the detail map parameters of a material
  19097. *
  19098. * Inspired from:
  19099. * 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
  19100. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19101. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19102. */
  19103. export class DetailMapConfiguration {
  19104. private _texture;
  19105. /**
  19106. * The detail texture of the material.
  19107. */
  19108. texture: Nullable<BaseTexture>;
  19109. /**
  19110. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19111. * Bigger values mean stronger blending
  19112. */
  19113. diffuseBlendLevel: number;
  19114. /**
  19115. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19116. * Bigger values mean stronger blending. Only used with PBR materials
  19117. */
  19118. roughnessBlendLevel: number;
  19119. /**
  19120. * Defines how strong the bump effect from the detail map is
  19121. * Bigger values mean stronger effect
  19122. */
  19123. bumpLevel: number;
  19124. private _normalBlendMethod;
  19125. /**
  19126. * The method used to blend the bump and detail normals together
  19127. */
  19128. normalBlendMethod: number;
  19129. private _isEnabled;
  19130. /**
  19131. * Enable or disable the detail map on this material
  19132. */
  19133. isEnabled: boolean;
  19134. /** @hidden */
  19135. private _internalMarkAllSubMeshesAsTexturesDirty;
  19136. /** @hidden */
  19137. _markAllSubMeshesAsTexturesDirty(): void;
  19138. /**
  19139. * Instantiate a new detail map
  19140. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19141. */
  19142. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19143. /**
  19144. * Gets whether the submesh is ready to be used or not.
  19145. * @param defines the list of "defines" to update.
  19146. * @param scene defines the scene the material belongs to.
  19147. * @returns - boolean indicating that the submesh is ready or not.
  19148. */
  19149. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19150. /**
  19151. * Update the defines for detail map usage
  19152. * @param defines the list of "defines" to update.
  19153. * @param scene defines the scene the material belongs to.
  19154. */
  19155. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19156. /**
  19157. * Binds the material data.
  19158. * @param uniformBuffer defines the Uniform buffer to fill in.
  19159. * @param scene defines the scene the material belongs to.
  19160. * @param isFrozen defines whether the material is frozen or not.
  19161. */
  19162. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19163. /**
  19164. * Checks to see if a texture is used in the material.
  19165. * @param texture - Base texture to use.
  19166. * @returns - Boolean specifying if a texture is used in the material.
  19167. */
  19168. hasTexture(texture: BaseTexture): boolean;
  19169. /**
  19170. * Returns an array of the actively used textures.
  19171. * @param activeTextures Array of BaseTextures
  19172. */
  19173. getActiveTextures(activeTextures: BaseTexture[]): void;
  19174. /**
  19175. * Returns the animatable textures.
  19176. * @param animatables Array of animatable textures.
  19177. */
  19178. getAnimatables(animatables: IAnimatable[]): void;
  19179. /**
  19180. * Disposes the resources of the material.
  19181. * @param forceDisposeTextures - Forces the disposal of all textures.
  19182. */
  19183. dispose(forceDisposeTextures?: boolean): void;
  19184. /**
  19185. * Get the current class name useful for serialization or dynamic coding.
  19186. * @returns "DetailMap"
  19187. */
  19188. getClassName(): string;
  19189. /**
  19190. * Add the required uniforms to the current list.
  19191. * @param uniforms defines the current uniform list.
  19192. */
  19193. static AddUniforms(uniforms: string[]): void;
  19194. /**
  19195. * Add the required samplers to the current list.
  19196. * @param samplers defines the current sampler list.
  19197. */
  19198. static AddSamplers(samplers: string[]): void;
  19199. /**
  19200. * Add the required uniforms to the current buffer.
  19201. * @param uniformBuffer defines the current uniform buffer.
  19202. */
  19203. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19204. /**
  19205. * Makes a duplicate of the current instance into another one.
  19206. * @param detailMap define the instance where to copy the info
  19207. */
  19208. copyTo(detailMap: DetailMapConfiguration): void;
  19209. /**
  19210. * Serializes this detail map instance
  19211. * @returns - An object with the serialized instance.
  19212. */
  19213. serialize(): any;
  19214. /**
  19215. * Parses a detail map setting from a serialized object.
  19216. * @param source - Serialized object.
  19217. * @param scene Defines the scene we are parsing for
  19218. * @param rootUrl Defines the rootUrl to load from
  19219. */
  19220. parse(source: any, scene: Scene, rootUrl: string): void;
  19221. }
  19222. }
  19223. declare module "babylonjs/Materials/standardMaterial" {
  19224. import { SmartArray } from "babylonjs/Misc/smartArray";
  19225. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19226. import { Nullable } from "babylonjs/types";
  19227. import { Scene } from "babylonjs/scene";
  19228. import { Matrix } from "babylonjs/Maths/math.vector";
  19229. import { Color3 } from "babylonjs/Maths/math.color";
  19230. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19232. import { Mesh } from "babylonjs/Meshes/mesh";
  19233. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  19234. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  19235. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  19236. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  19237. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  19238. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  19239. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19240. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19241. import "babylonjs/Shaders/default.fragment";
  19242. import "babylonjs/Shaders/default.vertex";
  19243. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  19244. /** @hidden */
  19245. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19246. MAINUV1: boolean;
  19247. MAINUV2: boolean;
  19248. DIFFUSE: boolean;
  19249. DIFFUSEDIRECTUV: number;
  19250. DETAIL: boolean;
  19251. DETAILDIRECTUV: number;
  19252. DETAIL_NORMALBLENDMETHOD: number;
  19253. AMBIENT: boolean;
  19254. AMBIENTDIRECTUV: number;
  19255. OPACITY: boolean;
  19256. OPACITYDIRECTUV: number;
  19257. OPACITYRGB: boolean;
  19258. REFLECTION: boolean;
  19259. EMISSIVE: boolean;
  19260. EMISSIVEDIRECTUV: number;
  19261. SPECULAR: boolean;
  19262. SPECULARDIRECTUV: number;
  19263. BUMP: boolean;
  19264. BUMPDIRECTUV: number;
  19265. PARALLAX: boolean;
  19266. PARALLAXOCCLUSION: boolean;
  19267. SPECULAROVERALPHA: boolean;
  19268. CLIPPLANE: boolean;
  19269. CLIPPLANE2: boolean;
  19270. CLIPPLANE3: boolean;
  19271. CLIPPLANE4: boolean;
  19272. CLIPPLANE5: boolean;
  19273. CLIPPLANE6: boolean;
  19274. ALPHATEST: boolean;
  19275. DEPTHPREPASS: boolean;
  19276. ALPHAFROMDIFFUSE: boolean;
  19277. POINTSIZE: boolean;
  19278. FOG: boolean;
  19279. SPECULARTERM: boolean;
  19280. DIFFUSEFRESNEL: boolean;
  19281. OPACITYFRESNEL: boolean;
  19282. REFLECTIONFRESNEL: boolean;
  19283. REFRACTIONFRESNEL: boolean;
  19284. EMISSIVEFRESNEL: boolean;
  19285. FRESNEL: boolean;
  19286. NORMAL: boolean;
  19287. UV1: boolean;
  19288. UV2: boolean;
  19289. VERTEXCOLOR: boolean;
  19290. VERTEXALPHA: boolean;
  19291. NUM_BONE_INFLUENCERS: number;
  19292. BonesPerMesh: number;
  19293. BONETEXTURE: boolean;
  19294. BONES_VELOCITY_ENABLED: boolean;
  19295. INSTANCES: boolean;
  19296. THIN_INSTANCES: boolean;
  19297. GLOSSINESS: boolean;
  19298. ROUGHNESS: boolean;
  19299. EMISSIVEASILLUMINATION: boolean;
  19300. LINKEMISSIVEWITHDIFFUSE: boolean;
  19301. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19302. LIGHTMAP: boolean;
  19303. LIGHTMAPDIRECTUV: number;
  19304. OBJECTSPACE_NORMALMAP: boolean;
  19305. USELIGHTMAPASSHADOWMAP: boolean;
  19306. REFLECTIONMAP_3D: boolean;
  19307. REFLECTIONMAP_SPHERICAL: boolean;
  19308. REFLECTIONMAP_PLANAR: boolean;
  19309. REFLECTIONMAP_CUBIC: boolean;
  19310. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19311. REFLECTIONMAP_PROJECTION: boolean;
  19312. REFLECTIONMAP_SKYBOX: boolean;
  19313. REFLECTIONMAP_EXPLICIT: boolean;
  19314. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19315. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19316. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19317. INVERTCUBICMAP: boolean;
  19318. LOGARITHMICDEPTH: boolean;
  19319. REFRACTION: boolean;
  19320. REFRACTIONMAP_3D: boolean;
  19321. REFLECTIONOVERALPHA: boolean;
  19322. TWOSIDEDLIGHTING: boolean;
  19323. SHADOWFLOAT: boolean;
  19324. MORPHTARGETS: boolean;
  19325. MORPHTARGETS_NORMAL: boolean;
  19326. MORPHTARGETS_TANGENT: boolean;
  19327. MORPHTARGETS_UV: boolean;
  19328. NUM_MORPH_INFLUENCERS: number;
  19329. NONUNIFORMSCALING: boolean;
  19330. PREMULTIPLYALPHA: boolean;
  19331. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19332. ALPHABLEND: boolean;
  19333. PREPASS: boolean;
  19334. PREPASS_IRRADIANCE: boolean;
  19335. PREPASS_IRRADIANCE_INDEX: number;
  19336. PREPASS_ALBEDO: boolean;
  19337. PREPASS_ALBEDO_INDEX: number;
  19338. PREPASS_DEPTHNORMAL: boolean;
  19339. PREPASS_DEPTHNORMAL_INDEX: number;
  19340. PREPASS_POSITION: boolean;
  19341. PREPASS_POSITION_INDEX: number;
  19342. PREPASS_VELOCITY: boolean;
  19343. PREPASS_VELOCITY_INDEX: number;
  19344. PREPASS_REFLECTIVITY: boolean;
  19345. PREPASS_REFLECTIVITY_INDEX: number;
  19346. SCENE_MRT_COUNT: number;
  19347. RGBDLIGHTMAP: boolean;
  19348. RGBDREFLECTION: boolean;
  19349. RGBDREFRACTION: boolean;
  19350. IMAGEPROCESSING: boolean;
  19351. VIGNETTE: boolean;
  19352. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19353. VIGNETTEBLENDMODEOPAQUE: boolean;
  19354. TONEMAPPING: boolean;
  19355. TONEMAPPING_ACES: boolean;
  19356. CONTRAST: boolean;
  19357. COLORCURVES: boolean;
  19358. COLORGRADING: boolean;
  19359. COLORGRADING3D: boolean;
  19360. SAMPLER3DGREENDEPTH: boolean;
  19361. SAMPLER3DBGRMAP: boolean;
  19362. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19363. MULTIVIEW: boolean;
  19364. /**
  19365. * If the reflection texture on this material is in linear color space
  19366. * @hidden
  19367. */
  19368. IS_REFLECTION_LINEAR: boolean;
  19369. /**
  19370. * If the refraction texture on this material is in linear color space
  19371. * @hidden
  19372. */
  19373. IS_REFRACTION_LINEAR: boolean;
  19374. EXPOSURE: boolean;
  19375. constructor();
  19376. setReflectionMode(modeToEnable: string): void;
  19377. }
  19378. /**
  19379. * This is the default material used in Babylon. It is the best trade off between quality
  19380. * and performances.
  19381. * @see https://doc.babylonjs.com/babylon101/materials
  19382. */
  19383. export class StandardMaterial extends PushMaterial {
  19384. private _diffuseTexture;
  19385. /**
  19386. * The basic texture of the material as viewed under a light.
  19387. */
  19388. diffuseTexture: Nullable<BaseTexture>;
  19389. private _ambientTexture;
  19390. /**
  19391. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19392. */
  19393. ambientTexture: Nullable<BaseTexture>;
  19394. private _opacityTexture;
  19395. /**
  19396. * Define the transparency of the material from a texture.
  19397. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19398. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19399. */
  19400. opacityTexture: Nullable<BaseTexture>;
  19401. private _reflectionTexture;
  19402. /**
  19403. * Define the texture used to display the reflection.
  19404. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19405. */
  19406. reflectionTexture: Nullable<BaseTexture>;
  19407. private _emissiveTexture;
  19408. /**
  19409. * Define texture of the material as if self lit.
  19410. * This will be mixed in the final result even in the absence of light.
  19411. */
  19412. emissiveTexture: Nullable<BaseTexture>;
  19413. private _specularTexture;
  19414. /**
  19415. * Define how the color and intensity of the highlight given by the light in the material.
  19416. */
  19417. specularTexture: Nullable<BaseTexture>;
  19418. private _bumpTexture;
  19419. /**
  19420. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19421. * 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.
  19422. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  19423. */
  19424. bumpTexture: Nullable<BaseTexture>;
  19425. private _lightmapTexture;
  19426. /**
  19427. * Complex lighting can be computationally expensive to compute at runtime.
  19428. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19429. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  19430. */
  19431. lightmapTexture: Nullable<BaseTexture>;
  19432. private _refractionTexture;
  19433. /**
  19434. * Define the texture used to display the refraction.
  19435. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19436. */
  19437. refractionTexture: Nullable<BaseTexture>;
  19438. /**
  19439. * The color of the material lit by the environmental background lighting.
  19440. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19441. */
  19442. ambientColor: Color3;
  19443. /**
  19444. * The basic color of the material as viewed under a light.
  19445. */
  19446. diffuseColor: Color3;
  19447. /**
  19448. * Define how the color and intensity of the highlight given by the light in the material.
  19449. */
  19450. specularColor: Color3;
  19451. /**
  19452. * Define the color of the material as if self lit.
  19453. * This will be mixed in the final result even in the absence of light.
  19454. */
  19455. emissiveColor: Color3;
  19456. /**
  19457. * Defines how sharp are the highlights in the material.
  19458. * The bigger the value the sharper giving a more glossy feeling to the result.
  19459. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19460. */
  19461. specularPower: number;
  19462. private _useAlphaFromDiffuseTexture;
  19463. /**
  19464. * Does the transparency come from the diffuse texture alpha channel.
  19465. */
  19466. useAlphaFromDiffuseTexture: boolean;
  19467. private _useEmissiveAsIllumination;
  19468. /**
  19469. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19470. */
  19471. useEmissiveAsIllumination: boolean;
  19472. private _linkEmissiveWithDiffuse;
  19473. /**
  19474. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19475. * the emissive level when the final color is close to one.
  19476. */
  19477. linkEmissiveWithDiffuse: boolean;
  19478. private _useSpecularOverAlpha;
  19479. /**
  19480. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19481. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19482. */
  19483. useSpecularOverAlpha: boolean;
  19484. private _useReflectionOverAlpha;
  19485. /**
  19486. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19487. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19488. */
  19489. useReflectionOverAlpha: boolean;
  19490. private _disableLighting;
  19491. /**
  19492. * Does lights from the scene impacts this material.
  19493. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19494. */
  19495. disableLighting: boolean;
  19496. private _useObjectSpaceNormalMap;
  19497. /**
  19498. * Allows using an object space normal map (instead of tangent space).
  19499. */
  19500. useObjectSpaceNormalMap: boolean;
  19501. private _useParallax;
  19502. /**
  19503. * Is parallax enabled or not.
  19504. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19505. */
  19506. useParallax: boolean;
  19507. private _useParallaxOcclusion;
  19508. /**
  19509. * Is parallax occlusion enabled or not.
  19510. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19511. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19512. */
  19513. useParallaxOcclusion: boolean;
  19514. /**
  19515. * 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.
  19516. */
  19517. parallaxScaleBias: number;
  19518. private _roughness;
  19519. /**
  19520. * Helps to define how blurry the reflections should appears in the material.
  19521. */
  19522. roughness: number;
  19523. /**
  19524. * In case of refraction, define the value of the index of refraction.
  19525. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19526. */
  19527. indexOfRefraction: number;
  19528. /**
  19529. * Invert the refraction texture alongside the y axis.
  19530. * It can be useful with procedural textures or probe for instance.
  19531. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19532. */
  19533. invertRefractionY: boolean;
  19534. /**
  19535. * Defines the alpha limits in alpha test mode.
  19536. */
  19537. alphaCutOff: number;
  19538. private _useLightmapAsShadowmap;
  19539. /**
  19540. * In case of light mapping, define whether the map contains light or shadow informations.
  19541. */
  19542. useLightmapAsShadowmap: boolean;
  19543. private _diffuseFresnelParameters;
  19544. /**
  19545. * Define the diffuse fresnel parameters of the material.
  19546. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19547. */
  19548. diffuseFresnelParameters: FresnelParameters;
  19549. private _opacityFresnelParameters;
  19550. /**
  19551. * Define the opacity fresnel parameters of the material.
  19552. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19553. */
  19554. opacityFresnelParameters: FresnelParameters;
  19555. private _reflectionFresnelParameters;
  19556. /**
  19557. * Define the reflection fresnel parameters of the material.
  19558. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19559. */
  19560. reflectionFresnelParameters: FresnelParameters;
  19561. private _refractionFresnelParameters;
  19562. /**
  19563. * Define the refraction fresnel parameters of the material.
  19564. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19565. */
  19566. refractionFresnelParameters: FresnelParameters;
  19567. private _emissiveFresnelParameters;
  19568. /**
  19569. * Define the emissive fresnel parameters of the material.
  19570. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19571. */
  19572. emissiveFresnelParameters: FresnelParameters;
  19573. private _useReflectionFresnelFromSpecular;
  19574. /**
  19575. * If true automatically deducts the fresnels values from the material specularity.
  19576. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19577. */
  19578. useReflectionFresnelFromSpecular: boolean;
  19579. private _useGlossinessFromSpecularMapAlpha;
  19580. /**
  19581. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19582. */
  19583. useGlossinessFromSpecularMapAlpha: boolean;
  19584. private _maxSimultaneousLights;
  19585. /**
  19586. * Defines the maximum number of lights that can be used in the material
  19587. */
  19588. maxSimultaneousLights: number;
  19589. private _invertNormalMapX;
  19590. /**
  19591. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19592. */
  19593. invertNormalMapX: boolean;
  19594. private _invertNormalMapY;
  19595. /**
  19596. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19597. */
  19598. invertNormalMapY: boolean;
  19599. private _twoSidedLighting;
  19600. /**
  19601. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19602. */
  19603. twoSidedLighting: boolean;
  19604. /**
  19605. * Default configuration related to image processing available in the standard Material.
  19606. */
  19607. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19608. /**
  19609. * Gets the image processing configuration used either in this material.
  19610. */
  19611. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19612. /**
  19613. * Sets the Default image processing configuration used either in the this material.
  19614. *
  19615. * If sets to null, the scene one is in use.
  19616. */
  19617. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19618. /**
  19619. * Keep track of the image processing observer to allow dispose and replace.
  19620. */
  19621. private _imageProcessingObserver;
  19622. /**
  19623. * Attaches a new image processing configuration to the Standard Material.
  19624. * @param configuration
  19625. */
  19626. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19627. /**
  19628. * Defines additionnal PrePass parameters for the material.
  19629. */
  19630. readonly prePassConfiguration: PrePassConfiguration;
  19631. /**
  19632. * Gets wether the color curves effect is enabled.
  19633. */
  19634. get cameraColorCurvesEnabled(): boolean;
  19635. /**
  19636. * Sets wether the color curves effect is enabled.
  19637. */
  19638. set cameraColorCurvesEnabled(value: boolean);
  19639. /**
  19640. * Gets wether the color grading effect is enabled.
  19641. */
  19642. get cameraColorGradingEnabled(): boolean;
  19643. /**
  19644. * Gets wether the color grading effect is enabled.
  19645. */
  19646. set cameraColorGradingEnabled(value: boolean);
  19647. /**
  19648. * Gets wether tonemapping is enabled or not.
  19649. */
  19650. get cameraToneMappingEnabled(): boolean;
  19651. /**
  19652. * Sets wether tonemapping is enabled or not
  19653. */
  19654. set cameraToneMappingEnabled(value: boolean);
  19655. /**
  19656. * The camera exposure used on this material.
  19657. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19658. * This corresponds to a photographic exposure.
  19659. */
  19660. get cameraExposure(): number;
  19661. /**
  19662. * The camera exposure used on this material.
  19663. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19664. * This corresponds to a photographic exposure.
  19665. */
  19666. set cameraExposure(value: number);
  19667. /**
  19668. * Gets The camera contrast used on this material.
  19669. */
  19670. get cameraContrast(): number;
  19671. /**
  19672. * Sets The camera contrast used on this material.
  19673. */
  19674. set cameraContrast(value: number);
  19675. /**
  19676. * Gets the Color Grading 2D Lookup Texture.
  19677. */
  19678. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19679. /**
  19680. * Sets the Color Grading 2D Lookup Texture.
  19681. */
  19682. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19683. /**
  19684. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19685. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19686. * 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;
  19687. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19688. */
  19689. get cameraColorCurves(): Nullable<ColorCurves>;
  19690. /**
  19691. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19692. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19693. * 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;
  19694. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19695. */
  19696. set cameraColorCurves(value: Nullable<ColorCurves>);
  19697. /**
  19698. * Can this material render to several textures at once
  19699. */
  19700. get canRenderToMRT(): boolean;
  19701. /**
  19702. * Defines the detail map parameters for the material.
  19703. */
  19704. readonly detailMap: DetailMapConfiguration;
  19705. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19706. protected _worldViewProjectionMatrix: Matrix;
  19707. protected _globalAmbientColor: Color3;
  19708. protected _useLogarithmicDepth: boolean;
  19709. protected _rebuildInParallel: boolean;
  19710. /**
  19711. * Instantiates a new standard material.
  19712. * This is the default material used in Babylon. It is the best trade off between quality
  19713. * and performances.
  19714. * @see https://doc.babylonjs.com/babylon101/materials
  19715. * @param name Define the name of the material in the scene
  19716. * @param scene Define the scene the material belong to
  19717. */
  19718. constructor(name: string, scene: Scene);
  19719. /**
  19720. * Gets a boolean indicating that current material needs to register RTT
  19721. */
  19722. get hasRenderTargetTextures(): boolean;
  19723. /**
  19724. * Gets the current class name of the material e.g. "StandardMaterial"
  19725. * Mainly use in serialization.
  19726. * @returns the class name
  19727. */
  19728. getClassName(): string;
  19729. /**
  19730. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19731. * You can try switching to logarithmic depth.
  19732. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19733. */
  19734. get useLogarithmicDepth(): boolean;
  19735. set useLogarithmicDepth(value: boolean);
  19736. /**
  19737. * Specifies if the material will require alpha blending
  19738. * @returns a boolean specifying if alpha blending is needed
  19739. */
  19740. needAlphaBlending(): boolean;
  19741. /**
  19742. * Specifies if this material should be rendered in alpha test mode
  19743. * @returns a boolean specifying if an alpha test is needed.
  19744. */
  19745. needAlphaTesting(): boolean;
  19746. /**
  19747. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19748. */
  19749. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19750. /**
  19751. * Specifies whether or not there is a usable alpha channel for transparency.
  19752. */
  19753. protected _hasAlphaChannel(): boolean;
  19754. /**
  19755. * Get the texture used for alpha test purpose.
  19756. * @returns the diffuse texture in case of the standard material.
  19757. */
  19758. getAlphaTestTexture(): Nullable<BaseTexture>;
  19759. /**
  19760. * Get if the submesh is ready to be used and all its information available.
  19761. * Child classes can use it to update shaders
  19762. * @param mesh defines the mesh to check
  19763. * @param subMesh defines which submesh to check
  19764. * @param useInstances specifies that instances should be used
  19765. * @returns a boolean indicating that the submesh is ready or not
  19766. */
  19767. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19768. /**
  19769. * Builds the material UBO layouts.
  19770. * Used internally during the effect preparation.
  19771. */
  19772. buildUniformLayout(): void;
  19773. /**
  19774. * Unbinds the material from the mesh
  19775. */
  19776. unbind(): void;
  19777. /**
  19778. * Binds the submesh to this material by preparing the effect and shader to draw
  19779. * @param world defines the world transformation matrix
  19780. * @param mesh defines the mesh containing the submesh
  19781. * @param subMesh defines the submesh to bind the material to
  19782. */
  19783. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19784. /**
  19785. * Get the list of animatables in the material.
  19786. * @returns the list of animatables object used in the material
  19787. */
  19788. getAnimatables(): IAnimatable[];
  19789. /**
  19790. * Gets the active textures from the material
  19791. * @returns an array of textures
  19792. */
  19793. getActiveTextures(): BaseTexture[];
  19794. /**
  19795. * Specifies if the material uses a texture
  19796. * @param texture defines the texture to check against the material
  19797. * @returns a boolean specifying if the material uses the texture
  19798. */
  19799. hasTexture(texture: BaseTexture): boolean;
  19800. /**
  19801. * Disposes the material
  19802. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19803. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19804. */
  19805. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19806. /**
  19807. * Makes a duplicate of the material, and gives it a new name
  19808. * @param name defines the new name for the duplicated material
  19809. * @returns the cloned material
  19810. */
  19811. clone(name: string): StandardMaterial;
  19812. /**
  19813. * Serializes this material in a JSON representation
  19814. * @returns the serialized material object
  19815. */
  19816. serialize(): any;
  19817. /**
  19818. * Creates a standard material from parsed material data
  19819. * @param source defines the JSON representation of the material
  19820. * @param scene defines the hosting scene
  19821. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19822. * @returns a new standard material
  19823. */
  19824. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19825. /**
  19826. * Are diffuse textures enabled in the application.
  19827. */
  19828. static get DiffuseTextureEnabled(): boolean;
  19829. static set DiffuseTextureEnabled(value: boolean);
  19830. /**
  19831. * Are detail textures enabled in the application.
  19832. */
  19833. static get DetailTextureEnabled(): boolean;
  19834. static set DetailTextureEnabled(value: boolean);
  19835. /**
  19836. * Are ambient textures enabled in the application.
  19837. */
  19838. static get AmbientTextureEnabled(): boolean;
  19839. static set AmbientTextureEnabled(value: boolean);
  19840. /**
  19841. * Are opacity textures enabled in the application.
  19842. */
  19843. static get OpacityTextureEnabled(): boolean;
  19844. static set OpacityTextureEnabled(value: boolean);
  19845. /**
  19846. * Are reflection textures enabled in the application.
  19847. */
  19848. static get ReflectionTextureEnabled(): boolean;
  19849. static set ReflectionTextureEnabled(value: boolean);
  19850. /**
  19851. * Are emissive textures enabled in the application.
  19852. */
  19853. static get EmissiveTextureEnabled(): boolean;
  19854. static set EmissiveTextureEnabled(value: boolean);
  19855. /**
  19856. * Are specular textures enabled in the application.
  19857. */
  19858. static get SpecularTextureEnabled(): boolean;
  19859. static set SpecularTextureEnabled(value: boolean);
  19860. /**
  19861. * Are bump textures enabled in the application.
  19862. */
  19863. static get BumpTextureEnabled(): boolean;
  19864. static set BumpTextureEnabled(value: boolean);
  19865. /**
  19866. * Are lightmap textures enabled in the application.
  19867. */
  19868. static get LightmapTextureEnabled(): boolean;
  19869. static set LightmapTextureEnabled(value: boolean);
  19870. /**
  19871. * Are refraction textures enabled in the application.
  19872. */
  19873. static get RefractionTextureEnabled(): boolean;
  19874. static set RefractionTextureEnabled(value: boolean);
  19875. /**
  19876. * Are color grading textures enabled in the application.
  19877. */
  19878. static get ColorGradingTextureEnabled(): boolean;
  19879. static set ColorGradingTextureEnabled(value: boolean);
  19880. /**
  19881. * Are fresnels enabled in the application.
  19882. */
  19883. static get FresnelEnabled(): boolean;
  19884. static set FresnelEnabled(value: boolean);
  19885. }
  19886. }
  19887. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  19888. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19889. /** @hidden */
  19890. export var rgbdDecodePixelShader: {
  19891. name: string;
  19892. shader: string;
  19893. };
  19894. }
  19895. declare module "babylonjs/Misc/rgbdTextureTools" {
  19896. import "babylonjs/Shaders/rgbdDecode.fragment";
  19897. import "babylonjs/Engines/Extensions/engine.renderTarget";
  19898. import { Texture } from "babylonjs/Materials/Textures/texture";
  19899. /**
  19900. * Class used to host RGBD texture specific utilities
  19901. */
  19902. export class RGBDTextureTools {
  19903. /**
  19904. * Expand the RGBD Texture from RGBD to Half Float if possible.
  19905. * @param texture the texture to expand.
  19906. */
  19907. static ExpandRGBDTexture(texture: Texture): void;
  19908. }
  19909. }
  19910. declare module "babylonjs/Misc/brdfTextureTools" {
  19911. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19912. import { Scene } from "babylonjs/scene";
  19913. /**
  19914. * Class used to host texture specific utilities
  19915. */
  19916. export class BRDFTextureTools {
  19917. /**
  19918. * Prevents texture cache collision
  19919. */
  19920. private static _instanceNumber;
  19921. /**
  19922. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  19923. * @param scene defines the hosting scene
  19924. * @returns the environment BRDF texture
  19925. */
  19926. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  19927. private static _environmentBRDFBase64Texture;
  19928. }
  19929. }
  19930. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  19931. import { Nullable } from "babylonjs/types";
  19932. import { Color3 } from "babylonjs/Maths/math.color";
  19933. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19934. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19935. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19936. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  19937. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19938. import { Engine } from "babylonjs/Engines/engine";
  19939. import { Scene } from "babylonjs/scene";
  19940. /**
  19941. * @hidden
  19942. */
  19943. export interface IMaterialClearCoatDefines {
  19944. CLEARCOAT: boolean;
  19945. CLEARCOAT_DEFAULTIOR: boolean;
  19946. CLEARCOAT_TEXTURE: boolean;
  19947. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  19948. CLEARCOAT_TEXTUREDIRECTUV: number;
  19949. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  19950. CLEARCOAT_BUMP: boolean;
  19951. CLEARCOAT_BUMPDIRECTUV: number;
  19952. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  19953. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  19954. CLEARCOAT_REMAP_F0: boolean;
  19955. CLEARCOAT_TINT: boolean;
  19956. CLEARCOAT_TINT_TEXTURE: boolean;
  19957. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  19958. /** @hidden */
  19959. _areTexturesDirty: boolean;
  19960. }
  19961. /**
  19962. * Define the code related to the clear coat parameters of the pbr material.
  19963. */
  19964. export class PBRClearCoatConfiguration {
  19965. /**
  19966. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19967. * The default fits with a polyurethane material.
  19968. * @hidden
  19969. */
  19970. static readonly _DefaultIndexOfRefraction: number;
  19971. private _isEnabled;
  19972. /**
  19973. * Defines if the clear coat is enabled in the material.
  19974. */
  19975. isEnabled: boolean;
  19976. /**
  19977. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  19978. */
  19979. intensity: number;
  19980. /**
  19981. * Defines the clear coat layer roughness.
  19982. */
  19983. roughness: number;
  19984. private _indexOfRefraction;
  19985. /**
  19986. * Defines the index of refraction of the clear coat.
  19987. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19988. * The default fits with a polyurethane material.
  19989. * Changing the default value is more performance intensive.
  19990. */
  19991. indexOfRefraction: number;
  19992. private _texture;
  19993. /**
  19994. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  19995. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  19996. * if textureRoughness is not empty, else no texture roughness is used
  19997. */
  19998. texture: Nullable<BaseTexture>;
  19999. private _useRoughnessFromMainTexture;
  20000. /**
  20001. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20002. * If false, the green channel from textureRoughness is used for roughness
  20003. */
  20004. useRoughnessFromMainTexture: boolean;
  20005. private _textureRoughness;
  20006. /**
  20007. * Stores the clear coat roughness in a texture (green channel)
  20008. * Not used if useRoughnessFromMainTexture is true
  20009. */
  20010. textureRoughness: Nullable<BaseTexture>;
  20011. private _remapF0OnInterfaceChange;
  20012. /**
  20013. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20014. */
  20015. remapF0OnInterfaceChange: boolean;
  20016. private _bumpTexture;
  20017. /**
  20018. * Define the clear coat specific bump texture.
  20019. */
  20020. bumpTexture: Nullable<BaseTexture>;
  20021. private _isTintEnabled;
  20022. /**
  20023. * Defines if the clear coat tint is enabled in the material.
  20024. */
  20025. isTintEnabled: boolean;
  20026. /**
  20027. * Defines the clear coat tint of the material.
  20028. * This is only use if tint is enabled
  20029. */
  20030. tintColor: Color3;
  20031. /**
  20032. * Defines the distance at which the tint color should be found in the
  20033. * clear coat media.
  20034. * This is only use if tint is enabled
  20035. */
  20036. tintColorAtDistance: number;
  20037. /**
  20038. * Defines the clear coat layer thickness.
  20039. * This is only use if tint is enabled
  20040. */
  20041. tintThickness: number;
  20042. private _tintTexture;
  20043. /**
  20044. * Stores the clear tint values in a texture.
  20045. * rgb is tint
  20046. * a is a thickness factor
  20047. */
  20048. tintTexture: Nullable<BaseTexture>;
  20049. /** @hidden */
  20050. private _internalMarkAllSubMeshesAsTexturesDirty;
  20051. /** @hidden */
  20052. _markAllSubMeshesAsTexturesDirty(): void;
  20053. /**
  20054. * Instantiate a new istance of clear coat configuration.
  20055. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20056. */
  20057. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20058. /**
  20059. * Gets wehter the submesh is ready to be used or not.
  20060. * @param defines the list of "defines" to update.
  20061. * @param scene defines the scene the material belongs to.
  20062. * @param engine defines the engine the material belongs to.
  20063. * @param disableBumpMap defines wether the material disables bump or not.
  20064. * @returns - boolean indicating that the submesh is ready or not.
  20065. */
  20066. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20067. /**
  20068. * Checks to see if a texture is used in the material.
  20069. * @param defines the list of "defines" to update.
  20070. * @param scene defines the scene to the material belongs to.
  20071. */
  20072. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20073. /**
  20074. * Binds the material data.
  20075. * @param uniformBuffer defines the Uniform buffer to fill in.
  20076. * @param scene defines the scene the material belongs to.
  20077. * @param engine defines the engine the material belongs to.
  20078. * @param disableBumpMap defines wether the material disables bump or not.
  20079. * @param isFrozen defines wether the material is frozen or not.
  20080. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20081. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20082. * @param subMesh the submesh to bind data for
  20083. */
  20084. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20085. /**
  20086. * Checks to see if a texture is used in the material.
  20087. * @param texture - Base texture to use.
  20088. * @returns - Boolean specifying if a texture is used in the material.
  20089. */
  20090. hasTexture(texture: BaseTexture): boolean;
  20091. /**
  20092. * Returns an array of the actively used textures.
  20093. * @param activeTextures Array of BaseTextures
  20094. */
  20095. getActiveTextures(activeTextures: BaseTexture[]): void;
  20096. /**
  20097. * Returns the animatable textures.
  20098. * @param animatables Array of animatable textures.
  20099. */
  20100. getAnimatables(animatables: IAnimatable[]): void;
  20101. /**
  20102. * Disposes the resources of the material.
  20103. * @param forceDisposeTextures - Forces the disposal of all textures.
  20104. */
  20105. dispose(forceDisposeTextures?: boolean): void;
  20106. /**
  20107. * Get the current class name of the texture useful for serialization or dynamic coding.
  20108. * @returns "PBRClearCoatConfiguration"
  20109. */
  20110. getClassName(): string;
  20111. /**
  20112. * Add fallbacks to the effect fallbacks list.
  20113. * @param defines defines the Base texture to use.
  20114. * @param fallbacks defines the current fallback list.
  20115. * @param currentRank defines the current fallback rank.
  20116. * @returns the new fallback rank.
  20117. */
  20118. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20119. /**
  20120. * Add the required uniforms to the current list.
  20121. * @param uniforms defines the current uniform list.
  20122. */
  20123. static AddUniforms(uniforms: string[]): void;
  20124. /**
  20125. * Add the required samplers to the current list.
  20126. * @param samplers defines the current sampler list.
  20127. */
  20128. static AddSamplers(samplers: string[]): void;
  20129. /**
  20130. * Add the required uniforms to the current buffer.
  20131. * @param uniformBuffer defines the current uniform buffer.
  20132. */
  20133. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20134. /**
  20135. * Makes a duplicate of the current configuration into another one.
  20136. * @param clearCoatConfiguration define the config where to copy the info
  20137. */
  20138. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20139. /**
  20140. * Serializes this clear coat configuration.
  20141. * @returns - An object with the serialized config.
  20142. */
  20143. serialize(): any;
  20144. /**
  20145. * Parses a anisotropy Configuration from a serialized object.
  20146. * @param source - Serialized object.
  20147. * @param scene Defines the scene we are parsing for
  20148. * @param rootUrl Defines the rootUrl to load from
  20149. */
  20150. parse(source: any, scene: Scene, rootUrl: string): void;
  20151. }
  20152. }
  20153. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  20154. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20156. import { Vector2 } from "babylonjs/Maths/math.vector";
  20157. import { Scene } from "babylonjs/scene";
  20158. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20159. import { Nullable } from "babylonjs/types";
  20160. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20161. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20162. /**
  20163. * @hidden
  20164. */
  20165. export interface IMaterialAnisotropicDefines {
  20166. ANISOTROPIC: boolean;
  20167. ANISOTROPIC_TEXTURE: boolean;
  20168. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20169. MAINUV1: boolean;
  20170. _areTexturesDirty: boolean;
  20171. _needUVs: boolean;
  20172. }
  20173. /**
  20174. * Define the code related to the anisotropic parameters of the pbr material.
  20175. */
  20176. export class PBRAnisotropicConfiguration {
  20177. private _isEnabled;
  20178. /**
  20179. * Defines if the anisotropy is enabled in the material.
  20180. */
  20181. isEnabled: boolean;
  20182. /**
  20183. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20184. */
  20185. intensity: number;
  20186. /**
  20187. * Defines if the effect is along the tangents, bitangents or in between.
  20188. * By default, the effect is "strectching" the highlights along the tangents.
  20189. */
  20190. direction: Vector2;
  20191. private _texture;
  20192. /**
  20193. * Stores the anisotropy values in a texture.
  20194. * rg is direction (like normal from -1 to 1)
  20195. * b is a intensity
  20196. */
  20197. texture: Nullable<BaseTexture>;
  20198. /** @hidden */
  20199. private _internalMarkAllSubMeshesAsTexturesDirty;
  20200. /** @hidden */
  20201. _markAllSubMeshesAsTexturesDirty(): void;
  20202. /**
  20203. * Instantiate a new istance of anisotropy configuration.
  20204. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20205. */
  20206. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20207. /**
  20208. * Specifies that the submesh is ready to be used.
  20209. * @param defines the list of "defines" to update.
  20210. * @param scene defines the scene the material belongs to.
  20211. * @returns - boolean indicating that the submesh is ready or not.
  20212. */
  20213. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20214. /**
  20215. * Checks to see if a texture is used in the material.
  20216. * @param defines the list of "defines" to update.
  20217. * @param mesh the mesh we are preparing the defines for.
  20218. * @param scene defines the scene the material belongs to.
  20219. */
  20220. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20221. /**
  20222. * Binds the material data.
  20223. * @param uniformBuffer defines the Uniform buffer to fill in.
  20224. * @param scene defines the scene the material belongs to.
  20225. * @param isFrozen defines wether the material is frozen or not.
  20226. */
  20227. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20228. /**
  20229. * Checks to see if a texture is used in the material.
  20230. * @param texture - Base texture to use.
  20231. * @returns - Boolean specifying if a texture is used in the material.
  20232. */
  20233. hasTexture(texture: BaseTexture): boolean;
  20234. /**
  20235. * Returns an array of the actively used textures.
  20236. * @param activeTextures Array of BaseTextures
  20237. */
  20238. getActiveTextures(activeTextures: BaseTexture[]): void;
  20239. /**
  20240. * Returns the animatable textures.
  20241. * @param animatables Array of animatable textures.
  20242. */
  20243. getAnimatables(animatables: IAnimatable[]): void;
  20244. /**
  20245. * Disposes the resources of the material.
  20246. * @param forceDisposeTextures - Forces the disposal of all textures.
  20247. */
  20248. dispose(forceDisposeTextures?: boolean): void;
  20249. /**
  20250. * Get the current class name of the texture useful for serialization or dynamic coding.
  20251. * @returns "PBRAnisotropicConfiguration"
  20252. */
  20253. getClassName(): string;
  20254. /**
  20255. * Add fallbacks to the effect fallbacks list.
  20256. * @param defines defines the Base texture to use.
  20257. * @param fallbacks defines the current fallback list.
  20258. * @param currentRank defines the current fallback rank.
  20259. * @returns the new fallback rank.
  20260. */
  20261. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20262. /**
  20263. * Add the required uniforms to the current list.
  20264. * @param uniforms defines the current uniform list.
  20265. */
  20266. static AddUniforms(uniforms: string[]): void;
  20267. /**
  20268. * Add the required uniforms to the current buffer.
  20269. * @param uniformBuffer defines the current uniform buffer.
  20270. */
  20271. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20272. /**
  20273. * Add the required samplers to the current list.
  20274. * @param samplers defines the current sampler list.
  20275. */
  20276. static AddSamplers(samplers: string[]): void;
  20277. /**
  20278. * Makes a duplicate of the current configuration into another one.
  20279. * @param anisotropicConfiguration define the config where to copy the info
  20280. */
  20281. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  20282. /**
  20283. * Serializes this anisotropy configuration.
  20284. * @returns - An object with the serialized config.
  20285. */
  20286. serialize(): any;
  20287. /**
  20288. * Parses a anisotropy Configuration from a serialized object.
  20289. * @param source - Serialized object.
  20290. * @param scene Defines the scene we are parsing for
  20291. * @param rootUrl Defines the rootUrl to load from
  20292. */
  20293. parse(source: any, scene: Scene, rootUrl: string): void;
  20294. }
  20295. }
  20296. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  20297. import { Scene } from "babylonjs/scene";
  20298. /**
  20299. * @hidden
  20300. */
  20301. export interface IMaterialBRDFDefines {
  20302. BRDF_V_HEIGHT_CORRELATED: boolean;
  20303. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20304. SPHERICAL_HARMONICS: boolean;
  20305. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20306. /** @hidden */
  20307. _areMiscDirty: boolean;
  20308. }
  20309. /**
  20310. * Define the code related to the BRDF parameters of the pbr material.
  20311. */
  20312. export class PBRBRDFConfiguration {
  20313. /**
  20314. * Default value used for the energy conservation.
  20315. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20316. */
  20317. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  20318. /**
  20319. * Default value used for the Smith Visibility Height Correlated mode.
  20320. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20321. */
  20322. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  20323. /**
  20324. * Default value used for the IBL diffuse part.
  20325. * This can help switching back to the polynomials mode globally which is a tiny bit
  20326. * less GPU intensive at the drawback of a lower quality.
  20327. */
  20328. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  20329. /**
  20330. * Default value used for activating energy conservation for the specular workflow.
  20331. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20332. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20333. */
  20334. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  20335. private _useEnergyConservation;
  20336. /**
  20337. * Defines if the material uses energy conservation.
  20338. */
  20339. useEnergyConservation: boolean;
  20340. private _useSmithVisibilityHeightCorrelated;
  20341. /**
  20342. * LEGACY Mode set to false
  20343. * Defines if the material uses height smith correlated visibility term.
  20344. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  20345. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  20346. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  20347. * Not relying on height correlated will also disable energy conservation.
  20348. */
  20349. useSmithVisibilityHeightCorrelated: boolean;
  20350. private _useSphericalHarmonics;
  20351. /**
  20352. * LEGACY Mode set to false
  20353. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  20354. * diffuse part of the IBL.
  20355. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  20356. * to the ground truth.
  20357. */
  20358. useSphericalHarmonics: boolean;
  20359. private _useSpecularGlossinessInputEnergyConservation;
  20360. /**
  20361. * Defines if the material uses energy conservation, when the specular workflow is active.
  20362. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20363. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20364. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  20365. */
  20366. useSpecularGlossinessInputEnergyConservation: boolean;
  20367. /** @hidden */
  20368. private _internalMarkAllSubMeshesAsMiscDirty;
  20369. /** @hidden */
  20370. _markAllSubMeshesAsMiscDirty(): void;
  20371. /**
  20372. * Instantiate a new istance of clear coat configuration.
  20373. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  20374. */
  20375. constructor(markAllSubMeshesAsMiscDirty: () => void);
  20376. /**
  20377. * Checks to see if a texture is used in the material.
  20378. * @param defines the list of "defines" to update.
  20379. */
  20380. prepareDefines(defines: IMaterialBRDFDefines): void;
  20381. /**
  20382. * Get the current class name of the texture useful for serialization or dynamic coding.
  20383. * @returns "PBRClearCoatConfiguration"
  20384. */
  20385. getClassName(): string;
  20386. /**
  20387. * Makes a duplicate of the current configuration into another one.
  20388. * @param brdfConfiguration define the config where to copy the info
  20389. */
  20390. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  20391. /**
  20392. * Serializes this BRDF configuration.
  20393. * @returns - An object with the serialized config.
  20394. */
  20395. serialize(): any;
  20396. /**
  20397. * Parses a anisotropy Configuration from a serialized object.
  20398. * @param source - Serialized object.
  20399. * @param scene Defines the scene we are parsing for
  20400. * @param rootUrl Defines the rootUrl to load from
  20401. */
  20402. parse(source: any, scene: Scene, rootUrl: string): void;
  20403. }
  20404. }
  20405. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  20406. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20407. import { Color3 } from "babylonjs/Maths/math.color";
  20408. import { Scene } from "babylonjs/scene";
  20409. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20410. import { Nullable } from "babylonjs/types";
  20411. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20412. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20413. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20414. /**
  20415. * @hidden
  20416. */
  20417. export interface IMaterialSheenDefines {
  20418. SHEEN: boolean;
  20419. SHEEN_TEXTURE: boolean;
  20420. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20421. SHEEN_TEXTUREDIRECTUV: number;
  20422. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20423. SHEEN_LINKWITHALBEDO: boolean;
  20424. SHEEN_ROUGHNESS: boolean;
  20425. SHEEN_ALBEDOSCALING: boolean;
  20426. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20427. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20428. /** @hidden */
  20429. _areTexturesDirty: boolean;
  20430. }
  20431. /**
  20432. * Define the code related to the Sheen parameters of the pbr material.
  20433. */
  20434. export class PBRSheenConfiguration {
  20435. private _isEnabled;
  20436. /**
  20437. * Defines if the material uses sheen.
  20438. */
  20439. isEnabled: boolean;
  20440. private _linkSheenWithAlbedo;
  20441. /**
  20442. * Defines if the sheen is linked to the sheen color.
  20443. */
  20444. linkSheenWithAlbedo: boolean;
  20445. /**
  20446. * Defines the sheen intensity.
  20447. */
  20448. intensity: number;
  20449. /**
  20450. * Defines the sheen color.
  20451. */
  20452. color: Color3;
  20453. private _texture;
  20454. /**
  20455. * Stores the sheen tint values in a texture.
  20456. * rgb is tint
  20457. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  20458. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  20459. */
  20460. texture: Nullable<BaseTexture>;
  20461. private _useRoughnessFromMainTexture;
  20462. /**
  20463. * Indicates that the alpha channel of the texture property will be used for roughness.
  20464. * Has no effect if the roughness (and texture!) property is not defined
  20465. */
  20466. useRoughnessFromMainTexture: boolean;
  20467. private _roughness;
  20468. /**
  20469. * Defines the sheen roughness.
  20470. * It is not taken into account if linkSheenWithAlbedo is true.
  20471. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  20472. */
  20473. roughness: Nullable<number>;
  20474. private _textureRoughness;
  20475. /**
  20476. * Stores the sheen roughness in a texture.
  20477. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  20478. */
  20479. textureRoughness: Nullable<BaseTexture>;
  20480. private _albedoScaling;
  20481. /**
  20482. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  20483. * It allows the strength of the sheen effect to not depend on the base color of the material,
  20484. * making it easier to setup and tweak the effect
  20485. */
  20486. albedoScaling: boolean;
  20487. /** @hidden */
  20488. private _internalMarkAllSubMeshesAsTexturesDirty;
  20489. /** @hidden */
  20490. _markAllSubMeshesAsTexturesDirty(): void;
  20491. /**
  20492. * Instantiate a new istance of clear coat configuration.
  20493. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20494. */
  20495. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20496. /**
  20497. * Specifies that the submesh is ready to be used.
  20498. * @param defines the list of "defines" to update.
  20499. * @param scene defines the scene the material belongs to.
  20500. * @returns - boolean indicating that the submesh is ready or not.
  20501. */
  20502. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  20503. /**
  20504. * Checks to see if a texture is used in the material.
  20505. * @param defines the list of "defines" to update.
  20506. * @param scene defines the scene the material belongs to.
  20507. */
  20508. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  20509. /**
  20510. * Binds the material data.
  20511. * @param uniformBuffer defines the Uniform buffer to fill in.
  20512. * @param scene defines the scene the material belongs to.
  20513. * @param isFrozen defines wether the material is frozen or not.
  20514. * @param subMesh the submesh to bind data for
  20515. */
  20516. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  20517. /**
  20518. * Checks to see if a texture is used in the material.
  20519. * @param texture - Base texture to use.
  20520. * @returns - Boolean specifying if a texture is used in the material.
  20521. */
  20522. hasTexture(texture: BaseTexture): boolean;
  20523. /**
  20524. * Returns an array of the actively used textures.
  20525. * @param activeTextures Array of BaseTextures
  20526. */
  20527. getActiveTextures(activeTextures: BaseTexture[]): void;
  20528. /**
  20529. * Returns the animatable textures.
  20530. * @param animatables Array of animatable textures.
  20531. */
  20532. getAnimatables(animatables: IAnimatable[]): void;
  20533. /**
  20534. * Disposes the resources of the material.
  20535. * @param forceDisposeTextures - Forces the disposal of all textures.
  20536. */
  20537. dispose(forceDisposeTextures?: boolean): void;
  20538. /**
  20539. * Get the current class name of the texture useful for serialization or dynamic coding.
  20540. * @returns "PBRSheenConfiguration"
  20541. */
  20542. getClassName(): string;
  20543. /**
  20544. * Add fallbacks to the effect fallbacks list.
  20545. * @param defines defines the Base texture to use.
  20546. * @param fallbacks defines the current fallback list.
  20547. * @param currentRank defines the current fallback rank.
  20548. * @returns the new fallback rank.
  20549. */
  20550. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20551. /**
  20552. * Add the required uniforms to the current list.
  20553. * @param uniforms defines the current uniform list.
  20554. */
  20555. static AddUniforms(uniforms: string[]): void;
  20556. /**
  20557. * Add the required uniforms to the current buffer.
  20558. * @param uniformBuffer defines the current uniform buffer.
  20559. */
  20560. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20561. /**
  20562. * Add the required samplers to the current list.
  20563. * @param samplers defines the current sampler list.
  20564. */
  20565. static AddSamplers(samplers: string[]): void;
  20566. /**
  20567. * Makes a duplicate of the current configuration into another one.
  20568. * @param sheenConfiguration define the config where to copy the info
  20569. */
  20570. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  20571. /**
  20572. * Serializes this BRDF configuration.
  20573. * @returns - An object with the serialized config.
  20574. */
  20575. serialize(): any;
  20576. /**
  20577. * Parses a anisotropy Configuration from a serialized object.
  20578. * @param source - Serialized object.
  20579. * @param scene Defines the scene we are parsing for
  20580. * @param rootUrl Defines the rootUrl to load from
  20581. */
  20582. parse(source: any, scene: Scene, rootUrl: string): void;
  20583. }
  20584. }
  20585. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  20586. import { Nullable } from "babylonjs/types";
  20587. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20588. import { Color3 } from "babylonjs/Maths/math.color";
  20589. import { SmartArray } from "babylonjs/Misc/smartArray";
  20590. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20591. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20592. import { Effect } from "babylonjs/Materials/effect";
  20593. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20594. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20595. import { Engine } from "babylonjs/Engines/engine";
  20596. import { Scene } from "babylonjs/scene";
  20597. /**
  20598. * @hidden
  20599. */
  20600. export interface IMaterialSubSurfaceDefines {
  20601. SUBSURFACE: boolean;
  20602. SS_REFRACTION: boolean;
  20603. SS_TRANSLUCENCY: boolean;
  20604. SS_SCATTERING: boolean;
  20605. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20606. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20607. SS_REFRACTIONMAP_3D: boolean;
  20608. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20609. SS_LODINREFRACTIONALPHA: boolean;
  20610. SS_GAMMAREFRACTION: boolean;
  20611. SS_RGBDREFRACTION: boolean;
  20612. SS_LINEARSPECULARREFRACTION: boolean;
  20613. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20614. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20615. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20616. /** @hidden */
  20617. _areTexturesDirty: boolean;
  20618. }
  20619. /**
  20620. * Define the code related to the sub surface parameters of the pbr material.
  20621. */
  20622. export class PBRSubSurfaceConfiguration {
  20623. private _isRefractionEnabled;
  20624. /**
  20625. * Defines if the refraction is enabled in the material.
  20626. */
  20627. isRefractionEnabled: boolean;
  20628. private _isTranslucencyEnabled;
  20629. /**
  20630. * Defines if the translucency is enabled in the material.
  20631. */
  20632. isTranslucencyEnabled: boolean;
  20633. private _isScatteringEnabled;
  20634. /**
  20635. * Defines if the sub surface scattering is enabled in the material.
  20636. */
  20637. isScatteringEnabled: boolean;
  20638. private _scatteringDiffusionProfileIndex;
  20639. /**
  20640. * Diffusion profile for subsurface scattering.
  20641. * Useful for better scattering in the skins or foliages.
  20642. */
  20643. get scatteringDiffusionProfile(): Nullable<Color3>;
  20644. set scatteringDiffusionProfile(c: Nullable<Color3>);
  20645. /**
  20646. * Defines the refraction intensity of the material.
  20647. * The refraction when enabled replaces the Diffuse part of the material.
  20648. * The intensity helps transitionning between diffuse and refraction.
  20649. */
  20650. refractionIntensity: number;
  20651. /**
  20652. * Defines the translucency intensity of the material.
  20653. * When translucency has been enabled, this defines how much of the "translucency"
  20654. * is addded to the diffuse part of the material.
  20655. */
  20656. translucencyIntensity: number;
  20657. /**
  20658. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  20659. */
  20660. useAlbedoToTintRefraction: boolean;
  20661. private _thicknessTexture;
  20662. /**
  20663. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  20664. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  20665. * 0 would mean minimumThickness
  20666. * 1 would mean maximumThickness
  20667. * The other channels might be use as a mask to vary the different effects intensity.
  20668. */
  20669. thicknessTexture: Nullable<BaseTexture>;
  20670. private _refractionTexture;
  20671. /**
  20672. * Defines the texture to use for refraction.
  20673. */
  20674. refractionTexture: Nullable<BaseTexture>;
  20675. private _indexOfRefraction;
  20676. /**
  20677. * Index of refraction of the material base layer.
  20678. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20679. *
  20680. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20681. *
  20682. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20683. */
  20684. indexOfRefraction: number;
  20685. private _volumeIndexOfRefraction;
  20686. /**
  20687. * Index of refraction of the material's volume.
  20688. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20689. *
  20690. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20691. * the volume will use the same IOR as the surface.
  20692. */
  20693. get volumeIndexOfRefraction(): number;
  20694. set volumeIndexOfRefraction(value: number);
  20695. private _invertRefractionY;
  20696. /**
  20697. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20698. */
  20699. invertRefractionY: boolean;
  20700. private _linkRefractionWithTransparency;
  20701. /**
  20702. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20703. * Materials half opaque for instance using refraction could benefit from this control.
  20704. */
  20705. linkRefractionWithTransparency: boolean;
  20706. /**
  20707. * Defines the minimum thickness stored in the thickness map.
  20708. * If no thickness map is defined, this value will be used to simulate thickness.
  20709. */
  20710. minimumThickness: number;
  20711. /**
  20712. * Defines the maximum thickness stored in the thickness map.
  20713. */
  20714. maximumThickness: number;
  20715. /**
  20716. * Defines the volume tint of the material.
  20717. * This is used for both translucency and scattering.
  20718. */
  20719. tintColor: Color3;
  20720. /**
  20721. * Defines the distance at which the tint color should be found in the media.
  20722. * This is used for refraction only.
  20723. */
  20724. tintColorAtDistance: number;
  20725. /**
  20726. * Defines how far each channel transmit through the media.
  20727. * It is defined as a color to simplify it selection.
  20728. */
  20729. diffusionDistance: Color3;
  20730. private _useMaskFromThicknessTexture;
  20731. /**
  20732. * Stores the intensity of the different subsurface effects in the thickness texture.
  20733. * * the green channel is the translucency intensity.
  20734. * * the blue channel is the scattering intensity.
  20735. * * the alpha channel is the refraction intensity.
  20736. */
  20737. useMaskFromThicknessTexture: boolean;
  20738. private _scene;
  20739. /** @hidden */
  20740. private _internalMarkAllSubMeshesAsTexturesDirty;
  20741. private _internalMarkScenePrePassDirty;
  20742. /** @hidden */
  20743. _markAllSubMeshesAsTexturesDirty(): void;
  20744. /** @hidden */
  20745. _markScenePrePassDirty(): void;
  20746. /**
  20747. * Instantiate a new istance of sub surface configuration.
  20748. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20749. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  20750. * @param scene The scene
  20751. */
  20752. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  20753. /**
  20754. * Gets wehter the submesh is ready to be used or not.
  20755. * @param defines the list of "defines" to update.
  20756. * @param scene defines the scene the material belongs to.
  20757. * @returns - boolean indicating that the submesh is ready or not.
  20758. */
  20759. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  20760. /**
  20761. * Checks to see if a texture is used in the material.
  20762. * @param defines the list of "defines" to update.
  20763. * @param scene defines the scene to the material belongs to.
  20764. */
  20765. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  20766. /**
  20767. * Binds the material data.
  20768. * @param uniformBuffer defines the Uniform buffer to fill in.
  20769. * @param scene defines the scene the material belongs to.
  20770. * @param engine defines the engine the material belongs to.
  20771. * @param isFrozen defines whether the material is frozen or not.
  20772. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  20773. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  20774. */
  20775. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  20776. /**
  20777. * Unbinds the material from the mesh.
  20778. * @param activeEffect defines the effect that should be unbound from.
  20779. * @returns true if unbound, otherwise false
  20780. */
  20781. unbind(activeEffect: Effect): boolean;
  20782. /**
  20783. * Returns the texture used for refraction or null if none is used.
  20784. * @param scene defines the scene the material belongs to.
  20785. * @returns - Refraction texture if present. If no refraction texture and refraction
  20786. * is linked with transparency, returns environment texture. Otherwise, returns null.
  20787. */
  20788. private _getRefractionTexture;
  20789. /**
  20790. * Returns true if alpha blending should be disabled.
  20791. */
  20792. get disableAlphaBlending(): boolean;
  20793. /**
  20794. * Fills the list of render target textures.
  20795. * @param renderTargets the list of render targets to update
  20796. */
  20797. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  20798. /**
  20799. * Checks to see if a texture is used in the material.
  20800. * @param texture - Base texture to use.
  20801. * @returns - Boolean specifying if a texture is used in the material.
  20802. */
  20803. hasTexture(texture: BaseTexture): boolean;
  20804. /**
  20805. * Gets a boolean indicating that current material needs to register RTT
  20806. * @returns true if this uses a render target otherwise false.
  20807. */
  20808. hasRenderTargetTextures(): boolean;
  20809. /**
  20810. * Returns an array of the actively used textures.
  20811. * @param activeTextures Array of BaseTextures
  20812. */
  20813. getActiveTextures(activeTextures: BaseTexture[]): void;
  20814. /**
  20815. * Returns the animatable textures.
  20816. * @param animatables Array of animatable textures.
  20817. */
  20818. getAnimatables(animatables: IAnimatable[]): void;
  20819. /**
  20820. * Disposes the resources of the material.
  20821. * @param forceDisposeTextures - Forces the disposal of all textures.
  20822. */
  20823. dispose(forceDisposeTextures?: boolean): void;
  20824. /**
  20825. * Get the current class name of the texture useful for serialization or dynamic coding.
  20826. * @returns "PBRSubSurfaceConfiguration"
  20827. */
  20828. getClassName(): string;
  20829. /**
  20830. * Add fallbacks to the effect fallbacks list.
  20831. * @param defines defines the Base texture to use.
  20832. * @param fallbacks defines the current fallback list.
  20833. * @param currentRank defines the current fallback rank.
  20834. * @returns the new fallback rank.
  20835. */
  20836. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20837. /**
  20838. * Add the required uniforms to the current list.
  20839. * @param uniforms defines the current uniform list.
  20840. */
  20841. static AddUniforms(uniforms: string[]): void;
  20842. /**
  20843. * Add the required samplers to the current list.
  20844. * @param samplers defines the current sampler list.
  20845. */
  20846. static AddSamplers(samplers: string[]): void;
  20847. /**
  20848. * Add the required uniforms to the current buffer.
  20849. * @param uniformBuffer defines the current uniform buffer.
  20850. */
  20851. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20852. /**
  20853. * Makes a duplicate of the current configuration into another one.
  20854. * @param configuration define the config where to copy the info
  20855. */
  20856. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  20857. /**
  20858. * Serializes this Sub Surface configuration.
  20859. * @returns - An object with the serialized config.
  20860. */
  20861. serialize(): any;
  20862. /**
  20863. * Parses a anisotropy Configuration from a serialized object.
  20864. * @param source - Serialized object.
  20865. * @param scene Defines the scene we are parsing for
  20866. * @param rootUrl Defines the rootUrl to load from
  20867. */
  20868. parse(source: any, scene: Scene, rootUrl: string): void;
  20869. }
  20870. }
  20871. declare module "babylonjs/Maths/sphericalPolynomial" {
  20872. import { Vector3 } from "babylonjs/Maths/math.vector";
  20873. import { Color3 } from "babylonjs/Maths/math.color";
  20874. /**
  20875. * Class representing spherical harmonics coefficients to the 3rd degree
  20876. */
  20877. export class SphericalHarmonics {
  20878. /**
  20879. * Defines whether or not the harmonics have been prescaled for rendering.
  20880. */
  20881. preScaled: boolean;
  20882. /**
  20883. * The l0,0 coefficients of the spherical harmonics
  20884. */
  20885. l00: Vector3;
  20886. /**
  20887. * The l1,-1 coefficients of the spherical harmonics
  20888. */
  20889. l1_1: Vector3;
  20890. /**
  20891. * The l1,0 coefficients of the spherical harmonics
  20892. */
  20893. l10: Vector3;
  20894. /**
  20895. * The l1,1 coefficients of the spherical harmonics
  20896. */
  20897. l11: Vector3;
  20898. /**
  20899. * The l2,-2 coefficients of the spherical harmonics
  20900. */
  20901. l2_2: Vector3;
  20902. /**
  20903. * The l2,-1 coefficients of the spherical harmonics
  20904. */
  20905. l2_1: Vector3;
  20906. /**
  20907. * The l2,0 coefficients of the spherical harmonics
  20908. */
  20909. l20: Vector3;
  20910. /**
  20911. * The l2,1 coefficients of the spherical harmonics
  20912. */
  20913. l21: Vector3;
  20914. /**
  20915. * The l2,2 coefficients of the spherical harmonics
  20916. */
  20917. l22: Vector3;
  20918. /**
  20919. * Adds a light to the spherical harmonics
  20920. * @param direction the direction of the light
  20921. * @param color the color of the light
  20922. * @param deltaSolidAngle the delta solid angle of the light
  20923. */
  20924. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  20925. /**
  20926. * Scales the spherical harmonics by the given amount
  20927. * @param scale the amount to scale
  20928. */
  20929. scaleInPlace(scale: number): void;
  20930. /**
  20931. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  20932. *
  20933. * ```
  20934. * E_lm = A_l * L_lm
  20935. * ```
  20936. *
  20937. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  20938. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  20939. * the scaling factors are given in equation 9.
  20940. */
  20941. convertIncidentRadianceToIrradiance(): void;
  20942. /**
  20943. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  20944. *
  20945. * ```
  20946. * L = (1/pi) * E * rho
  20947. * ```
  20948. *
  20949. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  20950. */
  20951. convertIrradianceToLambertianRadiance(): void;
  20952. /**
  20953. * Integrates the reconstruction coefficients directly in to the SH preventing further
  20954. * required operations at run time.
  20955. *
  20956. * This is simply done by scaling back the SH with Ylm constants parameter.
  20957. * The trigonometric part being applied by the shader at run time.
  20958. */
  20959. preScaleForRendering(): void;
  20960. /**
  20961. * Constructs a spherical harmonics from an array.
  20962. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  20963. * @returns the spherical harmonics
  20964. */
  20965. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  20966. /**
  20967. * Gets the spherical harmonics from polynomial
  20968. * @param polynomial the spherical polynomial
  20969. * @returns the spherical harmonics
  20970. */
  20971. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  20972. }
  20973. /**
  20974. * Class representing spherical polynomial coefficients to the 3rd degree
  20975. */
  20976. export class SphericalPolynomial {
  20977. private _harmonics;
  20978. /**
  20979. * The spherical harmonics used to create the polynomials.
  20980. */
  20981. get preScaledHarmonics(): SphericalHarmonics;
  20982. /**
  20983. * The x coefficients of the spherical polynomial
  20984. */
  20985. x: Vector3;
  20986. /**
  20987. * The y coefficients of the spherical polynomial
  20988. */
  20989. y: Vector3;
  20990. /**
  20991. * The z coefficients of the spherical polynomial
  20992. */
  20993. z: Vector3;
  20994. /**
  20995. * The xx coefficients of the spherical polynomial
  20996. */
  20997. xx: Vector3;
  20998. /**
  20999. * The yy coefficients of the spherical polynomial
  21000. */
  21001. yy: Vector3;
  21002. /**
  21003. * The zz coefficients of the spherical polynomial
  21004. */
  21005. zz: Vector3;
  21006. /**
  21007. * The xy coefficients of the spherical polynomial
  21008. */
  21009. xy: Vector3;
  21010. /**
  21011. * The yz coefficients of the spherical polynomial
  21012. */
  21013. yz: Vector3;
  21014. /**
  21015. * The zx coefficients of the spherical polynomial
  21016. */
  21017. zx: Vector3;
  21018. /**
  21019. * Adds an ambient color to the spherical polynomial
  21020. * @param color the color to add
  21021. */
  21022. addAmbient(color: Color3): void;
  21023. /**
  21024. * Scales the spherical polynomial by the given amount
  21025. * @param scale the amount to scale
  21026. */
  21027. scaleInPlace(scale: number): void;
  21028. /**
  21029. * Gets the spherical polynomial from harmonics
  21030. * @param harmonics the spherical harmonics
  21031. * @returns the spherical polynomial
  21032. */
  21033. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21034. /**
  21035. * Constructs a spherical polynomial from an array.
  21036. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21037. * @returns the spherical polynomial
  21038. */
  21039. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21040. }
  21041. }
  21042. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  21043. import { Nullable } from "babylonjs/types";
  21044. /**
  21045. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21046. */
  21047. export interface CubeMapInfo {
  21048. /**
  21049. * The pixel array for the front face.
  21050. * This is stored in format, left to right, up to down format.
  21051. */
  21052. front: Nullable<ArrayBufferView>;
  21053. /**
  21054. * The pixel array for the back face.
  21055. * This is stored in format, left to right, up to down format.
  21056. */
  21057. back: Nullable<ArrayBufferView>;
  21058. /**
  21059. * The pixel array for the left face.
  21060. * This is stored in format, left to right, up to down format.
  21061. */
  21062. left: Nullable<ArrayBufferView>;
  21063. /**
  21064. * The pixel array for the right face.
  21065. * This is stored in format, left to right, up to down format.
  21066. */
  21067. right: Nullable<ArrayBufferView>;
  21068. /**
  21069. * The pixel array for the up face.
  21070. * This is stored in format, left to right, up to down format.
  21071. */
  21072. up: Nullable<ArrayBufferView>;
  21073. /**
  21074. * The pixel array for the down face.
  21075. * This is stored in format, left to right, up to down format.
  21076. */
  21077. down: Nullable<ArrayBufferView>;
  21078. /**
  21079. * The size of the cubemap stored.
  21080. *
  21081. * Each faces will be size * size pixels.
  21082. */
  21083. size: number;
  21084. /**
  21085. * The format of the texture.
  21086. *
  21087. * RGBA, RGB.
  21088. */
  21089. format: number;
  21090. /**
  21091. * The type of the texture data.
  21092. *
  21093. * UNSIGNED_INT, FLOAT.
  21094. */
  21095. type: number;
  21096. /**
  21097. * Specifies whether the texture is in gamma space.
  21098. */
  21099. gammaSpace: boolean;
  21100. }
  21101. /**
  21102. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21103. */
  21104. export class PanoramaToCubeMapTools {
  21105. private static FACE_LEFT;
  21106. private static FACE_RIGHT;
  21107. private static FACE_FRONT;
  21108. private static FACE_BACK;
  21109. private static FACE_DOWN;
  21110. private static FACE_UP;
  21111. /**
  21112. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  21113. *
  21114. * @param float32Array The source data.
  21115. * @param inputWidth The width of the input panorama.
  21116. * @param inputHeight The height of the input panorama.
  21117. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21118. * @return The cubemap data
  21119. */
  21120. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21121. private static CreateCubemapTexture;
  21122. private static CalcProjectionSpherical;
  21123. }
  21124. }
  21125. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  21126. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  21127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21128. import { Nullable } from "babylonjs/types";
  21129. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  21130. /**
  21131. * Helper class dealing with the extraction of spherical polynomial dataArray
  21132. * from a cube map.
  21133. */
  21134. export class CubeMapToSphericalPolynomialTools {
  21135. private static FileFaces;
  21136. /**
  21137. * Converts a texture to the according Spherical Polynomial data.
  21138. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21139. *
  21140. * @param texture The texture to extract the information from.
  21141. * @return The Spherical Polynomial data.
  21142. */
  21143. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  21144. /**
  21145. * Converts a cubemap to the according Spherical Polynomial data.
  21146. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21147. *
  21148. * @param cubeInfo The Cube map to extract the information from.
  21149. * @return The Spherical Polynomial data.
  21150. */
  21151. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21152. }
  21153. }
  21154. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  21155. import { Nullable } from "babylonjs/types";
  21156. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  21157. module "babylonjs/Materials/Textures/baseTexture" {
  21158. interface BaseTexture {
  21159. /**
  21160. * Get the polynomial representation of the texture data.
  21161. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21162. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21163. */
  21164. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21165. }
  21166. }
  21167. }
  21168. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  21169. /** @hidden */
  21170. export var pbrFragmentDeclaration: {
  21171. name: string;
  21172. shader: string;
  21173. };
  21174. }
  21175. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  21176. /** @hidden */
  21177. export var pbrUboDeclaration: {
  21178. name: string;
  21179. shader: string;
  21180. };
  21181. }
  21182. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  21183. /** @hidden */
  21184. export var pbrFragmentExtraDeclaration: {
  21185. name: string;
  21186. shader: string;
  21187. };
  21188. }
  21189. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  21190. /** @hidden */
  21191. export var pbrFragmentSamplersDeclaration: {
  21192. name: string;
  21193. shader: string;
  21194. };
  21195. }
  21196. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  21197. /** @hidden */
  21198. export var subSurfaceScatteringFunctions: {
  21199. name: string;
  21200. shader: string;
  21201. };
  21202. }
  21203. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  21204. /** @hidden */
  21205. export var importanceSampling: {
  21206. name: string;
  21207. shader: string;
  21208. };
  21209. }
  21210. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  21211. /** @hidden */
  21212. export var pbrHelperFunctions: {
  21213. name: string;
  21214. shader: string;
  21215. };
  21216. }
  21217. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  21218. /** @hidden */
  21219. export var harmonicsFunctions: {
  21220. name: string;
  21221. shader: string;
  21222. };
  21223. }
  21224. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  21225. /** @hidden */
  21226. export var pbrDirectLightingSetupFunctions: {
  21227. name: string;
  21228. shader: string;
  21229. };
  21230. }
  21231. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  21232. /** @hidden */
  21233. export var pbrDirectLightingFalloffFunctions: {
  21234. name: string;
  21235. shader: string;
  21236. };
  21237. }
  21238. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  21239. /** @hidden */
  21240. export var pbrBRDFFunctions: {
  21241. name: string;
  21242. shader: string;
  21243. };
  21244. }
  21245. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  21246. /** @hidden */
  21247. export var hdrFilteringFunctions: {
  21248. name: string;
  21249. shader: string;
  21250. };
  21251. }
  21252. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  21253. /** @hidden */
  21254. export var pbrDirectLightingFunctions: {
  21255. name: string;
  21256. shader: string;
  21257. };
  21258. }
  21259. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  21260. /** @hidden */
  21261. export var pbrIBLFunctions: {
  21262. name: string;
  21263. shader: string;
  21264. };
  21265. }
  21266. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  21267. /** @hidden */
  21268. export var pbrBlockAlbedoOpacity: {
  21269. name: string;
  21270. shader: string;
  21271. };
  21272. }
  21273. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  21274. /** @hidden */
  21275. export var pbrBlockReflectivity: {
  21276. name: string;
  21277. shader: string;
  21278. };
  21279. }
  21280. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  21281. /** @hidden */
  21282. export var pbrBlockAmbientOcclusion: {
  21283. name: string;
  21284. shader: string;
  21285. };
  21286. }
  21287. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  21288. /** @hidden */
  21289. export var pbrBlockAlphaFresnel: {
  21290. name: string;
  21291. shader: string;
  21292. };
  21293. }
  21294. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  21295. /** @hidden */
  21296. export var pbrBlockAnisotropic: {
  21297. name: string;
  21298. shader: string;
  21299. };
  21300. }
  21301. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  21302. /** @hidden */
  21303. export var pbrBlockReflection: {
  21304. name: string;
  21305. shader: string;
  21306. };
  21307. }
  21308. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  21309. /** @hidden */
  21310. export var pbrBlockSheen: {
  21311. name: string;
  21312. shader: string;
  21313. };
  21314. }
  21315. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  21316. /** @hidden */
  21317. export var pbrBlockClearcoat: {
  21318. name: string;
  21319. shader: string;
  21320. };
  21321. }
  21322. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  21323. /** @hidden */
  21324. export var pbrBlockSubSurface: {
  21325. name: string;
  21326. shader: string;
  21327. };
  21328. }
  21329. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  21330. /** @hidden */
  21331. export var pbrBlockNormalGeometric: {
  21332. name: string;
  21333. shader: string;
  21334. };
  21335. }
  21336. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  21337. /** @hidden */
  21338. export var pbrBlockNormalFinal: {
  21339. name: string;
  21340. shader: string;
  21341. };
  21342. }
  21343. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  21344. /** @hidden */
  21345. export var pbrBlockLightmapInit: {
  21346. name: string;
  21347. shader: string;
  21348. };
  21349. }
  21350. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  21351. /** @hidden */
  21352. export var pbrBlockGeometryInfo: {
  21353. name: string;
  21354. shader: string;
  21355. };
  21356. }
  21357. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  21358. /** @hidden */
  21359. export var pbrBlockReflectance0: {
  21360. name: string;
  21361. shader: string;
  21362. };
  21363. }
  21364. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  21365. /** @hidden */
  21366. export var pbrBlockReflectance: {
  21367. name: string;
  21368. shader: string;
  21369. };
  21370. }
  21371. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  21372. /** @hidden */
  21373. export var pbrBlockDirectLighting: {
  21374. name: string;
  21375. shader: string;
  21376. };
  21377. }
  21378. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  21379. /** @hidden */
  21380. export var pbrBlockFinalLitComponents: {
  21381. name: string;
  21382. shader: string;
  21383. };
  21384. }
  21385. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  21386. /** @hidden */
  21387. export var pbrBlockFinalUnlitComponents: {
  21388. name: string;
  21389. shader: string;
  21390. };
  21391. }
  21392. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  21393. /** @hidden */
  21394. export var pbrBlockFinalColorComposition: {
  21395. name: string;
  21396. shader: string;
  21397. };
  21398. }
  21399. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  21400. /** @hidden */
  21401. export var pbrBlockImageProcessing: {
  21402. name: string;
  21403. shader: string;
  21404. };
  21405. }
  21406. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  21407. /** @hidden */
  21408. export var pbrDebug: {
  21409. name: string;
  21410. shader: string;
  21411. };
  21412. }
  21413. declare module "babylonjs/Shaders/pbr.fragment" {
  21414. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  21415. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  21416. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  21417. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  21418. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  21419. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  21420. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  21421. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  21422. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  21423. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  21424. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  21425. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21426. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  21427. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  21428. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  21429. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  21430. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  21431. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  21432. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  21433. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  21434. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  21435. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  21436. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  21437. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  21438. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  21439. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  21440. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21441. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  21442. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  21443. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  21444. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  21445. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  21446. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  21447. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  21448. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  21449. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  21450. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  21451. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  21452. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  21453. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  21454. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  21455. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  21456. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  21457. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  21458. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  21459. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  21460. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  21461. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  21462. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  21463. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  21464. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  21465. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  21466. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  21467. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  21468. /** @hidden */
  21469. export var pbrPixelShader: {
  21470. name: string;
  21471. shader: string;
  21472. };
  21473. }
  21474. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  21475. /** @hidden */
  21476. export var pbrVertexDeclaration: {
  21477. name: string;
  21478. shader: string;
  21479. };
  21480. }
  21481. declare module "babylonjs/Shaders/pbr.vertex" {
  21482. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  21483. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  21484. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21485. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  21486. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  21487. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  21488. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  21489. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  21490. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  21491. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  21492. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  21493. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  21494. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  21495. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  21496. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  21497. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  21498. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  21499. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  21500. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  21501. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  21502. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  21503. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  21504. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  21505. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  21506. /** @hidden */
  21507. export var pbrVertexShader: {
  21508. name: string;
  21509. shader: string;
  21510. };
  21511. }
  21512. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  21513. import { Nullable } from "babylonjs/types";
  21514. import { Scene } from "babylonjs/scene";
  21515. import { Matrix } from "babylonjs/Maths/math.vector";
  21516. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21518. import { Mesh } from "babylonjs/Meshes/mesh";
  21519. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  21520. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  21521. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  21522. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  21523. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  21524. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  21525. import { Color3 } from "babylonjs/Maths/math.color";
  21526. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  21527. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  21528. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21529. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  21530. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21531. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21532. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  21533. import "babylonjs/Shaders/pbr.fragment";
  21534. import "babylonjs/Shaders/pbr.vertex";
  21535. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  21536. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  21537. /**
  21538. * Manages the defines for the PBR Material.
  21539. * @hidden
  21540. */
  21541. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  21542. PBR: boolean;
  21543. NUM_SAMPLES: string;
  21544. REALTIME_FILTERING: boolean;
  21545. MAINUV1: boolean;
  21546. MAINUV2: boolean;
  21547. UV1: boolean;
  21548. UV2: boolean;
  21549. ALBEDO: boolean;
  21550. GAMMAALBEDO: boolean;
  21551. ALBEDODIRECTUV: number;
  21552. VERTEXCOLOR: boolean;
  21553. DETAIL: boolean;
  21554. DETAILDIRECTUV: number;
  21555. DETAIL_NORMALBLENDMETHOD: number;
  21556. AMBIENT: boolean;
  21557. AMBIENTDIRECTUV: number;
  21558. AMBIENTINGRAYSCALE: boolean;
  21559. OPACITY: boolean;
  21560. VERTEXALPHA: boolean;
  21561. OPACITYDIRECTUV: number;
  21562. OPACITYRGB: boolean;
  21563. ALPHATEST: boolean;
  21564. DEPTHPREPASS: boolean;
  21565. ALPHABLEND: boolean;
  21566. ALPHAFROMALBEDO: boolean;
  21567. ALPHATESTVALUE: string;
  21568. SPECULAROVERALPHA: boolean;
  21569. RADIANCEOVERALPHA: boolean;
  21570. ALPHAFRESNEL: boolean;
  21571. LINEARALPHAFRESNEL: boolean;
  21572. PREMULTIPLYALPHA: boolean;
  21573. EMISSIVE: boolean;
  21574. EMISSIVEDIRECTUV: number;
  21575. REFLECTIVITY: boolean;
  21576. REFLECTIVITYDIRECTUV: number;
  21577. SPECULARTERM: boolean;
  21578. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  21579. MICROSURFACEAUTOMATIC: boolean;
  21580. LODBASEDMICROSFURACE: boolean;
  21581. MICROSURFACEMAP: boolean;
  21582. MICROSURFACEMAPDIRECTUV: number;
  21583. METALLICWORKFLOW: boolean;
  21584. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  21585. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  21586. METALLNESSSTOREINMETALMAPBLUE: boolean;
  21587. AOSTOREINMETALMAPRED: boolean;
  21588. METALLIC_REFLECTANCE: boolean;
  21589. METALLIC_REFLECTANCEDIRECTUV: number;
  21590. ENVIRONMENTBRDF: boolean;
  21591. ENVIRONMENTBRDF_RGBD: boolean;
  21592. NORMAL: boolean;
  21593. TANGENT: boolean;
  21594. BUMP: boolean;
  21595. BUMPDIRECTUV: number;
  21596. OBJECTSPACE_NORMALMAP: boolean;
  21597. PARALLAX: boolean;
  21598. PARALLAXOCCLUSION: boolean;
  21599. NORMALXYSCALE: boolean;
  21600. LIGHTMAP: boolean;
  21601. LIGHTMAPDIRECTUV: number;
  21602. USELIGHTMAPASSHADOWMAP: boolean;
  21603. GAMMALIGHTMAP: boolean;
  21604. RGBDLIGHTMAP: boolean;
  21605. REFLECTION: boolean;
  21606. REFLECTIONMAP_3D: boolean;
  21607. REFLECTIONMAP_SPHERICAL: boolean;
  21608. REFLECTIONMAP_PLANAR: boolean;
  21609. REFLECTIONMAP_CUBIC: boolean;
  21610. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  21611. REFLECTIONMAP_PROJECTION: boolean;
  21612. REFLECTIONMAP_SKYBOX: boolean;
  21613. REFLECTIONMAP_EXPLICIT: boolean;
  21614. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  21615. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  21616. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  21617. INVERTCUBICMAP: boolean;
  21618. USESPHERICALFROMREFLECTIONMAP: boolean;
  21619. USEIRRADIANCEMAP: boolean;
  21620. SPHERICAL_HARMONICS: boolean;
  21621. USESPHERICALINVERTEX: boolean;
  21622. REFLECTIONMAP_OPPOSITEZ: boolean;
  21623. LODINREFLECTIONALPHA: boolean;
  21624. GAMMAREFLECTION: boolean;
  21625. RGBDREFLECTION: boolean;
  21626. LINEARSPECULARREFLECTION: boolean;
  21627. RADIANCEOCCLUSION: boolean;
  21628. HORIZONOCCLUSION: boolean;
  21629. INSTANCES: boolean;
  21630. THIN_INSTANCES: boolean;
  21631. PREPASS: boolean;
  21632. PREPASS_IRRADIANCE: boolean;
  21633. PREPASS_IRRADIANCE_INDEX: number;
  21634. PREPASS_ALBEDO: boolean;
  21635. PREPASS_ALBEDO_INDEX: number;
  21636. PREPASS_DEPTHNORMAL: boolean;
  21637. PREPASS_DEPTHNORMAL_INDEX: number;
  21638. PREPASS_POSITION: boolean;
  21639. PREPASS_POSITION_INDEX: number;
  21640. PREPASS_VELOCITY: boolean;
  21641. PREPASS_VELOCITY_INDEX: number;
  21642. PREPASS_REFLECTIVITY: boolean;
  21643. PREPASS_REFLECTIVITY_INDEX: number;
  21644. SCENE_MRT_COUNT: number;
  21645. NUM_BONE_INFLUENCERS: number;
  21646. BonesPerMesh: number;
  21647. BONETEXTURE: boolean;
  21648. BONES_VELOCITY_ENABLED: boolean;
  21649. NONUNIFORMSCALING: boolean;
  21650. MORPHTARGETS: boolean;
  21651. MORPHTARGETS_NORMAL: boolean;
  21652. MORPHTARGETS_TANGENT: boolean;
  21653. MORPHTARGETS_UV: boolean;
  21654. NUM_MORPH_INFLUENCERS: number;
  21655. IMAGEPROCESSING: boolean;
  21656. VIGNETTE: boolean;
  21657. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21658. VIGNETTEBLENDMODEOPAQUE: boolean;
  21659. TONEMAPPING: boolean;
  21660. TONEMAPPING_ACES: boolean;
  21661. CONTRAST: boolean;
  21662. COLORCURVES: boolean;
  21663. COLORGRADING: boolean;
  21664. COLORGRADING3D: boolean;
  21665. SAMPLER3DGREENDEPTH: boolean;
  21666. SAMPLER3DBGRMAP: boolean;
  21667. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21668. EXPOSURE: boolean;
  21669. MULTIVIEW: boolean;
  21670. USEPHYSICALLIGHTFALLOFF: boolean;
  21671. USEGLTFLIGHTFALLOFF: boolean;
  21672. TWOSIDEDLIGHTING: boolean;
  21673. SHADOWFLOAT: boolean;
  21674. CLIPPLANE: boolean;
  21675. CLIPPLANE2: boolean;
  21676. CLIPPLANE3: boolean;
  21677. CLIPPLANE4: boolean;
  21678. CLIPPLANE5: boolean;
  21679. CLIPPLANE6: boolean;
  21680. POINTSIZE: boolean;
  21681. FOG: boolean;
  21682. LOGARITHMICDEPTH: boolean;
  21683. FORCENORMALFORWARD: boolean;
  21684. SPECULARAA: boolean;
  21685. CLEARCOAT: boolean;
  21686. CLEARCOAT_DEFAULTIOR: boolean;
  21687. CLEARCOAT_TEXTURE: boolean;
  21688. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  21689. CLEARCOAT_TEXTUREDIRECTUV: number;
  21690. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  21691. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21692. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21693. CLEARCOAT_BUMP: boolean;
  21694. CLEARCOAT_BUMPDIRECTUV: number;
  21695. CLEARCOAT_REMAP_F0: boolean;
  21696. CLEARCOAT_TINT: boolean;
  21697. CLEARCOAT_TINT_TEXTURE: boolean;
  21698. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  21699. ANISOTROPIC: boolean;
  21700. ANISOTROPIC_TEXTURE: boolean;
  21701. ANISOTROPIC_TEXTUREDIRECTUV: number;
  21702. BRDF_V_HEIGHT_CORRELATED: boolean;
  21703. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21704. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21705. SHEEN: boolean;
  21706. SHEEN_TEXTURE: boolean;
  21707. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21708. SHEEN_TEXTUREDIRECTUV: number;
  21709. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21710. SHEEN_LINKWITHALBEDO: boolean;
  21711. SHEEN_ROUGHNESS: boolean;
  21712. SHEEN_ALBEDOSCALING: boolean;
  21713. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21714. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21715. SUBSURFACE: boolean;
  21716. SS_REFRACTION: boolean;
  21717. SS_TRANSLUCENCY: boolean;
  21718. SS_SCATTERING: boolean;
  21719. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21720. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21721. SS_REFRACTIONMAP_3D: boolean;
  21722. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21723. SS_LODINREFRACTIONALPHA: boolean;
  21724. SS_GAMMAREFRACTION: boolean;
  21725. SS_RGBDREFRACTION: boolean;
  21726. SS_LINEARSPECULARREFRACTION: boolean;
  21727. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21728. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21729. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21730. UNLIT: boolean;
  21731. DEBUGMODE: number;
  21732. /**
  21733. * Initializes the PBR Material defines.
  21734. */
  21735. constructor();
  21736. /**
  21737. * Resets the PBR Material defines.
  21738. */
  21739. reset(): void;
  21740. }
  21741. /**
  21742. * The Physically based material base class of BJS.
  21743. *
  21744. * This offers the main features of a standard PBR material.
  21745. * For more information, please refer to the documentation :
  21746. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21747. */
  21748. export abstract class PBRBaseMaterial extends PushMaterial {
  21749. /**
  21750. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21751. */
  21752. static readonly PBRMATERIAL_OPAQUE: number;
  21753. /**
  21754. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21755. */
  21756. static readonly PBRMATERIAL_ALPHATEST: number;
  21757. /**
  21758. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21759. */
  21760. static readonly PBRMATERIAL_ALPHABLEND: number;
  21761. /**
  21762. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21763. * They are also discarded below the alpha cutoff threshold to improve performances.
  21764. */
  21765. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21766. /**
  21767. * Defines the default value of how much AO map is occluding the analytical lights
  21768. * (point spot...).
  21769. */
  21770. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21771. /**
  21772. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21773. */
  21774. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21775. /**
  21776. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21777. * to enhance interoperability with other engines.
  21778. */
  21779. static readonly LIGHTFALLOFF_GLTF: number;
  21780. /**
  21781. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21782. * to enhance interoperability with other materials.
  21783. */
  21784. static readonly LIGHTFALLOFF_STANDARD: number;
  21785. /**
  21786. * Intensity of the direct lights e.g. the four lights available in your scene.
  21787. * This impacts both the direct diffuse and specular highlights.
  21788. */
  21789. protected _directIntensity: number;
  21790. /**
  21791. * Intensity of the emissive part of the material.
  21792. * This helps controlling the emissive effect without modifying the emissive color.
  21793. */
  21794. protected _emissiveIntensity: number;
  21795. /**
  21796. * Intensity of the environment e.g. how much the environment will light the object
  21797. * either through harmonics for rough material or through the refelction for shiny ones.
  21798. */
  21799. protected _environmentIntensity: number;
  21800. /**
  21801. * This is a special control allowing the reduction of the specular highlights coming from the
  21802. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21803. */
  21804. protected _specularIntensity: number;
  21805. /**
  21806. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21807. */
  21808. private _lightingInfos;
  21809. /**
  21810. * Debug Control allowing disabling the bump map on this material.
  21811. */
  21812. protected _disableBumpMap: boolean;
  21813. /**
  21814. * AKA Diffuse Texture in standard nomenclature.
  21815. */
  21816. protected _albedoTexture: Nullable<BaseTexture>;
  21817. /**
  21818. * AKA Occlusion Texture in other nomenclature.
  21819. */
  21820. protected _ambientTexture: Nullable<BaseTexture>;
  21821. /**
  21822. * AKA Occlusion Texture Intensity in other nomenclature.
  21823. */
  21824. protected _ambientTextureStrength: number;
  21825. /**
  21826. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21827. * 1 means it completely occludes it
  21828. * 0 mean it has no impact
  21829. */
  21830. protected _ambientTextureImpactOnAnalyticalLights: number;
  21831. /**
  21832. * Stores the alpha values in a texture.
  21833. */
  21834. protected _opacityTexture: Nullable<BaseTexture>;
  21835. /**
  21836. * Stores the reflection values in a texture.
  21837. */
  21838. protected _reflectionTexture: Nullable<BaseTexture>;
  21839. /**
  21840. * Stores the emissive values in a texture.
  21841. */
  21842. protected _emissiveTexture: Nullable<BaseTexture>;
  21843. /**
  21844. * AKA Specular texture in other nomenclature.
  21845. */
  21846. protected _reflectivityTexture: Nullable<BaseTexture>;
  21847. /**
  21848. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21849. */
  21850. protected _metallicTexture: Nullable<BaseTexture>;
  21851. /**
  21852. * Specifies the metallic scalar of the metallic/roughness workflow.
  21853. * Can also be used to scale the metalness values of the metallic texture.
  21854. */
  21855. protected _metallic: Nullable<number>;
  21856. /**
  21857. * Specifies the roughness scalar of the metallic/roughness workflow.
  21858. * Can also be used to scale the roughness values of the metallic texture.
  21859. */
  21860. protected _roughness: Nullable<number>;
  21861. /**
  21862. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21863. * By default the indexOfrefraction is used to compute F0;
  21864. *
  21865. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21866. *
  21867. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21868. * F90 = metallicReflectanceColor;
  21869. */
  21870. protected _metallicF0Factor: number;
  21871. /**
  21872. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21873. * By default the F90 is always 1;
  21874. *
  21875. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21876. *
  21877. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21878. * F90 = metallicReflectanceColor;
  21879. */
  21880. protected _metallicReflectanceColor: Color3;
  21881. /**
  21882. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21883. * This is multiply against the scalar values defined in the material.
  21884. */
  21885. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  21886. /**
  21887. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21888. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21889. */
  21890. protected _microSurfaceTexture: Nullable<BaseTexture>;
  21891. /**
  21892. * Stores surface normal data used to displace a mesh in a texture.
  21893. */
  21894. protected _bumpTexture: Nullable<BaseTexture>;
  21895. /**
  21896. * Stores the pre-calculated light information of a mesh in a texture.
  21897. */
  21898. protected _lightmapTexture: Nullable<BaseTexture>;
  21899. /**
  21900. * The color of a material in ambient lighting.
  21901. */
  21902. protected _ambientColor: Color3;
  21903. /**
  21904. * AKA Diffuse Color in other nomenclature.
  21905. */
  21906. protected _albedoColor: Color3;
  21907. /**
  21908. * AKA Specular Color in other nomenclature.
  21909. */
  21910. protected _reflectivityColor: Color3;
  21911. /**
  21912. * The color applied when light is reflected from a material.
  21913. */
  21914. protected _reflectionColor: Color3;
  21915. /**
  21916. * The color applied when light is emitted from a material.
  21917. */
  21918. protected _emissiveColor: Color3;
  21919. /**
  21920. * AKA Glossiness in other nomenclature.
  21921. */
  21922. protected _microSurface: number;
  21923. /**
  21924. * Specifies that the material will use the light map as a show map.
  21925. */
  21926. protected _useLightmapAsShadowmap: boolean;
  21927. /**
  21928. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21929. * makes the reflect vector face the model (under horizon).
  21930. */
  21931. protected _useHorizonOcclusion: boolean;
  21932. /**
  21933. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21934. * too much the area relying on ambient texture to define their ambient occlusion.
  21935. */
  21936. protected _useRadianceOcclusion: boolean;
  21937. /**
  21938. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21939. */
  21940. protected _useAlphaFromAlbedoTexture: boolean;
  21941. /**
  21942. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  21943. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21944. */
  21945. protected _useSpecularOverAlpha: boolean;
  21946. /**
  21947. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21948. */
  21949. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21950. /**
  21951. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21952. */
  21953. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  21954. /**
  21955. * Specifies if the metallic texture contains the roughness information in its green channel.
  21956. */
  21957. protected _useRoughnessFromMetallicTextureGreen: boolean;
  21958. /**
  21959. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21960. */
  21961. protected _useMetallnessFromMetallicTextureBlue: boolean;
  21962. /**
  21963. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21964. */
  21965. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  21966. /**
  21967. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21968. */
  21969. protected _useAmbientInGrayScale: boolean;
  21970. /**
  21971. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21972. * The material will try to infer what glossiness each pixel should be.
  21973. */
  21974. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  21975. /**
  21976. * Defines the falloff type used in this material.
  21977. * It by default is Physical.
  21978. */
  21979. protected _lightFalloff: number;
  21980. /**
  21981. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21982. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21983. */
  21984. protected _useRadianceOverAlpha: boolean;
  21985. /**
  21986. * Allows using an object space normal map (instead of tangent space).
  21987. */
  21988. protected _useObjectSpaceNormalMap: boolean;
  21989. /**
  21990. * Allows using the bump map in parallax mode.
  21991. */
  21992. protected _useParallax: boolean;
  21993. /**
  21994. * Allows using the bump map in parallax occlusion mode.
  21995. */
  21996. protected _useParallaxOcclusion: boolean;
  21997. /**
  21998. * Controls the scale bias of the parallax mode.
  21999. */
  22000. protected _parallaxScaleBias: number;
  22001. /**
  22002. * If sets to true, disables all the lights affecting the material.
  22003. */
  22004. protected _disableLighting: boolean;
  22005. /**
  22006. * Number of Simultaneous lights allowed on the material.
  22007. */
  22008. protected _maxSimultaneousLights: number;
  22009. /**
  22010. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  22011. */
  22012. protected _invertNormalMapX: boolean;
  22013. /**
  22014. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  22015. */
  22016. protected _invertNormalMapY: boolean;
  22017. /**
  22018. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22019. */
  22020. protected _twoSidedLighting: boolean;
  22021. /**
  22022. * Defines the alpha limits in alpha test mode.
  22023. */
  22024. protected _alphaCutOff: number;
  22025. /**
  22026. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22027. */
  22028. protected _forceAlphaTest: boolean;
  22029. /**
  22030. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22031. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22032. */
  22033. protected _useAlphaFresnel: boolean;
  22034. /**
  22035. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22036. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22037. */
  22038. protected _useLinearAlphaFresnel: boolean;
  22039. /**
  22040. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  22041. * from cos thetav and roughness:
  22042. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  22043. */
  22044. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  22045. /**
  22046. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22047. */
  22048. protected _forceIrradianceInFragment: boolean;
  22049. private _realTimeFiltering;
  22050. /**
  22051. * Enables realtime filtering on the texture.
  22052. */
  22053. get realTimeFiltering(): boolean;
  22054. set realTimeFiltering(b: boolean);
  22055. private _realTimeFilteringQuality;
  22056. /**
  22057. * Quality switch for realtime filtering
  22058. */
  22059. get realTimeFilteringQuality(): number;
  22060. set realTimeFilteringQuality(n: number);
  22061. /**
  22062. * Can this material render to several textures at once
  22063. */
  22064. get canRenderToMRT(): boolean;
  22065. /**
  22066. * Force normal to face away from face.
  22067. */
  22068. protected _forceNormalForward: boolean;
  22069. /**
  22070. * Enables specular anti aliasing in the PBR shader.
  22071. * It will both interacts on the Geometry for analytical and IBL lighting.
  22072. * It also prefilter the roughness map based on the bump values.
  22073. */
  22074. protected _enableSpecularAntiAliasing: boolean;
  22075. /**
  22076. * Default configuration related to image processing available in the PBR Material.
  22077. */
  22078. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22079. /**
  22080. * Keep track of the image processing observer to allow dispose and replace.
  22081. */
  22082. private _imageProcessingObserver;
  22083. /**
  22084. * Attaches a new image processing configuration to the PBR Material.
  22085. * @param configuration
  22086. */
  22087. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22088. /**
  22089. * Stores the available render targets.
  22090. */
  22091. private _renderTargets;
  22092. /**
  22093. * Sets the global ambient color for the material used in lighting calculations.
  22094. */
  22095. private _globalAmbientColor;
  22096. /**
  22097. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22098. */
  22099. private _useLogarithmicDepth;
  22100. /**
  22101. * If set to true, no lighting calculations will be applied.
  22102. */
  22103. private _unlit;
  22104. private _debugMode;
  22105. /**
  22106. * @hidden
  22107. * This is reserved for the inspector.
  22108. * Defines the material debug mode.
  22109. * It helps seeing only some components of the material while troubleshooting.
  22110. */
  22111. debugMode: number;
  22112. /**
  22113. * @hidden
  22114. * This is reserved for the inspector.
  22115. * Specify from where on screen the debug mode should start.
  22116. * The value goes from -1 (full screen) to 1 (not visible)
  22117. * It helps with side by side comparison against the final render
  22118. * This defaults to -1
  22119. */
  22120. private debugLimit;
  22121. /**
  22122. * @hidden
  22123. * This is reserved for the inspector.
  22124. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22125. * You can use the factor to better multiply the final value.
  22126. */
  22127. private debugFactor;
  22128. /**
  22129. * Defines the clear coat layer parameters for the material.
  22130. */
  22131. readonly clearCoat: PBRClearCoatConfiguration;
  22132. /**
  22133. * Defines the anisotropic parameters for the material.
  22134. */
  22135. readonly anisotropy: PBRAnisotropicConfiguration;
  22136. /**
  22137. * Defines the BRDF parameters for the material.
  22138. */
  22139. readonly brdf: PBRBRDFConfiguration;
  22140. /**
  22141. * Defines the Sheen parameters for the material.
  22142. */
  22143. readonly sheen: PBRSheenConfiguration;
  22144. /**
  22145. * Defines the SubSurface parameters for the material.
  22146. */
  22147. readonly subSurface: PBRSubSurfaceConfiguration;
  22148. /**
  22149. * Defines additionnal PrePass parameters for the material.
  22150. */
  22151. readonly prePassConfiguration: PrePassConfiguration;
  22152. /**
  22153. * Defines the detail map parameters for the material.
  22154. */
  22155. readonly detailMap: DetailMapConfiguration;
  22156. protected _rebuildInParallel: boolean;
  22157. /**
  22158. * Instantiates a new PBRMaterial instance.
  22159. *
  22160. * @param name The material name
  22161. * @param scene The scene the material will be use in.
  22162. */
  22163. constructor(name: string, scene: Scene);
  22164. /**
  22165. * Gets a boolean indicating that current material needs to register RTT
  22166. */
  22167. get hasRenderTargetTextures(): boolean;
  22168. /**
  22169. * Gets the name of the material class.
  22170. */
  22171. getClassName(): string;
  22172. /**
  22173. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22174. */
  22175. get useLogarithmicDepth(): boolean;
  22176. /**
  22177. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22178. */
  22179. set useLogarithmicDepth(value: boolean);
  22180. /**
  22181. * Returns true if alpha blending should be disabled.
  22182. */
  22183. protected get _disableAlphaBlending(): boolean;
  22184. /**
  22185. * Specifies whether or not this material should be rendered in alpha blend mode.
  22186. */
  22187. needAlphaBlending(): boolean;
  22188. /**
  22189. * Specifies whether or not this material should be rendered in alpha test mode.
  22190. */
  22191. needAlphaTesting(): boolean;
  22192. /**
  22193. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22194. */
  22195. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22196. /**
  22197. * Specifies whether or not there is a usable alpha channel for transparency.
  22198. */
  22199. protected _hasAlphaChannel(): boolean;
  22200. /**
  22201. * Gets the texture used for the alpha test.
  22202. */
  22203. getAlphaTestTexture(): Nullable<BaseTexture>;
  22204. /**
  22205. * Specifies that the submesh is ready to be used.
  22206. * @param mesh - BJS mesh.
  22207. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22208. * @param useInstances - Specifies that instances should be used.
  22209. * @returns - boolean indicating that the submesh is ready or not.
  22210. */
  22211. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22212. /**
  22213. * Specifies if the material uses metallic roughness workflow.
  22214. * @returns boolean specifiying if the material uses metallic roughness workflow.
  22215. */
  22216. isMetallicWorkflow(): boolean;
  22217. private _prepareEffect;
  22218. private _prepareDefines;
  22219. /**
  22220. * Force shader compilation
  22221. */
  22222. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  22223. /**
  22224. * Initializes the uniform buffer layout for the shader.
  22225. */
  22226. buildUniformLayout(): void;
  22227. /**
  22228. * Unbinds the material from the mesh
  22229. */
  22230. unbind(): void;
  22231. /**
  22232. * Binds the submesh data.
  22233. * @param world - The world matrix.
  22234. * @param mesh - The BJS mesh.
  22235. * @param subMesh - A submesh of the BJS mesh.
  22236. */
  22237. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22238. /**
  22239. * Returns the animatable textures.
  22240. * @returns - Array of animatable textures.
  22241. */
  22242. getAnimatables(): IAnimatable[];
  22243. /**
  22244. * Returns the texture used for reflections.
  22245. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  22246. */
  22247. private _getReflectionTexture;
  22248. /**
  22249. * Returns an array of the actively used textures.
  22250. * @returns - Array of BaseTextures
  22251. */
  22252. getActiveTextures(): BaseTexture[];
  22253. /**
  22254. * Checks to see if a texture is used in the material.
  22255. * @param texture - Base texture to use.
  22256. * @returns - Boolean specifying if a texture is used in the material.
  22257. */
  22258. hasTexture(texture: BaseTexture): boolean;
  22259. /**
  22260. * Sets the required values to the prepass renderer.
  22261. * @param prePassRenderer defines the prepass renderer to setup
  22262. */
  22263. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22264. /**
  22265. * Disposes the resources of the material.
  22266. * @param forceDisposeEffect - Forces the disposal of effects.
  22267. * @param forceDisposeTextures - Forces the disposal of all textures.
  22268. */
  22269. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22270. }
  22271. }
  22272. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  22273. import { Nullable } from "babylonjs/types";
  22274. import { Scene } from "babylonjs/scene";
  22275. import { Color3 } from "babylonjs/Maths/math.color";
  22276. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  22277. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  22278. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22279. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  22280. /**
  22281. * The Physically based material of BJS.
  22282. *
  22283. * This offers the main features of a standard PBR material.
  22284. * For more information, please refer to the documentation :
  22285. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22286. */
  22287. export class PBRMaterial extends PBRBaseMaterial {
  22288. /**
  22289. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22290. */
  22291. static readonly PBRMATERIAL_OPAQUE: number;
  22292. /**
  22293. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22294. */
  22295. static readonly PBRMATERIAL_ALPHATEST: number;
  22296. /**
  22297. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22298. */
  22299. static readonly PBRMATERIAL_ALPHABLEND: number;
  22300. /**
  22301. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22302. * They are also discarded below the alpha cutoff threshold to improve performances.
  22303. */
  22304. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22305. /**
  22306. * Defines the default value of how much AO map is occluding the analytical lights
  22307. * (point spot...).
  22308. */
  22309. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22310. /**
  22311. * Intensity of the direct lights e.g. the four lights available in your scene.
  22312. * This impacts both the direct diffuse and specular highlights.
  22313. */
  22314. directIntensity: number;
  22315. /**
  22316. * Intensity of the emissive part of the material.
  22317. * This helps controlling the emissive effect without modifying the emissive color.
  22318. */
  22319. emissiveIntensity: number;
  22320. /**
  22321. * Intensity of the environment e.g. how much the environment will light the object
  22322. * either through harmonics for rough material or through the refelction for shiny ones.
  22323. */
  22324. environmentIntensity: number;
  22325. /**
  22326. * This is a special control allowing the reduction of the specular highlights coming from the
  22327. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22328. */
  22329. specularIntensity: number;
  22330. /**
  22331. * Debug Control allowing disabling the bump map on this material.
  22332. */
  22333. disableBumpMap: boolean;
  22334. /**
  22335. * AKA Diffuse Texture in standard nomenclature.
  22336. */
  22337. albedoTexture: BaseTexture;
  22338. /**
  22339. * AKA Occlusion Texture in other nomenclature.
  22340. */
  22341. ambientTexture: BaseTexture;
  22342. /**
  22343. * AKA Occlusion Texture Intensity in other nomenclature.
  22344. */
  22345. ambientTextureStrength: number;
  22346. /**
  22347. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22348. * 1 means it completely occludes it
  22349. * 0 mean it has no impact
  22350. */
  22351. ambientTextureImpactOnAnalyticalLights: number;
  22352. /**
  22353. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  22354. */
  22355. opacityTexture: BaseTexture;
  22356. /**
  22357. * Stores the reflection values in a texture.
  22358. */
  22359. reflectionTexture: Nullable<BaseTexture>;
  22360. /**
  22361. * Stores the emissive values in a texture.
  22362. */
  22363. emissiveTexture: BaseTexture;
  22364. /**
  22365. * AKA Specular texture in other nomenclature.
  22366. */
  22367. reflectivityTexture: BaseTexture;
  22368. /**
  22369. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22370. */
  22371. metallicTexture: BaseTexture;
  22372. /**
  22373. * Specifies the metallic scalar of the metallic/roughness workflow.
  22374. * Can also be used to scale the metalness values of the metallic texture.
  22375. */
  22376. metallic: Nullable<number>;
  22377. /**
  22378. * Specifies the roughness scalar of the metallic/roughness workflow.
  22379. * Can also be used to scale the roughness values of the metallic texture.
  22380. */
  22381. roughness: Nullable<number>;
  22382. /**
  22383. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22384. * By default the indexOfrefraction is used to compute F0;
  22385. *
  22386. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22387. *
  22388. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22389. * F90 = metallicReflectanceColor;
  22390. */
  22391. metallicF0Factor: number;
  22392. /**
  22393. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22394. * By default the F90 is always 1;
  22395. *
  22396. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22397. *
  22398. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22399. * F90 = metallicReflectanceColor;
  22400. */
  22401. metallicReflectanceColor: Color3;
  22402. /**
  22403. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22404. * This is multiply against the scalar values defined in the material.
  22405. */
  22406. metallicReflectanceTexture: Nullable<BaseTexture>;
  22407. /**
  22408. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22409. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22410. */
  22411. microSurfaceTexture: BaseTexture;
  22412. /**
  22413. * Stores surface normal data used to displace a mesh in a texture.
  22414. */
  22415. bumpTexture: BaseTexture;
  22416. /**
  22417. * Stores the pre-calculated light information of a mesh in a texture.
  22418. */
  22419. lightmapTexture: BaseTexture;
  22420. /**
  22421. * Stores the refracted light information in a texture.
  22422. */
  22423. get refractionTexture(): Nullable<BaseTexture>;
  22424. set refractionTexture(value: Nullable<BaseTexture>);
  22425. /**
  22426. * The color of a material in ambient lighting.
  22427. */
  22428. ambientColor: Color3;
  22429. /**
  22430. * AKA Diffuse Color in other nomenclature.
  22431. */
  22432. albedoColor: Color3;
  22433. /**
  22434. * AKA Specular Color in other nomenclature.
  22435. */
  22436. reflectivityColor: Color3;
  22437. /**
  22438. * The color reflected from the material.
  22439. */
  22440. reflectionColor: Color3;
  22441. /**
  22442. * The color emitted from the material.
  22443. */
  22444. emissiveColor: Color3;
  22445. /**
  22446. * AKA Glossiness in other nomenclature.
  22447. */
  22448. microSurface: number;
  22449. /**
  22450. * Index of refraction of the material base layer.
  22451. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  22452. *
  22453. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  22454. *
  22455. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  22456. */
  22457. get indexOfRefraction(): number;
  22458. set indexOfRefraction(value: number);
  22459. /**
  22460. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22461. */
  22462. get invertRefractionY(): boolean;
  22463. set invertRefractionY(value: boolean);
  22464. /**
  22465. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  22466. * Materials half opaque for instance using refraction could benefit from this control.
  22467. */
  22468. get linkRefractionWithTransparency(): boolean;
  22469. set linkRefractionWithTransparency(value: boolean);
  22470. /**
  22471. * If true, the light map contains occlusion information instead of lighting info.
  22472. */
  22473. useLightmapAsShadowmap: boolean;
  22474. /**
  22475. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22476. */
  22477. useAlphaFromAlbedoTexture: boolean;
  22478. /**
  22479. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22480. */
  22481. forceAlphaTest: boolean;
  22482. /**
  22483. * Defines the alpha limits in alpha test mode.
  22484. */
  22485. alphaCutOff: number;
  22486. /**
  22487. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  22488. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  22489. */
  22490. useSpecularOverAlpha: boolean;
  22491. /**
  22492. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22493. */
  22494. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22495. /**
  22496. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22497. */
  22498. useRoughnessFromMetallicTextureAlpha: boolean;
  22499. /**
  22500. * Specifies if the metallic texture contains the roughness information in its green channel.
  22501. */
  22502. useRoughnessFromMetallicTextureGreen: boolean;
  22503. /**
  22504. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22505. */
  22506. useMetallnessFromMetallicTextureBlue: boolean;
  22507. /**
  22508. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22509. */
  22510. useAmbientOcclusionFromMetallicTextureRed: boolean;
  22511. /**
  22512. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22513. */
  22514. useAmbientInGrayScale: boolean;
  22515. /**
  22516. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22517. * The material will try to infer what glossiness each pixel should be.
  22518. */
  22519. useAutoMicroSurfaceFromReflectivityMap: boolean;
  22520. /**
  22521. * BJS is using an harcoded light falloff based on a manually sets up range.
  22522. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22523. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22524. */
  22525. get usePhysicalLightFalloff(): boolean;
  22526. /**
  22527. * BJS is using an harcoded light falloff based on a manually sets up range.
  22528. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22529. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22530. */
  22531. set usePhysicalLightFalloff(value: boolean);
  22532. /**
  22533. * In order to support the falloff compatibility with gltf, a special mode has been added
  22534. * to reproduce the gltf light falloff.
  22535. */
  22536. get useGLTFLightFalloff(): boolean;
  22537. /**
  22538. * In order to support the falloff compatibility with gltf, a special mode has been added
  22539. * to reproduce the gltf light falloff.
  22540. */
  22541. set useGLTFLightFalloff(value: boolean);
  22542. /**
  22543. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  22544. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  22545. */
  22546. useRadianceOverAlpha: boolean;
  22547. /**
  22548. * Allows using an object space normal map (instead of tangent space).
  22549. */
  22550. useObjectSpaceNormalMap: boolean;
  22551. /**
  22552. * Allows using the bump map in parallax mode.
  22553. */
  22554. useParallax: boolean;
  22555. /**
  22556. * Allows using the bump map in parallax occlusion mode.
  22557. */
  22558. useParallaxOcclusion: boolean;
  22559. /**
  22560. * Controls the scale bias of the parallax mode.
  22561. */
  22562. parallaxScaleBias: number;
  22563. /**
  22564. * If sets to true, disables all the lights affecting the material.
  22565. */
  22566. disableLighting: boolean;
  22567. /**
  22568. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22569. */
  22570. forceIrradianceInFragment: boolean;
  22571. /**
  22572. * Number of Simultaneous lights allowed on the material.
  22573. */
  22574. maxSimultaneousLights: number;
  22575. /**
  22576. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  22577. */
  22578. invertNormalMapX: boolean;
  22579. /**
  22580. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  22581. */
  22582. invertNormalMapY: boolean;
  22583. /**
  22584. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22585. */
  22586. twoSidedLighting: boolean;
  22587. /**
  22588. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22589. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22590. */
  22591. useAlphaFresnel: boolean;
  22592. /**
  22593. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22594. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22595. */
  22596. useLinearAlphaFresnel: boolean;
  22597. /**
  22598. * Let user defines the brdf lookup texture used for IBL.
  22599. * A default 8bit version is embedded but you could point at :
  22600. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  22601. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  22602. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  22603. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  22604. */
  22605. environmentBRDFTexture: Nullable<BaseTexture>;
  22606. /**
  22607. * Force normal to face away from face.
  22608. */
  22609. forceNormalForward: boolean;
  22610. /**
  22611. * Enables specular anti aliasing in the PBR shader.
  22612. * It will both interacts on the Geometry for analytical and IBL lighting.
  22613. * It also prefilter the roughness map based on the bump values.
  22614. */
  22615. enableSpecularAntiAliasing: boolean;
  22616. /**
  22617. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22618. * makes the reflect vector face the model (under horizon).
  22619. */
  22620. useHorizonOcclusion: boolean;
  22621. /**
  22622. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22623. * too much the area relying on ambient texture to define their ambient occlusion.
  22624. */
  22625. useRadianceOcclusion: boolean;
  22626. /**
  22627. * If set to true, no lighting calculations will be applied.
  22628. */
  22629. unlit: boolean;
  22630. /**
  22631. * Gets the image processing configuration used either in this material.
  22632. */
  22633. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22634. /**
  22635. * Sets the Default image processing configuration used either in the this material.
  22636. *
  22637. * If sets to null, the scene one is in use.
  22638. */
  22639. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22640. /**
  22641. * Gets wether the color curves effect is enabled.
  22642. */
  22643. get cameraColorCurvesEnabled(): boolean;
  22644. /**
  22645. * Sets wether the color curves effect is enabled.
  22646. */
  22647. set cameraColorCurvesEnabled(value: boolean);
  22648. /**
  22649. * Gets wether the color grading effect is enabled.
  22650. */
  22651. get cameraColorGradingEnabled(): boolean;
  22652. /**
  22653. * Gets wether the color grading effect is enabled.
  22654. */
  22655. set cameraColorGradingEnabled(value: boolean);
  22656. /**
  22657. * Gets wether tonemapping is enabled or not.
  22658. */
  22659. get cameraToneMappingEnabled(): boolean;
  22660. /**
  22661. * Sets wether tonemapping is enabled or not
  22662. */
  22663. set cameraToneMappingEnabled(value: boolean);
  22664. /**
  22665. * The camera exposure used on this material.
  22666. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22667. * This corresponds to a photographic exposure.
  22668. */
  22669. get cameraExposure(): number;
  22670. /**
  22671. * The camera exposure used on this material.
  22672. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22673. * This corresponds to a photographic exposure.
  22674. */
  22675. set cameraExposure(value: number);
  22676. /**
  22677. * Gets The camera contrast used on this material.
  22678. */
  22679. get cameraContrast(): number;
  22680. /**
  22681. * Sets The camera contrast used on this material.
  22682. */
  22683. set cameraContrast(value: number);
  22684. /**
  22685. * Gets the Color Grading 2D Lookup Texture.
  22686. */
  22687. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  22688. /**
  22689. * Sets the Color Grading 2D Lookup Texture.
  22690. */
  22691. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  22692. /**
  22693. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22694. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22695. * 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;
  22696. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22697. */
  22698. get cameraColorCurves(): Nullable<ColorCurves>;
  22699. /**
  22700. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22701. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22702. * 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;
  22703. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22704. */
  22705. set cameraColorCurves(value: Nullable<ColorCurves>);
  22706. /**
  22707. * Instantiates a new PBRMaterial instance.
  22708. *
  22709. * @param name The material name
  22710. * @param scene The scene the material will be use in.
  22711. */
  22712. constructor(name: string, scene: Scene);
  22713. /**
  22714. * Returns the name of this material class.
  22715. */
  22716. getClassName(): string;
  22717. /**
  22718. * Makes a duplicate of the current material.
  22719. * @param name - name to use for the new material.
  22720. */
  22721. clone(name: string): PBRMaterial;
  22722. /**
  22723. * Serializes this PBR Material.
  22724. * @returns - An object with the serialized material.
  22725. */
  22726. serialize(): any;
  22727. /**
  22728. * Parses a PBR Material from a serialized object.
  22729. * @param source - Serialized object.
  22730. * @param scene - BJS scene instance.
  22731. * @param rootUrl - url for the scene object
  22732. * @returns - PBRMaterial
  22733. */
  22734. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  22735. }
  22736. }
  22737. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  22738. /** @hidden */
  22739. export var mrtFragmentDeclaration: {
  22740. name: string;
  22741. shader: string;
  22742. };
  22743. }
  22744. declare module "babylonjs/Shaders/geometry.fragment" {
  22745. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  22746. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  22747. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  22748. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  22749. /** @hidden */
  22750. export var geometryPixelShader: {
  22751. name: string;
  22752. shader: string;
  22753. };
  22754. }
  22755. declare module "babylonjs/Shaders/geometry.vertex" {
  22756. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  22757. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  22758. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  22759. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  22760. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  22761. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  22762. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  22763. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  22764. /** @hidden */
  22765. export var geometryVertexShader: {
  22766. name: string;
  22767. shader: string;
  22768. };
  22769. }
  22770. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  22771. import { Matrix } from "babylonjs/Maths/math.vector";
  22772. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22773. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  22774. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  22775. import { Effect } from "babylonjs/Materials/effect";
  22776. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  22777. import { Scene } from "babylonjs/scene";
  22778. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22779. import { Nullable } from "babylonjs/types";
  22780. import "babylonjs/Shaders/geometry.fragment";
  22781. import "babylonjs/Shaders/geometry.vertex";
  22782. /** @hidden */
  22783. interface ISavedTransformationMatrix {
  22784. world: Matrix;
  22785. viewProjection: Matrix;
  22786. }
  22787. /**
  22788. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  22789. */
  22790. export class GeometryBufferRenderer {
  22791. /**
  22792. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  22793. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  22794. */
  22795. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  22796. /**
  22797. * Constant used to retrieve the position texture index in the G-Buffer textures array
  22798. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  22799. */
  22800. static readonly POSITION_TEXTURE_TYPE: number;
  22801. /**
  22802. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22803. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22804. */
  22805. static readonly VELOCITY_TEXTURE_TYPE: number;
  22806. /**
  22807. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22808. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22809. */
  22810. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22811. /**
  22812. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22813. * in order to compute objects velocities when enableVelocity is set to "true"
  22814. * @hidden
  22815. */
  22816. _previousTransformationMatrices: {
  22817. [index: number]: ISavedTransformationMatrix;
  22818. };
  22819. /**
  22820. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22821. * in order to compute objects velocities when enableVelocity is set to "true"
  22822. * @hidden
  22823. */
  22824. _previousBonesTransformationMatrices: {
  22825. [index: number]: Float32Array;
  22826. };
  22827. /**
  22828. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22829. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22830. */
  22831. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22832. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22833. renderTransparentMeshes: boolean;
  22834. private _scene;
  22835. private _resizeObserver;
  22836. private _multiRenderTarget;
  22837. private _ratio;
  22838. private _enablePosition;
  22839. private _enableVelocity;
  22840. private _enableReflectivity;
  22841. private _positionIndex;
  22842. private _velocityIndex;
  22843. private _reflectivityIndex;
  22844. private _depthNormalIndex;
  22845. private _linkedWithPrePass;
  22846. private _prePassRenderer;
  22847. private _attachments;
  22848. protected _effect: Effect;
  22849. protected _cachedDefines: string;
  22850. /**
  22851. * @hidden
  22852. * Sets up internal structures to share outputs with PrePassRenderer
  22853. * This method should only be called by the PrePassRenderer itself
  22854. */
  22855. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  22856. /**
  22857. * @hidden
  22858. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  22859. * This method should only be called by the PrePassRenderer itself
  22860. */
  22861. _unlinkPrePassRenderer(): void;
  22862. /**
  22863. * @hidden
  22864. * Resets the geometry buffer layout
  22865. */
  22866. _resetLayout(): void;
  22867. /**
  22868. * @hidden
  22869. * Replaces a texture in the geometry buffer renderer
  22870. * Useful when linking textures of the prepass renderer
  22871. */
  22872. _forceTextureType(geometryBufferType: number, index: number): void;
  22873. /**
  22874. * @hidden
  22875. * Sets texture attachments
  22876. * Useful when linking textures of the prepass renderer
  22877. */
  22878. _setAttachments(attachments: number[]): void;
  22879. /**
  22880. * @hidden
  22881. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  22882. * Useful when linking textures of the prepass renderer
  22883. */
  22884. _linkInternalTexture(internalTexture: InternalTexture): void;
  22885. /**
  22886. * Gets the render list (meshes to be rendered) used in the G buffer.
  22887. */
  22888. get renderList(): Nullable<AbstractMesh[]>;
  22889. /**
  22890. * Set the render list (meshes to be rendered) used in the G buffer.
  22891. */
  22892. set renderList(meshes: Nullable<AbstractMesh[]>);
  22893. /**
  22894. * Gets wether or not G buffer are supported by the running hardware.
  22895. * This requires draw buffer supports
  22896. */
  22897. get isSupported(): boolean;
  22898. /**
  22899. * Returns the index of the given texture type in the G-Buffer textures array
  22900. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  22901. * @returns the index of the given texture type in the G-Buffer textures array
  22902. */
  22903. getTextureIndex(textureType: number): number;
  22904. /**
  22905. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  22906. */
  22907. get enablePosition(): boolean;
  22908. /**
  22909. * Sets whether or not objects positions are enabled for the G buffer.
  22910. */
  22911. set enablePosition(enable: boolean);
  22912. /**
  22913. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  22914. */
  22915. get enableVelocity(): boolean;
  22916. /**
  22917. * Sets wether or not objects velocities are enabled for the G buffer.
  22918. */
  22919. set enableVelocity(enable: boolean);
  22920. /**
  22921. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  22922. */
  22923. get enableReflectivity(): boolean;
  22924. /**
  22925. * Sets wether or not objects roughness are enabled for the G buffer.
  22926. */
  22927. set enableReflectivity(enable: boolean);
  22928. /**
  22929. * Gets the scene associated with the buffer.
  22930. */
  22931. get scene(): Scene;
  22932. /**
  22933. * Gets the ratio used by the buffer during its creation.
  22934. * How big is the buffer related to the main canvas.
  22935. */
  22936. get ratio(): number;
  22937. /** @hidden */
  22938. static _SceneComponentInitialization: (scene: Scene) => void;
  22939. /**
  22940. * Creates a new G Buffer for the scene
  22941. * @param scene The scene the buffer belongs to
  22942. * @param ratio How big is the buffer related to the main canvas.
  22943. */
  22944. constructor(scene: Scene, ratio?: number);
  22945. /**
  22946. * Checks wether everything is ready to render a submesh to the G buffer.
  22947. * @param subMesh the submesh to check readiness for
  22948. * @param useInstances is the mesh drawn using instance or not
  22949. * @returns true if ready otherwise false
  22950. */
  22951. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  22952. /**
  22953. * Gets the current underlying G Buffer.
  22954. * @returns the buffer
  22955. */
  22956. getGBuffer(): MultiRenderTarget;
  22957. /**
  22958. * Gets the number of samples used to render the buffer (anti aliasing).
  22959. */
  22960. get samples(): number;
  22961. /**
  22962. * Sets the number of samples used to render the buffer (anti aliasing).
  22963. */
  22964. set samples(value: number);
  22965. /**
  22966. * Disposes the renderer and frees up associated resources.
  22967. */
  22968. dispose(): void;
  22969. private _assignRenderTargetIndices;
  22970. protected _createRenderTargets(): void;
  22971. private _copyBonesTransformationMatrices;
  22972. }
  22973. }
  22974. declare module "babylonjs/Rendering/prePassRenderer" {
  22975. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  22976. import { Scene } from "babylonjs/scene";
  22977. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  22978. import { Effect } from "babylonjs/Materials/effect";
  22979. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  22980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22981. import { Material } from "babylonjs/Materials/material";
  22982. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22983. /**
  22984. * Renders a pre pass of the scene
  22985. * This means every mesh in the scene will be rendered to a render target texture
  22986. * And then this texture will be composited to the rendering canvas with post processes
  22987. * It is necessary for effects like subsurface scattering or deferred shading
  22988. */
  22989. export class PrePassRenderer {
  22990. /** @hidden */
  22991. static _SceneComponentInitialization: (scene: Scene) => void;
  22992. private _textureFormats;
  22993. /**
  22994. * To save performance, we can excluded skinned meshes from the prepass
  22995. */
  22996. excludedSkinnedMesh: AbstractMesh[];
  22997. /**
  22998. * Force material to be excluded from the prepass
  22999. * Can be useful when `useGeometryBufferFallback` is set to `true`
  23000. * and you don't want a material to show in the effect.
  23001. */
  23002. excludedMaterials: Material[];
  23003. private _textureIndices;
  23004. private _scene;
  23005. private _engine;
  23006. private _isDirty;
  23007. /**
  23008. * Number of textures in the multi render target texture where the scene is directly rendered
  23009. */
  23010. mrtCount: number;
  23011. /**
  23012. * The render target where the scene is directly rendered
  23013. */
  23014. prePassRT: MultiRenderTarget;
  23015. private _multiRenderAttachments;
  23016. private _defaultAttachments;
  23017. private _clearAttachments;
  23018. private _postProcesses;
  23019. private readonly _clearColor;
  23020. /**
  23021. * Image processing post process for composition
  23022. */
  23023. imageProcessingPostProcess: ImageProcessingPostProcess;
  23024. /**
  23025. * Configuration for prepass effects
  23026. */
  23027. private _effectConfigurations;
  23028. private _mrtFormats;
  23029. private _mrtLayout;
  23030. private _enabled;
  23031. /**
  23032. * Indicates if the prepass is enabled
  23033. */
  23034. get enabled(): boolean;
  23035. /**
  23036. * How many samples are used for MSAA of the scene render target
  23037. */
  23038. get samples(): number;
  23039. set samples(n: number);
  23040. private _geometryBuffer;
  23041. private _useGeometryBufferFallback;
  23042. /**
  23043. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  23044. */
  23045. get useGeometryBufferFallback(): boolean;
  23046. set useGeometryBufferFallback(value: boolean);
  23047. /**
  23048. * Instanciates a prepass renderer
  23049. * @param scene The scene
  23050. */
  23051. constructor(scene: Scene);
  23052. private _initializeAttachments;
  23053. private _createCompositionEffect;
  23054. /**
  23055. * Indicates if rendering a prepass is supported
  23056. */
  23057. get isSupported(): boolean;
  23058. /**
  23059. * Sets the proper output textures to draw in the engine.
  23060. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  23061. * @param subMesh Submesh on which the effect is applied
  23062. */
  23063. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  23064. /**
  23065. * @hidden
  23066. */
  23067. _beforeCameraDraw(): void;
  23068. /**
  23069. * @hidden
  23070. */
  23071. _afterCameraDraw(): void;
  23072. private _checkRTSize;
  23073. private _bindFrameBuffer;
  23074. /**
  23075. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  23076. */
  23077. clear(): void;
  23078. private _setState;
  23079. private _updateGeometryBufferLayout;
  23080. /**
  23081. * Adds an effect configuration to the prepass.
  23082. * If an effect has already been added, it won't add it twice and will return the configuration
  23083. * already present.
  23084. * @param cfg the effect configuration
  23085. * @return the effect configuration now used by the prepass
  23086. */
  23087. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23088. /**
  23089. * Returns the index of a texture in the multi render target texture array.
  23090. * @param type Texture type
  23091. * @return The index
  23092. */
  23093. getIndex(type: number): number;
  23094. private _enable;
  23095. private _disable;
  23096. private _resetLayout;
  23097. private _resetPostProcessChain;
  23098. private _bindPostProcessChain;
  23099. /**
  23100. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23101. */
  23102. markAsDirty(): void;
  23103. /**
  23104. * Enables a texture on the MultiRenderTarget for prepass
  23105. */
  23106. private _enableTextures;
  23107. private _update;
  23108. private _markAllMaterialsAsPrePassDirty;
  23109. /**
  23110. * Disposes the prepass renderer.
  23111. */
  23112. dispose(): void;
  23113. }
  23114. }
  23115. declare module "babylonjs/PostProcesses/postProcess" {
  23116. import { Nullable } from "babylonjs/types";
  23117. import { SmartArray } from "babylonjs/Misc/smartArray";
  23118. import { Observable } from "babylonjs/Misc/observable";
  23119. import { Vector2 } from "babylonjs/Maths/math.vector";
  23120. import { Camera } from "babylonjs/Cameras/camera";
  23121. import { Effect } from "babylonjs/Materials/effect";
  23122. import "babylonjs/Shaders/postprocess.vertex";
  23123. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23124. import { Engine } from "babylonjs/Engines/engine";
  23125. import { Color4 } from "babylonjs/Maths/math.color";
  23126. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23127. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23128. import { Scene } from "babylonjs/scene";
  23129. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23130. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  23131. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  23132. /**
  23133. * Size options for a post process
  23134. */
  23135. export type PostProcessOptions = {
  23136. width: number;
  23137. height: number;
  23138. };
  23139. /**
  23140. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23141. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23142. */
  23143. export class PostProcess {
  23144. /**
  23145. * Gets or sets the unique id of the post process
  23146. */
  23147. uniqueId: number;
  23148. /** Name of the PostProcess. */
  23149. name: string;
  23150. /**
  23151. * Width of the texture to apply the post process on
  23152. */
  23153. width: number;
  23154. /**
  23155. * Height of the texture to apply the post process on
  23156. */
  23157. height: number;
  23158. /**
  23159. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23160. */
  23161. nodeMaterialSource: Nullable<NodeMaterial>;
  23162. /**
  23163. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23164. * @hidden
  23165. */
  23166. _outputTexture: Nullable<InternalTexture>;
  23167. /**
  23168. * Sampling mode used by the shader
  23169. * See https://doc.babylonjs.com/classes/3.1/texture
  23170. */
  23171. renderTargetSamplingMode: number;
  23172. /**
  23173. * Clear color to use when screen clearing
  23174. */
  23175. clearColor: Color4;
  23176. /**
  23177. * If the buffer needs to be cleared before applying the post process. (default: true)
  23178. * Should be set to false if shader will overwrite all previous pixels.
  23179. */
  23180. autoClear: boolean;
  23181. /**
  23182. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23183. */
  23184. alphaMode: number;
  23185. /**
  23186. * Sets the setAlphaBlendConstants of the babylon engine
  23187. */
  23188. alphaConstants: Color4;
  23189. /**
  23190. * Animations to be used for the post processing
  23191. */
  23192. animations: import("babylonjs/Animations/animation").Animation[];
  23193. /**
  23194. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23195. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23196. */
  23197. enablePixelPerfectMode: boolean;
  23198. /**
  23199. * Force the postprocess to be applied without taking in account viewport
  23200. */
  23201. forceFullscreenViewport: boolean;
  23202. /**
  23203. * List of inspectable custom properties (used by the Inspector)
  23204. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23205. */
  23206. inspectableCustomProperties: IInspectable[];
  23207. /**
  23208. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23209. *
  23210. * | Value | Type | Description |
  23211. * | ----- | ----------------------------------- | ----------- |
  23212. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23213. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23214. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23215. *
  23216. */
  23217. scaleMode: number;
  23218. /**
  23219. * Force textures to be a power of two (default: false)
  23220. */
  23221. alwaysForcePOT: boolean;
  23222. private _samples;
  23223. /**
  23224. * Number of sample textures (default: 1)
  23225. */
  23226. get samples(): number;
  23227. set samples(n: number);
  23228. /**
  23229. * Modify the scale of the post process to be the same as the viewport (default: false)
  23230. */
  23231. adaptScaleToCurrentViewport: boolean;
  23232. private _camera;
  23233. protected _scene: Scene;
  23234. private _engine;
  23235. private _options;
  23236. private _reusable;
  23237. private _textureType;
  23238. private _textureFormat;
  23239. /**
  23240. * Smart array of input and output textures for the post process.
  23241. * @hidden
  23242. */
  23243. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23244. /**
  23245. * The index in _textures that corresponds to the output texture.
  23246. * @hidden
  23247. */
  23248. _currentRenderTextureInd: number;
  23249. private _effect;
  23250. private _samplers;
  23251. private _fragmentUrl;
  23252. private _vertexUrl;
  23253. private _parameters;
  23254. private _scaleRatio;
  23255. protected _indexParameters: any;
  23256. private _shareOutputWithPostProcess;
  23257. private _texelSize;
  23258. private _forcedOutputTexture;
  23259. /**
  23260. * Prepass configuration in case this post process needs a texture from prepass
  23261. * @hidden
  23262. */
  23263. _prePassEffectConfiguration: PrePassEffectConfiguration;
  23264. /**
  23265. * Returns the fragment url or shader name used in the post process.
  23266. * @returns the fragment url or name in the shader store.
  23267. */
  23268. getEffectName(): string;
  23269. /**
  23270. * An event triggered when the postprocess is activated.
  23271. */
  23272. onActivateObservable: Observable<Camera>;
  23273. private _onActivateObserver;
  23274. /**
  23275. * A function that is added to the onActivateObservable
  23276. */
  23277. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23278. /**
  23279. * An event triggered when the postprocess changes its size.
  23280. */
  23281. onSizeChangedObservable: Observable<PostProcess>;
  23282. private _onSizeChangedObserver;
  23283. /**
  23284. * A function that is added to the onSizeChangedObservable
  23285. */
  23286. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23287. /**
  23288. * An event triggered when the postprocess applies its effect.
  23289. */
  23290. onApplyObservable: Observable<Effect>;
  23291. private _onApplyObserver;
  23292. /**
  23293. * A function that is added to the onApplyObservable
  23294. */
  23295. set onApply(callback: (effect: Effect) => void);
  23296. /**
  23297. * An event triggered before rendering the postprocess
  23298. */
  23299. onBeforeRenderObservable: Observable<Effect>;
  23300. private _onBeforeRenderObserver;
  23301. /**
  23302. * A function that is added to the onBeforeRenderObservable
  23303. */
  23304. set onBeforeRender(callback: (effect: Effect) => void);
  23305. /**
  23306. * An event triggered after rendering the postprocess
  23307. */
  23308. onAfterRenderObservable: Observable<Effect>;
  23309. private _onAfterRenderObserver;
  23310. /**
  23311. * A function that is added to the onAfterRenderObservable
  23312. */
  23313. set onAfterRender(callback: (efect: Effect) => void);
  23314. /**
  23315. * 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
  23316. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23317. */
  23318. get inputTexture(): InternalTexture;
  23319. set inputTexture(value: InternalTexture);
  23320. /**
  23321. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23322. * the only way to unset it is to use this function to restore its internal state
  23323. */
  23324. restoreDefaultInputTexture(): void;
  23325. /**
  23326. * Gets the camera which post process is applied to.
  23327. * @returns The camera the post process is applied to.
  23328. */
  23329. getCamera(): Camera;
  23330. /**
  23331. * Gets the texel size of the postprocess.
  23332. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23333. */
  23334. get texelSize(): Vector2;
  23335. /**
  23336. * Creates a new instance PostProcess
  23337. * @param name The name of the PostProcess.
  23338. * @param fragmentUrl The url of the fragment shader to be used.
  23339. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23340. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23341. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23342. * @param camera The camera to apply the render pass to.
  23343. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23344. * @param engine The engine which the post process will be applied. (default: current engine)
  23345. * @param reusable If the post process can be reused on the same frame. (default: false)
  23346. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23347. * @param textureType Type of textures used when performing the post process. (default: 0)
  23348. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23349. * @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
  23350. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23351. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23352. */
  23353. 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);
  23354. /**
  23355. * Gets a string identifying the name of the class
  23356. * @returns "PostProcess" string
  23357. */
  23358. getClassName(): string;
  23359. /**
  23360. * Gets the engine which this post process belongs to.
  23361. * @returns The engine the post process was enabled with.
  23362. */
  23363. getEngine(): Engine;
  23364. /**
  23365. * The effect that is created when initializing the post process.
  23366. * @returns The created effect corresponding the the postprocess.
  23367. */
  23368. getEffect(): Effect;
  23369. /**
  23370. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23371. * @param postProcess The post process to share the output with.
  23372. * @returns This post process.
  23373. */
  23374. shareOutputWith(postProcess: PostProcess): PostProcess;
  23375. /**
  23376. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23377. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23378. */
  23379. useOwnOutput(): void;
  23380. /**
  23381. * Updates the effect with the current post process compile time values and recompiles the shader.
  23382. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23383. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23384. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23385. * @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
  23386. * @param onCompiled Called when the shader has been compiled.
  23387. * @param onError Called if there is an error when compiling a shader.
  23388. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23389. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23390. */
  23391. 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;
  23392. /**
  23393. * The post process is reusable if it can be used multiple times within one frame.
  23394. * @returns If the post process is reusable
  23395. */
  23396. isReusable(): boolean;
  23397. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23398. markTextureDirty(): void;
  23399. /**
  23400. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23401. * 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.
  23402. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23403. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23404. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23405. * @returns The target texture that was bound to be written to.
  23406. */
  23407. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23408. /**
  23409. * If the post process is supported.
  23410. */
  23411. get isSupported(): boolean;
  23412. /**
  23413. * The aspect ratio of the output texture.
  23414. */
  23415. get aspectRatio(): number;
  23416. /**
  23417. * Get a value indicating if the post-process is ready to be used
  23418. * @returns true if the post-process is ready (shader is compiled)
  23419. */
  23420. isReady(): boolean;
  23421. /**
  23422. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23423. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23424. */
  23425. apply(): Nullable<Effect>;
  23426. private _disposeTextures;
  23427. /**
  23428. * Sets the required values to the prepass renderer.
  23429. * @param prePassRenderer defines the prepass renderer to setup.
  23430. * @returns true if the pre pass is needed.
  23431. */
  23432. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23433. /**
  23434. * Disposes the post process.
  23435. * @param camera The camera to dispose the post process on.
  23436. */
  23437. dispose(camera?: Camera): void;
  23438. /**
  23439. * Serializes the particle system to a JSON object
  23440. * @returns the JSON object
  23441. */
  23442. serialize(): any;
  23443. /**
  23444. * Creates a material from parsed material data
  23445. * @param parsedPostProcess defines parsed post process data
  23446. * @param scene defines the hosting scene
  23447. * @param rootUrl defines the root URL to use to load textures
  23448. * @returns a new post process
  23449. */
  23450. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23451. }
  23452. }
  23453. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23454. /** @hidden */
  23455. export var kernelBlurVaryingDeclaration: {
  23456. name: string;
  23457. shader: string;
  23458. };
  23459. }
  23460. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  23461. /** @hidden */
  23462. export var packingFunctions: {
  23463. name: string;
  23464. shader: string;
  23465. };
  23466. }
  23467. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23468. /** @hidden */
  23469. export var kernelBlurFragment: {
  23470. name: string;
  23471. shader: string;
  23472. };
  23473. }
  23474. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23475. /** @hidden */
  23476. export var kernelBlurFragment2: {
  23477. name: string;
  23478. shader: string;
  23479. };
  23480. }
  23481. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23482. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23483. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23484. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23485. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23486. /** @hidden */
  23487. export var kernelBlurPixelShader: {
  23488. name: string;
  23489. shader: string;
  23490. };
  23491. }
  23492. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23493. /** @hidden */
  23494. export var kernelBlurVertex: {
  23495. name: string;
  23496. shader: string;
  23497. };
  23498. }
  23499. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23500. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23501. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23502. /** @hidden */
  23503. export var kernelBlurVertexShader: {
  23504. name: string;
  23505. shader: string;
  23506. };
  23507. }
  23508. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23509. import { Vector2 } from "babylonjs/Maths/math.vector";
  23510. import { Nullable } from "babylonjs/types";
  23511. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23512. import { Camera } from "babylonjs/Cameras/camera";
  23513. import { Effect } from "babylonjs/Materials/effect";
  23514. import { Engine } from "babylonjs/Engines/engine";
  23515. import "babylonjs/Shaders/kernelBlur.fragment";
  23516. import "babylonjs/Shaders/kernelBlur.vertex";
  23517. import { Scene } from "babylonjs/scene";
  23518. /**
  23519. * The Blur Post Process which blurs an image based on a kernel and direction.
  23520. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23521. */
  23522. export class BlurPostProcess extends PostProcess {
  23523. private blockCompilation;
  23524. protected _kernel: number;
  23525. protected _idealKernel: number;
  23526. protected _packedFloat: boolean;
  23527. private _staticDefines;
  23528. /** The direction in which to blur the image. */
  23529. direction: Vector2;
  23530. /**
  23531. * Sets the length in pixels of the blur sample region
  23532. */
  23533. set kernel(v: number);
  23534. /**
  23535. * Gets the length in pixels of the blur sample region
  23536. */
  23537. get kernel(): number;
  23538. /**
  23539. * Sets wether or not the blur needs to unpack/repack floats
  23540. */
  23541. set packedFloat(v: boolean);
  23542. /**
  23543. * Gets wether or not the blur is unpacking/repacking floats
  23544. */
  23545. get packedFloat(): boolean;
  23546. /**
  23547. * Gets a string identifying the name of the class
  23548. * @returns "BlurPostProcess" string
  23549. */
  23550. getClassName(): string;
  23551. /**
  23552. * Creates a new instance BlurPostProcess
  23553. * @param name The name of the effect.
  23554. * @param direction The direction in which to blur the image.
  23555. * @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.
  23556. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23557. * @param camera The camera to apply the render pass to.
  23558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23559. * @param engine The engine which the post process will be applied. (default: current engine)
  23560. * @param reusable If the post process can be reused on the same frame. (default: false)
  23561. * @param textureType Type of textures used when performing the post process. (default: 0)
  23562. * @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)
  23563. */
  23564. 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);
  23565. /**
  23566. * Updates the effect with the current post process compile time values and recompiles the shader.
  23567. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23568. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23569. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23570. * @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
  23571. * @param onCompiled Called when the shader has been compiled.
  23572. * @param onError Called if there is an error when compiling a shader.
  23573. */
  23574. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23575. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23576. /**
  23577. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23578. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23579. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23580. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23581. * The gaps between physical kernels are compensated for in the weighting of the samples
  23582. * @param idealKernel Ideal blur kernel.
  23583. * @return Nearest best kernel.
  23584. */
  23585. protected _nearestBestKernel(idealKernel: number): number;
  23586. /**
  23587. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23588. * @param x The point on the Gaussian distribution to sample.
  23589. * @return the value of the Gaussian function at x.
  23590. */
  23591. protected _gaussianWeight(x: number): number;
  23592. /**
  23593. * Generates a string that can be used as a floating point number in GLSL.
  23594. * @param x Value to print.
  23595. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23596. * @return GLSL float string.
  23597. */
  23598. protected _glslFloat(x: number, decimalFigures?: number): string;
  23599. /** @hidden */
  23600. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23601. }
  23602. }
  23603. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23604. import { Scene } from "babylonjs/scene";
  23605. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23606. import { Plane } from "babylonjs/Maths/math.plane";
  23607. /**
  23608. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23609. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23610. * You can then easily use it as a reflectionTexture on a flat surface.
  23611. * In case the surface is not a plane, please consider relying on reflection probes.
  23612. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23613. */
  23614. export class MirrorTexture extends RenderTargetTexture {
  23615. private scene;
  23616. /**
  23617. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23618. * 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.
  23619. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23620. */
  23621. mirrorPlane: Plane;
  23622. /**
  23623. * Define the blur ratio used to blur the reflection if needed.
  23624. */
  23625. set blurRatio(value: number);
  23626. get blurRatio(): number;
  23627. /**
  23628. * Define the adaptive blur kernel used to blur the reflection if needed.
  23629. * This will autocompute the closest best match for the `blurKernel`
  23630. */
  23631. set adaptiveBlurKernel(value: number);
  23632. /**
  23633. * Define the blur kernel used to blur the reflection if needed.
  23634. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23635. */
  23636. set blurKernel(value: number);
  23637. /**
  23638. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23639. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23640. */
  23641. set blurKernelX(value: number);
  23642. get blurKernelX(): number;
  23643. /**
  23644. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23645. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23646. */
  23647. set blurKernelY(value: number);
  23648. get blurKernelY(): number;
  23649. private _autoComputeBlurKernel;
  23650. protected _onRatioRescale(): void;
  23651. private _updateGammaSpace;
  23652. private _imageProcessingConfigChangeObserver;
  23653. private _transformMatrix;
  23654. private _mirrorMatrix;
  23655. private _savedViewMatrix;
  23656. private _blurX;
  23657. private _blurY;
  23658. private _adaptiveBlurKernel;
  23659. private _blurKernelX;
  23660. private _blurKernelY;
  23661. private _blurRatio;
  23662. /**
  23663. * Instantiates a Mirror Texture.
  23664. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23665. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23666. * You can then easily use it as a reflectionTexture on a flat surface.
  23667. * In case the surface is not a plane, please consider relying on reflection probes.
  23668. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23669. * @param name
  23670. * @param size
  23671. * @param scene
  23672. * @param generateMipMaps
  23673. * @param type
  23674. * @param samplingMode
  23675. * @param generateDepthBuffer
  23676. */
  23677. constructor(name: string, size: number | {
  23678. width: number;
  23679. height: number;
  23680. } | {
  23681. ratio: number;
  23682. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23683. private _preparePostProcesses;
  23684. /**
  23685. * Clone the mirror texture.
  23686. * @returns the cloned texture
  23687. */
  23688. clone(): MirrorTexture;
  23689. /**
  23690. * Serialize the texture to a JSON representation you could use in Parse later on
  23691. * @returns the serialized JSON representation
  23692. */
  23693. serialize(): any;
  23694. /**
  23695. * Dispose the texture and release its associated resources.
  23696. */
  23697. dispose(): void;
  23698. }
  23699. }
  23700. declare module "babylonjs/Materials/Textures/texture" {
  23701. import { Observable } from "babylonjs/Misc/observable";
  23702. import { Nullable } from "babylonjs/types";
  23703. import { Matrix } from "babylonjs/Maths/math.vector";
  23704. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23705. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23706. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23707. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  23708. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  23709. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23710. import { Scene } from "babylonjs/scene";
  23711. /**
  23712. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23713. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23714. */
  23715. export class Texture extends BaseTexture {
  23716. /**
  23717. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23718. */
  23719. static SerializeBuffers: boolean;
  23720. /**
  23721. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  23722. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  23723. */
  23724. static ForceSerializeBuffers: boolean;
  23725. /** @hidden */
  23726. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23727. /** @hidden */
  23728. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23729. /** @hidden */
  23730. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23731. /** nearest is mag = nearest and min = nearest and mip = linear */
  23732. static readonly NEAREST_SAMPLINGMODE: number;
  23733. /** nearest is mag = nearest and min = nearest and mip = linear */
  23734. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23735. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23736. static readonly BILINEAR_SAMPLINGMODE: number;
  23737. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23738. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23739. /** Trilinear is mag = linear and min = linear and mip = linear */
  23740. static readonly TRILINEAR_SAMPLINGMODE: number;
  23741. /** Trilinear is mag = linear and min = linear and mip = linear */
  23742. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23743. /** mag = nearest and min = nearest and mip = nearest */
  23744. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23745. /** mag = nearest and min = linear and mip = nearest */
  23746. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23747. /** mag = nearest and min = linear and mip = linear */
  23748. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23749. /** mag = nearest and min = linear and mip = none */
  23750. static readonly NEAREST_LINEAR: number;
  23751. /** mag = nearest and min = nearest and mip = none */
  23752. static readonly NEAREST_NEAREST: number;
  23753. /** mag = linear and min = nearest and mip = nearest */
  23754. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23755. /** mag = linear and min = nearest and mip = linear */
  23756. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23757. /** mag = linear and min = linear and mip = none */
  23758. static readonly LINEAR_LINEAR: number;
  23759. /** mag = linear and min = nearest and mip = none */
  23760. static readonly LINEAR_NEAREST: number;
  23761. /** Explicit coordinates mode */
  23762. static readonly EXPLICIT_MODE: number;
  23763. /** Spherical coordinates mode */
  23764. static readonly SPHERICAL_MODE: number;
  23765. /** Planar coordinates mode */
  23766. static readonly PLANAR_MODE: number;
  23767. /** Cubic coordinates mode */
  23768. static readonly CUBIC_MODE: number;
  23769. /** Projection coordinates mode */
  23770. static readonly PROJECTION_MODE: number;
  23771. /** Inverse Cubic coordinates mode */
  23772. static readonly SKYBOX_MODE: number;
  23773. /** Inverse Cubic coordinates mode */
  23774. static readonly INVCUBIC_MODE: number;
  23775. /** Equirectangular coordinates mode */
  23776. static readonly EQUIRECTANGULAR_MODE: number;
  23777. /** Equirectangular Fixed coordinates mode */
  23778. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23779. /** Equirectangular Fixed Mirrored coordinates mode */
  23780. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23781. /** Texture is not repeating outside of 0..1 UVs */
  23782. static readonly CLAMP_ADDRESSMODE: number;
  23783. /** Texture is repeating outside of 0..1 UVs */
  23784. static readonly WRAP_ADDRESSMODE: number;
  23785. /** Texture is repeating and mirrored */
  23786. static readonly MIRROR_ADDRESSMODE: number;
  23787. /**
  23788. * 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
  23789. */
  23790. static UseSerializedUrlIfAny: boolean;
  23791. /**
  23792. * Define the url of the texture.
  23793. */
  23794. url: Nullable<string>;
  23795. /**
  23796. * Define an offset on the texture to offset the u coordinates of the UVs
  23797. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23798. */
  23799. uOffset: number;
  23800. /**
  23801. * Define an offset on the texture to offset the v coordinates of the UVs
  23802. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23803. */
  23804. vOffset: number;
  23805. /**
  23806. * Define an offset on the texture to scale the u coordinates of the UVs
  23807. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23808. */
  23809. uScale: number;
  23810. /**
  23811. * Define an offset on the texture to scale the v coordinates of the UVs
  23812. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23813. */
  23814. vScale: number;
  23815. /**
  23816. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23817. * @see https://doc.babylonjs.com/how_to/more_materials
  23818. */
  23819. uAng: number;
  23820. /**
  23821. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23822. * @see https://doc.babylonjs.com/how_to/more_materials
  23823. */
  23824. vAng: number;
  23825. /**
  23826. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23827. * @see https://doc.babylonjs.com/how_to/more_materials
  23828. */
  23829. wAng: number;
  23830. /**
  23831. * Defines the center of rotation (U)
  23832. */
  23833. uRotationCenter: number;
  23834. /**
  23835. * Defines the center of rotation (V)
  23836. */
  23837. vRotationCenter: number;
  23838. /**
  23839. * Defines the center of rotation (W)
  23840. */
  23841. wRotationCenter: number;
  23842. /**
  23843. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  23844. */
  23845. homogeneousRotationInUVTransform: boolean;
  23846. /**
  23847. * Are mip maps generated for this texture or not.
  23848. */
  23849. get noMipmap(): boolean;
  23850. /**
  23851. * List of inspectable custom properties (used by the Inspector)
  23852. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23853. */
  23854. inspectableCustomProperties: Nullable<IInspectable[]>;
  23855. private _noMipmap;
  23856. /** @hidden */
  23857. _invertY: boolean;
  23858. private _rowGenerationMatrix;
  23859. private _cachedTextureMatrix;
  23860. private _projectionModeMatrix;
  23861. private _t0;
  23862. private _t1;
  23863. private _t2;
  23864. private _cachedUOffset;
  23865. private _cachedVOffset;
  23866. private _cachedUScale;
  23867. private _cachedVScale;
  23868. private _cachedUAng;
  23869. private _cachedVAng;
  23870. private _cachedWAng;
  23871. private _cachedProjectionMatrixId;
  23872. private _cachedURotationCenter;
  23873. private _cachedVRotationCenter;
  23874. private _cachedWRotationCenter;
  23875. private _cachedHomogeneousRotationInUVTransform;
  23876. private _cachedCoordinatesMode;
  23877. /** @hidden */
  23878. protected _initialSamplingMode: number;
  23879. /** @hidden */
  23880. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23881. private _deleteBuffer;
  23882. protected _format: Nullable<number>;
  23883. private _delayedOnLoad;
  23884. private _delayedOnError;
  23885. private _mimeType?;
  23886. private _loaderOptions?;
  23887. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23888. get mimeType(): string | undefined;
  23889. /**
  23890. * Observable triggered once the texture has been loaded.
  23891. */
  23892. onLoadObservable: Observable<Texture>;
  23893. protected _isBlocking: boolean;
  23894. /**
  23895. * Is the texture preventing material to render while loading.
  23896. * If false, a default texture will be used instead of the loading one during the preparation step.
  23897. */
  23898. set isBlocking(value: boolean);
  23899. get isBlocking(): boolean;
  23900. /**
  23901. * Get the current sampling mode associated with the texture.
  23902. */
  23903. get samplingMode(): number;
  23904. /**
  23905. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23906. */
  23907. get invertY(): boolean;
  23908. /**
  23909. * Instantiates a new texture.
  23910. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23911. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23912. * @param url defines the url of the picture to load as a texture
  23913. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23914. * @param noMipmap defines if the texture will require mip maps or not
  23915. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23916. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23917. * @param onLoad defines a callback triggered when the texture has been loaded
  23918. * @param onError defines a callback triggered when an error occurred during the loading session
  23919. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23920. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23921. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23922. * @param mimeType defines an optional mime type information
  23923. * @param loaderOptions options to be passed to the loader
  23924. */
  23925. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string, loaderOptions?: any);
  23926. /**
  23927. * Update the url (and optional buffer) of this texture if url was null during construction.
  23928. * @param url the url of the texture
  23929. * @param buffer the buffer of the texture (defaults to null)
  23930. * @param onLoad callback called when the texture is loaded (defaults to null)
  23931. */
  23932. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23933. /**
  23934. * Finish the loading sequence of a texture flagged as delayed load.
  23935. * @hidden
  23936. */
  23937. delayLoad(): void;
  23938. private _prepareRowForTextureGeneration;
  23939. /**
  23940. * Checks if the texture has the same transform matrix than another texture
  23941. * @param texture texture to check against
  23942. * @returns true if the transforms are the same, else false
  23943. */
  23944. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  23945. /**
  23946. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23947. * @returns the transform matrix of the texture.
  23948. */
  23949. getTextureMatrix(uBase?: number): Matrix;
  23950. /**
  23951. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23952. * @returns The reflection texture transform
  23953. */
  23954. getReflectionTextureMatrix(): Matrix;
  23955. /**
  23956. * Clones the texture.
  23957. * @returns the cloned texture
  23958. */
  23959. clone(): Texture;
  23960. /**
  23961. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23962. * @returns The JSON representation of the texture
  23963. */
  23964. serialize(): any;
  23965. /**
  23966. * Get the current class name of the texture useful for serialization or dynamic coding.
  23967. * @returns "Texture"
  23968. */
  23969. getClassName(): string;
  23970. /**
  23971. * Dispose the texture and release its associated resources.
  23972. */
  23973. dispose(): void;
  23974. /**
  23975. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23976. * @param parsedTexture Define the JSON representation of the texture
  23977. * @param scene Define the scene the parsed texture should be instantiated in
  23978. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23979. * @returns The parsed texture if successful
  23980. */
  23981. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23982. /**
  23983. * Creates a texture from its base 64 representation.
  23984. * @param data Define the base64 payload without the data: prefix
  23985. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23986. * @param scene Define the scene the texture should belong to
  23987. * @param noMipmap Forces the texture to not create mip map information if true
  23988. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23989. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23990. * @param onLoad define a callback triggered when the texture has been loaded
  23991. * @param onError define a callback triggered when an error occurred during the loading session
  23992. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23993. * @returns the created texture
  23994. */
  23995. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23996. /**
  23997. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23998. * @param data Define the base64 payload without the data: prefix
  23999. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24000. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24001. * @param scene Define the scene the texture should belong to
  24002. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24003. * @param noMipmap Forces the texture to not create mip map information if true
  24004. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24005. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24006. * @param onLoad define a callback triggered when the texture has been loaded
  24007. * @param onError define a callback triggered when an error occurred during the loading session
  24008. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24009. * @returns the created texture
  24010. */
  24011. 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;
  24012. }
  24013. }
  24014. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility" {
  24015. /** @hidden */
  24016. export var imageProcessingCompatibility: {
  24017. name: string;
  24018. shader: string;
  24019. };
  24020. }
  24021. declare module "babylonjs/Shaders/sprites.fragment" {
  24022. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  24023. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  24024. import "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility";
  24025. /** @hidden */
  24026. export var spritesPixelShader: {
  24027. name: string;
  24028. shader: string;
  24029. };
  24030. }
  24031. declare module "babylonjs/Shaders/sprites.vertex" {
  24032. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  24033. /** @hidden */
  24034. export var spritesVertexShader: {
  24035. name: string;
  24036. shader: string;
  24037. };
  24038. }
  24039. declare module "babylonjs/Sprites/thinSprite" {
  24040. import { IVector3Like, IColor4Like } from "babylonjs/Maths/math.like";
  24041. import { Nullable } from "babylonjs/types";
  24042. /**
  24043. * ThinSprite Class used to represent a thin sprite
  24044. * This is the base class for sprites but can also directly be used with ThinEngine
  24045. * @see https://doc.babylonjs.com/babylon101/sprites
  24046. */
  24047. export class ThinSprite {
  24048. /** Gets or sets the cell index in the sprite sheet */
  24049. cellIndex: number;
  24050. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  24051. cellRef: string;
  24052. /** Gets or sets the current world position */
  24053. position: IVector3Like;
  24054. /** Gets or sets the main color */
  24055. color: IColor4Like;
  24056. /** Gets or sets the width */
  24057. width: number;
  24058. /** Gets or sets the height */
  24059. height: number;
  24060. /** Gets or sets rotation angle */
  24061. angle: number;
  24062. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  24063. invertU: boolean;
  24064. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  24065. invertV: boolean;
  24066. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  24067. isVisible: boolean;
  24068. /**
  24069. * Returns a boolean indicating if the animation is started
  24070. */
  24071. get animationStarted(): boolean;
  24072. /** Gets the initial key for the animation (setting it will restart the animation) */
  24073. get fromIndex(): number;
  24074. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24075. get toIndex(): number;
  24076. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24077. get loopAnimation(): boolean;
  24078. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24079. get delay(): number;
  24080. /** @hidden */
  24081. _xOffset: number;
  24082. /** @hidden */
  24083. _yOffset: number;
  24084. /** @hidden */
  24085. _xSize: number;
  24086. /** @hidden */
  24087. _ySize: number;
  24088. private _animationStarted;
  24089. private _loopAnimation;
  24090. private _fromIndex;
  24091. private _toIndex;
  24092. private _delay;
  24093. private _direction;
  24094. private _time;
  24095. private _onBaseAnimationEnd;
  24096. /**
  24097. * Creates a new Thin Sprite
  24098. */
  24099. constructor();
  24100. /**
  24101. * Starts an animation
  24102. * @param from defines the initial key
  24103. * @param to defines the end key
  24104. * @param loop defines if the animation must loop
  24105. * @param delay defines the start delay (in ms)
  24106. * @param onAnimationEnd defines a callback for when the animation ends
  24107. */
  24108. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  24109. /** Stops current animation (if any) */
  24110. stopAnimation(): void;
  24111. /** @hidden */
  24112. _animate(deltaTime: number): void;
  24113. }
  24114. }
  24115. declare module "babylonjs/Sprites/spriteRenderer" {
  24116. import { Nullable } from "babylonjs/types";
  24117. import { IMatrixLike } from "babylonjs/Maths/math.like";
  24118. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24119. import { ThinSprite } from "babylonjs/Sprites/thinSprite";
  24120. import { ISize } from "babylonjs/Maths/math.size";
  24121. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  24122. import { Scene } from "babylonjs/scene";
  24123. import "babylonjs/Engines/Extensions/engine.alpha";
  24124. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  24125. import "babylonjs/Shaders/sprites.fragment";
  24126. import "babylonjs/Shaders/sprites.vertex";
  24127. /**
  24128. * Class used to render sprites.
  24129. *
  24130. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  24131. */
  24132. export class SpriteRenderer {
  24133. /**
  24134. * Defines the texture of the spritesheet
  24135. */
  24136. texture: Nullable<ThinTexture>;
  24137. /**
  24138. * Defines the default width of a cell in the spritesheet
  24139. */
  24140. cellWidth: number;
  24141. /**
  24142. * Defines the default height of a cell in the spritesheet
  24143. */
  24144. cellHeight: number;
  24145. /**
  24146. * Blend mode use to render the particle, it can be any of
  24147. * the static Constants.ALPHA_x properties provided in this class.
  24148. * Default value is Constants.ALPHA_COMBINE
  24149. */
  24150. blendMode: number;
  24151. /**
  24152. * Gets or sets a boolean indicating if alpha mode is automatically
  24153. * reset.
  24154. */
  24155. autoResetAlpha: boolean;
  24156. /**
  24157. * Disables writing to the depth buffer when rendering the sprites.
  24158. * It can be handy to disable depth writing when using textures without alpha channel
  24159. * and setting some specific blend modes.
  24160. */
  24161. disableDepthWrite: boolean;
  24162. /**
  24163. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24164. */
  24165. fogEnabled: boolean;
  24166. /**
  24167. * Gets the capacity of the manager
  24168. */
  24169. get capacity(): number;
  24170. private readonly _engine;
  24171. private readonly _useVAO;
  24172. private readonly _useInstancing;
  24173. private readonly _scene;
  24174. private readonly _capacity;
  24175. private readonly _epsilon;
  24176. private _vertexBufferSize;
  24177. private _vertexData;
  24178. private _buffer;
  24179. private _vertexBuffers;
  24180. private _spriteBuffer;
  24181. private _indexBuffer;
  24182. private _effectBase;
  24183. private _effectFog;
  24184. private _vertexArrayObject;
  24185. /**
  24186. * Creates a new sprite Renderer
  24187. * @param engine defines the engine the renderer works with
  24188. * @param capacity defines the maximum allowed number of sprites
  24189. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24190. * @param scene defines the hosting scene
  24191. */
  24192. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24193. /**
  24194. * Render all child sprites
  24195. * @param sprites defines the list of sprites to render
  24196. * @param deltaTime defines the time since last frame
  24197. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24198. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24199. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24200. */
  24201. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  24202. private _appendSpriteVertex;
  24203. /**
  24204. * Release associated resources
  24205. */
  24206. dispose(): void;
  24207. }
  24208. }
  24209. declare module "babylonjs/Sprites/spriteManager" {
  24210. import { IDisposable, Scene } from "babylonjs/scene";
  24211. import { Nullable } from "babylonjs/types";
  24212. import { Observable } from "babylonjs/Misc/observable";
  24213. import { Sprite } from "babylonjs/Sprites/sprite";
  24214. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24215. import { Camera } from "babylonjs/Cameras/camera";
  24216. import { Texture } from "babylonjs/Materials/Textures/texture";
  24217. import "babylonjs/Shaders/sprites.fragment";
  24218. import "babylonjs/Shaders/sprites.vertex";
  24219. import { Ray } from "babylonjs/Culling/ray";
  24220. /**
  24221. * Defines the minimum interface to fullfil in order to be a sprite manager.
  24222. */
  24223. export interface ISpriteManager extends IDisposable {
  24224. /**
  24225. * Gets manager's name
  24226. */
  24227. name: string;
  24228. /**
  24229. * Restricts the camera to viewing objects with the same layerMask.
  24230. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  24231. */
  24232. layerMask: number;
  24233. /**
  24234. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24235. */
  24236. isPickable: boolean;
  24237. /**
  24238. * Gets the hosting scene
  24239. */
  24240. scene: Scene;
  24241. /**
  24242. * Specifies the rendering group id for this mesh (0 by default)
  24243. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24244. */
  24245. renderingGroupId: number;
  24246. /**
  24247. * Defines the list of sprites managed by the manager.
  24248. */
  24249. sprites: Array<Sprite>;
  24250. /**
  24251. * Gets or sets the spritesheet texture
  24252. */
  24253. texture: Texture;
  24254. /** Defines the default width of a cell in the spritesheet */
  24255. cellWidth: number;
  24256. /** Defines the default height of a cell in the spritesheet */
  24257. cellHeight: number;
  24258. /**
  24259. * Tests the intersection of a sprite with a specific ray.
  24260. * @param ray The ray we are sending to test the collision
  24261. * @param camera The camera space we are sending rays in
  24262. * @param predicate A predicate allowing excluding sprites from the list of object to test
  24263. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24264. * @returns picking info or null.
  24265. */
  24266. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24267. /**
  24268. * Intersects the sprites with a ray
  24269. * @param ray defines the ray to intersect with
  24270. * @param camera defines the current active camera
  24271. * @param predicate defines a predicate used to select candidate sprites
  24272. * @returns null if no hit or a PickingInfo array
  24273. */
  24274. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24275. /**
  24276. * Renders the list of sprites on screen.
  24277. */
  24278. render(): void;
  24279. }
  24280. /**
  24281. * Class used to manage multiple sprites on the same spritesheet
  24282. * @see https://doc.babylonjs.com/babylon101/sprites
  24283. */
  24284. export class SpriteManager implements ISpriteManager {
  24285. /** defines the manager's name */
  24286. name: string;
  24287. /** Define the Url to load snippets */
  24288. static SnippetUrl: string;
  24289. /** Snippet ID if the manager was created from the snippet server */
  24290. snippetId: string;
  24291. /** Gets the list of sprites */
  24292. sprites: Sprite[];
  24293. /** Gets or sets the rendering group id (0 by default) */
  24294. renderingGroupId: number;
  24295. /** Gets or sets camera layer mask */
  24296. layerMask: number;
  24297. /** Gets or sets a boolean indicating if the sprites are pickable */
  24298. isPickable: boolean;
  24299. /**
  24300. * An event triggered when the manager is disposed.
  24301. */
  24302. onDisposeObservable: Observable<SpriteManager>;
  24303. /**
  24304. * Callback called when the manager is disposed
  24305. */
  24306. set onDispose(callback: () => void);
  24307. /**
  24308. * Gets or sets the unique id of the sprite
  24309. */
  24310. uniqueId: number;
  24311. /**
  24312. * Gets the array of sprites
  24313. */
  24314. get children(): Sprite[];
  24315. /**
  24316. * Gets the hosting scene
  24317. */
  24318. get scene(): Scene;
  24319. /**
  24320. * Gets the capacity of the manager
  24321. */
  24322. get capacity(): number;
  24323. /**
  24324. * Gets or sets the spritesheet texture
  24325. */
  24326. get texture(): Texture;
  24327. set texture(value: Texture);
  24328. /** Defines the default width of a cell in the spritesheet */
  24329. get cellWidth(): number;
  24330. set cellWidth(value: number);
  24331. /** Defines the default height of a cell in the spritesheet */
  24332. get cellHeight(): number;
  24333. set cellHeight(value: number);
  24334. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  24335. get fogEnabled(): boolean;
  24336. set fogEnabled(value: boolean);
  24337. /**
  24338. * Blend mode use to render the particle, it can be any of
  24339. * the static Constants.ALPHA_x properties provided in this class.
  24340. * Default value is Constants.ALPHA_COMBINE
  24341. */
  24342. get blendMode(): number;
  24343. set blendMode(blendMode: number);
  24344. /** Disables writing to the depth buffer when rendering the sprites.
  24345. * It can be handy to disable depth writing when using textures without alpha channel
  24346. * and setting some specific blend modes.
  24347. */
  24348. disableDepthWrite: boolean;
  24349. private _spriteRenderer;
  24350. /** Associative array from JSON sprite data file */
  24351. private _cellData;
  24352. /** Array of sprite names from JSON sprite data file */
  24353. private _spriteMap;
  24354. /** True when packed cell data from JSON file is ready*/
  24355. private _packedAndReady;
  24356. private _textureContent;
  24357. private _onDisposeObserver;
  24358. private _fromPacked;
  24359. private _scene;
  24360. /**
  24361. * Creates a new sprite manager
  24362. * @param name defines the manager's name
  24363. * @param imgUrl defines the sprite sheet url
  24364. * @param capacity defines the maximum allowed number of sprites
  24365. * @param cellSize defines the size of a sprite cell
  24366. * @param scene defines the hosting scene
  24367. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24368. * @param samplingMode defines the smapling mode to use with spritesheet
  24369. * @param fromPacked set to false; do not alter
  24370. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  24371. */
  24372. constructor(
  24373. /** defines the manager's name */
  24374. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  24375. /**
  24376. * Returns the string "SpriteManager"
  24377. * @returns "SpriteManager"
  24378. */
  24379. getClassName(): string;
  24380. private _makePacked;
  24381. private _checkTextureAlpha;
  24382. /**
  24383. * Intersects the sprites with a ray
  24384. * @param ray defines the ray to intersect with
  24385. * @param camera defines the current active camera
  24386. * @param predicate defines a predicate used to select candidate sprites
  24387. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  24388. * @returns null if no hit or a PickingInfo
  24389. */
  24390. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24391. /**
  24392. * Intersects the sprites with a ray
  24393. * @param ray defines the ray to intersect with
  24394. * @param camera defines the current active camera
  24395. * @param predicate defines a predicate used to select candidate sprites
  24396. * @returns null if no hit or a PickingInfo array
  24397. */
  24398. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24399. /**
  24400. * Render all child sprites
  24401. */
  24402. render(): void;
  24403. private _customUpdate;
  24404. /**
  24405. * Release associated resources
  24406. */
  24407. dispose(): void;
  24408. /**
  24409. * Serializes the sprite manager to a JSON object
  24410. * @param serializeTexture defines if the texture must be serialized as well
  24411. * @returns the JSON object
  24412. */
  24413. serialize(serializeTexture?: boolean): any;
  24414. /**
  24415. * Parses a JSON object to create a new sprite manager.
  24416. * @param parsedManager The JSON object to parse
  24417. * @param scene The scene to create the sprite managerin
  24418. * @param rootUrl The root url to use to load external dependencies like texture
  24419. * @returns the new sprite manager
  24420. */
  24421. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  24422. /**
  24423. * Creates a sprite manager from a snippet saved in a remote file
  24424. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  24425. * @param url defines the url to load from
  24426. * @param scene defines the hosting scene
  24427. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24428. * @returns a promise that will resolve to the new sprite manager
  24429. */
  24430. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24431. /**
  24432. * Creates a sprite manager from a snippet saved by the sprite editor
  24433. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  24434. * @param scene defines the hosting scene
  24435. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24436. * @returns a promise that will resolve to the new sprite manager
  24437. */
  24438. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24439. }
  24440. }
  24441. declare module "babylonjs/Sprites/sprite" {
  24442. import { Vector3 } from "babylonjs/Maths/math.vector";
  24443. import { Nullable } from "babylonjs/types";
  24444. import { ActionManager } from "babylonjs/Actions/actionManager";
  24445. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  24446. import { Color4 } from "babylonjs/Maths/math.color";
  24447. import { Observable } from "babylonjs/Misc/observable";
  24448. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24449. import { ThinSprite } from "babylonjs/Sprites/thinSprite";
  24450. import { Animation } from "babylonjs/Animations/animation";
  24451. /**
  24452. * Class used to represent a sprite
  24453. * @see https://doc.babylonjs.com/babylon101/sprites
  24454. */
  24455. export class Sprite extends ThinSprite implements IAnimatable {
  24456. /** defines the name */
  24457. name: string;
  24458. /** Gets or sets the current world position */
  24459. position: Vector3;
  24460. /** Gets or sets the main color */
  24461. color: Color4;
  24462. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  24463. disposeWhenFinishedAnimating: boolean;
  24464. /** Gets the list of attached animations */
  24465. animations: Nullable<Array<Animation>>;
  24466. /** Gets or sets a boolean indicating if the sprite can be picked */
  24467. isPickable: boolean;
  24468. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  24469. useAlphaForPicking: boolean;
  24470. /**
  24471. * Gets or sets the associated action manager
  24472. */
  24473. actionManager: Nullable<ActionManager>;
  24474. /**
  24475. * An event triggered when the control has been disposed
  24476. */
  24477. onDisposeObservable: Observable<Sprite>;
  24478. private _manager;
  24479. private _onAnimationEnd;
  24480. /**
  24481. * Gets or sets the sprite size
  24482. */
  24483. get size(): number;
  24484. set size(value: number);
  24485. /**
  24486. * Gets or sets the unique id of the sprite
  24487. */
  24488. uniqueId: number;
  24489. /**
  24490. * Gets the manager of this sprite
  24491. */
  24492. get manager(): ISpriteManager;
  24493. /**
  24494. * Creates a new Sprite
  24495. * @param name defines the name
  24496. * @param manager defines the manager
  24497. */
  24498. constructor(
  24499. /** defines the name */
  24500. name: string, manager: ISpriteManager);
  24501. /**
  24502. * Returns the string "Sprite"
  24503. * @returns "Sprite"
  24504. */
  24505. getClassName(): string;
  24506. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  24507. set fromIndex(value: number);
  24508. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24509. set toIndex(value: number);
  24510. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24511. set loopAnimation(value: boolean);
  24512. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24513. set delay(value: number);
  24514. /**
  24515. * Starts an animation
  24516. * @param from defines the initial key
  24517. * @param to defines the end key
  24518. * @param loop defines if the animation must loop
  24519. * @param delay defines the start delay (in ms)
  24520. * @param onAnimationEnd defines a callback to call when animation ends
  24521. */
  24522. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  24523. private _endAnimation;
  24524. /** Release associated resources */
  24525. dispose(): void;
  24526. /**
  24527. * Serializes the sprite to a JSON object
  24528. * @returns the JSON object
  24529. */
  24530. serialize(): any;
  24531. /**
  24532. * Parses a JSON object to create a new sprite
  24533. * @param parsedSprite The JSON object to parse
  24534. * @param manager defines the hosting manager
  24535. * @returns the new sprite
  24536. */
  24537. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  24538. }
  24539. }
  24540. declare module "babylonjs/Collisions/pickingInfo" {
  24541. import { Nullable } from "babylonjs/types";
  24542. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  24543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24544. import { Sprite } from "babylonjs/Sprites/sprite";
  24545. import { Ray } from "babylonjs/Culling/ray";
  24546. /**
  24547. * Information about the result of picking within a scene
  24548. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24549. */
  24550. export class PickingInfo {
  24551. /** @hidden */
  24552. _pickingUnavailable: boolean;
  24553. /**
  24554. * If the pick collided with an object
  24555. */
  24556. hit: boolean;
  24557. /**
  24558. * Distance away where the pick collided
  24559. */
  24560. distance: number;
  24561. /**
  24562. * The location of pick collision
  24563. */
  24564. pickedPoint: Nullable<Vector3>;
  24565. /**
  24566. * The mesh corresponding the the pick collision
  24567. */
  24568. pickedMesh: Nullable<AbstractMesh>;
  24569. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  24570. bu: number;
  24571. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  24572. bv: number;
  24573. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24574. faceId: number;
  24575. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24576. subMeshFaceId: number;
  24577. /** Id of the the submesh that was picked */
  24578. subMeshId: number;
  24579. /** If a sprite was picked, this will be the sprite the pick collided with */
  24580. pickedSprite: Nullable<Sprite>;
  24581. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  24582. thinInstanceIndex: number;
  24583. /**
  24584. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24585. */
  24586. originMesh: Nullable<AbstractMesh>;
  24587. /**
  24588. * The ray that was used to perform the picking.
  24589. */
  24590. ray: Nullable<Ray>;
  24591. /**
  24592. * Gets the normal correspodning to the face the pick collided with
  24593. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24594. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24595. * @returns The normal correspodning to the face the pick collided with
  24596. */
  24597. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  24598. /**
  24599. * Gets the texture coordinates of where the pick occured
  24600. * @returns the vector containing the coordnates of the texture
  24601. */
  24602. getTextureCoordinates(): Nullable<Vector2>;
  24603. }
  24604. }
  24605. declare module "babylonjs/Events/pointerEvents" {
  24606. import { Nullable } from "babylonjs/types";
  24607. import { Vector2 } from "babylonjs/Maths/math.vector";
  24608. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24609. import { Ray } from "babylonjs/Culling/ray";
  24610. /**
  24611. * Gather the list of pointer event types as constants.
  24612. */
  24613. export class PointerEventTypes {
  24614. /**
  24615. * 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.
  24616. */
  24617. static readonly POINTERDOWN: number;
  24618. /**
  24619. * The pointerup event is fired when a pointer is no longer active.
  24620. */
  24621. static readonly POINTERUP: number;
  24622. /**
  24623. * The pointermove event is fired when a pointer changes coordinates.
  24624. */
  24625. static readonly POINTERMOVE: number;
  24626. /**
  24627. * The pointerwheel event is fired when a mouse wheel has been rotated.
  24628. */
  24629. static readonly POINTERWHEEL: number;
  24630. /**
  24631. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  24632. */
  24633. static readonly POINTERPICK: number;
  24634. /**
  24635. * The pointertap event is fired when a the object has been touched and released without drag.
  24636. */
  24637. static readonly POINTERTAP: number;
  24638. /**
  24639. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  24640. */
  24641. static readonly POINTERDOUBLETAP: number;
  24642. }
  24643. /**
  24644. * Base class of pointer info types.
  24645. */
  24646. export class PointerInfoBase {
  24647. /**
  24648. * Defines the type of event (PointerEventTypes)
  24649. */
  24650. type: number;
  24651. /**
  24652. * Defines the related dom event
  24653. */
  24654. event: PointerEvent | MouseWheelEvent;
  24655. /**
  24656. * Instantiates the base class of pointers info.
  24657. * @param type Defines the type of event (PointerEventTypes)
  24658. * @param event Defines the related dom event
  24659. */
  24660. constructor(
  24661. /**
  24662. * Defines the type of event (PointerEventTypes)
  24663. */
  24664. type: number,
  24665. /**
  24666. * Defines the related dom event
  24667. */
  24668. event: PointerEvent | MouseWheelEvent);
  24669. }
  24670. /**
  24671. * This class is used to store pointer related info for the onPrePointerObservable event.
  24672. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  24673. */
  24674. export class PointerInfoPre extends PointerInfoBase {
  24675. /**
  24676. * Ray from a pointer if availible (eg. 6dof controller)
  24677. */
  24678. ray: Nullable<Ray>;
  24679. /**
  24680. * Defines the local position of the pointer on the canvas.
  24681. */
  24682. localPosition: Vector2;
  24683. /**
  24684. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  24685. */
  24686. skipOnPointerObservable: boolean;
  24687. /**
  24688. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  24689. * @param type Defines the type of event (PointerEventTypes)
  24690. * @param event Defines the related dom event
  24691. * @param localX Defines the local x coordinates of the pointer when the event occured
  24692. * @param localY Defines the local y coordinates of the pointer when the event occured
  24693. */
  24694. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  24695. }
  24696. /**
  24697. * This type contains all the data related to a pointer event in Babylon.js.
  24698. * 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.
  24699. */
  24700. export class PointerInfo extends PointerInfoBase {
  24701. /**
  24702. * Defines the picking info associated to the info (if any)\
  24703. */
  24704. pickInfo: Nullable<PickingInfo>;
  24705. /**
  24706. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  24707. * @param type Defines the type of event (PointerEventTypes)
  24708. * @param event Defines the related dom event
  24709. * @param pickInfo Defines the picking info associated to the info (if any)\
  24710. */
  24711. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  24712. /**
  24713. * Defines the picking info associated to the info (if any)\
  24714. */
  24715. pickInfo: Nullable<PickingInfo>);
  24716. }
  24717. /**
  24718. * Data relating to a touch event on the screen.
  24719. */
  24720. export interface PointerTouch {
  24721. /**
  24722. * X coordinate of touch.
  24723. */
  24724. x: number;
  24725. /**
  24726. * Y coordinate of touch.
  24727. */
  24728. y: number;
  24729. /**
  24730. * Id of touch. Unique for each finger.
  24731. */
  24732. pointerId: number;
  24733. /**
  24734. * Event type passed from DOM.
  24735. */
  24736. type: any;
  24737. }
  24738. }
  24739. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  24740. import { Observable } from "babylonjs/Misc/observable";
  24741. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  24742. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  24743. /**
  24744. * Manage the mouse inputs to control the movement of a free camera.
  24745. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24746. */
  24747. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  24748. /**
  24749. * Define if touch is enabled in the mouse input
  24750. */
  24751. touchEnabled: boolean;
  24752. /**
  24753. * Defines the camera the input is attached to.
  24754. */
  24755. camera: FreeCamera;
  24756. /**
  24757. * Defines the buttons associated with the input to handle camera move.
  24758. */
  24759. buttons: number[];
  24760. /**
  24761. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  24762. */
  24763. angularSensibility: number;
  24764. private _pointerInput;
  24765. private _onMouseMove;
  24766. private _observer;
  24767. private previousPosition;
  24768. /**
  24769. * Observable for when a pointer move event occurs containing the move offset
  24770. */
  24771. onPointerMovedObservable: Observable<{
  24772. offsetX: number;
  24773. offsetY: number;
  24774. }>;
  24775. /**
  24776. * @hidden
  24777. * If the camera should be rotated automatically based on pointer movement
  24778. */
  24779. _allowCameraRotation: boolean;
  24780. /**
  24781. * Manage the mouse inputs to control the movement of a free camera.
  24782. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24783. * @param touchEnabled Defines if touch is enabled or not
  24784. */
  24785. constructor(
  24786. /**
  24787. * Define if touch is enabled in the mouse input
  24788. */
  24789. touchEnabled?: boolean);
  24790. /**
  24791. * Attach the input controls to a specific dom element to get the input from.
  24792. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24793. */
  24794. attachControl(noPreventDefault?: boolean): void;
  24795. /**
  24796. * Called on JS contextmenu event.
  24797. * Override this method to provide functionality.
  24798. */
  24799. protected onContextMenu(evt: PointerEvent): void;
  24800. /**
  24801. * Detach the current controls from the specified dom element.
  24802. */
  24803. detachControl(): void;
  24804. /**
  24805. * Gets the class name of the current intput.
  24806. * @returns the class name
  24807. */
  24808. getClassName(): string;
  24809. /**
  24810. * Get the friendly name associated with the input class.
  24811. * @returns the input friendly name
  24812. */
  24813. getSimpleName(): string;
  24814. }
  24815. }
  24816. declare module "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput" {
  24817. import { Observable } from "babylonjs/Misc/observable";
  24818. import { Camera } from "babylonjs/Cameras/camera";
  24819. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  24820. /**
  24821. * Base class for mouse wheel input..
  24822. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  24823. * for example usage.
  24824. */
  24825. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  24826. /**
  24827. * Defines the camera the input is attached to.
  24828. */
  24829. abstract camera: Camera;
  24830. /**
  24831. * How fast is the camera moves in relation to X axis mouseWheel events.
  24832. * Use negative value to reverse direction.
  24833. */
  24834. wheelPrecisionX: number;
  24835. /**
  24836. * How fast is the camera moves in relation to Y axis mouseWheel events.
  24837. * Use negative value to reverse direction.
  24838. */
  24839. wheelPrecisionY: number;
  24840. /**
  24841. * How fast is the camera moves in relation to Z axis mouseWheel events.
  24842. * Use negative value to reverse direction.
  24843. */
  24844. wheelPrecisionZ: number;
  24845. /**
  24846. * Observable for when a mouse wheel move event occurs.
  24847. */
  24848. onChangedObservable: Observable<{
  24849. wheelDeltaX: number;
  24850. wheelDeltaY: number;
  24851. wheelDeltaZ: number;
  24852. }>;
  24853. private _wheel;
  24854. private _observer;
  24855. /**
  24856. * Attach the input controls to a specific dom element to get the input from.
  24857. * @param noPreventDefault Defines whether event caught by the controls
  24858. * should call preventdefault().
  24859. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24860. */
  24861. attachControl(noPreventDefault?: boolean): void;
  24862. /**
  24863. * Detach the current controls from the specified dom element.
  24864. */
  24865. detachControl(): void;
  24866. /**
  24867. * Called for each rendered frame.
  24868. */
  24869. checkInputs(): void;
  24870. /**
  24871. * Gets the class name of the current intput.
  24872. * @returns the class name
  24873. */
  24874. getClassName(): string;
  24875. /**
  24876. * Get the friendly name associated with the input class.
  24877. * @returns the input friendly name
  24878. */
  24879. getSimpleName(): string;
  24880. /**
  24881. * Incremental value of multiple mouse wheel movements of the X axis.
  24882. * Should be zero-ed when read.
  24883. */
  24884. protected _wheelDeltaX: number;
  24885. /**
  24886. * Incremental value of multiple mouse wheel movements of the Y axis.
  24887. * Should be zero-ed when read.
  24888. */
  24889. protected _wheelDeltaY: number;
  24890. /**
  24891. * Incremental value of multiple mouse wheel movements of the Z axis.
  24892. * Should be zero-ed when read.
  24893. */
  24894. protected _wheelDeltaZ: number;
  24895. /**
  24896. * Firefox uses a different scheme to report scroll distances to other
  24897. * browsers. Rather than use complicated methods to calculate the exact
  24898. * multiple we need to apply, let's just cheat and use a constant.
  24899. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  24900. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  24901. */
  24902. private readonly _ffMultiplier;
  24903. /**
  24904. * Different event attributes for wheel data fall into a few set ranges.
  24905. * Some relevant but dated date here:
  24906. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  24907. */
  24908. private readonly _normalize;
  24909. }
  24910. }
  24911. declare module "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput" {
  24912. import { Nullable } from "babylonjs/types";
  24913. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  24914. import { BaseCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput";
  24915. import { Coordinate } from "babylonjs/Maths/math.axis";
  24916. /**
  24917. * Manage the mouse wheel inputs to control a free camera.
  24918. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24919. */
  24920. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  24921. /**
  24922. * Defines the camera the input is attached to.
  24923. */
  24924. camera: FreeCamera;
  24925. /**
  24926. * Gets the class name of the current input.
  24927. * @returns the class name
  24928. */
  24929. getClassName(): string;
  24930. /**
  24931. * Set which movement axis (relative to camera's orientation) the mouse
  24932. * wheel's X axis controls.
  24933. * @param axis The axis to be moved. Set null to clear.
  24934. */
  24935. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  24936. /**
  24937. * Get the configured movement axis (relative to camera's orientation) the
  24938. * mouse wheel's X axis controls.
  24939. * @returns The configured axis or null if none.
  24940. */
  24941. get wheelXMoveRelative(): Nullable<Coordinate>;
  24942. /**
  24943. * Set which movement axis (relative to camera's orientation) the mouse
  24944. * wheel's Y axis controls.
  24945. * @param axis The axis to be moved. Set null to clear.
  24946. */
  24947. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  24948. /**
  24949. * Get the configured movement axis (relative to camera's orientation) the
  24950. * mouse wheel's Y axis controls.
  24951. * @returns The configured axis or null if none.
  24952. */
  24953. get wheelYMoveRelative(): Nullable<Coordinate>;
  24954. /**
  24955. * Set which movement axis (relative to camera's orientation) the mouse
  24956. * wheel's Z axis controls.
  24957. * @param axis The axis to be moved. Set null to clear.
  24958. */
  24959. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  24960. /**
  24961. * Get the configured movement axis (relative to camera's orientation) the
  24962. * mouse wheel's Z axis controls.
  24963. * @returns The configured axis or null if none.
  24964. */
  24965. get wheelZMoveRelative(): Nullable<Coordinate>;
  24966. /**
  24967. * Set which rotation axis (relative to camera's orientation) the mouse
  24968. * wheel's X axis controls.
  24969. * @param axis The axis to be moved. Set null to clear.
  24970. */
  24971. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  24972. /**
  24973. * Get the configured rotation axis (relative to camera's orientation) the
  24974. * mouse wheel's X axis controls.
  24975. * @returns The configured axis or null if none.
  24976. */
  24977. get wheelXRotateRelative(): Nullable<Coordinate>;
  24978. /**
  24979. * Set which rotation axis (relative to camera's orientation) the mouse
  24980. * wheel's Y axis controls.
  24981. * @param axis The axis to be moved. Set null to clear.
  24982. */
  24983. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  24984. /**
  24985. * Get the configured rotation axis (relative to camera's orientation) the
  24986. * mouse wheel's Y axis controls.
  24987. * @returns The configured axis or null if none.
  24988. */
  24989. get wheelYRotateRelative(): Nullable<Coordinate>;
  24990. /**
  24991. * Set which rotation axis (relative to camera's orientation) the mouse
  24992. * wheel's Z axis controls.
  24993. * @param axis The axis to be moved. Set null to clear.
  24994. */
  24995. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  24996. /**
  24997. * Get the configured rotation axis (relative to camera's orientation) the
  24998. * mouse wheel's Z axis controls.
  24999. * @returns The configured axis or null if none.
  25000. */
  25001. get wheelZRotateRelative(): Nullable<Coordinate>;
  25002. /**
  25003. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  25004. * controls.
  25005. * @param axis The axis to be moved. Set null to clear.
  25006. */
  25007. set wheelXMoveScene(axis: Nullable<Coordinate>);
  25008. /**
  25009. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25010. * X axis controls.
  25011. * @returns The configured axis or null if none.
  25012. */
  25013. get wheelXMoveScene(): Nullable<Coordinate>;
  25014. /**
  25015. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  25016. * controls.
  25017. * @param axis The axis to be moved. Set null to clear.
  25018. */
  25019. set wheelYMoveScene(axis: Nullable<Coordinate>);
  25020. /**
  25021. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25022. * Y axis controls.
  25023. * @returns The configured axis or null if none.
  25024. */
  25025. get wheelYMoveScene(): Nullable<Coordinate>;
  25026. /**
  25027. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  25028. * controls.
  25029. * @param axis The axis to be moved. Set null to clear.
  25030. */
  25031. set wheelZMoveScene(axis: Nullable<Coordinate>);
  25032. /**
  25033. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25034. * Z axis controls.
  25035. * @returns The configured axis or null if none.
  25036. */
  25037. get wheelZMoveScene(): Nullable<Coordinate>;
  25038. /**
  25039. * Called for each rendered frame.
  25040. */
  25041. checkInputs(): void;
  25042. private _moveRelative;
  25043. private _rotateRelative;
  25044. private _moveScene;
  25045. /**
  25046. * These are set to the desired default behaviour.
  25047. */
  25048. private _wheelXAction;
  25049. private _wheelXActionCoordinate;
  25050. private _wheelYAction;
  25051. private _wheelYActionCoordinate;
  25052. private _wheelZAction;
  25053. private _wheelZActionCoordinate;
  25054. /**
  25055. * Update the camera according to any configured properties for the 3
  25056. * mouse-wheel axis.
  25057. */
  25058. private _updateCamera;
  25059. }
  25060. }
  25061. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  25062. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  25063. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25064. /**
  25065. * Manage the touch inputs to control the movement of a free camera.
  25066. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25067. */
  25068. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  25069. /**
  25070. * Define if mouse events can be treated as touch events
  25071. */
  25072. allowMouse: boolean;
  25073. /**
  25074. * Defines the camera the input is attached to.
  25075. */
  25076. camera: FreeCamera;
  25077. /**
  25078. * Defines the touch sensibility for rotation.
  25079. * The higher the faster.
  25080. */
  25081. touchAngularSensibility: number;
  25082. /**
  25083. * Defines the touch sensibility for move.
  25084. * The higher the faster.
  25085. */
  25086. touchMoveSensibility: number;
  25087. private _offsetX;
  25088. private _offsetY;
  25089. private _pointerPressed;
  25090. private _pointerInput?;
  25091. private _observer;
  25092. private _onLostFocus;
  25093. /**
  25094. * Manage the touch inputs to control the movement of a free camera.
  25095. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25096. * @param allowMouse Defines if mouse events can be treated as touch events
  25097. */
  25098. constructor(
  25099. /**
  25100. * Define if mouse events can be treated as touch events
  25101. */
  25102. allowMouse?: boolean);
  25103. /**
  25104. * Attach the input controls to a specific dom element to get the input from.
  25105. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25106. */
  25107. attachControl(noPreventDefault?: boolean): void;
  25108. /**
  25109. * Detach the current controls from the specified dom element.
  25110. */
  25111. detachControl(): void;
  25112. /**
  25113. * Update the current camera state depending on the inputs that have been used this frame.
  25114. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  25115. */
  25116. checkInputs(): void;
  25117. /**
  25118. * Gets the class name of the current intput.
  25119. * @returns the class name
  25120. */
  25121. getClassName(): string;
  25122. /**
  25123. * Get the friendly name associated with the input class.
  25124. * @returns the input friendly name
  25125. */
  25126. getSimpleName(): string;
  25127. }
  25128. }
  25129. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  25130. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25131. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25132. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  25133. import { FreeCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  25134. import { Nullable } from "babylonjs/types";
  25135. /**
  25136. * Default Inputs manager for the FreeCamera.
  25137. * It groups all the default supported inputs for ease of use.
  25138. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25139. */
  25140. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  25141. /**
  25142. * @hidden
  25143. */
  25144. _mouseInput: Nullable<FreeCameraMouseInput>;
  25145. /**
  25146. * @hidden
  25147. */
  25148. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  25149. /**
  25150. * Instantiates a new FreeCameraInputsManager.
  25151. * @param camera Defines the camera the inputs belong to
  25152. */
  25153. constructor(camera: FreeCamera);
  25154. /**
  25155. * Add keyboard input support to the input manager.
  25156. * @returns the current input manager
  25157. */
  25158. addKeyboard(): FreeCameraInputsManager;
  25159. /**
  25160. * Add mouse input support to the input manager.
  25161. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  25162. * @returns the current input manager
  25163. */
  25164. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  25165. /**
  25166. * Removes the mouse input support from the manager
  25167. * @returns the current input manager
  25168. */
  25169. removeMouse(): FreeCameraInputsManager;
  25170. /**
  25171. * Add mouse wheel input support to the input manager.
  25172. * @returns the current input manager
  25173. */
  25174. addMouseWheel(): FreeCameraInputsManager;
  25175. /**
  25176. * Removes the mouse wheel input support from the manager
  25177. * @returns the current input manager
  25178. */
  25179. removeMouseWheel(): FreeCameraInputsManager;
  25180. /**
  25181. * Add touch input support to the input manager.
  25182. * @returns the current input manager
  25183. */
  25184. addTouch(): FreeCameraInputsManager;
  25185. /**
  25186. * Remove all attached input methods from a camera
  25187. */
  25188. clear(): void;
  25189. }
  25190. }
  25191. declare module "babylonjs/Cameras/freeCamera" {
  25192. import { Vector3 } from "babylonjs/Maths/math.vector";
  25193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25194. import { Scene } from "babylonjs/scene";
  25195. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  25196. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  25197. /**
  25198. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25199. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25200. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25201. */
  25202. export class FreeCamera extends TargetCamera {
  25203. /**
  25204. * Define the collision ellipsoid of the camera.
  25205. * This is helpful to simulate a camera body like the player body around the camera
  25206. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25207. */
  25208. ellipsoid: Vector3;
  25209. /**
  25210. * Define an offset for the position of the ellipsoid around the camera.
  25211. * This can be helpful to determine the center of the body near the gravity center of the body
  25212. * instead of its head.
  25213. */
  25214. ellipsoidOffset: Vector3;
  25215. /**
  25216. * Enable or disable collisions of the camera with the rest of the scene objects.
  25217. */
  25218. checkCollisions: boolean;
  25219. /**
  25220. * Enable or disable gravity on the camera.
  25221. */
  25222. applyGravity: boolean;
  25223. /**
  25224. * Define the input manager associated to the camera.
  25225. */
  25226. inputs: FreeCameraInputsManager;
  25227. /**
  25228. * Gets the input sensibility for a mouse input. (default is 2000.0)
  25229. * Higher values reduce sensitivity.
  25230. */
  25231. get angularSensibility(): number;
  25232. /**
  25233. * Sets the input sensibility for a mouse input. (default is 2000.0)
  25234. * Higher values reduce sensitivity.
  25235. */
  25236. set angularSensibility(value: number);
  25237. /**
  25238. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  25239. */
  25240. get keysUp(): number[];
  25241. set keysUp(value: number[]);
  25242. /**
  25243. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  25244. */
  25245. get keysUpward(): number[];
  25246. set keysUpward(value: number[]);
  25247. /**
  25248. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  25249. */
  25250. get keysDown(): number[];
  25251. set keysDown(value: number[]);
  25252. /**
  25253. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  25254. */
  25255. get keysDownward(): number[];
  25256. set keysDownward(value: number[]);
  25257. /**
  25258. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  25259. */
  25260. get keysLeft(): number[];
  25261. set keysLeft(value: number[]);
  25262. /**
  25263. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  25264. */
  25265. get keysRight(): number[];
  25266. set keysRight(value: number[]);
  25267. /**
  25268. * Event raised when the camera collide with a mesh in the scene.
  25269. */
  25270. onCollide: (collidedMesh: AbstractMesh) => void;
  25271. private _collider;
  25272. private _needMoveForGravity;
  25273. private _oldPosition;
  25274. private _diffPosition;
  25275. private _newPosition;
  25276. /** @hidden */
  25277. _localDirection: Vector3;
  25278. /** @hidden */
  25279. _transformedDirection: Vector3;
  25280. /**
  25281. * Instantiates a Free Camera.
  25282. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25283. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  25284. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25285. * @param name Define the name of the camera in the scene
  25286. * @param position Define the start position of the camera in the scene
  25287. * @param scene Define the scene the camera belongs to
  25288. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  25289. */
  25290. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25291. /**
  25292. * Attach the input controls to a specific dom element to get the input from.
  25293. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25294. */
  25295. attachControl(noPreventDefault?: boolean): void;
  25296. /**
  25297. * Attach the input controls to a specific dom element to get the input from.
  25298. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  25299. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25300. * BACK COMPAT SIGNATURE ONLY.
  25301. */
  25302. attachControl(ignored: any, noPreventDefault?: boolean): void;
  25303. /**
  25304. * Detach the current controls from the specified dom element.
  25305. */
  25306. detachControl(): void;
  25307. /**
  25308. * Detach the current controls from the specified dom element.
  25309. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  25310. */
  25311. detachControl(ignored: any): void;
  25312. private _collisionMask;
  25313. /**
  25314. * Define a collision mask to limit the list of object the camera can collide with
  25315. */
  25316. get collisionMask(): number;
  25317. set collisionMask(mask: number);
  25318. /** @hidden */
  25319. _collideWithWorld(displacement: Vector3): void;
  25320. private _onCollisionPositionChange;
  25321. /** @hidden */
  25322. _checkInputs(): void;
  25323. /** @hidden */
  25324. _decideIfNeedsToMove(): boolean;
  25325. /** @hidden */
  25326. _updatePosition(): void;
  25327. /**
  25328. * Destroy the camera and release the current resources hold by it.
  25329. */
  25330. dispose(): void;
  25331. /**
  25332. * Gets the current object class name.
  25333. * @return the class name
  25334. */
  25335. getClassName(): string;
  25336. }
  25337. }
  25338. declare module "babylonjs/Gamepads/gamepad" {
  25339. import { Observable } from "babylonjs/Misc/observable";
  25340. /**
  25341. * Represents a gamepad control stick position
  25342. */
  25343. export class StickValues {
  25344. /**
  25345. * The x component of the control stick
  25346. */
  25347. x: number;
  25348. /**
  25349. * The y component of the control stick
  25350. */
  25351. y: number;
  25352. /**
  25353. * Initializes the gamepad x and y control stick values
  25354. * @param x The x component of the gamepad control stick value
  25355. * @param y The y component of the gamepad control stick value
  25356. */
  25357. constructor(
  25358. /**
  25359. * The x component of the control stick
  25360. */
  25361. x: number,
  25362. /**
  25363. * The y component of the control stick
  25364. */
  25365. y: number);
  25366. }
  25367. /**
  25368. * An interface which manages callbacks for gamepad button changes
  25369. */
  25370. export interface GamepadButtonChanges {
  25371. /**
  25372. * Called when a gamepad has been changed
  25373. */
  25374. changed: boolean;
  25375. /**
  25376. * Called when a gamepad press event has been triggered
  25377. */
  25378. pressChanged: boolean;
  25379. /**
  25380. * Called when a touch event has been triggered
  25381. */
  25382. touchChanged: boolean;
  25383. /**
  25384. * Called when a value has changed
  25385. */
  25386. valueChanged: boolean;
  25387. }
  25388. /**
  25389. * Represents a gamepad
  25390. */
  25391. export class Gamepad {
  25392. /**
  25393. * The id of the gamepad
  25394. */
  25395. id: string;
  25396. /**
  25397. * The index of the gamepad
  25398. */
  25399. index: number;
  25400. /**
  25401. * The browser gamepad
  25402. */
  25403. browserGamepad: any;
  25404. /**
  25405. * Specifies what type of gamepad this represents
  25406. */
  25407. type: number;
  25408. private _leftStick;
  25409. private _rightStick;
  25410. /** @hidden */
  25411. _isConnected: boolean;
  25412. private _leftStickAxisX;
  25413. private _leftStickAxisY;
  25414. private _rightStickAxisX;
  25415. private _rightStickAxisY;
  25416. /**
  25417. * Triggered when the left control stick has been changed
  25418. */
  25419. private _onleftstickchanged;
  25420. /**
  25421. * Triggered when the right control stick has been changed
  25422. */
  25423. private _onrightstickchanged;
  25424. /**
  25425. * Represents a gamepad controller
  25426. */
  25427. static GAMEPAD: number;
  25428. /**
  25429. * Represents a generic controller
  25430. */
  25431. static GENERIC: number;
  25432. /**
  25433. * Represents an XBox controller
  25434. */
  25435. static XBOX: number;
  25436. /**
  25437. * Represents a pose-enabled controller
  25438. */
  25439. static POSE_ENABLED: number;
  25440. /**
  25441. * Represents an Dual Shock controller
  25442. */
  25443. static DUALSHOCK: number;
  25444. /**
  25445. * Specifies whether the left control stick should be Y-inverted
  25446. */
  25447. protected _invertLeftStickY: boolean;
  25448. /**
  25449. * Specifies if the gamepad has been connected
  25450. */
  25451. get isConnected(): boolean;
  25452. /**
  25453. * Initializes the gamepad
  25454. * @param id The id of the gamepad
  25455. * @param index The index of the gamepad
  25456. * @param browserGamepad The browser gamepad
  25457. * @param leftStickX The x component of the left joystick
  25458. * @param leftStickY The y component of the left joystick
  25459. * @param rightStickX The x component of the right joystick
  25460. * @param rightStickY The y component of the right joystick
  25461. */
  25462. constructor(
  25463. /**
  25464. * The id of the gamepad
  25465. */
  25466. id: string,
  25467. /**
  25468. * The index of the gamepad
  25469. */
  25470. index: number,
  25471. /**
  25472. * The browser gamepad
  25473. */
  25474. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  25475. /**
  25476. * Callback triggered when the left joystick has changed
  25477. * @param callback
  25478. */
  25479. onleftstickchanged(callback: (values: StickValues) => void): void;
  25480. /**
  25481. * Callback triggered when the right joystick has changed
  25482. * @param callback
  25483. */
  25484. onrightstickchanged(callback: (values: StickValues) => void): void;
  25485. /**
  25486. * Gets the left joystick
  25487. */
  25488. get leftStick(): StickValues;
  25489. /**
  25490. * Sets the left joystick values
  25491. */
  25492. set leftStick(newValues: StickValues);
  25493. /**
  25494. * Gets the right joystick
  25495. */
  25496. get rightStick(): StickValues;
  25497. /**
  25498. * Sets the right joystick value
  25499. */
  25500. set rightStick(newValues: StickValues);
  25501. /**
  25502. * Updates the gamepad joystick positions
  25503. */
  25504. update(): void;
  25505. /**
  25506. * Disposes the gamepad
  25507. */
  25508. dispose(): void;
  25509. }
  25510. /**
  25511. * Represents a generic gamepad
  25512. */
  25513. export class GenericPad extends Gamepad {
  25514. private _buttons;
  25515. private _onbuttondown;
  25516. private _onbuttonup;
  25517. /**
  25518. * Observable triggered when a button has been pressed
  25519. */
  25520. onButtonDownObservable: Observable<number>;
  25521. /**
  25522. * Observable triggered when a button has been released
  25523. */
  25524. onButtonUpObservable: Observable<number>;
  25525. /**
  25526. * Callback triggered when a button has been pressed
  25527. * @param callback Called when a button has been pressed
  25528. */
  25529. onbuttondown(callback: (buttonPressed: number) => void): void;
  25530. /**
  25531. * Callback triggered when a button has been released
  25532. * @param callback Called when a button has been released
  25533. */
  25534. onbuttonup(callback: (buttonReleased: number) => void): void;
  25535. /**
  25536. * Initializes the generic gamepad
  25537. * @param id The id of the generic gamepad
  25538. * @param index The index of the generic gamepad
  25539. * @param browserGamepad The browser gamepad
  25540. */
  25541. constructor(id: string, index: number, browserGamepad: any);
  25542. private _setButtonValue;
  25543. /**
  25544. * Updates the generic gamepad
  25545. */
  25546. update(): void;
  25547. /**
  25548. * Disposes the generic gamepad
  25549. */
  25550. dispose(): void;
  25551. }
  25552. }
  25553. declare module "babylonjs/Animations/runtimeAnimation" {
  25554. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  25555. import { Animatable } from "babylonjs/Animations/animatable";
  25556. import { Scene } from "babylonjs/scene";
  25557. /**
  25558. * Defines a runtime animation
  25559. */
  25560. export class RuntimeAnimation {
  25561. private _events;
  25562. /**
  25563. * The current frame of the runtime animation
  25564. */
  25565. private _currentFrame;
  25566. /**
  25567. * The animation used by the runtime animation
  25568. */
  25569. private _animation;
  25570. /**
  25571. * The target of the runtime animation
  25572. */
  25573. private _target;
  25574. /**
  25575. * The initiating animatable
  25576. */
  25577. private _host;
  25578. /**
  25579. * The original value of the runtime animation
  25580. */
  25581. private _originalValue;
  25582. /**
  25583. * The original blend value of the runtime animation
  25584. */
  25585. private _originalBlendValue;
  25586. /**
  25587. * The offsets cache of the runtime animation
  25588. */
  25589. private _offsetsCache;
  25590. /**
  25591. * The high limits cache of the runtime animation
  25592. */
  25593. private _highLimitsCache;
  25594. /**
  25595. * Specifies if the runtime animation has been stopped
  25596. */
  25597. private _stopped;
  25598. /**
  25599. * The blending factor of the runtime animation
  25600. */
  25601. private _blendingFactor;
  25602. /**
  25603. * The BabylonJS scene
  25604. */
  25605. private _scene;
  25606. /**
  25607. * The current value of the runtime animation
  25608. */
  25609. private _currentValue;
  25610. /** @hidden */
  25611. _animationState: _IAnimationState;
  25612. /**
  25613. * The active target of the runtime animation
  25614. */
  25615. private _activeTargets;
  25616. private _currentActiveTarget;
  25617. private _directTarget;
  25618. /**
  25619. * The target path of the runtime animation
  25620. */
  25621. private _targetPath;
  25622. /**
  25623. * The weight of the runtime animation
  25624. */
  25625. private _weight;
  25626. /**
  25627. * The ratio offset of the runtime animation
  25628. */
  25629. private _ratioOffset;
  25630. /**
  25631. * The previous delay of the runtime animation
  25632. */
  25633. private _previousDelay;
  25634. /**
  25635. * The previous ratio of the runtime animation
  25636. */
  25637. private _previousRatio;
  25638. private _enableBlending;
  25639. private _keys;
  25640. private _minFrame;
  25641. private _maxFrame;
  25642. private _minValue;
  25643. private _maxValue;
  25644. private _targetIsArray;
  25645. /**
  25646. * Gets the current frame of the runtime animation
  25647. */
  25648. get currentFrame(): number;
  25649. /**
  25650. * Gets the weight of the runtime animation
  25651. */
  25652. get weight(): number;
  25653. /**
  25654. * Gets the current value of the runtime animation
  25655. */
  25656. get currentValue(): any;
  25657. /**
  25658. * Gets the target path of the runtime animation
  25659. */
  25660. get targetPath(): string;
  25661. /**
  25662. * Gets the actual target of the runtime animation
  25663. */
  25664. get target(): any;
  25665. /**
  25666. * Gets the additive state of the runtime animation
  25667. */
  25668. get isAdditive(): boolean;
  25669. /** @hidden */
  25670. _onLoop: () => void;
  25671. /**
  25672. * Create a new RuntimeAnimation object
  25673. * @param target defines the target of the animation
  25674. * @param animation defines the source animation object
  25675. * @param scene defines the hosting scene
  25676. * @param host defines the initiating Animatable
  25677. */
  25678. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  25679. private _preparePath;
  25680. /**
  25681. * Gets the animation from the runtime animation
  25682. */
  25683. get animation(): Animation;
  25684. /**
  25685. * Resets the runtime animation to the beginning
  25686. * @param restoreOriginal defines whether to restore the target property to the original value
  25687. */
  25688. reset(restoreOriginal?: boolean): void;
  25689. /**
  25690. * Specifies if the runtime animation is stopped
  25691. * @returns Boolean specifying if the runtime animation is stopped
  25692. */
  25693. isStopped(): boolean;
  25694. /**
  25695. * Disposes of the runtime animation
  25696. */
  25697. dispose(): void;
  25698. /**
  25699. * Apply the interpolated value to the target
  25700. * @param currentValue defines the value computed by the animation
  25701. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  25702. */
  25703. setValue(currentValue: any, weight: number): void;
  25704. private _getOriginalValues;
  25705. private _setValue;
  25706. /**
  25707. * Gets the loop pmode of the runtime animation
  25708. * @returns Loop Mode
  25709. */
  25710. private _getCorrectLoopMode;
  25711. /**
  25712. * Move the current animation to a given frame
  25713. * @param frame defines the frame to move to
  25714. */
  25715. goToFrame(frame: number): void;
  25716. /**
  25717. * @hidden Internal use only
  25718. */
  25719. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  25720. /**
  25721. * Execute the current animation
  25722. * @param delay defines the delay to add to the current frame
  25723. * @param from defines the lower bound of the animation range
  25724. * @param to defines the upper bound of the animation range
  25725. * @param loop defines if the current animation must loop
  25726. * @param speedRatio defines the current speed ratio
  25727. * @param weight defines the weight of the animation (default is -1 so no weight)
  25728. * @param onLoop optional callback called when animation loops
  25729. * @returns a boolean indicating if the animation is running
  25730. */
  25731. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  25732. }
  25733. }
  25734. declare module "babylonjs/Animations/animatable" {
  25735. import { Animation } from "babylonjs/Animations/animation";
  25736. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25737. import { Nullable } from "babylonjs/types";
  25738. import { Observable } from "babylonjs/Misc/observable";
  25739. import { Scene } from "babylonjs/scene";
  25740. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  25741. import { Node } from "babylonjs/node";
  25742. /**
  25743. * Class used to store an actual running animation
  25744. */
  25745. export class Animatable {
  25746. /** defines the target object */
  25747. target: any;
  25748. /** defines the starting frame number (default is 0) */
  25749. fromFrame: number;
  25750. /** defines the ending frame number (default is 100) */
  25751. toFrame: number;
  25752. /** defines if the animation must loop (default is false) */
  25753. loopAnimation: boolean;
  25754. /** defines a callback to call when animation ends if it is not looping */
  25755. onAnimationEnd?: (() => void) | null | undefined;
  25756. /** defines a callback to call when animation loops */
  25757. onAnimationLoop?: (() => void) | null | undefined;
  25758. /** defines whether the animation should be evaluated additively */
  25759. isAdditive: boolean;
  25760. private _localDelayOffset;
  25761. private _pausedDelay;
  25762. private _runtimeAnimations;
  25763. private _paused;
  25764. private _scene;
  25765. private _speedRatio;
  25766. private _weight;
  25767. private _syncRoot;
  25768. /**
  25769. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  25770. * This will only apply for non looping animation (default is true)
  25771. */
  25772. disposeOnEnd: boolean;
  25773. /**
  25774. * Gets a boolean indicating if the animation has started
  25775. */
  25776. animationStarted: boolean;
  25777. /**
  25778. * Observer raised when the animation ends
  25779. */
  25780. onAnimationEndObservable: Observable<Animatable>;
  25781. /**
  25782. * Observer raised when the animation loops
  25783. */
  25784. onAnimationLoopObservable: Observable<Animatable>;
  25785. /**
  25786. * Gets the root Animatable used to synchronize and normalize animations
  25787. */
  25788. get syncRoot(): Nullable<Animatable>;
  25789. /**
  25790. * Gets the current frame of the first RuntimeAnimation
  25791. * Used to synchronize Animatables
  25792. */
  25793. get masterFrame(): number;
  25794. /**
  25795. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  25796. */
  25797. get weight(): number;
  25798. set weight(value: number);
  25799. /**
  25800. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  25801. */
  25802. get speedRatio(): number;
  25803. set speedRatio(value: number);
  25804. /**
  25805. * Creates a new Animatable
  25806. * @param scene defines the hosting scene
  25807. * @param target defines the target object
  25808. * @param fromFrame defines the starting frame number (default is 0)
  25809. * @param toFrame defines the ending frame number (default is 100)
  25810. * @param loopAnimation defines if the animation must loop (default is false)
  25811. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  25812. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  25813. * @param animations defines a group of animation to add to the new Animatable
  25814. * @param onAnimationLoop defines a callback to call when animation loops
  25815. * @param isAdditive defines whether the animation should be evaluated additively
  25816. */
  25817. constructor(scene: Scene,
  25818. /** defines the target object */
  25819. target: any,
  25820. /** defines the starting frame number (default is 0) */
  25821. fromFrame?: number,
  25822. /** defines the ending frame number (default is 100) */
  25823. toFrame?: number,
  25824. /** defines if the animation must loop (default is false) */
  25825. loopAnimation?: boolean, speedRatio?: number,
  25826. /** defines a callback to call when animation ends if it is not looping */
  25827. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  25828. /** defines a callback to call when animation loops */
  25829. onAnimationLoop?: (() => void) | null | undefined,
  25830. /** defines whether the animation should be evaluated additively */
  25831. isAdditive?: boolean);
  25832. /**
  25833. * Synchronize and normalize current Animatable with a source Animatable
  25834. * This is useful when using animation weights and when animations are not of the same length
  25835. * @param root defines the root Animatable to synchronize with
  25836. * @returns the current Animatable
  25837. */
  25838. syncWith(root: Animatable): Animatable;
  25839. /**
  25840. * Gets the list of runtime animations
  25841. * @returns an array of RuntimeAnimation
  25842. */
  25843. getAnimations(): RuntimeAnimation[];
  25844. /**
  25845. * Adds more animations to the current animatable
  25846. * @param target defines the target of the animations
  25847. * @param animations defines the new animations to add
  25848. */
  25849. appendAnimations(target: any, animations: Animation[]): void;
  25850. /**
  25851. * Gets the source animation for a specific property
  25852. * @param property defines the propertyu to look for
  25853. * @returns null or the source animation for the given property
  25854. */
  25855. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  25856. /**
  25857. * Gets the runtime animation for a specific property
  25858. * @param property defines the propertyu to look for
  25859. * @returns null or the runtime animation for the given property
  25860. */
  25861. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  25862. /**
  25863. * Resets the animatable to its original state
  25864. */
  25865. reset(): void;
  25866. /**
  25867. * Allows the animatable to blend with current running animations
  25868. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25869. * @param blendingSpeed defines the blending speed to use
  25870. */
  25871. enableBlending(blendingSpeed: number): void;
  25872. /**
  25873. * Disable animation blending
  25874. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25875. */
  25876. disableBlending(): void;
  25877. /**
  25878. * Jump directly to a given frame
  25879. * @param frame defines the frame to jump to
  25880. */
  25881. goToFrame(frame: number): void;
  25882. /**
  25883. * Pause the animation
  25884. */
  25885. pause(): void;
  25886. /**
  25887. * Restart the animation
  25888. */
  25889. restart(): void;
  25890. private _raiseOnAnimationEnd;
  25891. /**
  25892. * Stop and delete the current animation
  25893. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  25894. * @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)
  25895. */
  25896. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  25897. /**
  25898. * Wait asynchronously for the animation to end
  25899. * @returns a promise which will be fullfilled when the animation ends
  25900. */
  25901. waitAsync(): Promise<Animatable>;
  25902. /** @hidden */
  25903. _animate(delay: number): boolean;
  25904. }
  25905. module "babylonjs/scene" {
  25906. interface Scene {
  25907. /** @hidden */
  25908. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  25909. /** @hidden */
  25910. _processLateAnimationBindingsForMatrices(holder: {
  25911. totalWeight: number;
  25912. totalAdditiveWeight: number;
  25913. animations: RuntimeAnimation[];
  25914. additiveAnimations: RuntimeAnimation[];
  25915. originalValue: Matrix;
  25916. }): any;
  25917. /** @hidden */
  25918. _processLateAnimationBindingsForQuaternions(holder: {
  25919. totalWeight: number;
  25920. totalAdditiveWeight: number;
  25921. animations: RuntimeAnimation[];
  25922. additiveAnimations: RuntimeAnimation[];
  25923. originalValue: Quaternion;
  25924. }, refQuaternion: Quaternion): Quaternion;
  25925. /** @hidden */
  25926. _processLateAnimationBindings(): void;
  25927. /**
  25928. * Will start the animation sequence of a given target
  25929. * @param target defines the target
  25930. * @param from defines from which frame should animation start
  25931. * @param to defines until which frame should animation run.
  25932. * @param weight defines the weight to apply to the animation (1.0 by default)
  25933. * @param loop defines if the animation loops
  25934. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25935. * @param onAnimationEnd defines the function to be executed when the animation ends
  25936. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25937. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25938. * @param onAnimationLoop defines the callback to call when an animation loops
  25939. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25940. * @returns the animatable object created for this animation
  25941. */
  25942. 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;
  25943. /**
  25944. * Will start the animation sequence of a given target
  25945. * @param target defines the target
  25946. * @param from defines from which frame should animation start
  25947. * @param to defines until which frame should animation run.
  25948. * @param loop defines if the animation loops
  25949. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25950. * @param onAnimationEnd defines the function to be executed when the animation ends
  25951. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25952. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25953. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  25954. * @param onAnimationLoop defines the callback to call when an animation loops
  25955. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25956. * @returns the animatable object created for this animation
  25957. */
  25958. 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;
  25959. /**
  25960. * Will start the animation sequence of a given target and its hierarchy
  25961. * @param target defines the target
  25962. * @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.
  25963. * @param from defines from which frame should animation start
  25964. * @param to defines until which frame should animation run.
  25965. * @param loop defines if the animation loops
  25966. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25967. * @param onAnimationEnd defines the function to be executed when the animation ends
  25968. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25969. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25970. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25971. * @param onAnimationLoop defines the callback to call when an animation loops
  25972. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25973. * @returns the list of created animatables
  25974. */
  25975. 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[];
  25976. /**
  25977. * Begin a new animation on a given node
  25978. * @param target defines the target where the animation will take place
  25979. * @param animations defines the list of animations to start
  25980. * @param from defines the initial value
  25981. * @param to defines the final value
  25982. * @param loop defines if you want animation to loop (off by default)
  25983. * @param speedRatio defines the speed ratio to apply to all animations
  25984. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25985. * @param onAnimationLoop defines the callback to call when an animation loops
  25986. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25987. * @returns the list of created animatables
  25988. */
  25989. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  25990. /**
  25991. * Begin a new animation on a given node and its hierarchy
  25992. * @param target defines the root node where the animation will take place
  25993. * @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.
  25994. * @param animations defines the list of animations to start
  25995. * @param from defines the initial value
  25996. * @param to defines the final value
  25997. * @param loop defines if you want animation to loop (off by default)
  25998. * @param speedRatio defines the speed ratio to apply to all animations
  25999. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26000. * @param onAnimationLoop defines the callback to call when an animation loops
  26001. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26002. * @returns the list of animatables created for all nodes
  26003. */
  26004. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  26005. /**
  26006. * Gets the animatable associated with a specific target
  26007. * @param target defines the target of the animatable
  26008. * @returns the required animatable if found
  26009. */
  26010. getAnimatableByTarget(target: any): Nullable<Animatable>;
  26011. /**
  26012. * Gets all animatables associated with a given target
  26013. * @param target defines the target to look animatables for
  26014. * @returns an array of Animatables
  26015. */
  26016. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  26017. /**
  26018. * Stops and removes all animations that have been applied to the scene
  26019. */
  26020. stopAllAnimations(): void;
  26021. /**
  26022. * Gets the current delta time used by animation engine
  26023. */
  26024. deltaTime: number;
  26025. }
  26026. }
  26027. module "babylonjs/Bones/bone" {
  26028. interface Bone {
  26029. /**
  26030. * Copy an animation range from another bone
  26031. * @param source defines the source bone
  26032. * @param rangeName defines the range name to copy
  26033. * @param frameOffset defines the frame offset
  26034. * @param rescaleAsRequired defines if rescaling must be applied if required
  26035. * @param skelDimensionsRatio defines the scaling ratio
  26036. * @returns true if operation was successful
  26037. */
  26038. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  26039. }
  26040. }
  26041. }
  26042. declare module "babylonjs/Animations/animationPropertiesOverride" {
  26043. /**
  26044. * Class used to override all child animations of a given target
  26045. */
  26046. export class AnimationPropertiesOverride {
  26047. /**
  26048. * Gets or sets a value indicating if animation blending must be used
  26049. */
  26050. enableBlending: boolean;
  26051. /**
  26052. * Gets or sets the blending speed to use when enableBlending is true
  26053. */
  26054. blendingSpeed: number;
  26055. /**
  26056. * Gets or sets the default loop mode to use
  26057. */
  26058. loopMode: number;
  26059. }
  26060. }
  26061. declare module "babylonjs/Bones/skeleton" {
  26062. import { Bone } from "babylonjs/Bones/bone";
  26063. import { Observable } from "babylonjs/Misc/observable";
  26064. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  26065. import { Scene } from "babylonjs/scene";
  26066. import { Nullable } from "babylonjs/types";
  26067. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26068. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26069. import { Animatable } from "babylonjs/Animations/animatable";
  26070. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26071. import { Animation } from "babylonjs/Animations/animation";
  26072. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26073. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26074. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26075. /**
  26076. * Class used to handle skinning animations
  26077. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26078. */
  26079. export class Skeleton implements IAnimatable {
  26080. /** defines the skeleton name */
  26081. name: string;
  26082. /** defines the skeleton Id */
  26083. id: string;
  26084. /**
  26085. * Defines the list of child bones
  26086. */
  26087. bones: Bone[];
  26088. /**
  26089. * Defines an estimate of the dimension of the skeleton at rest
  26090. */
  26091. dimensionsAtRest: Vector3;
  26092. /**
  26093. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  26094. */
  26095. needInitialSkinMatrix: boolean;
  26096. /**
  26097. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  26098. */
  26099. overrideMesh: Nullable<AbstractMesh>;
  26100. /**
  26101. * Gets the list of animations attached to this skeleton
  26102. */
  26103. animations: Array<Animation>;
  26104. private _scene;
  26105. private _isDirty;
  26106. private _transformMatrices;
  26107. private _transformMatrixTexture;
  26108. private _meshesWithPoseMatrix;
  26109. private _animatables;
  26110. private _identity;
  26111. private _synchronizedWithMesh;
  26112. private _ranges;
  26113. private _lastAbsoluteTransformsUpdateId;
  26114. private _canUseTextureForBones;
  26115. private _uniqueId;
  26116. /** @hidden */
  26117. _numBonesWithLinkedTransformNode: number;
  26118. /** @hidden */
  26119. _hasWaitingData: Nullable<boolean>;
  26120. /** @hidden */
  26121. _waitingOverrideMeshId: Nullable<string>;
  26122. /**
  26123. * Specifies if the skeleton should be serialized
  26124. */
  26125. doNotSerialize: boolean;
  26126. private _useTextureToStoreBoneMatrices;
  26127. /**
  26128. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  26129. * Please note that this option is not available if the hardware does not support it
  26130. */
  26131. get useTextureToStoreBoneMatrices(): boolean;
  26132. set useTextureToStoreBoneMatrices(value: boolean);
  26133. private _animationPropertiesOverride;
  26134. /**
  26135. * Gets or sets the animation properties override
  26136. */
  26137. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26138. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26139. /**
  26140. * List of inspectable custom properties (used by the Inspector)
  26141. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26142. */
  26143. inspectableCustomProperties: IInspectable[];
  26144. /**
  26145. * An observable triggered before computing the skeleton's matrices
  26146. */
  26147. onBeforeComputeObservable: Observable<Skeleton>;
  26148. /**
  26149. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  26150. */
  26151. get isUsingTextureForMatrices(): boolean;
  26152. /**
  26153. * Gets the unique ID of this skeleton
  26154. */
  26155. get uniqueId(): number;
  26156. /**
  26157. * Creates a new skeleton
  26158. * @param name defines the skeleton name
  26159. * @param id defines the skeleton Id
  26160. * @param scene defines the hosting scene
  26161. */
  26162. constructor(
  26163. /** defines the skeleton name */
  26164. name: string,
  26165. /** defines the skeleton Id */
  26166. id: string, scene: Scene);
  26167. /**
  26168. * Gets the current object class name.
  26169. * @return the class name
  26170. */
  26171. getClassName(): string;
  26172. /**
  26173. * Returns an array containing the root bones
  26174. * @returns an array containing the root bones
  26175. */
  26176. getChildren(): Array<Bone>;
  26177. /**
  26178. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  26179. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26180. * @returns a Float32Array containing matrices data
  26181. */
  26182. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  26183. /**
  26184. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  26185. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26186. * @returns a raw texture containing the data
  26187. */
  26188. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  26189. /**
  26190. * Gets the current hosting scene
  26191. * @returns a scene object
  26192. */
  26193. getScene(): Scene;
  26194. /**
  26195. * Gets a string representing the current skeleton data
  26196. * @param fullDetails defines a boolean indicating if we want a verbose version
  26197. * @returns a string representing the current skeleton data
  26198. */
  26199. toString(fullDetails?: boolean): string;
  26200. /**
  26201. * Get bone's index searching by name
  26202. * @param name defines bone's name to search for
  26203. * @return the indice of the bone. Returns -1 if not found
  26204. */
  26205. getBoneIndexByName(name: string): number;
  26206. /**
  26207. * Creater a new animation range
  26208. * @param name defines the name of the range
  26209. * @param from defines the start key
  26210. * @param to defines the end key
  26211. */
  26212. createAnimationRange(name: string, from: number, to: number): void;
  26213. /**
  26214. * Delete a specific animation range
  26215. * @param name defines the name of the range
  26216. * @param deleteFrames defines if frames must be removed as well
  26217. */
  26218. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26219. /**
  26220. * Gets a specific animation range
  26221. * @param name defines the name of the range to look for
  26222. * @returns the requested animation range or null if not found
  26223. */
  26224. getAnimationRange(name: string): Nullable<AnimationRange>;
  26225. /**
  26226. * Gets the list of all animation ranges defined on this skeleton
  26227. * @returns an array
  26228. */
  26229. getAnimationRanges(): Nullable<AnimationRange>[];
  26230. /**
  26231. * Copy animation range from a source skeleton.
  26232. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  26233. * @param source defines the source skeleton
  26234. * @param name defines the name of the range to copy
  26235. * @param rescaleAsRequired defines if rescaling must be applied if required
  26236. * @returns true if operation was successful
  26237. */
  26238. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  26239. /**
  26240. * Forces the skeleton to go to rest pose
  26241. */
  26242. returnToRest(): void;
  26243. private _getHighestAnimationFrame;
  26244. /**
  26245. * Begin a specific animation range
  26246. * @param name defines the name of the range to start
  26247. * @param loop defines if looping must be turned on (false by default)
  26248. * @param speedRatio defines the speed ratio to apply (1 by default)
  26249. * @param onAnimationEnd defines a callback which will be called when animation will end
  26250. * @returns a new animatable
  26251. */
  26252. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26253. /**
  26254. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  26255. * @param skeleton defines the Skeleton containing the animation range to convert
  26256. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  26257. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  26258. * @returns the original skeleton
  26259. */
  26260. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  26261. /** @hidden */
  26262. _markAsDirty(): void;
  26263. /** @hidden */
  26264. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26265. /** @hidden */
  26266. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26267. private _computeTransformMatrices;
  26268. /**
  26269. * Build all resources required to render a skeleton
  26270. */
  26271. prepare(): void;
  26272. /**
  26273. * Gets the list of animatables currently running for this skeleton
  26274. * @returns an array of animatables
  26275. */
  26276. getAnimatables(): IAnimatable[];
  26277. /**
  26278. * Clone the current skeleton
  26279. * @param name defines the name of the new skeleton
  26280. * @param id defines the id of the new skeleton
  26281. * @returns the new skeleton
  26282. */
  26283. clone(name: string, id?: string): Skeleton;
  26284. /**
  26285. * Enable animation blending for this skeleton
  26286. * @param blendingSpeed defines the blending speed to apply
  26287. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26288. */
  26289. enableBlending(blendingSpeed?: number): void;
  26290. /**
  26291. * Releases all resources associated with the current skeleton
  26292. */
  26293. dispose(): void;
  26294. /**
  26295. * Serialize the skeleton in a JSON object
  26296. * @returns a JSON object
  26297. */
  26298. serialize(): any;
  26299. /**
  26300. * Creates a new skeleton from serialized data
  26301. * @param parsedSkeleton defines the serialized data
  26302. * @param scene defines the hosting scene
  26303. * @returns a new skeleton
  26304. */
  26305. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  26306. /**
  26307. * Compute all node absolute transforms
  26308. * @param forceUpdate defines if computation must be done even if cache is up to date
  26309. */
  26310. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  26311. /**
  26312. * Gets the root pose matrix
  26313. * @returns a matrix
  26314. */
  26315. getPoseMatrix(): Nullable<Matrix>;
  26316. /**
  26317. * Sorts bones per internal index
  26318. */
  26319. sortBones(): void;
  26320. private _sortBones;
  26321. /**
  26322. * Set the current local matrix as the restPose for all bones in the skeleton.
  26323. */
  26324. setCurrentPoseAsRest(): void;
  26325. }
  26326. }
  26327. declare module "babylonjs/Bones/bone" {
  26328. import { Skeleton } from "babylonjs/Bones/skeleton";
  26329. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  26330. import { Nullable } from "babylonjs/types";
  26331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26332. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26333. import { Node } from "babylonjs/node";
  26334. import { Space } from "babylonjs/Maths/math.axis";
  26335. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26336. /**
  26337. * Class used to store bone information
  26338. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26339. */
  26340. export class Bone extends Node {
  26341. /**
  26342. * defines the bone name
  26343. */
  26344. name: string;
  26345. private static _tmpVecs;
  26346. private static _tmpQuat;
  26347. private static _tmpMats;
  26348. /**
  26349. * Gets the list of child bones
  26350. */
  26351. children: Bone[];
  26352. /** Gets the animations associated with this bone */
  26353. animations: import("babylonjs/Animations/animation").Animation[];
  26354. /**
  26355. * Gets or sets bone length
  26356. */
  26357. length: number;
  26358. /**
  26359. * @hidden Internal only
  26360. * Set this value to map this bone to a different index in the transform matrices
  26361. * Set this value to -1 to exclude the bone from the transform matrices
  26362. */
  26363. _index: Nullable<number>;
  26364. private _skeleton;
  26365. private _localMatrix;
  26366. private _restPose;
  26367. private _bindPose;
  26368. private _baseMatrix;
  26369. private _absoluteTransform;
  26370. private _invertedAbsoluteTransform;
  26371. private _parent;
  26372. private _scalingDeterminant;
  26373. private _worldTransform;
  26374. private _localScaling;
  26375. private _localRotation;
  26376. private _localPosition;
  26377. private _needToDecompose;
  26378. private _needToCompose;
  26379. /** @hidden */
  26380. _linkedTransformNode: Nullable<TransformNode>;
  26381. /** @hidden */
  26382. _waitingTransformNodeId: Nullable<string>;
  26383. /** @hidden */
  26384. get _matrix(): Matrix;
  26385. /** @hidden */
  26386. set _matrix(value: Matrix);
  26387. /**
  26388. * Create a new bone
  26389. * @param name defines the bone name
  26390. * @param skeleton defines the parent skeleton
  26391. * @param parentBone defines the parent (can be null if the bone is the root)
  26392. * @param localMatrix defines the local matrix
  26393. * @param restPose defines the rest pose matrix
  26394. * @param baseMatrix defines the base matrix
  26395. * @param index defines index of the bone in the hiearchy
  26396. */
  26397. constructor(
  26398. /**
  26399. * defines the bone name
  26400. */
  26401. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  26402. /**
  26403. * Gets the current object class name.
  26404. * @return the class name
  26405. */
  26406. getClassName(): string;
  26407. /**
  26408. * Gets the parent skeleton
  26409. * @returns a skeleton
  26410. */
  26411. getSkeleton(): Skeleton;
  26412. /**
  26413. * Gets parent bone
  26414. * @returns a bone or null if the bone is the root of the bone hierarchy
  26415. */
  26416. getParent(): Nullable<Bone>;
  26417. /**
  26418. * Returns an array containing the root bones
  26419. * @returns an array containing the root bones
  26420. */
  26421. getChildren(): Array<Bone>;
  26422. /**
  26423. * Gets the node index in matrix array generated for rendering
  26424. * @returns the node index
  26425. */
  26426. getIndex(): number;
  26427. /**
  26428. * Sets the parent bone
  26429. * @param parent defines the parent (can be null if the bone is the root)
  26430. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26431. */
  26432. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  26433. /**
  26434. * Gets the local matrix
  26435. * @returns a matrix
  26436. */
  26437. getLocalMatrix(): Matrix;
  26438. /**
  26439. * Gets the base matrix (initial matrix which remains unchanged)
  26440. * @returns a matrix
  26441. */
  26442. getBaseMatrix(): Matrix;
  26443. /**
  26444. * Gets the rest pose matrix
  26445. * @returns a matrix
  26446. */
  26447. getRestPose(): Matrix;
  26448. /**
  26449. * Sets the rest pose matrix
  26450. * @param matrix the local-space rest pose to set for this bone
  26451. */
  26452. setRestPose(matrix: Matrix): void;
  26453. /**
  26454. * Gets the bind pose matrix
  26455. * @returns the bind pose matrix
  26456. */
  26457. getBindPose(): Matrix;
  26458. /**
  26459. * Sets the bind pose matrix
  26460. * @param matrix the local-space bind pose to set for this bone
  26461. */
  26462. setBindPose(matrix: Matrix): void;
  26463. /**
  26464. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  26465. */
  26466. getWorldMatrix(): Matrix;
  26467. /**
  26468. * Sets the local matrix to rest pose matrix
  26469. */
  26470. returnToRest(): void;
  26471. /**
  26472. * Gets the inverse of the absolute transform matrix.
  26473. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  26474. * @returns a matrix
  26475. */
  26476. getInvertedAbsoluteTransform(): Matrix;
  26477. /**
  26478. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  26479. * @returns a matrix
  26480. */
  26481. getAbsoluteTransform(): Matrix;
  26482. /**
  26483. * Links with the given transform node.
  26484. * The local matrix of this bone is copied from the transform node every frame.
  26485. * @param transformNode defines the transform node to link to
  26486. */
  26487. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  26488. /**
  26489. * Gets the node used to drive the bone's transformation
  26490. * @returns a transform node or null
  26491. */
  26492. getTransformNode(): Nullable<TransformNode>;
  26493. /** Gets or sets current position (in local space) */
  26494. get position(): Vector3;
  26495. set position(newPosition: Vector3);
  26496. /** Gets or sets current rotation (in local space) */
  26497. get rotation(): Vector3;
  26498. set rotation(newRotation: Vector3);
  26499. /** Gets or sets current rotation quaternion (in local space) */
  26500. get rotationQuaternion(): Quaternion;
  26501. set rotationQuaternion(newRotation: Quaternion);
  26502. /** Gets or sets current scaling (in local space) */
  26503. get scaling(): Vector3;
  26504. set scaling(newScaling: Vector3);
  26505. /**
  26506. * Gets the animation properties override
  26507. */
  26508. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26509. private _decompose;
  26510. private _compose;
  26511. /**
  26512. * Update the base and local matrices
  26513. * @param matrix defines the new base or local matrix
  26514. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26515. * @param updateLocalMatrix defines if the local matrix should be updated
  26516. */
  26517. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  26518. /** @hidden */
  26519. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  26520. /**
  26521. * Flag the bone as dirty (Forcing it to update everything)
  26522. */
  26523. markAsDirty(): void;
  26524. /** @hidden */
  26525. _markAsDirtyAndCompose(): void;
  26526. private _markAsDirtyAndDecompose;
  26527. /**
  26528. * Translate the bone in local or world space
  26529. * @param vec The amount to translate the bone
  26530. * @param space The space that the translation is in
  26531. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26532. */
  26533. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26534. /**
  26535. * Set the postion of the bone in local or world space
  26536. * @param position The position to set the bone
  26537. * @param space The space that the position is in
  26538. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26539. */
  26540. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26541. /**
  26542. * Set the absolute position of the bone (world space)
  26543. * @param position The position to set the bone
  26544. * @param mesh The mesh that this bone is attached to
  26545. */
  26546. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  26547. /**
  26548. * Scale the bone on the x, y and z axes (in local space)
  26549. * @param x The amount to scale the bone on the x axis
  26550. * @param y The amount to scale the bone on the y axis
  26551. * @param z The amount to scale the bone on the z axis
  26552. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  26553. */
  26554. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  26555. /**
  26556. * Set the bone scaling in local space
  26557. * @param scale defines the scaling vector
  26558. */
  26559. setScale(scale: Vector3): void;
  26560. /**
  26561. * Gets the current scaling in local space
  26562. * @returns the current scaling vector
  26563. */
  26564. getScale(): Vector3;
  26565. /**
  26566. * Gets the current scaling in local space and stores it in a target vector
  26567. * @param result defines the target vector
  26568. */
  26569. getScaleToRef(result: Vector3): void;
  26570. /**
  26571. * Set the yaw, pitch, and roll of the bone in local or world space
  26572. * @param yaw The rotation of the bone on the y axis
  26573. * @param pitch The rotation of the bone on the x axis
  26574. * @param roll The rotation of the bone on the z axis
  26575. * @param space The space that the axes of rotation are in
  26576. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26577. */
  26578. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  26579. /**
  26580. * Add a rotation to the bone on an axis in local or world space
  26581. * @param axis The axis to rotate the bone on
  26582. * @param amount The amount to rotate the bone
  26583. * @param space The space that the axis is in
  26584. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26585. */
  26586. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  26587. /**
  26588. * Set the rotation of the bone to a particular axis angle in local or world space
  26589. * @param axis The axis to rotate the bone on
  26590. * @param angle The angle that the bone should be rotated to
  26591. * @param space The space that the axis is in
  26592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26593. */
  26594. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  26595. /**
  26596. * Set the euler rotation of the bone in local or world space
  26597. * @param rotation The euler rotation that the bone should be set to
  26598. * @param space The space that the rotation is in
  26599. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26600. */
  26601. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26602. /**
  26603. * Set the quaternion rotation of the bone in local or world space
  26604. * @param quat The quaternion rotation that the bone should be set to
  26605. * @param space The space that the rotation is in
  26606. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26607. */
  26608. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  26609. /**
  26610. * Set the rotation matrix of the bone in local or world space
  26611. * @param rotMat The rotation matrix that the bone should be set to
  26612. * @param space The space that the rotation is in
  26613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26614. */
  26615. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  26616. private _rotateWithMatrix;
  26617. private _getNegativeRotationToRef;
  26618. /**
  26619. * Get the position of the bone in local or world space
  26620. * @param space The space that the returned position is in
  26621. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26622. * @returns The position of the bone
  26623. */
  26624. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26625. /**
  26626. * Copy the position of the bone to a vector3 in local or world space
  26627. * @param space The space that the returned position is in
  26628. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26629. * @param result The vector3 to copy the position to
  26630. */
  26631. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  26632. /**
  26633. * Get the absolute position of the bone (world space)
  26634. * @param mesh The mesh that this bone is attached to
  26635. * @returns The absolute position of the bone
  26636. */
  26637. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  26638. /**
  26639. * Copy the absolute position of the bone (world space) to the result param
  26640. * @param mesh The mesh that this bone is attached to
  26641. * @param result The vector3 to copy the absolute position to
  26642. */
  26643. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  26644. /**
  26645. * Compute the absolute transforms of this bone and its children
  26646. */
  26647. computeAbsoluteTransforms(): void;
  26648. /**
  26649. * Get the world direction from an axis that is in the local space of the bone
  26650. * @param localAxis The local direction that is used to compute the world direction
  26651. * @param mesh The mesh that this bone is attached to
  26652. * @returns The world direction
  26653. */
  26654. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26655. /**
  26656. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  26657. * @param localAxis The local direction that is used to compute the world direction
  26658. * @param mesh The mesh that this bone is attached to
  26659. * @param result The vector3 that the world direction will be copied to
  26660. */
  26661. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26662. /**
  26663. * Get the euler rotation of the bone in local or world space
  26664. * @param space The space that the rotation should be in
  26665. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26666. * @returns The euler rotation
  26667. */
  26668. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26669. /**
  26670. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  26671. * @param space The space that the rotation should be in
  26672. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26673. * @param result The vector3 that the rotation should be copied to
  26674. */
  26675. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26676. /**
  26677. * Get the quaternion rotation of the bone in either local or world space
  26678. * @param space The space that the rotation should be in
  26679. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26680. * @returns The quaternion rotation
  26681. */
  26682. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  26683. /**
  26684. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  26685. * @param space The space that the rotation should be in
  26686. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26687. * @param result The quaternion that the rotation should be copied to
  26688. */
  26689. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  26690. /**
  26691. * Get the rotation matrix of the bone in local or world space
  26692. * @param space The space that the rotation should be in
  26693. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26694. * @returns The rotation matrix
  26695. */
  26696. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  26697. /**
  26698. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  26699. * @param space The space that the rotation should be in
  26700. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26701. * @param result The quaternion that the rotation should be copied to
  26702. */
  26703. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  26704. /**
  26705. * Get the world position of a point that is in the local space of the bone
  26706. * @param position The local position
  26707. * @param mesh The mesh that this bone is attached to
  26708. * @returns The world position
  26709. */
  26710. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26711. /**
  26712. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  26713. * @param position The local position
  26714. * @param mesh The mesh that this bone is attached to
  26715. * @param result The vector3 that the world position should be copied to
  26716. */
  26717. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26718. /**
  26719. * Get the local position of a point that is in world space
  26720. * @param position The world position
  26721. * @param mesh The mesh that this bone is attached to
  26722. * @returns The local position
  26723. */
  26724. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26725. /**
  26726. * Get the local position of a point that is in world space and copy it to the result param
  26727. * @param position The world position
  26728. * @param mesh The mesh that this bone is attached to
  26729. * @param result The vector3 that the local position should be copied to
  26730. */
  26731. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26732. /**
  26733. * Set the current local matrix as the restPose for this bone.
  26734. */
  26735. setCurrentPoseAsRest(): void;
  26736. }
  26737. }
  26738. declare module "babylonjs/Meshes/transformNode" {
  26739. import { DeepImmutable } from "babylonjs/types";
  26740. import { Observable } from "babylonjs/Misc/observable";
  26741. import { Nullable } from "babylonjs/types";
  26742. import { Camera } from "babylonjs/Cameras/camera";
  26743. import { Scene } from "babylonjs/scene";
  26744. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26745. import { Node } from "babylonjs/node";
  26746. import { Bone } from "babylonjs/Bones/bone";
  26747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26748. import { Space } from "babylonjs/Maths/math.axis";
  26749. /**
  26750. * 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.
  26751. * @see https://doc.babylonjs.com/how_to/transformnode
  26752. */
  26753. export class TransformNode extends Node {
  26754. /**
  26755. * Object will not rotate to face the camera
  26756. */
  26757. static BILLBOARDMODE_NONE: number;
  26758. /**
  26759. * Object will rotate to face the camera but only on the x axis
  26760. */
  26761. static BILLBOARDMODE_X: number;
  26762. /**
  26763. * Object will rotate to face the camera but only on the y axis
  26764. */
  26765. static BILLBOARDMODE_Y: number;
  26766. /**
  26767. * Object will rotate to face the camera but only on the z axis
  26768. */
  26769. static BILLBOARDMODE_Z: number;
  26770. /**
  26771. * Object will rotate to face the camera
  26772. */
  26773. static BILLBOARDMODE_ALL: number;
  26774. /**
  26775. * Object will rotate to face the camera's position instead of orientation
  26776. */
  26777. static BILLBOARDMODE_USE_POSITION: number;
  26778. private static _TmpRotation;
  26779. private static _TmpScaling;
  26780. private static _TmpTranslation;
  26781. private _forward;
  26782. private _forwardInverted;
  26783. private _up;
  26784. private _right;
  26785. private _rightInverted;
  26786. private _position;
  26787. private _rotation;
  26788. private _rotationQuaternion;
  26789. protected _scaling: Vector3;
  26790. protected _isDirty: boolean;
  26791. private _transformToBoneReferal;
  26792. private _isAbsoluteSynced;
  26793. private _billboardMode;
  26794. /**
  26795. * Gets or sets the billboard mode. Default is 0.
  26796. *
  26797. * | Value | Type | Description |
  26798. * | --- | --- | --- |
  26799. * | 0 | BILLBOARDMODE_NONE | |
  26800. * | 1 | BILLBOARDMODE_X | |
  26801. * | 2 | BILLBOARDMODE_Y | |
  26802. * | 4 | BILLBOARDMODE_Z | |
  26803. * | 7 | BILLBOARDMODE_ALL | |
  26804. *
  26805. */
  26806. get billboardMode(): number;
  26807. set billboardMode(value: number);
  26808. private _preserveParentRotationForBillboard;
  26809. /**
  26810. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  26811. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  26812. */
  26813. get preserveParentRotationForBillboard(): boolean;
  26814. set preserveParentRotationForBillboard(value: boolean);
  26815. /**
  26816. * 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
  26817. */
  26818. scalingDeterminant: number;
  26819. private _infiniteDistance;
  26820. /**
  26821. * Gets or sets the distance of the object to max, often used by skybox
  26822. */
  26823. get infiniteDistance(): boolean;
  26824. set infiniteDistance(value: boolean);
  26825. /**
  26826. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  26827. * By default the system will update normals to compensate
  26828. */
  26829. ignoreNonUniformScaling: boolean;
  26830. /**
  26831. * 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
  26832. */
  26833. reIntegrateRotationIntoRotationQuaternion: boolean;
  26834. /** @hidden */
  26835. _poseMatrix: Nullable<Matrix>;
  26836. /** @hidden */
  26837. _localMatrix: Matrix;
  26838. private _usePivotMatrix;
  26839. private _absolutePosition;
  26840. private _absoluteScaling;
  26841. private _absoluteRotationQuaternion;
  26842. private _pivotMatrix;
  26843. private _pivotMatrixInverse;
  26844. /** @hidden */
  26845. _postMultiplyPivotMatrix: boolean;
  26846. protected _isWorldMatrixFrozen: boolean;
  26847. /** @hidden */
  26848. _indexInSceneTransformNodesArray: number;
  26849. /**
  26850. * An event triggered after the world matrix is updated
  26851. */
  26852. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  26853. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  26854. /**
  26855. * Gets a string identifying the name of the class
  26856. * @returns "TransformNode" string
  26857. */
  26858. getClassName(): string;
  26859. /**
  26860. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  26861. */
  26862. get position(): Vector3;
  26863. set position(newPosition: Vector3);
  26864. /**
  26865. * 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)).
  26866. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  26867. */
  26868. get rotation(): Vector3;
  26869. set rotation(newRotation: Vector3);
  26870. /**
  26871. * 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)).
  26872. */
  26873. get scaling(): Vector3;
  26874. set scaling(newScaling: Vector3);
  26875. /**
  26876. * 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).
  26877. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  26878. */
  26879. get rotationQuaternion(): Nullable<Quaternion>;
  26880. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  26881. /**
  26882. * The forward direction of that transform in world space.
  26883. */
  26884. get forward(): Vector3;
  26885. /**
  26886. * The up direction of that transform in world space.
  26887. */
  26888. get up(): Vector3;
  26889. /**
  26890. * The right direction of that transform in world space.
  26891. */
  26892. get right(): Vector3;
  26893. /**
  26894. * Copies the parameter passed Matrix into the mesh Pose matrix.
  26895. * @param matrix the matrix to copy the pose from
  26896. * @returns this TransformNode.
  26897. */
  26898. updatePoseMatrix(matrix: Matrix): TransformNode;
  26899. /**
  26900. * Returns the mesh Pose matrix.
  26901. * @returns the pose matrix
  26902. */
  26903. getPoseMatrix(): Matrix;
  26904. /** @hidden */
  26905. _isSynchronized(): boolean;
  26906. /** @hidden */
  26907. _initCache(): void;
  26908. /**
  26909. * Flag the transform node as dirty (Forcing it to update everything)
  26910. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  26911. * @returns this transform node
  26912. */
  26913. markAsDirty(property: string): TransformNode;
  26914. /**
  26915. * Returns the current mesh absolute position.
  26916. * Returns a Vector3.
  26917. */
  26918. get absolutePosition(): Vector3;
  26919. /**
  26920. * Returns the current mesh absolute scaling.
  26921. * Returns a Vector3.
  26922. */
  26923. get absoluteScaling(): Vector3;
  26924. /**
  26925. * Returns the current mesh absolute rotation.
  26926. * Returns a Quaternion.
  26927. */
  26928. get absoluteRotationQuaternion(): Quaternion;
  26929. /**
  26930. * Sets a new matrix to apply before all other transformation
  26931. * @param matrix defines the transform matrix
  26932. * @returns the current TransformNode
  26933. */
  26934. setPreTransformMatrix(matrix: Matrix): TransformNode;
  26935. /**
  26936. * Sets a new pivot matrix to the current node
  26937. * @param matrix defines the new pivot matrix to use
  26938. * @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
  26939. * @returns the current TransformNode
  26940. */
  26941. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  26942. /**
  26943. * Returns the mesh pivot matrix.
  26944. * Default : Identity.
  26945. * @returns the matrix
  26946. */
  26947. getPivotMatrix(): Matrix;
  26948. /**
  26949. * Instantiate (when possible) or clone that node with its hierarchy
  26950. * @param newParent defines the new parent to use for the instance (or clone)
  26951. * @param options defines options to configure how copy is done
  26952. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  26953. * @returns an instance (or a clone) of the current node with its hiearchy
  26954. */
  26955. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  26956. doNotInstantiate: boolean;
  26957. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  26958. /**
  26959. * Prevents the World matrix to be computed any longer
  26960. * @param newWorldMatrix defines an optional matrix to use as world matrix
  26961. * @returns the TransformNode.
  26962. */
  26963. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  26964. /**
  26965. * Allows back the World matrix computation.
  26966. * @returns the TransformNode.
  26967. */
  26968. unfreezeWorldMatrix(): this;
  26969. /**
  26970. * True if the World matrix has been frozen.
  26971. */
  26972. get isWorldMatrixFrozen(): boolean;
  26973. /**
  26974. * Retuns the mesh absolute position in the World.
  26975. * @returns a Vector3.
  26976. */
  26977. getAbsolutePosition(): Vector3;
  26978. /**
  26979. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  26980. * @param absolutePosition the absolute position to set
  26981. * @returns the TransformNode.
  26982. */
  26983. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26984. /**
  26985. * Sets the mesh position in its local space.
  26986. * @param vector3 the position to set in localspace
  26987. * @returns the TransformNode.
  26988. */
  26989. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  26990. /**
  26991. * Returns the mesh position in the local space from the current World matrix values.
  26992. * @returns a new Vector3.
  26993. */
  26994. getPositionExpressedInLocalSpace(): Vector3;
  26995. /**
  26996. * Translates the mesh along the passed Vector3 in its local space.
  26997. * @param vector3 the distance to translate in localspace
  26998. * @returns the TransformNode.
  26999. */
  27000. locallyTranslate(vector3: Vector3): TransformNode;
  27001. private static _lookAtVectorCache;
  27002. /**
  27003. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  27004. * @param targetPoint the position (must be in same space as current mesh) to look at
  27005. * @param yawCor optional yaw (y-axis) correction in radians
  27006. * @param pitchCor optional pitch (x-axis) correction in radians
  27007. * @param rollCor optional roll (z-axis) correction in radians
  27008. * @param space the choosen space of the target
  27009. * @returns the TransformNode.
  27010. */
  27011. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  27012. /**
  27013. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27014. * This Vector3 is expressed in the World space.
  27015. * @param localAxis axis to rotate
  27016. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27017. */
  27018. getDirection(localAxis: Vector3): Vector3;
  27019. /**
  27020. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  27021. * localAxis is expressed in the mesh local space.
  27022. * result is computed in the Wordl space from the mesh World matrix.
  27023. * @param localAxis axis to rotate
  27024. * @param result the resulting transformnode
  27025. * @returns this TransformNode.
  27026. */
  27027. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  27028. /**
  27029. * Sets this transform node rotation to the given local axis.
  27030. * @param localAxis the axis in local space
  27031. * @param yawCor optional yaw (y-axis) correction in radians
  27032. * @param pitchCor optional pitch (x-axis) correction in radians
  27033. * @param rollCor optional roll (z-axis) correction in radians
  27034. * @returns this TransformNode
  27035. */
  27036. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  27037. /**
  27038. * Sets a new pivot point to the current node
  27039. * @param point defines the new pivot point to use
  27040. * @param space defines if the point is in world or local space (local by default)
  27041. * @returns the current TransformNode
  27042. */
  27043. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  27044. /**
  27045. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  27046. * @returns the pivot point
  27047. */
  27048. getPivotPoint(): Vector3;
  27049. /**
  27050. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  27051. * @param result the vector3 to store the result
  27052. * @returns this TransformNode.
  27053. */
  27054. getPivotPointToRef(result: Vector3): TransformNode;
  27055. /**
  27056. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  27057. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  27058. */
  27059. getAbsolutePivotPoint(): Vector3;
  27060. /**
  27061. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  27062. * @param result vector3 to store the result
  27063. * @returns this TransformNode.
  27064. */
  27065. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  27066. /**
  27067. * Defines the passed node as the parent of the current node.
  27068. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  27069. * @see https://doc.babylonjs.com/how_to/parenting
  27070. * @param node the node ot set as the parent
  27071. * @returns this TransformNode.
  27072. */
  27073. setParent(node: Nullable<Node>): TransformNode;
  27074. private _nonUniformScaling;
  27075. /**
  27076. * True if the scaling property of this object is non uniform eg. (1,2,1)
  27077. */
  27078. get nonUniformScaling(): boolean;
  27079. /** @hidden */
  27080. _updateNonUniformScalingState(value: boolean): boolean;
  27081. /**
  27082. * Attach the current TransformNode to another TransformNode associated with a bone
  27083. * @param bone Bone affecting the TransformNode
  27084. * @param affectedTransformNode TransformNode associated with the bone
  27085. * @returns this object
  27086. */
  27087. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  27088. /**
  27089. * Detach the transform node if its associated with a bone
  27090. * @returns this object
  27091. */
  27092. detachFromBone(): TransformNode;
  27093. private static _rotationAxisCache;
  27094. /**
  27095. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  27096. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27097. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27098. * The passed axis is also normalized.
  27099. * @param axis the axis to rotate around
  27100. * @param amount the amount to rotate in radians
  27101. * @param space Space to rotate in (Default: local)
  27102. * @returns the TransformNode.
  27103. */
  27104. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27105. /**
  27106. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  27107. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27108. * The passed axis is also normalized. .
  27109. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  27110. * @param point the point to rotate around
  27111. * @param axis the axis to rotate around
  27112. * @param amount the amount to rotate in radians
  27113. * @returns the TransformNode
  27114. */
  27115. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  27116. /**
  27117. * Translates the mesh along the axis vector for the passed distance in the given space.
  27118. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27119. * @param axis the axis to translate in
  27120. * @param distance the distance to translate
  27121. * @param space Space to rotate in (Default: local)
  27122. * @returns the TransformNode.
  27123. */
  27124. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27125. /**
  27126. * Adds a rotation step to the mesh current rotation.
  27127. * x, y, z are Euler angles expressed in radians.
  27128. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  27129. * This means this rotation is made in the mesh local space only.
  27130. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  27131. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  27132. * ```javascript
  27133. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  27134. * ```
  27135. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  27136. * 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.
  27137. * @param x Rotation to add
  27138. * @param y Rotation to add
  27139. * @param z Rotation to add
  27140. * @returns the TransformNode.
  27141. */
  27142. addRotation(x: number, y: number, z: number): TransformNode;
  27143. /**
  27144. * @hidden
  27145. */
  27146. protected _getEffectiveParent(): Nullable<Node>;
  27147. /**
  27148. * Computes the world matrix of the node
  27149. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27150. * @returns the world matrix
  27151. */
  27152. computeWorldMatrix(force?: boolean): Matrix;
  27153. /**
  27154. * Resets this nodeTransform's local matrix to Matrix.Identity().
  27155. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  27156. */
  27157. resetLocalMatrix(independentOfChildren?: boolean): void;
  27158. protected _afterComputeWorldMatrix(): void;
  27159. /**
  27160. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  27161. * @param func callback function to add
  27162. *
  27163. * @returns the TransformNode.
  27164. */
  27165. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27166. /**
  27167. * Removes a registered callback function.
  27168. * @param func callback function to remove
  27169. * @returns the TransformNode.
  27170. */
  27171. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27172. /**
  27173. * Gets the position of the current mesh in camera space
  27174. * @param camera defines the camera to use
  27175. * @returns a position
  27176. */
  27177. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  27178. /**
  27179. * Returns the distance from the mesh to the active camera
  27180. * @param camera defines the camera to use
  27181. * @returns the distance
  27182. */
  27183. getDistanceToCamera(camera?: Nullable<Camera>): number;
  27184. /**
  27185. * Clone the current transform node
  27186. * @param name Name of the new clone
  27187. * @param newParent New parent for the clone
  27188. * @param doNotCloneChildren Do not clone children hierarchy
  27189. * @returns the new transform node
  27190. */
  27191. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  27192. /**
  27193. * Serializes the objects information.
  27194. * @param currentSerializationObject defines the object to serialize in
  27195. * @returns the serialized object
  27196. */
  27197. serialize(currentSerializationObject?: any): any;
  27198. /**
  27199. * Returns a new TransformNode object parsed from the source provided.
  27200. * @param parsedTransformNode is the source.
  27201. * @param scene the scne the object belongs to
  27202. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  27203. * @returns a new TransformNode object parsed from the source provided.
  27204. */
  27205. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  27206. /**
  27207. * Get all child-transformNodes of this node
  27208. * @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
  27209. * @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
  27210. * @returns an array of TransformNode
  27211. */
  27212. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  27213. /**
  27214. * Releases resources associated with this transform node.
  27215. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27216. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27217. */
  27218. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27219. /**
  27220. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27221. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27222. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27223. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27224. * @returns the current mesh
  27225. */
  27226. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  27227. private _syncAbsoluteScalingAndRotation;
  27228. }
  27229. }
  27230. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  27231. import { Observable } from "babylonjs/Misc/observable";
  27232. import { Nullable } from "babylonjs/types";
  27233. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27234. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27236. import { Ray } from "babylonjs/Culling/ray";
  27237. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  27238. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  27239. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  27240. /**
  27241. * Defines the types of pose enabled controllers that are supported
  27242. */
  27243. export enum PoseEnabledControllerType {
  27244. /**
  27245. * HTC Vive
  27246. */
  27247. VIVE = 0,
  27248. /**
  27249. * Oculus Rift
  27250. */
  27251. OCULUS = 1,
  27252. /**
  27253. * Windows mixed reality
  27254. */
  27255. WINDOWS = 2,
  27256. /**
  27257. * Samsung gear VR
  27258. */
  27259. GEAR_VR = 3,
  27260. /**
  27261. * Google Daydream
  27262. */
  27263. DAYDREAM = 4,
  27264. /**
  27265. * Generic
  27266. */
  27267. GENERIC = 5
  27268. }
  27269. /**
  27270. * Defines the MutableGamepadButton interface for the state of a gamepad button
  27271. */
  27272. export interface MutableGamepadButton {
  27273. /**
  27274. * Value of the button/trigger
  27275. */
  27276. value: number;
  27277. /**
  27278. * If the button/trigger is currently touched
  27279. */
  27280. touched: boolean;
  27281. /**
  27282. * If the button/trigger is currently pressed
  27283. */
  27284. pressed: boolean;
  27285. }
  27286. /**
  27287. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  27288. * @hidden
  27289. */
  27290. export interface ExtendedGamepadButton extends GamepadButton {
  27291. /**
  27292. * If the button/trigger is currently pressed
  27293. */
  27294. readonly pressed: boolean;
  27295. /**
  27296. * If the button/trigger is currently touched
  27297. */
  27298. readonly touched: boolean;
  27299. /**
  27300. * Value of the button/trigger
  27301. */
  27302. readonly value: number;
  27303. }
  27304. /** @hidden */
  27305. export interface _GamePadFactory {
  27306. /**
  27307. * Returns whether or not the current gamepad can be created for this type of controller.
  27308. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27309. * @returns true if it can be created, otherwise false
  27310. */
  27311. canCreate(gamepadInfo: any): boolean;
  27312. /**
  27313. * Creates a new instance of the Gamepad.
  27314. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27315. * @returns the new gamepad instance
  27316. */
  27317. create(gamepadInfo: any): Gamepad;
  27318. }
  27319. /**
  27320. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27321. */
  27322. export class PoseEnabledControllerHelper {
  27323. /** @hidden */
  27324. static _ControllerFactories: _GamePadFactory[];
  27325. /** @hidden */
  27326. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  27327. /**
  27328. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27329. * @param vrGamepad the gamepad to initialized
  27330. * @returns a vr controller of the type the gamepad identified as
  27331. */
  27332. static InitiateController(vrGamepad: any): Gamepad;
  27333. }
  27334. /**
  27335. * Defines the PoseEnabledController object that contains state of a vr capable controller
  27336. */
  27337. export class PoseEnabledController extends Gamepad implements PoseControlled {
  27338. /**
  27339. * If the controller is used in a webXR session
  27340. */
  27341. isXR: boolean;
  27342. private _deviceRoomPosition;
  27343. private _deviceRoomRotationQuaternion;
  27344. /**
  27345. * The device position in babylon space
  27346. */
  27347. devicePosition: Vector3;
  27348. /**
  27349. * The device rotation in babylon space
  27350. */
  27351. deviceRotationQuaternion: Quaternion;
  27352. /**
  27353. * The scale factor of the device in babylon space
  27354. */
  27355. deviceScaleFactor: number;
  27356. /**
  27357. * (Likely devicePosition should be used instead) The device position in its room space
  27358. */
  27359. position: Vector3;
  27360. /**
  27361. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  27362. */
  27363. rotationQuaternion: Quaternion;
  27364. /**
  27365. * The type of controller (Eg. Windows mixed reality)
  27366. */
  27367. controllerType: PoseEnabledControllerType;
  27368. protected _calculatedPosition: Vector3;
  27369. private _calculatedRotation;
  27370. /**
  27371. * The raw pose from the device
  27372. */
  27373. rawPose: DevicePose;
  27374. private _trackPosition;
  27375. private _maxRotationDistFromHeadset;
  27376. private _draggedRoomRotation;
  27377. /**
  27378. * @hidden
  27379. */
  27380. _disableTrackPosition(fixedPosition: Vector3): void;
  27381. /**
  27382. * Internal, the mesh attached to the controller
  27383. * @hidden
  27384. */
  27385. _mesh: Nullable<AbstractMesh>;
  27386. private _poseControlledCamera;
  27387. private _leftHandSystemQuaternion;
  27388. /**
  27389. * Internal, matrix used to convert room space to babylon space
  27390. * @hidden
  27391. */
  27392. _deviceToWorld: Matrix;
  27393. /**
  27394. * Node to be used when casting a ray from the controller
  27395. * @hidden
  27396. */
  27397. _pointingPoseNode: Nullable<TransformNode>;
  27398. /**
  27399. * Name of the child mesh that can be used to cast a ray from the controller
  27400. */
  27401. static readonly POINTING_POSE: string;
  27402. /**
  27403. * Creates a new PoseEnabledController from a gamepad
  27404. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  27405. */
  27406. constructor(browserGamepad: any);
  27407. private _workingMatrix;
  27408. /**
  27409. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  27410. */
  27411. update(): void;
  27412. /**
  27413. * Updates only the pose device and mesh without doing any button event checking
  27414. */
  27415. protected _updatePoseAndMesh(): void;
  27416. /**
  27417. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  27418. * @param poseData raw pose fromthe device
  27419. */
  27420. updateFromDevice(poseData: DevicePose): void;
  27421. /**
  27422. * @hidden
  27423. */
  27424. _meshAttachedObservable: Observable<AbstractMesh>;
  27425. /**
  27426. * Attaches a mesh to the controller
  27427. * @param mesh the mesh to be attached
  27428. */
  27429. attachToMesh(mesh: AbstractMesh): void;
  27430. /**
  27431. * Attaches the controllers mesh to a camera
  27432. * @param camera the camera the mesh should be attached to
  27433. */
  27434. attachToPoseControlledCamera(camera: TargetCamera): void;
  27435. /**
  27436. * Disposes of the controller
  27437. */
  27438. dispose(): void;
  27439. /**
  27440. * The mesh that is attached to the controller
  27441. */
  27442. get mesh(): Nullable<AbstractMesh>;
  27443. /**
  27444. * Gets the ray of the controller in the direction the controller is pointing
  27445. * @param length the length the resulting ray should be
  27446. * @returns a ray in the direction the controller is pointing
  27447. */
  27448. getForwardRay(length?: number): Ray;
  27449. }
  27450. }
  27451. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  27452. import { Observable } from "babylonjs/Misc/observable";
  27453. import { Scene } from "babylonjs/scene";
  27454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27455. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  27456. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  27457. import { Nullable } from "babylonjs/types";
  27458. /**
  27459. * Defines the WebVRController object that represents controllers tracked in 3D space
  27460. */
  27461. export abstract class WebVRController extends PoseEnabledController {
  27462. /**
  27463. * Internal, the default controller model for the controller
  27464. */
  27465. protected _defaultModel: Nullable<AbstractMesh>;
  27466. /**
  27467. * Fired when the trigger state has changed
  27468. */
  27469. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27470. /**
  27471. * Fired when the main button state has changed
  27472. */
  27473. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27474. /**
  27475. * Fired when the secondary button state has changed
  27476. */
  27477. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27478. /**
  27479. * Fired when the pad state has changed
  27480. */
  27481. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  27482. /**
  27483. * Fired when controllers stick values have changed
  27484. */
  27485. onPadValuesChangedObservable: Observable<StickValues>;
  27486. /**
  27487. * Array of button availible on the controller
  27488. */
  27489. protected _buttons: Array<MutableGamepadButton>;
  27490. private _onButtonStateChange;
  27491. /**
  27492. * Fired when a controller button's state has changed
  27493. * @param callback the callback containing the button that was modified
  27494. */
  27495. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  27496. /**
  27497. * X and Y axis corresponding to the controllers joystick
  27498. */
  27499. pad: StickValues;
  27500. /**
  27501. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  27502. */
  27503. hand: string;
  27504. /**
  27505. * The default controller model for the controller
  27506. */
  27507. get defaultModel(): Nullable<AbstractMesh>;
  27508. /**
  27509. * Creates a new WebVRController from a gamepad
  27510. * @param vrGamepad the gamepad that the WebVRController should be created from
  27511. */
  27512. constructor(vrGamepad: any);
  27513. /**
  27514. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  27515. */
  27516. update(): void;
  27517. /**
  27518. * Function to be called when a button is modified
  27519. */
  27520. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27521. /**
  27522. * Loads a mesh and attaches it to the controller
  27523. * @param scene the scene the mesh should be added to
  27524. * @param meshLoaded callback for when the mesh has been loaded
  27525. */
  27526. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27527. private _setButtonValue;
  27528. private _changes;
  27529. private _checkChanges;
  27530. /**
  27531. * Disposes of th webVRCOntroller
  27532. */
  27533. dispose(): void;
  27534. }
  27535. }
  27536. declare module "babylonjs/Lights/hemisphericLight" {
  27537. import { Nullable } from "babylonjs/types";
  27538. import { Scene } from "babylonjs/scene";
  27539. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27540. import { Color3 } from "babylonjs/Maths/math.color";
  27541. import { Effect } from "babylonjs/Materials/effect";
  27542. import { Light } from "babylonjs/Lights/light";
  27543. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  27544. /**
  27545. * The HemisphericLight simulates the ambient environment light,
  27546. * so the passed direction is the light reflection direction, not the incoming direction.
  27547. */
  27548. export class HemisphericLight extends Light {
  27549. /**
  27550. * The groundColor is the light in the opposite direction to the one specified during creation.
  27551. * 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.
  27552. */
  27553. groundColor: Color3;
  27554. /**
  27555. * The light reflection direction, not the incoming direction.
  27556. */
  27557. direction: Vector3;
  27558. /**
  27559. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  27560. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  27561. * The HemisphericLight can't cast shadows.
  27562. * Documentation : https://doc.babylonjs.com/babylon101/lights
  27563. * @param name The friendly name of the light
  27564. * @param direction The direction of the light reflection
  27565. * @param scene The scene the light belongs to
  27566. */
  27567. constructor(name: string, direction: Vector3, scene: Scene);
  27568. protected _buildUniformLayout(): void;
  27569. /**
  27570. * Returns the string "HemisphericLight".
  27571. * @return The class name
  27572. */
  27573. getClassName(): string;
  27574. /**
  27575. * Sets the HemisphericLight direction towards the passed target (Vector3).
  27576. * Returns the updated direction.
  27577. * @param target The target the direction should point to
  27578. * @return The computed direction
  27579. */
  27580. setDirectionToTarget(target: Vector3): Vector3;
  27581. /**
  27582. * Returns the shadow generator associated to the light.
  27583. * @returns Always null for hemispheric lights because it does not support shadows.
  27584. */
  27585. getShadowGenerator(): Nullable<IShadowGenerator>;
  27586. /**
  27587. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  27588. * @param effect The effect to update
  27589. * @param lightIndex The index of the light in the effect to update
  27590. * @returns The hemispheric light
  27591. */
  27592. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  27593. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  27594. /**
  27595. * Computes the world matrix of the node
  27596. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27597. * @param useWasUpdatedFlag defines a reserved property
  27598. * @returns the world matrix
  27599. */
  27600. computeWorldMatrix(): Matrix;
  27601. /**
  27602. * Returns the integer 3.
  27603. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  27604. */
  27605. getTypeID(): number;
  27606. /**
  27607. * Prepares the list of defines specific to the light type.
  27608. * @param defines the list of defines
  27609. * @param lightIndex defines the index of the light for the effect
  27610. */
  27611. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  27612. }
  27613. }
  27614. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  27615. /** @hidden */
  27616. export var vrMultiviewToSingleviewPixelShader: {
  27617. name: string;
  27618. shader: string;
  27619. };
  27620. }
  27621. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  27622. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27623. import { Scene } from "babylonjs/scene";
  27624. /**
  27625. * Renders to multiple views with a single draw call
  27626. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  27627. */
  27628. export class MultiviewRenderTarget extends RenderTargetTexture {
  27629. /**
  27630. * Creates a multiview render target
  27631. * @param scene scene used with the render target
  27632. * @param size the size of the render target (used for each view)
  27633. */
  27634. constructor(scene: Scene, size?: number | {
  27635. width: number;
  27636. height: number;
  27637. } | {
  27638. ratio: number;
  27639. });
  27640. /**
  27641. * @hidden
  27642. * @param faceIndex the face index, if its a cube texture
  27643. */
  27644. _bindFrameBuffer(faceIndex?: number): void;
  27645. /**
  27646. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  27647. * @returns the view count
  27648. */
  27649. getViewCount(): number;
  27650. }
  27651. }
  27652. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  27653. import { Camera } from "babylonjs/Cameras/camera";
  27654. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27655. import { Nullable } from "babylonjs/types";
  27656. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27657. import { Matrix } from "babylonjs/Maths/math.vector";
  27658. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27659. module "babylonjs/Engines/engine" {
  27660. interface Engine {
  27661. /**
  27662. * Creates a new multiview render target
  27663. * @param width defines the width of the texture
  27664. * @param height defines the height of the texture
  27665. * @returns the created multiview texture
  27666. */
  27667. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  27668. /**
  27669. * Binds a multiview framebuffer to be drawn to
  27670. * @param multiviewTexture texture to bind
  27671. */
  27672. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  27673. }
  27674. }
  27675. module "babylonjs/Cameras/camera" {
  27676. interface Camera {
  27677. /**
  27678. * @hidden
  27679. * 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)
  27680. */
  27681. _useMultiviewToSingleView: boolean;
  27682. /**
  27683. * @hidden
  27684. * 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)
  27685. */
  27686. _multiviewTexture: Nullable<RenderTargetTexture>;
  27687. /**
  27688. * @hidden
  27689. * ensures the multiview texture of the camera exists and has the specified width/height
  27690. * @param width height to set on the multiview texture
  27691. * @param height width to set on the multiview texture
  27692. */
  27693. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  27694. }
  27695. }
  27696. module "babylonjs/scene" {
  27697. interface Scene {
  27698. /** @hidden */
  27699. _transformMatrixR: Matrix;
  27700. /** @hidden */
  27701. _multiviewSceneUbo: Nullable<UniformBuffer>;
  27702. /** @hidden */
  27703. _createMultiviewUbo(): void;
  27704. /** @hidden */
  27705. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  27706. /** @hidden */
  27707. _renderMultiviewToSingleView(camera: Camera): void;
  27708. }
  27709. }
  27710. }
  27711. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  27712. import { Camera } from "babylonjs/Cameras/camera";
  27713. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27714. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  27715. import "babylonjs/Engines/Extensions/engine.multiview";
  27716. /**
  27717. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  27718. * This will not be used for webXR as it supports displaying texture arrays directly
  27719. */
  27720. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  27721. /**
  27722. * Gets a string identifying the name of the class
  27723. * @returns "VRMultiviewToSingleviewPostProcess" string
  27724. */
  27725. getClassName(): string;
  27726. /**
  27727. * Initializes a VRMultiviewToSingleview
  27728. * @param name name of the post process
  27729. * @param camera camera to be applied to
  27730. * @param scaleFactor scaling factor to the size of the output texture
  27731. */
  27732. constructor(name: string, camera: Camera, scaleFactor: number);
  27733. }
  27734. }
  27735. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  27736. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  27737. import { Nullable } from "babylonjs/types";
  27738. import { Size } from "babylonjs/Maths/math.size";
  27739. import { Observable } from "babylonjs/Misc/observable";
  27740. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  27741. /**
  27742. * Interface used to define additional presentation attributes
  27743. */
  27744. export interface IVRPresentationAttributes {
  27745. /**
  27746. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  27747. */
  27748. highRefreshRate: boolean;
  27749. /**
  27750. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  27751. */
  27752. foveationLevel: number;
  27753. }
  27754. module "babylonjs/Engines/engine" {
  27755. interface Engine {
  27756. /** @hidden */
  27757. _vrDisplay: any;
  27758. /** @hidden */
  27759. _vrSupported: boolean;
  27760. /** @hidden */
  27761. _oldSize: Size;
  27762. /** @hidden */
  27763. _oldHardwareScaleFactor: number;
  27764. /** @hidden */
  27765. _vrExclusivePointerMode: boolean;
  27766. /** @hidden */
  27767. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  27768. /** @hidden */
  27769. _onVRDisplayPointerRestricted: () => void;
  27770. /** @hidden */
  27771. _onVRDisplayPointerUnrestricted: () => void;
  27772. /** @hidden */
  27773. _onVrDisplayConnect: Nullable<(display: any) => void>;
  27774. /** @hidden */
  27775. _onVrDisplayDisconnect: Nullable<() => void>;
  27776. /** @hidden */
  27777. _onVrDisplayPresentChange: Nullable<() => void>;
  27778. /**
  27779. * Observable signaled when VR display mode changes
  27780. */
  27781. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27782. /**
  27783. * Observable signaled when VR request present is complete
  27784. */
  27785. onVRRequestPresentComplete: Observable<boolean>;
  27786. /**
  27787. * Observable signaled when VR request present starts
  27788. */
  27789. onVRRequestPresentStart: Observable<Engine>;
  27790. /**
  27791. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27792. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27793. */
  27794. isInVRExclusivePointerMode: boolean;
  27795. /**
  27796. * Gets a boolean indicating if a webVR device was detected
  27797. * @returns true if a webVR device was detected
  27798. */
  27799. isVRDevicePresent(): boolean;
  27800. /**
  27801. * Gets the current webVR device
  27802. * @returns the current webVR device (or null)
  27803. */
  27804. getVRDevice(): any;
  27805. /**
  27806. * Initializes a webVR display and starts listening to display change events
  27807. * The onVRDisplayChangedObservable will be notified upon these changes
  27808. * @returns A promise containing a VRDisplay and if vr is supported
  27809. */
  27810. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27811. /** @hidden */
  27812. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  27813. /**
  27814. * Gets or sets the presentation attributes used to configure VR rendering
  27815. */
  27816. vrPresentationAttributes?: IVRPresentationAttributes;
  27817. /**
  27818. * Call this function to switch to webVR mode
  27819. * Will do nothing if webVR is not supported or if there is no webVR device
  27820. * @param options the webvr options provided to the camera. mainly used for multiview
  27821. * @see https://doc.babylonjs.com/how_to/webvr_camera
  27822. */
  27823. enableVR(options: WebVROptions): void;
  27824. /** @hidden */
  27825. _onVRFullScreenTriggered(): void;
  27826. }
  27827. }
  27828. }
  27829. declare module "babylonjs/Cameras/VR/webVRCamera" {
  27830. import { Nullable } from "babylonjs/types";
  27831. import { Observable } from "babylonjs/Misc/observable";
  27832. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  27833. import { Scene } from "babylonjs/scene";
  27834. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27835. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  27836. import { Node } from "babylonjs/node";
  27837. import { Ray } from "babylonjs/Culling/ray";
  27838. import "babylonjs/Cameras/RigModes/webVRRigMode";
  27839. import "babylonjs/Engines/Extensions/engine.webVR";
  27840. /**
  27841. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  27842. * IMPORTANT!! The data is right-hand data.
  27843. * @export
  27844. * @interface DevicePose
  27845. */
  27846. export interface DevicePose {
  27847. /**
  27848. * The position of the device, values in array are [x,y,z].
  27849. */
  27850. readonly position: Nullable<Float32Array>;
  27851. /**
  27852. * The linearVelocity of the device, values in array are [x,y,z].
  27853. */
  27854. readonly linearVelocity: Nullable<Float32Array>;
  27855. /**
  27856. * The linearAcceleration of the device, values in array are [x,y,z].
  27857. */
  27858. readonly linearAcceleration: Nullable<Float32Array>;
  27859. /**
  27860. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  27861. */
  27862. readonly orientation: Nullable<Float32Array>;
  27863. /**
  27864. * The angularVelocity of the device, values in array are [x,y,z].
  27865. */
  27866. readonly angularVelocity: Nullable<Float32Array>;
  27867. /**
  27868. * The angularAcceleration of the device, values in array are [x,y,z].
  27869. */
  27870. readonly angularAcceleration: Nullable<Float32Array>;
  27871. }
  27872. /**
  27873. * Interface representing a pose controlled object in Babylon.
  27874. * A pose controlled object has both regular pose values as well as pose values
  27875. * from an external device such as a VR head mounted display
  27876. */
  27877. export interface PoseControlled {
  27878. /**
  27879. * The position of the object in babylon space.
  27880. */
  27881. position: Vector3;
  27882. /**
  27883. * The rotation quaternion of the object in babylon space.
  27884. */
  27885. rotationQuaternion: Quaternion;
  27886. /**
  27887. * The position of the device in babylon space.
  27888. */
  27889. devicePosition?: Vector3;
  27890. /**
  27891. * The rotation quaternion of the device in babylon space.
  27892. */
  27893. deviceRotationQuaternion: Quaternion;
  27894. /**
  27895. * The raw pose coming from the device.
  27896. */
  27897. rawPose: Nullable<DevicePose>;
  27898. /**
  27899. * The scale of the device to be used when translating from device space to babylon space.
  27900. */
  27901. deviceScaleFactor: number;
  27902. /**
  27903. * Updates the poseControlled values based on the input device pose.
  27904. * @param poseData the pose data to update the object with
  27905. */
  27906. updateFromDevice(poseData: DevicePose): void;
  27907. }
  27908. /**
  27909. * Set of options to customize the webVRCamera
  27910. */
  27911. export interface WebVROptions {
  27912. /**
  27913. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  27914. */
  27915. trackPosition?: boolean;
  27916. /**
  27917. * Sets the scale of the vrDevice in babylon space. (default: 1)
  27918. */
  27919. positionScale?: number;
  27920. /**
  27921. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  27922. */
  27923. displayName?: string;
  27924. /**
  27925. * Should the native controller meshes be initialized. (default: true)
  27926. */
  27927. controllerMeshes?: boolean;
  27928. /**
  27929. * Creating a default HemiLight only on controllers. (default: true)
  27930. */
  27931. defaultLightingOnControllers?: boolean;
  27932. /**
  27933. * If you don't want to use the default VR button of the helper. (default: false)
  27934. */
  27935. useCustomVRButton?: boolean;
  27936. /**
  27937. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  27938. */
  27939. customVRButton?: HTMLButtonElement;
  27940. /**
  27941. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  27942. */
  27943. rayLength?: number;
  27944. /**
  27945. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  27946. */
  27947. defaultHeight?: number;
  27948. /**
  27949. * If multiview should be used if availible (default: false)
  27950. */
  27951. useMultiview?: boolean;
  27952. }
  27953. /**
  27954. * This represents a WebVR camera.
  27955. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  27956. * @example https://doc.babylonjs.com/how_to/webvr_camera
  27957. */
  27958. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  27959. private webVROptions;
  27960. /**
  27961. * @hidden
  27962. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  27963. */
  27964. _vrDevice: any;
  27965. /**
  27966. * The rawPose of the vrDevice.
  27967. */
  27968. rawPose: Nullable<DevicePose>;
  27969. private _onVREnabled;
  27970. private _specsVersion;
  27971. private _attached;
  27972. private _frameData;
  27973. protected _descendants: Array<Node>;
  27974. private _deviceRoomPosition;
  27975. /** @hidden */
  27976. _deviceRoomRotationQuaternion: Quaternion;
  27977. private _standingMatrix;
  27978. /**
  27979. * Represents device position in babylon space.
  27980. */
  27981. devicePosition: Vector3;
  27982. /**
  27983. * Represents device rotation in babylon space.
  27984. */
  27985. deviceRotationQuaternion: Quaternion;
  27986. /**
  27987. * The scale of the device to be used when translating from device space to babylon space.
  27988. */
  27989. deviceScaleFactor: number;
  27990. private _deviceToWorld;
  27991. private _worldToDevice;
  27992. /**
  27993. * References to the webVR controllers for the vrDevice.
  27994. */
  27995. controllers: Array<WebVRController>;
  27996. /**
  27997. * Emits an event when a controller is attached.
  27998. */
  27999. onControllersAttachedObservable: Observable<WebVRController[]>;
  28000. /**
  28001. * Emits an event when a controller's mesh has been loaded;
  28002. */
  28003. onControllerMeshLoadedObservable: Observable<WebVRController>;
  28004. /**
  28005. * Emits an event when the HMD's pose has been updated.
  28006. */
  28007. onPoseUpdatedFromDeviceObservable: Observable<any>;
  28008. private _poseSet;
  28009. /**
  28010. * If the rig cameras be used as parent instead of this camera.
  28011. */
  28012. rigParenting: boolean;
  28013. private _lightOnControllers;
  28014. private _defaultHeight?;
  28015. /**
  28016. * Instantiates a WebVRFreeCamera.
  28017. * @param name The name of the WebVRFreeCamera
  28018. * @param position The starting anchor position for the camera
  28019. * @param scene The scene the camera belongs to
  28020. * @param webVROptions a set of customizable options for the webVRCamera
  28021. */
  28022. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  28023. /**
  28024. * Gets the device distance from the ground in meters.
  28025. * @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.
  28026. */
  28027. deviceDistanceToRoomGround(): number;
  28028. /**
  28029. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28030. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  28031. */
  28032. useStandingMatrix(callback?: (bool: boolean) => void): void;
  28033. /**
  28034. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28035. * @returns A promise with a boolean set to if the standing matrix is supported.
  28036. */
  28037. useStandingMatrixAsync(): Promise<boolean>;
  28038. /**
  28039. * Disposes the camera
  28040. */
  28041. dispose(): void;
  28042. /**
  28043. * Gets a vrController by name.
  28044. * @param name The name of the controller to retreive
  28045. * @returns the controller matching the name specified or null if not found
  28046. */
  28047. getControllerByName(name: string): Nullable<WebVRController>;
  28048. private _leftController;
  28049. /**
  28050. * The controller corresponding to the users left hand.
  28051. */
  28052. get leftController(): Nullable<WebVRController>;
  28053. private _rightController;
  28054. /**
  28055. * The controller corresponding to the users right hand.
  28056. */
  28057. get rightController(): Nullable<WebVRController>;
  28058. /**
  28059. * Casts a ray forward from the vrCamera's gaze.
  28060. * @param length Length of the ray (default: 100)
  28061. * @returns the ray corresponding to the gaze
  28062. */
  28063. getForwardRay(length?: number): Ray;
  28064. /**
  28065. * @hidden
  28066. * Updates the camera based on device's frame data
  28067. */
  28068. _checkInputs(): void;
  28069. /**
  28070. * Updates the poseControlled values based on the input device pose.
  28071. * @param poseData Pose coming from the device
  28072. */
  28073. updateFromDevice(poseData: DevicePose): void;
  28074. private _detachIfAttached;
  28075. /**
  28076. * WebVR's attach control will start broadcasting frames to the device.
  28077. * Note that in certain browsers (chrome for example) this function must be called
  28078. * within a user-interaction callback. Example:
  28079. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  28080. *
  28081. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  28082. */
  28083. attachControl(noPreventDefault?: boolean): void;
  28084. /**
  28085. * Detach the current controls from the specified dom element.
  28086. */
  28087. detachControl(): void;
  28088. /**
  28089. * @returns the name of this class
  28090. */
  28091. getClassName(): string;
  28092. /**
  28093. * Calls resetPose on the vrDisplay
  28094. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  28095. */
  28096. resetToCurrentRotation(): void;
  28097. /**
  28098. * @hidden
  28099. * Updates the rig cameras (left and right eye)
  28100. */
  28101. _updateRigCameras(): void;
  28102. private _workingVector;
  28103. private _oneVector;
  28104. private _workingMatrix;
  28105. private updateCacheCalled;
  28106. private _correctPositionIfNotTrackPosition;
  28107. /**
  28108. * @hidden
  28109. * Updates the cached values of the camera
  28110. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  28111. */
  28112. _updateCache(ignoreParentClass?: boolean): void;
  28113. /**
  28114. * @hidden
  28115. * Get current device position in babylon world
  28116. */
  28117. _computeDevicePosition(): void;
  28118. /**
  28119. * Updates the current device position and rotation in the babylon world
  28120. */
  28121. update(): void;
  28122. /**
  28123. * @hidden
  28124. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  28125. * @returns an identity matrix
  28126. */
  28127. _getViewMatrix(): Matrix;
  28128. private _tmpMatrix;
  28129. /**
  28130. * This function is called by the two RIG cameras.
  28131. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  28132. * @hidden
  28133. */
  28134. _getWebVRViewMatrix(): Matrix;
  28135. /** @hidden */
  28136. _getWebVRProjectionMatrix(): Matrix;
  28137. private _onGamepadConnectedObserver;
  28138. private _onGamepadDisconnectedObserver;
  28139. private _updateCacheWhenTrackingDisabledObserver;
  28140. /**
  28141. * Initializes the controllers and their meshes
  28142. */
  28143. initControllers(): void;
  28144. }
  28145. }
  28146. declare module "babylonjs/Materials/materialHelper" {
  28147. import { Nullable } from "babylonjs/types";
  28148. import { Scene } from "babylonjs/scene";
  28149. import { Engine } from "babylonjs/Engines/engine";
  28150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28151. import { Light } from "babylonjs/Lights/light";
  28152. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  28153. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  28154. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  28155. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28156. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  28157. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  28158. /**
  28159. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  28160. *
  28161. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  28162. *
  28163. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  28164. */
  28165. export class MaterialHelper {
  28166. /**
  28167. * Bind the current view position to an effect.
  28168. * @param effect The effect to be bound
  28169. * @param scene The scene the eyes position is used from
  28170. * @param variableName name of the shader variable that will hold the eye position
  28171. */
  28172. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  28173. /**
  28174. * Helps preparing the defines values about the UVs in used in the effect.
  28175. * UVs are shared as much as we can accross channels in the shaders.
  28176. * @param texture The texture we are preparing the UVs for
  28177. * @param defines The defines to update
  28178. * @param key The channel key "diffuse", "specular"... used in the shader
  28179. */
  28180. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  28181. /**
  28182. * Binds a texture matrix value to its corrsponding uniform
  28183. * @param texture The texture to bind the matrix for
  28184. * @param uniformBuffer The uniform buffer receivin the data
  28185. * @param key The channel key "diffuse", "specular"... used in the shader
  28186. */
  28187. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  28188. /**
  28189. * Gets the current status of the fog (should it be enabled?)
  28190. * @param mesh defines the mesh to evaluate for fog support
  28191. * @param scene defines the hosting scene
  28192. * @returns true if fog must be enabled
  28193. */
  28194. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  28195. /**
  28196. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  28197. * @param mesh defines the current mesh
  28198. * @param scene defines the current scene
  28199. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  28200. * @param pointsCloud defines if point cloud rendering has to be turned on
  28201. * @param fogEnabled defines if fog has to be turned on
  28202. * @param alphaTest defines if alpha testing has to be turned on
  28203. * @param defines defines the current list of defines
  28204. */
  28205. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  28206. /**
  28207. * Helper used to prepare the list of defines associated with frame values for shader compilation
  28208. * @param scene defines the current scene
  28209. * @param engine defines the current engine
  28210. * @param defines specifies the list of active defines
  28211. * @param useInstances defines if instances have to be turned on
  28212. * @param useClipPlane defines if clip plane have to be turned on
  28213. * @param useInstances defines if instances have to be turned on
  28214. * @param useThinInstances defines if thin instances have to be turned on
  28215. */
  28216. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  28217. /**
  28218. * Prepares the defines for bones
  28219. * @param mesh The mesh containing the geometry data we will draw
  28220. * @param defines The defines to update
  28221. */
  28222. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  28223. /**
  28224. * Prepares the defines for morph targets
  28225. * @param mesh The mesh containing the geometry data we will draw
  28226. * @param defines The defines to update
  28227. */
  28228. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  28229. /**
  28230. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  28231. * @param mesh The mesh containing the geometry data we will draw
  28232. * @param defines The defines to update
  28233. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  28234. * @param useBones Precise whether bones should be used or not (override mesh info)
  28235. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  28236. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  28237. * @returns false if defines are considered not dirty and have not been checked
  28238. */
  28239. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  28240. /**
  28241. * Prepares the defines related to multiview
  28242. * @param scene The scene we are intending to draw
  28243. * @param defines The defines to update
  28244. */
  28245. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  28246. /**
  28247. * Prepares the defines related to the prepass
  28248. * @param scene The scene we are intending to draw
  28249. * @param defines The defines to update
  28250. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  28251. */
  28252. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  28253. /**
  28254. * Prepares the defines related to the light information passed in parameter
  28255. * @param scene The scene we are intending to draw
  28256. * @param mesh The mesh the effect is compiling for
  28257. * @param light The light the effect is compiling for
  28258. * @param lightIndex The index of the light
  28259. * @param defines The defines to update
  28260. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28261. * @param state Defines the current state regarding what is needed (normals, etc...)
  28262. */
  28263. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  28264. needNormals: boolean;
  28265. needRebuild: boolean;
  28266. shadowEnabled: boolean;
  28267. specularEnabled: boolean;
  28268. lightmapMode: boolean;
  28269. }): void;
  28270. /**
  28271. * Prepares the defines related to the light information passed in parameter
  28272. * @param scene The scene we are intending to draw
  28273. * @param mesh The mesh the effect is compiling for
  28274. * @param defines The defines to update
  28275. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28276. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  28277. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  28278. * @returns true if normals will be required for the rest of the effect
  28279. */
  28280. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  28281. /**
  28282. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  28283. * @param lightIndex defines the light index
  28284. * @param uniformsList The uniform list
  28285. * @param samplersList The sampler list
  28286. * @param projectedLightTexture defines if projected texture must be used
  28287. * @param uniformBuffersList defines an optional list of uniform buffers
  28288. */
  28289. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  28290. /**
  28291. * Prepares the uniforms and samplers list to be used in the effect
  28292. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  28293. * @param samplersList The sampler list
  28294. * @param defines The defines helping in the list generation
  28295. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  28296. */
  28297. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  28298. /**
  28299. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  28300. * @param defines The defines to update while falling back
  28301. * @param fallbacks The authorized effect fallbacks
  28302. * @param maxSimultaneousLights The maximum number of lights allowed
  28303. * @param rank the current rank of the Effect
  28304. * @returns The newly affected rank
  28305. */
  28306. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  28307. private static _TmpMorphInfluencers;
  28308. /**
  28309. * Prepares the list of attributes required for morph targets according to the effect defines.
  28310. * @param attribs The current list of supported attribs
  28311. * @param mesh The mesh to prepare the morph targets attributes for
  28312. * @param influencers The number of influencers
  28313. */
  28314. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  28315. /**
  28316. * Prepares the list of attributes required for morph targets according to the effect defines.
  28317. * @param attribs The current list of supported attribs
  28318. * @param mesh The mesh to prepare the morph targets attributes for
  28319. * @param defines The current Defines of the effect
  28320. */
  28321. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  28322. /**
  28323. * Prepares the list of attributes required for bones according to the effect defines.
  28324. * @param attribs The current list of supported attribs
  28325. * @param mesh The mesh to prepare the bones attributes for
  28326. * @param defines The current Defines of the effect
  28327. * @param fallbacks The current efffect fallback strategy
  28328. */
  28329. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  28330. /**
  28331. * Check and prepare the list of attributes required for instances according to the effect defines.
  28332. * @param attribs The current list of supported attribs
  28333. * @param defines The current MaterialDefines of the effect
  28334. */
  28335. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  28336. /**
  28337. * Add the list of attributes required for instances to the attribs array.
  28338. * @param attribs The current list of supported attribs
  28339. */
  28340. static PushAttributesForInstances(attribs: string[]): void;
  28341. /**
  28342. * Binds the light information to the effect.
  28343. * @param light The light containing the generator
  28344. * @param effect The effect we are binding the data to
  28345. * @param lightIndex The light index in the effect used to render
  28346. */
  28347. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  28348. /**
  28349. * Binds the lights information from the scene to the effect for the given mesh.
  28350. * @param light Light to bind
  28351. * @param lightIndex Light index
  28352. * @param scene The scene where the light belongs to
  28353. * @param effect The effect we are binding the data to
  28354. * @param useSpecular Defines if specular is supported
  28355. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28356. */
  28357. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  28358. /**
  28359. * Binds the lights information from the scene to the effect for the given mesh.
  28360. * @param scene The scene the lights belongs to
  28361. * @param mesh The mesh we are binding the information to render
  28362. * @param effect The effect we are binding the data to
  28363. * @param defines The generated defines for the effect
  28364. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  28365. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28366. */
  28367. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  28368. private static _tempFogColor;
  28369. /**
  28370. * Binds the fog information from the scene to the effect for the given mesh.
  28371. * @param scene The scene the lights belongs to
  28372. * @param mesh The mesh we are binding the information to render
  28373. * @param effect The effect we are binding the data to
  28374. * @param linearSpace Defines if the fog effect is applied in linear space
  28375. */
  28376. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  28377. /**
  28378. * Binds the bones information from the mesh to the effect.
  28379. * @param mesh The mesh we are binding the information to render
  28380. * @param effect The effect we are binding the data to
  28381. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  28382. */
  28383. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  28384. private static _CopyBonesTransformationMatrices;
  28385. /**
  28386. * Binds the morph targets information from the mesh to the effect.
  28387. * @param abstractMesh The mesh we are binding the information to render
  28388. * @param effect The effect we are binding the data to
  28389. */
  28390. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  28391. /**
  28392. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  28393. * @param defines The generated defines used in the effect
  28394. * @param effect The effect we are binding the data to
  28395. * @param scene The scene we are willing to render with logarithmic scale for
  28396. */
  28397. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  28398. /**
  28399. * Binds the clip plane information from the scene to the effect.
  28400. * @param scene The scene the clip plane information are extracted from
  28401. * @param effect The effect we are binding the data to
  28402. */
  28403. static BindClipPlane(effect: Effect, scene: Scene): void;
  28404. }
  28405. }
  28406. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  28407. /** @hidden */
  28408. export var bayerDitherFunctions: {
  28409. name: string;
  28410. shader: string;
  28411. };
  28412. }
  28413. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  28414. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  28415. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  28416. /** @hidden */
  28417. export var shadowMapFragmentDeclaration: {
  28418. name: string;
  28419. shader: string;
  28420. };
  28421. }
  28422. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  28423. /** @hidden */
  28424. export var shadowMapFragment: {
  28425. name: string;
  28426. shader: string;
  28427. };
  28428. }
  28429. declare module "babylonjs/Shaders/shadowMap.fragment" {
  28430. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  28431. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  28432. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  28433. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  28434. /** @hidden */
  28435. export var shadowMapPixelShader: {
  28436. name: string;
  28437. shader: string;
  28438. };
  28439. }
  28440. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  28441. /** @hidden */
  28442. export var shadowMapVertexDeclaration: {
  28443. name: string;
  28444. shader: string;
  28445. };
  28446. }
  28447. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  28448. /** @hidden */
  28449. export var shadowMapVertexNormalBias: {
  28450. name: string;
  28451. shader: string;
  28452. };
  28453. }
  28454. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  28455. /** @hidden */
  28456. export var shadowMapVertexMetric: {
  28457. name: string;
  28458. shader: string;
  28459. };
  28460. }
  28461. declare module "babylonjs/Shaders/shadowMap.vertex" {
  28462. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  28463. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  28464. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  28465. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  28466. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  28467. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  28468. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  28469. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  28470. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  28471. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  28472. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  28473. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  28474. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  28475. /** @hidden */
  28476. export var shadowMapVertexShader: {
  28477. name: string;
  28478. shader: string;
  28479. };
  28480. }
  28481. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  28482. /** @hidden */
  28483. export var depthBoxBlurPixelShader: {
  28484. name: string;
  28485. shader: string;
  28486. };
  28487. }
  28488. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  28489. /** @hidden */
  28490. export var shadowMapFragmentSoftTransparentShadow: {
  28491. name: string;
  28492. shader: string;
  28493. };
  28494. }
  28495. declare module "babylonjs/Meshes/instancedMesh" {
  28496. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28497. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  28498. import { Camera } from "babylonjs/Cameras/camera";
  28499. import { Node } from "babylonjs/node";
  28500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28501. import { Mesh } from "babylonjs/Meshes/mesh";
  28502. import { Material } from "babylonjs/Materials/material";
  28503. import { Skeleton } from "babylonjs/Bones/skeleton";
  28504. import { Light } from "babylonjs/Lights/light";
  28505. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28506. /**
  28507. * Creates an instance based on a source mesh.
  28508. */
  28509. export class InstancedMesh extends AbstractMesh {
  28510. private _sourceMesh;
  28511. private _currentLOD;
  28512. /** @hidden */
  28513. _indexInSourceMeshInstanceArray: number;
  28514. constructor(name: string, source: Mesh);
  28515. /**
  28516. * Returns the string "InstancedMesh".
  28517. */
  28518. getClassName(): string;
  28519. /** Gets the list of lights affecting that mesh */
  28520. get lightSources(): Light[];
  28521. _resyncLightSources(): void;
  28522. _resyncLightSource(light: Light): void;
  28523. _removeLightSource(light: Light, dispose: boolean): void;
  28524. /**
  28525. * If the source mesh receives shadows
  28526. */
  28527. get receiveShadows(): boolean;
  28528. /**
  28529. * The material of the source mesh
  28530. */
  28531. get material(): Nullable<Material>;
  28532. /**
  28533. * Visibility of the source mesh
  28534. */
  28535. get visibility(): number;
  28536. /**
  28537. * Skeleton of the source mesh
  28538. */
  28539. get skeleton(): Nullable<Skeleton>;
  28540. /**
  28541. * Rendering ground id of the source mesh
  28542. */
  28543. get renderingGroupId(): number;
  28544. set renderingGroupId(value: number);
  28545. /**
  28546. * Returns the total number of vertices (integer).
  28547. */
  28548. getTotalVertices(): number;
  28549. /**
  28550. * Returns a positive integer : the total number of indices in this mesh geometry.
  28551. * @returns the numner of indices or zero if the mesh has no geometry.
  28552. */
  28553. getTotalIndices(): number;
  28554. /**
  28555. * The source mesh of the instance
  28556. */
  28557. get sourceMesh(): Mesh;
  28558. /**
  28559. * Creates a new InstancedMesh object from the mesh model.
  28560. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28561. * @param name defines the name of the new instance
  28562. * @returns a new InstancedMesh
  28563. */
  28564. createInstance(name: string): InstancedMesh;
  28565. /**
  28566. * Is this node ready to be used/rendered
  28567. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28568. * @return {boolean} is it ready
  28569. */
  28570. isReady(completeCheck?: boolean): boolean;
  28571. /**
  28572. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28573. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  28574. * @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.
  28575. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  28576. */
  28577. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  28578. /**
  28579. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28580. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28581. * The `data` are either a numeric array either a Float32Array.
  28582. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  28583. * 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).
  28584. * Note that a new underlying VertexBuffer object is created each call.
  28585. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28586. *
  28587. * Possible `kind` values :
  28588. * - VertexBuffer.PositionKind
  28589. * - VertexBuffer.UVKind
  28590. * - VertexBuffer.UV2Kind
  28591. * - VertexBuffer.UV3Kind
  28592. * - VertexBuffer.UV4Kind
  28593. * - VertexBuffer.UV5Kind
  28594. * - VertexBuffer.UV6Kind
  28595. * - VertexBuffer.ColorKind
  28596. * - VertexBuffer.MatricesIndicesKind
  28597. * - VertexBuffer.MatricesIndicesExtraKind
  28598. * - VertexBuffer.MatricesWeightsKind
  28599. * - VertexBuffer.MatricesWeightsExtraKind
  28600. *
  28601. * Returns the Mesh.
  28602. */
  28603. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28604. /**
  28605. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28606. * If the mesh has no geometry, it is simply returned as it is.
  28607. * The `data` are either a numeric array either a Float32Array.
  28608. * No new underlying VertexBuffer object is created.
  28609. * 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.
  28610. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  28611. *
  28612. * Possible `kind` values :
  28613. * - VertexBuffer.PositionKind
  28614. * - VertexBuffer.UVKind
  28615. * - VertexBuffer.UV2Kind
  28616. * - VertexBuffer.UV3Kind
  28617. * - VertexBuffer.UV4Kind
  28618. * - VertexBuffer.UV5Kind
  28619. * - VertexBuffer.UV6Kind
  28620. * - VertexBuffer.ColorKind
  28621. * - VertexBuffer.MatricesIndicesKind
  28622. * - VertexBuffer.MatricesIndicesExtraKind
  28623. * - VertexBuffer.MatricesWeightsKind
  28624. * - VertexBuffer.MatricesWeightsExtraKind
  28625. *
  28626. * Returns the Mesh.
  28627. */
  28628. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  28629. /**
  28630. * Sets the mesh indices.
  28631. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  28632. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28633. * This method creates a new index buffer each call.
  28634. * Returns the Mesh.
  28635. */
  28636. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  28637. /**
  28638. * Boolean : True if the mesh owns the requested kind of data.
  28639. */
  28640. isVerticesDataPresent(kind: string): boolean;
  28641. /**
  28642. * Returns an array of indices (IndicesArray).
  28643. */
  28644. getIndices(): Nullable<IndicesArray>;
  28645. get _positions(): Nullable<Vector3[]>;
  28646. /**
  28647. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28648. * This means the mesh underlying bounding box and sphere are recomputed.
  28649. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28650. * @returns the current mesh
  28651. */
  28652. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  28653. /** @hidden */
  28654. _preActivate(): InstancedMesh;
  28655. /** @hidden */
  28656. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28657. /** @hidden */
  28658. _postActivate(): void;
  28659. getWorldMatrix(): Matrix;
  28660. get isAnInstance(): boolean;
  28661. /**
  28662. * Returns the current associated LOD AbstractMesh.
  28663. */
  28664. getLOD(camera: Camera): AbstractMesh;
  28665. /** @hidden */
  28666. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28667. /** @hidden */
  28668. _syncSubMeshes(): InstancedMesh;
  28669. /** @hidden */
  28670. _generatePointsArray(): boolean;
  28671. /** @hidden */
  28672. _updateBoundingInfo(): AbstractMesh;
  28673. /**
  28674. * Creates a new InstancedMesh from the current mesh.
  28675. * - name (string) : the cloned mesh name
  28676. * - newParent (optional Node) : the optional Node to parent the clone to.
  28677. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  28678. *
  28679. * Returns the clone.
  28680. */
  28681. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  28682. /**
  28683. * Disposes the InstancedMesh.
  28684. * Returns nothing.
  28685. */
  28686. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28687. }
  28688. module "babylonjs/Meshes/mesh" {
  28689. interface Mesh {
  28690. /**
  28691. * Register a custom buffer that will be instanced
  28692. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28693. * @param kind defines the buffer kind
  28694. * @param stride defines the stride in floats
  28695. */
  28696. registerInstancedBuffer(kind: string, stride: number): void;
  28697. /**
  28698. * true to use the edge renderer for all instances of this mesh
  28699. */
  28700. edgesShareWithInstances: boolean;
  28701. /** @hidden */
  28702. _userInstancedBuffersStorage: {
  28703. data: {
  28704. [key: string]: Float32Array;
  28705. };
  28706. sizes: {
  28707. [key: string]: number;
  28708. };
  28709. vertexBuffers: {
  28710. [key: string]: Nullable<VertexBuffer>;
  28711. };
  28712. strides: {
  28713. [key: string]: number;
  28714. };
  28715. };
  28716. }
  28717. }
  28718. module "babylonjs/Meshes/abstractMesh" {
  28719. interface AbstractMesh {
  28720. /**
  28721. * Object used to store instanced buffers defined by user
  28722. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28723. */
  28724. instancedBuffers: {
  28725. [key: string]: any;
  28726. };
  28727. }
  28728. }
  28729. }
  28730. declare module "babylonjs/Materials/shaderMaterial" {
  28731. import { Nullable } from "babylonjs/types";
  28732. import { Scene } from "babylonjs/scene";
  28733. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28735. import { Mesh } from "babylonjs/Meshes/mesh";
  28736. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28737. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28738. import { Effect } from "babylonjs/Materials/effect";
  28739. import { Material } from "babylonjs/Materials/material";
  28740. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28741. /**
  28742. * Defines the options associated with the creation of a shader material.
  28743. */
  28744. export interface IShaderMaterialOptions {
  28745. /**
  28746. * Does the material work in alpha blend mode
  28747. */
  28748. needAlphaBlending: boolean;
  28749. /**
  28750. * Does the material work in alpha test mode
  28751. */
  28752. needAlphaTesting: boolean;
  28753. /**
  28754. * The list of attribute names used in the shader
  28755. */
  28756. attributes: string[];
  28757. /**
  28758. * The list of unifrom names used in the shader
  28759. */
  28760. uniforms: string[];
  28761. /**
  28762. * The list of UBO names used in the shader
  28763. */
  28764. uniformBuffers: string[];
  28765. /**
  28766. * The list of sampler names used in the shader
  28767. */
  28768. samplers: string[];
  28769. /**
  28770. * The list of defines used in the shader
  28771. */
  28772. defines: string[];
  28773. }
  28774. /**
  28775. * 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.
  28776. *
  28777. * This returned material effects how the mesh will look based on the code in the shaders.
  28778. *
  28779. * @see https://doc.babylonjs.com/how_to/shader_material
  28780. */
  28781. export class ShaderMaterial extends Material {
  28782. private _shaderPath;
  28783. private _options;
  28784. private _textures;
  28785. private _textureArrays;
  28786. private _floats;
  28787. private _ints;
  28788. private _floatsArrays;
  28789. private _colors3;
  28790. private _colors3Arrays;
  28791. private _colors4;
  28792. private _colors4Arrays;
  28793. private _vectors2;
  28794. private _vectors3;
  28795. private _vectors4;
  28796. private _matrices;
  28797. private _matrixArrays;
  28798. private _matrices3x3;
  28799. private _matrices2x2;
  28800. private _vectors2Arrays;
  28801. private _vectors3Arrays;
  28802. private _vectors4Arrays;
  28803. private _cachedWorldViewMatrix;
  28804. private _cachedWorldViewProjectionMatrix;
  28805. private _renderId;
  28806. private _multiview;
  28807. private _cachedDefines;
  28808. /** Define the Url to load snippets */
  28809. static SnippetUrl: string;
  28810. /** Snippet ID if the material was created from the snippet server */
  28811. snippetId: string;
  28812. /**
  28813. * Instantiate a new shader material.
  28814. * 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.
  28815. * This returned material effects how the mesh will look based on the code in the shaders.
  28816. * @see https://doc.babylonjs.com/how_to/shader_material
  28817. * @param name Define the name of the material in the scene
  28818. * @param scene Define the scene the material belongs to
  28819. * @param shaderPath Defines the route to the shader code in one of three ways:
  28820. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  28821. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  28822. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  28823. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  28824. * @param options Define the options used to create the shader
  28825. */
  28826. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  28827. /**
  28828. * Gets the shader path used to define the shader code
  28829. * It can be modified to trigger a new compilation
  28830. */
  28831. get shaderPath(): any;
  28832. /**
  28833. * Sets the shader path used to define the shader code
  28834. * It can be modified to trigger a new compilation
  28835. */
  28836. set shaderPath(shaderPath: any);
  28837. /**
  28838. * Gets the options used to compile the shader.
  28839. * They can be modified to trigger a new compilation
  28840. */
  28841. get options(): IShaderMaterialOptions;
  28842. /**
  28843. * Gets the current class name of the material e.g. "ShaderMaterial"
  28844. * Mainly use in serialization.
  28845. * @returns the class name
  28846. */
  28847. getClassName(): string;
  28848. /**
  28849. * Specifies if the material will require alpha blending
  28850. * @returns a boolean specifying if alpha blending is needed
  28851. */
  28852. needAlphaBlending(): boolean;
  28853. /**
  28854. * Specifies if this material should be rendered in alpha test mode
  28855. * @returns a boolean specifying if an alpha test is needed.
  28856. */
  28857. needAlphaTesting(): boolean;
  28858. private _checkUniform;
  28859. /**
  28860. * Set a texture in the shader.
  28861. * @param name Define the name of the uniform samplers as defined in the shader
  28862. * @param texture Define the texture to bind to this sampler
  28863. * @return the material itself allowing "fluent" like uniform updates
  28864. */
  28865. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  28866. /**
  28867. * Set a texture array in the shader.
  28868. * @param name Define the name of the uniform sampler array as defined in the shader
  28869. * @param textures Define the list of textures to bind to this sampler
  28870. * @return the material itself allowing "fluent" like uniform updates
  28871. */
  28872. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  28873. /**
  28874. * Set a float in the shader.
  28875. * @param name Define the name of the uniform as defined in the shader
  28876. * @param value Define the value to give to the uniform
  28877. * @return the material itself allowing "fluent" like uniform updates
  28878. */
  28879. setFloat(name: string, value: number): ShaderMaterial;
  28880. /**
  28881. * Set a int in the shader.
  28882. * @param name Define the name of the uniform as defined in the shader
  28883. * @param value Define the value to give to the uniform
  28884. * @return the material itself allowing "fluent" like uniform updates
  28885. */
  28886. setInt(name: string, value: number): ShaderMaterial;
  28887. /**
  28888. * Set an array of floats in the shader.
  28889. * @param name Define the name of the uniform as defined in the shader
  28890. * @param value Define the value to give to the uniform
  28891. * @return the material itself allowing "fluent" like uniform updates
  28892. */
  28893. setFloats(name: string, value: number[]): ShaderMaterial;
  28894. /**
  28895. * Set a vec3 in the shader from a Color3.
  28896. * @param name Define the name of the uniform as defined in the shader
  28897. * @param value Define the value to give to the uniform
  28898. * @return the material itself allowing "fluent" like uniform updates
  28899. */
  28900. setColor3(name: string, value: Color3): ShaderMaterial;
  28901. /**
  28902. * Set a vec3 array in the shader from a Color3 array.
  28903. * @param name Define the name of the uniform as defined in the shader
  28904. * @param value Define the value to give to the uniform
  28905. * @return the material itself allowing "fluent" like uniform updates
  28906. */
  28907. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  28908. /**
  28909. * Set a vec4 in the shader from a Color4.
  28910. * @param name Define the name of the uniform as defined in the shader
  28911. * @param value Define the value to give to the uniform
  28912. * @return the material itself allowing "fluent" like uniform updates
  28913. */
  28914. setColor4(name: string, value: Color4): ShaderMaterial;
  28915. /**
  28916. * Set a vec4 array in the shader from a Color4 array.
  28917. * @param name Define the name of the uniform as defined in the shader
  28918. * @param value Define the value to give to the uniform
  28919. * @return the material itself allowing "fluent" like uniform updates
  28920. */
  28921. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  28922. /**
  28923. * Set a vec2 in the shader from a Vector2.
  28924. * @param name Define the name of the uniform as defined in the shader
  28925. * @param value Define the value to give to the uniform
  28926. * @return the material itself allowing "fluent" like uniform updates
  28927. */
  28928. setVector2(name: string, value: Vector2): ShaderMaterial;
  28929. /**
  28930. * Set a vec3 in the shader from a Vector3.
  28931. * @param name Define the name of the uniform as defined in the shader
  28932. * @param value Define the value to give to the uniform
  28933. * @return the material itself allowing "fluent" like uniform updates
  28934. */
  28935. setVector3(name: string, value: Vector3): ShaderMaterial;
  28936. /**
  28937. * Set a vec4 in the shader from a Vector4.
  28938. * @param name Define the name of the uniform as defined in the shader
  28939. * @param value Define the value to give to the uniform
  28940. * @return the material itself allowing "fluent" like uniform updates
  28941. */
  28942. setVector4(name: string, value: Vector4): ShaderMaterial;
  28943. /**
  28944. * Set a mat4 in the shader from a Matrix.
  28945. * @param name Define the name of the uniform as defined in the shader
  28946. * @param value Define the value to give to the uniform
  28947. * @return the material itself allowing "fluent" like uniform updates
  28948. */
  28949. setMatrix(name: string, value: Matrix): ShaderMaterial;
  28950. /**
  28951. * Set a float32Array in the shader from a matrix array.
  28952. * @param name Define the name of the uniform as defined in the shader
  28953. * @param value Define the value to give to the uniform
  28954. * @return the material itself allowing "fluent" like uniform updates
  28955. */
  28956. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  28957. /**
  28958. * Set a mat3 in the shader from a Float32Array.
  28959. * @param name Define the name of the uniform as defined in the shader
  28960. * @param value Define the value to give to the uniform
  28961. * @return the material itself allowing "fluent" like uniform updates
  28962. */
  28963. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28964. /**
  28965. * Set a mat2 in the shader from a Float32Array.
  28966. * @param name Define the name of the uniform as defined in the shader
  28967. * @param value Define the value to give to the uniform
  28968. * @return the material itself allowing "fluent" like uniform updates
  28969. */
  28970. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28971. /**
  28972. * Set a vec2 array in the shader from a number array.
  28973. * @param name Define the name of the uniform as defined in the shader
  28974. * @param value Define the value to give to the uniform
  28975. * @return the material itself allowing "fluent" like uniform updates
  28976. */
  28977. setArray2(name: string, value: number[]): ShaderMaterial;
  28978. /**
  28979. * Set a vec3 array in the shader from a number array.
  28980. * @param name Define the name of the uniform as defined in the shader
  28981. * @param value Define the value to give to the uniform
  28982. * @return the material itself allowing "fluent" like uniform updates
  28983. */
  28984. setArray3(name: string, value: number[]): ShaderMaterial;
  28985. /**
  28986. * Set a vec4 array in the shader from a number array.
  28987. * @param name Define the name of the uniform as defined in the shader
  28988. * @param value Define the value to give to the uniform
  28989. * @return the material itself allowing "fluent" like uniform updates
  28990. */
  28991. setArray4(name: string, value: number[]): ShaderMaterial;
  28992. private _checkCache;
  28993. /**
  28994. * Specifies that the submesh is ready to be used
  28995. * @param mesh defines the mesh to check
  28996. * @param subMesh defines which submesh to check
  28997. * @param useInstances specifies that instances should be used
  28998. * @returns a boolean indicating that the submesh is ready or not
  28999. */
  29000. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29001. /**
  29002. * Checks if the material is ready to render the requested mesh
  29003. * @param mesh Define the mesh to render
  29004. * @param useInstances Define whether or not the material is used with instances
  29005. * @returns true if ready, otherwise false
  29006. */
  29007. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29008. /**
  29009. * Binds the world matrix to the material
  29010. * @param world defines the world transformation matrix
  29011. * @param effectOverride - If provided, use this effect instead of internal effect
  29012. */
  29013. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  29014. /**
  29015. * Binds the submesh to this material by preparing the effect and shader to draw
  29016. * @param world defines the world transformation matrix
  29017. * @param mesh defines the mesh containing the submesh
  29018. * @param subMesh defines the submesh to bind the material to
  29019. */
  29020. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29021. /**
  29022. * Binds the material to the mesh
  29023. * @param world defines the world transformation matrix
  29024. * @param mesh defines the mesh to bind the material to
  29025. * @param effectOverride - If provided, use this effect instead of internal effect
  29026. */
  29027. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  29028. protected _afterBind(mesh?: Mesh): void;
  29029. /**
  29030. * Gets the active textures from the material
  29031. * @returns an array of textures
  29032. */
  29033. getActiveTextures(): BaseTexture[];
  29034. /**
  29035. * Specifies if the material uses a texture
  29036. * @param texture defines the texture to check against the material
  29037. * @returns a boolean specifying if the material uses the texture
  29038. */
  29039. hasTexture(texture: BaseTexture): boolean;
  29040. /**
  29041. * Makes a duplicate of the material, and gives it a new name
  29042. * @param name defines the new name for the duplicated material
  29043. * @returns the cloned material
  29044. */
  29045. clone(name: string): ShaderMaterial;
  29046. /**
  29047. * Disposes the material
  29048. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29049. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29050. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29051. */
  29052. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29053. /**
  29054. * Serializes this material in a JSON representation
  29055. * @returns the serialized material object
  29056. */
  29057. serialize(): any;
  29058. /**
  29059. * Creates a shader material from parsed shader material data
  29060. * @param source defines the JSON represnetation of the material
  29061. * @param scene defines the hosting scene
  29062. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29063. * @returns a new material
  29064. */
  29065. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  29066. /**
  29067. * Creates a new ShaderMaterial from a snippet saved in a remote file
  29068. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  29069. * @param url defines the url to load from
  29070. * @param scene defines the hosting scene
  29071. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29072. * @returns a promise that will resolve to the new ShaderMaterial
  29073. */
  29074. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29075. /**
  29076. * Creates a ShaderMaterial from a snippet saved by the Inspector
  29077. * @param snippetId defines the snippet to load
  29078. * @param scene defines the hosting scene
  29079. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29080. * @returns a promise that will resolve to the new ShaderMaterial
  29081. */
  29082. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29083. }
  29084. }
  29085. declare module "babylonjs/Shaders/color.fragment" {
  29086. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  29087. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  29088. /** @hidden */
  29089. export var colorPixelShader: {
  29090. name: string;
  29091. shader: string;
  29092. };
  29093. }
  29094. declare module "babylonjs/Shaders/color.vertex" {
  29095. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  29096. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  29097. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  29098. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  29099. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  29100. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  29101. /** @hidden */
  29102. export var colorVertexShader: {
  29103. name: string;
  29104. shader: string;
  29105. };
  29106. }
  29107. declare module "babylonjs/Meshes/linesMesh" {
  29108. import { Nullable } from "babylonjs/types";
  29109. import { Scene } from "babylonjs/scene";
  29110. import { Color3 } from "babylonjs/Maths/math.color";
  29111. import { Node } from "babylonjs/node";
  29112. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29113. import { Mesh } from "babylonjs/Meshes/mesh";
  29114. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29115. import { Effect } from "babylonjs/Materials/effect";
  29116. import { Material } from "babylonjs/Materials/material";
  29117. import "babylonjs/Shaders/color.fragment";
  29118. import "babylonjs/Shaders/color.vertex";
  29119. /**
  29120. * Line mesh
  29121. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  29122. */
  29123. export class LinesMesh extends Mesh {
  29124. /**
  29125. * If vertex color should be applied to the mesh
  29126. */
  29127. readonly useVertexColor?: boolean | undefined;
  29128. /**
  29129. * If vertex alpha should be applied to the mesh
  29130. */
  29131. readonly useVertexAlpha?: boolean | undefined;
  29132. /**
  29133. * Color of the line (Default: White)
  29134. */
  29135. color: Color3;
  29136. /**
  29137. * Alpha of the line (Default: 1)
  29138. */
  29139. alpha: number;
  29140. /**
  29141. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29142. * This margin is expressed in world space coordinates, so its value may vary.
  29143. * Default value is 0.1
  29144. */
  29145. intersectionThreshold: number;
  29146. private _colorShader;
  29147. private color4;
  29148. /**
  29149. * Creates a new LinesMesh
  29150. * @param name defines the name
  29151. * @param scene defines the hosting scene
  29152. * @param parent defines the parent mesh if any
  29153. * @param source defines the optional source LinesMesh used to clone data from
  29154. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29155. * When false, achieved by calling a clone(), also passing False.
  29156. * This will make creation of children, recursive.
  29157. * @param useVertexColor defines if this LinesMesh supports vertex color
  29158. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  29159. */
  29160. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  29161. /**
  29162. * If vertex color should be applied to the mesh
  29163. */
  29164. useVertexColor?: boolean | undefined,
  29165. /**
  29166. * If vertex alpha should be applied to the mesh
  29167. */
  29168. useVertexAlpha?: boolean | undefined);
  29169. private _addClipPlaneDefine;
  29170. private _removeClipPlaneDefine;
  29171. isReady(): boolean;
  29172. /**
  29173. * Returns the string "LineMesh"
  29174. */
  29175. getClassName(): string;
  29176. /**
  29177. * @hidden
  29178. */
  29179. get material(): Material;
  29180. /**
  29181. * @hidden
  29182. */
  29183. set material(value: Material);
  29184. /**
  29185. * @hidden
  29186. */
  29187. get checkCollisions(): boolean;
  29188. /** @hidden */
  29189. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29190. /** @hidden */
  29191. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29192. /**
  29193. * Disposes of the line mesh
  29194. * @param doNotRecurse If children should be disposed
  29195. */
  29196. dispose(doNotRecurse?: boolean): void;
  29197. /**
  29198. * Returns a new LineMesh object cloned from the current one.
  29199. */
  29200. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  29201. /**
  29202. * Creates a new InstancedLinesMesh object from the mesh model.
  29203. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29204. * @param name defines the name of the new instance
  29205. * @returns a new InstancedLinesMesh
  29206. */
  29207. createInstance(name: string): InstancedLinesMesh;
  29208. }
  29209. /**
  29210. * Creates an instance based on a source LinesMesh
  29211. */
  29212. export class InstancedLinesMesh extends InstancedMesh {
  29213. /**
  29214. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29215. * This margin is expressed in world space coordinates, so its value may vary.
  29216. * Initilized with the intersectionThreshold value of the source LinesMesh
  29217. */
  29218. intersectionThreshold: number;
  29219. constructor(name: string, source: LinesMesh);
  29220. /**
  29221. * Returns the string "InstancedLinesMesh".
  29222. */
  29223. getClassName(): string;
  29224. }
  29225. }
  29226. declare module "babylonjs/Shaders/line.fragment" {
  29227. /** @hidden */
  29228. export var linePixelShader: {
  29229. name: string;
  29230. shader: string;
  29231. };
  29232. }
  29233. declare module "babylonjs/Shaders/line.vertex" {
  29234. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  29235. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  29236. /** @hidden */
  29237. export var lineVertexShader: {
  29238. name: string;
  29239. shader: string;
  29240. };
  29241. }
  29242. declare module "babylonjs/Rendering/edgesRenderer" {
  29243. import { Immutable, Nullable } from "babylonjs/types";
  29244. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29246. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  29247. import { IDisposable } from "babylonjs/scene";
  29248. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  29249. import "babylonjs/Shaders/line.fragment";
  29250. import "babylonjs/Shaders/line.vertex";
  29251. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29252. import { SmartArray } from "babylonjs/Misc/smartArray";
  29253. module "babylonjs/scene" {
  29254. interface Scene {
  29255. /** @hidden */
  29256. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  29257. }
  29258. }
  29259. module "babylonjs/Meshes/abstractMesh" {
  29260. interface AbstractMesh {
  29261. /**
  29262. * Gets the edgesRenderer associated with the mesh
  29263. */
  29264. edgesRenderer: Nullable<EdgesRenderer>;
  29265. }
  29266. }
  29267. module "babylonjs/Meshes/linesMesh" {
  29268. interface LinesMesh {
  29269. /**
  29270. * Enables the edge rendering mode on the mesh.
  29271. * This mode makes the mesh edges visible
  29272. * @param epsilon defines the maximal distance between two angles to detect a face
  29273. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29274. * @returns the currentAbstractMesh
  29275. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29276. */
  29277. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29278. }
  29279. }
  29280. module "babylonjs/Meshes/linesMesh" {
  29281. interface InstancedLinesMesh {
  29282. /**
  29283. * Enables the edge rendering mode on the mesh.
  29284. * This mode makes the mesh edges visible
  29285. * @param epsilon defines the maximal distance between two angles to detect a face
  29286. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29287. * @returns the current InstancedLinesMesh
  29288. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29289. */
  29290. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  29291. }
  29292. }
  29293. /**
  29294. * Defines the minimum contract an Edges renderer should follow.
  29295. */
  29296. export interface IEdgesRenderer extends IDisposable {
  29297. /**
  29298. * Gets or sets a boolean indicating if the edgesRenderer is active
  29299. */
  29300. isEnabled: boolean;
  29301. /**
  29302. * Renders the edges of the attached mesh,
  29303. */
  29304. render(): void;
  29305. /**
  29306. * Checks wether or not the edges renderer is ready to render.
  29307. * @return true if ready, otherwise false.
  29308. */
  29309. isReady(): boolean;
  29310. /**
  29311. * List of instances to render in case the source mesh has instances
  29312. */
  29313. customInstances: SmartArray<Matrix>;
  29314. }
  29315. /**
  29316. * Defines the additional options of the edges renderer
  29317. */
  29318. export interface IEdgesRendererOptions {
  29319. /**
  29320. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  29321. * If not defined, the default value is true
  29322. */
  29323. useAlternateEdgeFinder?: boolean;
  29324. /**
  29325. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  29326. * If not defined, the default value is true.
  29327. * 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)
  29328. * This option is used only if useAlternateEdgeFinder = true
  29329. */
  29330. useFastVertexMerger?: boolean;
  29331. /**
  29332. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  29333. * The default value is 1e-6
  29334. * This option is used only if useAlternateEdgeFinder = true
  29335. */
  29336. epsilonVertexMerge?: number;
  29337. /**
  29338. * 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
  29339. * 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.
  29340. * This option is used only if useAlternateEdgeFinder = true
  29341. */
  29342. applyTessellation?: boolean;
  29343. /**
  29344. * 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
  29345. * The default value is 1e-6
  29346. * This option is used only if useAlternateEdgeFinder = true
  29347. */
  29348. epsilonVertexAligned?: number;
  29349. }
  29350. /**
  29351. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  29352. */
  29353. export class EdgesRenderer implements IEdgesRenderer {
  29354. /**
  29355. * Define the size of the edges with an orthographic camera
  29356. */
  29357. edgesWidthScalerForOrthographic: number;
  29358. /**
  29359. * Define the size of the edges with a perspective camera
  29360. */
  29361. edgesWidthScalerForPerspective: number;
  29362. protected _source: AbstractMesh;
  29363. protected _linesPositions: number[];
  29364. protected _linesNormals: number[];
  29365. protected _linesIndices: number[];
  29366. protected _epsilon: number;
  29367. protected _indicesCount: number;
  29368. protected _lineShader: ShaderMaterial;
  29369. protected _ib: DataBuffer;
  29370. protected _buffers: {
  29371. [key: string]: Nullable<VertexBuffer>;
  29372. };
  29373. protected _buffersForInstances: {
  29374. [key: string]: Nullable<VertexBuffer>;
  29375. };
  29376. protected _checkVerticesInsteadOfIndices: boolean;
  29377. protected _options: Nullable<IEdgesRendererOptions>;
  29378. private _meshRebuildObserver;
  29379. private _meshDisposeObserver;
  29380. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29381. isEnabled: boolean;
  29382. /** Gets the vertices generated by the edge renderer */
  29383. get linesPositions(): Immutable<Array<number>>;
  29384. /** Gets the normals generated by the edge renderer */
  29385. get linesNormals(): Immutable<Array<number>>;
  29386. /** Gets the indices generated by the edge renderer */
  29387. get linesIndices(): Immutable<Array<number>>;
  29388. /**
  29389. * List of instances to render in case the source mesh has instances
  29390. */
  29391. customInstances: SmartArray<Matrix>;
  29392. private static GetShader;
  29393. /**
  29394. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29395. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29396. * @param source Mesh used to create edges
  29397. * @param epsilon sum of angles in adjacency to check for edge
  29398. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  29399. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29400. * @param options The options to apply when generating the edges
  29401. */
  29402. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  29403. protected _prepareRessources(): void;
  29404. /** @hidden */
  29405. _rebuild(): void;
  29406. /**
  29407. * Releases the required resources for the edges renderer
  29408. */
  29409. dispose(): void;
  29410. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29411. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29412. /**
  29413. * Checks if the pair of p0 and p1 is en edge
  29414. * @param faceIndex
  29415. * @param edge
  29416. * @param faceNormals
  29417. * @param p0
  29418. * @param p1
  29419. * @private
  29420. */
  29421. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29422. /**
  29423. * push line into the position, normal and index buffer
  29424. * @protected
  29425. */
  29426. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  29427. /**
  29428. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  29429. */
  29430. private _tessellateTriangle;
  29431. private _generateEdgesLinesAlternate;
  29432. /**
  29433. * Generates lines edges from adjacencjes
  29434. * @private
  29435. */
  29436. _generateEdgesLines(): void;
  29437. /**
  29438. * Checks wether or not the edges renderer is ready to render.
  29439. * @return true if ready, otherwise false.
  29440. */
  29441. isReady(): boolean;
  29442. /**
  29443. * Renders the edges of the attached mesh,
  29444. */
  29445. render(): void;
  29446. }
  29447. /**
  29448. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29449. */
  29450. export class LineEdgesRenderer extends EdgesRenderer {
  29451. /**
  29452. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29453. * @param source LineMesh used to generate edges
  29454. * @param epsilon not important (specified angle for edge detection)
  29455. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29456. */
  29457. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29458. /**
  29459. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29460. */
  29461. _generateEdgesLines(): void;
  29462. }
  29463. }
  29464. declare module "babylonjs/Rendering/renderingGroup" {
  29465. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  29466. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29468. import { Nullable } from "babylonjs/types";
  29469. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  29470. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  29471. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  29472. import { Material } from "babylonjs/Materials/material";
  29473. import { Scene } from "babylonjs/scene";
  29474. /**
  29475. * This represents the object necessary to create a rendering group.
  29476. * This is exclusively used and created by the rendering manager.
  29477. * To modify the behavior, you use the available helpers in your scene or meshes.
  29478. * @hidden
  29479. */
  29480. export class RenderingGroup {
  29481. index: number;
  29482. private static _zeroVector;
  29483. private _scene;
  29484. private _opaqueSubMeshes;
  29485. private _transparentSubMeshes;
  29486. private _alphaTestSubMeshes;
  29487. private _depthOnlySubMeshes;
  29488. private _particleSystems;
  29489. private _spriteManagers;
  29490. private _opaqueSortCompareFn;
  29491. private _alphaTestSortCompareFn;
  29492. private _transparentSortCompareFn;
  29493. private _renderOpaque;
  29494. private _renderAlphaTest;
  29495. private _renderTransparent;
  29496. /** @hidden */
  29497. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  29498. onBeforeTransparentRendering: () => void;
  29499. /**
  29500. * Set the opaque sort comparison function.
  29501. * If null the sub meshes will be render in the order they were created
  29502. */
  29503. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29504. /**
  29505. * Set the alpha test sort comparison function.
  29506. * If null the sub meshes will be render in the order they were created
  29507. */
  29508. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29509. /**
  29510. * Set the transparent sort comparison function.
  29511. * If null the sub meshes will be render in the order they were created
  29512. */
  29513. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29514. /**
  29515. * Creates a new rendering group.
  29516. * @param index The rendering group index
  29517. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29518. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29519. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29520. */
  29521. 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>);
  29522. /**
  29523. * Render all the sub meshes contained in the group.
  29524. * @param customRenderFunction Used to override the default render behaviour of the group.
  29525. * @returns true if rendered some submeshes.
  29526. */
  29527. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29528. /**
  29529. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29530. * @param subMeshes The submeshes to render
  29531. */
  29532. private renderOpaqueSorted;
  29533. /**
  29534. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29535. * @param subMeshes The submeshes to render
  29536. */
  29537. private renderAlphaTestSorted;
  29538. /**
  29539. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29540. * @param subMeshes The submeshes to render
  29541. */
  29542. private renderTransparentSorted;
  29543. /**
  29544. * Renders the submeshes in a specified order.
  29545. * @param subMeshes The submeshes to sort before render
  29546. * @param sortCompareFn The comparison function use to sort
  29547. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29548. * @param transparent Specifies to activate blending if true
  29549. */
  29550. private static renderSorted;
  29551. /**
  29552. * Renders the submeshes in the order they were dispatched (no sort applied).
  29553. * @param subMeshes The submeshes to render
  29554. */
  29555. private static renderUnsorted;
  29556. /**
  29557. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29558. * are rendered back to front if in the same alpha index.
  29559. *
  29560. * @param a The first submesh
  29561. * @param b The second submesh
  29562. * @returns The result of the comparison
  29563. */
  29564. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29565. /**
  29566. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29567. * are rendered back to front.
  29568. *
  29569. * @param a The first submesh
  29570. * @param b The second submesh
  29571. * @returns The result of the comparison
  29572. */
  29573. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29574. /**
  29575. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29576. * are rendered front to back (prevent overdraw).
  29577. *
  29578. * @param a The first submesh
  29579. * @param b The second submesh
  29580. * @returns The result of the comparison
  29581. */
  29582. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29583. /**
  29584. * Resets the different lists of submeshes to prepare a new frame.
  29585. */
  29586. prepare(): void;
  29587. dispose(): void;
  29588. /**
  29589. * Inserts the submesh in its correct queue depending on its material.
  29590. * @param subMesh The submesh to dispatch
  29591. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29592. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29593. */
  29594. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29595. dispatchSprites(spriteManager: ISpriteManager): void;
  29596. dispatchParticles(particleSystem: IParticleSystem): void;
  29597. private _renderParticles;
  29598. private _renderSprites;
  29599. }
  29600. }
  29601. declare module "babylonjs/Rendering/renderingManager" {
  29602. import { Nullable } from "babylonjs/types";
  29603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29604. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29605. import { SmartArray } from "babylonjs/Misc/smartArray";
  29606. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  29607. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  29608. import { Material } from "babylonjs/Materials/material";
  29609. import { Scene } from "babylonjs/scene";
  29610. import { Camera } from "babylonjs/Cameras/camera";
  29611. /**
  29612. * Interface describing the different options available in the rendering manager
  29613. * regarding Auto Clear between groups.
  29614. */
  29615. export interface IRenderingManagerAutoClearSetup {
  29616. /**
  29617. * Defines whether or not autoclear is enable.
  29618. */
  29619. autoClear: boolean;
  29620. /**
  29621. * Defines whether or not to autoclear the depth buffer.
  29622. */
  29623. depth: boolean;
  29624. /**
  29625. * Defines whether or not to autoclear the stencil buffer.
  29626. */
  29627. stencil: boolean;
  29628. }
  29629. /**
  29630. * This class is used by the onRenderingGroupObservable
  29631. */
  29632. export class RenderingGroupInfo {
  29633. /**
  29634. * The Scene that being rendered
  29635. */
  29636. scene: Scene;
  29637. /**
  29638. * The camera currently used for the rendering pass
  29639. */
  29640. camera: Nullable<Camera>;
  29641. /**
  29642. * The ID of the renderingGroup being processed
  29643. */
  29644. renderingGroupId: number;
  29645. }
  29646. /**
  29647. * This is the manager responsible of all the rendering for meshes sprites and particles.
  29648. * It is enable to manage the different groups as well as the different necessary sort functions.
  29649. * This should not be used directly aside of the few static configurations
  29650. */
  29651. export class RenderingManager {
  29652. /**
  29653. * The max id used for rendering groups (not included)
  29654. */
  29655. static MAX_RENDERINGGROUPS: number;
  29656. /**
  29657. * The min id used for rendering groups (included)
  29658. */
  29659. static MIN_RENDERINGGROUPS: number;
  29660. /**
  29661. * Used to globally prevent autoclearing scenes.
  29662. */
  29663. static AUTOCLEAR: boolean;
  29664. /**
  29665. * @hidden
  29666. */
  29667. _useSceneAutoClearSetup: boolean;
  29668. private _scene;
  29669. private _renderingGroups;
  29670. private _depthStencilBufferAlreadyCleaned;
  29671. private _autoClearDepthStencil;
  29672. private _customOpaqueSortCompareFn;
  29673. private _customAlphaTestSortCompareFn;
  29674. private _customTransparentSortCompareFn;
  29675. private _renderingGroupInfo;
  29676. /**
  29677. * Instantiates a new rendering group for a particular scene
  29678. * @param scene Defines the scene the groups belongs to
  29679. */
  29680. constructor(scene: Scene);
  29681. private _clearDepthStencilBuffer;
  29682. /**
  29683. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  29684. * @hidden
  29685. */
  29686. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29687. /**
  29688. * Resets the different information of the group to prepare a new frame
  29689. * @hidden
  29690. */
  29691. reset(): void;
  29692. /**
  29693. * Dispose and release the group and its associated resources.
  29694. * @hidden
  29695. */
  29696. dispose(): void;
  29697. /**
  29698. * Clear the info related to rendering groups preventing retention points during dispose.
  29699. */
  29700. freeRenderingGroups(): void;
  29701. private _prepareRenderingGroup;
  29702. /**
  29703. * Add a sprite manager to the rendering manager in order to render it this frame.
  29704. * @param spriteManager Define the sprite manager to render
  29705. */
  29706. dispatchSprites(spriteManager: ISpriteManager): void;
  29707. /**
  29708. * Add a particle system to the rendering manager in order to render it this frame.
  29709. * @param particleSystem Define the particle system to render
  29710. */
  29711. dispatchParticles(particleSystem: IParticleSystem): void;
  29712. /**
  29713. * Add a submesh to the manager in order to render it this frame
  29714. * @param subMesh The submesh to dispatch
  29715. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29716. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29717. */
  29718. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29719. /**
  29720. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29721. * This allowed control for front to back rendering or reversly depending of the special needs.
  29722. *
  29723. * @param renderingGroupId The rendering group id corresponding to its index
  29724. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29725. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29726. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29727. */
  29728. 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;
  29729. /**
  29730. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29731. *
  29732. * @param renderingGroupId The rendering group id corresponding to its index
  29733. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29734. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29735. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29736. */
  29737. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29738. /**
  29739. * Gets the current auto clear configuration for one rendering group of the rendering
  29740. * manager.
  29741. * @param index the rendering group index to get the information for
  29742. * @returns The auto clear setup for the requested rendering group
  29743. */
  29744. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29745. }
  29746. }
  29747. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  29748. import { SmartArray } from "babylonjs/Misc/smartArray";
  29749. import { Nullable } from "babylonjs/types";
  29750. import { Scene } from "babylonjs/scene";
  29751. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29752. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29754. import { Mesh } from "babylonjs/Meshes/mesh";
  29755. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  29756. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29757. import { Effect } from "babylonjs/Materials/effect";
  29758. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29759. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29760. import "babylonjs/Shaders/shadowMap.fragment";
  29761. import "babylonjs/Shaders/shadowMap.vertex";
  29762. import "babylonjs/Shaders/depthBoxBlur.fragment";
  29763. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  29764. import { Observable } from "babylonjs/Misc/observable";
  29765. /**
  29766. * Defines the options associated with the creation of a custom shader for a shadow generator.
  29767. */
  29768. export interface ICustomShaderOptions {
  29769. /**
  29770. * Gets or sets the custom shader name to use
  29771. */
  29772. shaderName: string;
  29773. /**
  29774. * The list of attribute names used in the shader
  29775. */
  29776. attributes?: string[];
  29777. /**
  29778. * The list of unifrom names used in the shader
  29779. */
  29780. uniforms?: string[];
  29781. /**
  29782. * The list of sampler names used in the shader
  29783. */
  29784. samplers?: string[];
  29785. /**
  29786. * The list of defines used in the shader
  29787. */
  29788. defines?: string[];
  29789. }
  29790. /**
  29791. * Interface to implement to create a shadow generator compatible with BJS.
  29792. */
  29793. export interface IShadowGenerator {
  29794. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29795. id: string;
  29796. /**
  29797. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29798. * @returns The render target texture if present otherwise, null
  29799. */
  29800. getShadowMap(): Nullable<RenderTargetTexture>;
  29801. /**
  29802. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29803. * @param subMesh The submesh we want to render in the shadow map
  29804. * @param useInstances Defines wether will draw in the map using instances
  29805. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29806. * @returns true if ready otherwise, false
  29807. */
  29808. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29809. /**
  29810. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29811. * @param defines Defines of the material we want to update
  29812. * @param lightIndex Index of the light in the enabled light list of the material
  29813. */
  29814. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29815. /**
  29816. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29817. * defined in the generator but impacting the effect).
  29818. * It implies the unifroms available on the materials are the standard BJS ones.
  29819. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29820. * @param effect The effect we are binfing the information for
  29821. */
  29822. bindShadowLight(lightIndex: string, effect: Effect): void;
  29823. /**
  29824. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29825. * (eq to shadow prjection matrix * light transform matrix)
  29826. * @returns The transform matrix used to create the shadow map
  29827. */
  29828. getTransformMatrix(): Matrix;
  29829. /**
  29830. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29831. * Cube and 2D textures for instance.
  29832. */
  29833. recreateShadowMap(): void;
  29834. /**
  29835. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29836. * @param onCompiled Callback triggered at the and of the effects compilation
  29837. * @param options Sets of optional options forcing the compilation with different modes
  29838. */
  29839. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29840. useInstances: boolean;
  29841. }>): void;
  29842. /**
  29843. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29844. * @param options Sets of optional options forcing the compilation with different modes
  29845. * @returns A promise that resolves when the compilation completes
  29846. */
  29847. forceCompilationAsync(options?: Partial<{
  29848. useInstances: boolean;
  29849. }>): Promise<void>;
  29850. /**
  29851. * Serializes the shadow generator setup to a json object.
  29852. * @returns The serialized JSON object
  29853. */
  29854. serialize(): any;
  29855. /**
  29856. * Disposes the Shadow map and related Textures and effects.
  29857. */
  29858. dispose(): void;
  29859. }
  29860. /**
  29861. * Default implementation IShadowGenerator.
  29862. * This is the main object responsible of generating shadows in the framework.
  29863. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  29864. */
  29865. export class ShadowGenerator implements IShadowGenerator {
  29866. /**
  29867. * Name of the shadow generator class
  29868. */
  29869. static CLASSNAME: string;
  29870. /**
  29871. * Shadow generator mode None: no filtering applied.
  29872. */
  29873. static readonly FILTER_NONE: number;
  29874. /**
  29875. * Shadow generator mode ESM: Exponential Shadow Mapping.
  29876. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29877. */
  29878. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  29879. /**
  29880. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  29881. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  29882. */
  29883. static readonly FILTER_POISSONSAMPLING: number;
  29884. /**
  29885. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  29886. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29887. */
  29888. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  29889. /**
  29890. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  29891. * edge artifacts on steep falloff.
  29892. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29893. */
  29894. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  29895. /**
  29896. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  29897. * edge artifacts on steep falloff.
  29898. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29899. */
  29900. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  29901. /**
  29902. * Shadow generator mode PCF: Percentage Closer Filtering
  29903. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29904. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  29905. */
  29906. static readonly FILTER_PCF: number;
  29907. /**
  29908. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  29909. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29910. * Contact Hardening
  29911. */
  29912. static readonly FILTER_PCSS: number;
  29913. /**
  29914. * Reserved for PCF and PCSS
  29915. * Highest Quality.
  29916. *
  29917. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  29918. *
  29919. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  29920. */
  29921. static readonly QUALITY_HIGH: number;
  29922. /**
  29923. * Reserved for PCF and PCSS
  29924. * Good tradeoff for quality/perf cross devices
  29925. *
  29926. * Execute PCF on a 3*3 kernel.
  29927. *
  29928. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  29929. */
  29930. static readonly QUALITY_MEDIUM: number;
  29931. /**
  29932. * Reserved for PCF and PCSS
  29933. * The lowest quality but the fastest.
  29934. *
  29935. * Execute PCF on a 1*1 kernel.
  29936. *
  29937. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  29938. */
  29939. static readonly QUALITY_LOW: number;
  29940. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29941. id: string;
  29942. /** Gets or sets the custom shader name to use */
  29943. customShaderOptions: ICustomShaderOptions;
  29944. /**
  29945. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  29946. */
  29947. onBeforeShadowMapRenderObservable: Observable<Effect>;
  29948. /**
  29949. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  29950. */
  29951. onAfterShadowMapRenderObservable: Observable<Effect>;
  29952. /**
  29953. * Observable triggered before a mesh is rendered in the shadow map.
  29954. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  29955. */
  29956. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  29957. /**
  29958. * Observable triggered after a mesh is rendered in the shadow map.
  29959. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  29960. */
  29961. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  29962. protected _bias: number;
  29963. /**
  29964. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  29965. */
  29966. get bias(): number;
  29967. /**
  29968. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  29969. */
  29970. set bias(bias: number);
  29971. protected _normalBias: number;
  29972. /**
  29973. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29974. */
  29975. get normalBias(): number;
  29976. /**
  29977. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29978. */
  29979. set normalBias(normalBias: number);
  29980. protected _blurBoxOffset: number;
  29981. /**
  29982. * Gets the blur box offset: offset applied during the blur pass.
  29983. * Only useful if useKernelBlur = false
  29984. */
  29985. get blurBoxOffset(): number;
  29986. /**
  29987. * Sets the blur box offset: offset applied during the blur pass.
  29988. * Only useful if useKernelBlur = false
  29989. */
  29990. set blurBoxOffset(value: number);
  29991. protected _blurScale: number;
  29992. /**
  29993. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  29994. * 2 means half of the size.
  29995. */
  29996. get blurScale(): number;
  29997. /**
  29998. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  29999. * 2 means half of the size.
  30000. */
  30001. set blurScale(value: number);
  30002. protected _blurKernel: number;
  30003. /**
  30004. * Gets the blur kernel: kernel size of the blur pass.
  30005. * Only useful if useKernelBlur = true
  30006. */
  30007. get blurKernel(): number;
  30008. /**
  30009. * Sets the blur kernel: kernel size of the blur pass.
  30010. * Only useful if useKernelBlur = true
  30011. */
  30012. set blurKernel(value: number);
  30013. protected _useKernelBlur: boolean;
  30014. /**
  30015. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  30016. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  30017. */
  30018. get useKernelBlur(): boolean;
  30019. /**
  30020. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  30021. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  30022. */
  30023. set useKernelBlur(value: boolean);
  30024. protected _depthScale: number;
  30025. /**
  30026. * Gets the depth scale used in ESM mode.
  30027. */
  30028. get depthScale(): number;
  30029. /**
  30030. * Sets the depth scale used in ESM mode.
  30031. * This can override the scale stored on the light.
  30032. */
  30033. set depthScale(value: number);
  30034. protected _validateFilter(filter: number): number;
  30035. protected _filter: number;
  30036. /**
  30037. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  30038. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30039. */
  30040. get filter(): number;
  30041. /**
  30042. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  30043. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30044. */
  30045. set filter(value: number);
  30046. /**
  30047. * Gets if the current filter is set to Poisson Sampling.
  30048. */
  30049. get usePoissonSampling(): boolean;
  30050. /**
  30051. * Sets the current filter to Poisson Sampling.
  30052. */
  30053. set usePoissonSampling(value: boolean);
  30054. /**
  30055. * Gets if the current filter is set to ESM.
  30056. */
  30057. get useExponentialShadowMap(): boolean;
  30058. /**
  30059. * Sets the current filter is to ESM.
  30060. */
  30061. set useExponentialShadowMap(value: boolean);
  30062. /**
  30063. * Gets if the current filter is set to filtered ESM.
  30064. */
  30065. get useBlurExponentialShadowMap(): boolean;
  30066. /**
  30067. * Gets if the current filter is set to filtered ESM.
  30068. */
  30069. set useBlurExponentialShadowMap(value: boolean);
  30070. /**
  30071. * Gets if the current filter is set to "close ESM" (using the inverse of the
  30072. * exponential to prevent steep falloff artifacts).
  30073. */
  30074. get useCloseExponentialShadowMap(): boolean;
  30075. /**
  30076. * Sets the current filter to "close ESM" (using the inverse of the
  30077. * exponential to prevent steep falloff artifacts).
  30078. */
  30079. set useCloseExponentialShadowMap(value: boolean);
  30080. /**
  30081. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  30082. * exponential to prevent steep falloff artifacts).
  30083. */
  30084. get useBlurCloseExponentialShadowMap(): boolean;
  30085. /**
  30086. * Sets the current filter to filtered "close ESM" (using the inverse of the
  30087. * exponential to prevent steep falloff artifacts).
  30088. */
  30089. set useBlurCloseExponentialShadowMap(value: boolean);
  30090. /**
  30091. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  30092. */
  30093. get usePercentageCloserFiltering(): boolean;
  30094. /**
  30095. * Sets the current filter to "PCF" (percentage closer filtering).
  30096. */
  30097. set usePercentageCloserFiltering(value: boolean);
  30098. protected _filteringQuality: number;
  30099. /**
  30100. * Gets the PCF or PCSS Quality.
  30101. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30102. */
  30103. get filteringQuality(): number;
  30104. /**
  30105. * Sets the PCF or PCSS Quality.
  30106. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30107. */
  30108. set filteringQuality(filteringQuality: number);
  30109. /**
  30110. * Gets if the current filter is set to "PCSS" (contact hardening).
  30111. */
  30112. get useContactHardeningShadow(): boolean;
  30113. /**
  30114. * Sets the current filter to "PCSS" (contact hardening).
  30115. */
  30116. set useContactHardeningShadow(value: boolean);
  30117. protected _contactHardeningLightSizeUVRatio: number;
  30118. /**
  30119. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30120. * Using a ratio helps keeping shape stability independently of the map size.
  30121. *
  30122. * It does not account for the light projection as it was having too much
  30123. * instability during the light setup or during light position changes.
  30124. *
  30125. * Only valid if useContactHardeningShadow is true.
  30126. */
  30127. get contactHardeningLightSizeUVRatio(): number;
  30128. /**
  30129. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30130. * Using a ratio helps keeping shape stability independently of the map size.
  30131. *
  30132. * It does not account for the light projection as it was having too much
  30133. * instability during the light setup or during light position changes.
  30134. *
  30135. * Only valid if useContactHardeningShadow is true.
  30136. */
  30137. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  30138. protected _darkness: number;
  30139. /** Gets or sets the actual darkness of a shadow */
  30140. get darkness(): number;
  30141. set darkness(value: number);
  30142. /**
  30143. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  30144. * 0 means strongest and 1 would means no shadow.
  30145. * @returns the darkness.
  30146. */
  30147. getDarkness(): number;
  30148. /**
  30149. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  30150. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  30151. * @returns the shadow generator allowing fluent coding.
  30152. */
  30153. setDarkness(darkness: number): ShadowGenerator;
  30154. protected _transparencyShadow: boolean;
  30155. /** Gets or sets the ability to have transparent shadow */
  30156. get transparencyShadow(): boolean;
  30157. set transparencyShadow(value: boolean);
  30158. /**
  30159. * Sets the ability to have transparent shadow (boolean).
  30160. * @param transparent True if transparent else False
  30161. * @returns the shadow generator allowing fluent coding
  30162. */
  30163. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  30164. /**
  30165. * Enables or disables shadows with varying strength based on the transparency
  30166. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  30167. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  30168. * mesh.visibility * alphaTexture.a
  30169. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  30170. */
  30171. enableSoftTransparentShadow: boolean;
  30172. protected _shadowMap: Nullable<RenderTargetTexture>;
  30173. protected _shadowMap2: Nullable<RenderTargetTexture>;
  30174. /**
  30175. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30176. * @returns The render target texture if present otherwise, null
  30177. */
  30178. getShadowMap(): Nullable<RenderTargetTexture>;
  30179. /**
  30180. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30181. * @returns The render target texture if the shadow map is present otherwise, null
  30182. */
  30183. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30184. /**
  30185. * Gets the class name of that object
  30186. * @returns "ShadowGenerator"
  30187. */
  30188. getClassName(): string;
  30189. /**
  30190. * Helper function to add a mesh and its descendants to the list of shadow casters.
  30191. * @param mesh Mesh to add
  30192. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  30193. * @returns the Shadow Generator itself
  30194. */
  30195. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30196. /**
  30197. * Helper function to remove a mesh and its descendants from the list of shadow casters
  30198. * @param mesh Mesh to remove
  30199. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  30200. * @returns the Shadow Generator itself
  30201. */
  30202. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30203. /**
  30204. * Controls the extent to which the shadows fade out at the edge of the frustum
  30205. */
  30206. frustumEdgeFalloff: number;
  30207. protected _light: IShadowLight;
  30208. /**
  30209. * Returns the associated light object.
  30210. * @returns the light generating the shadow
  30211. */
  30212. getLight(): IShadowLight;
  30213. /**
  30214. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  30215. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  30216. * It might on the other hand introduce peter panning.
  30217. */
  30218. forceBackFacesOnly: boolean;
  30219. protected _scene: Scene;
  30220. protected _lightDirection: Vector3;
  30221. protected _effect: Effect;
  30222. protected _viewMatrix: Matrix;
  30223. protected _projectionMatrix: Matrix;
  30224. protected _transformMatrix: Matrix;
  30225. protected _cachedPosition: Vector3;
  30226. protected _cachedDirection: Vector3;
  30227. protected _cachedDefines: string;
  30228. protected _currentRenderID: number;
  30229. protected _boxBlurPostprocess: Nullable<PostProcess>;
  30230. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  30231. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  30232. protected _blurPostProcesses: PostProcess[];
  30233. protected _mapSize: number;
  30234. protected _currentFaceIndex: number;
  30235. protected _currentFaceIndexCache: number;
  30236. protected _textureType: number;
  30237. protected _defaultTextureMatrix: Matrix;
  30238. protected _storedUniqueId: Nullable<number>;
  30239. /** @hidden */
  30240. static _SceneComponentInitialization: (scene: Scene) => void;
  30241. /**
  30242. * Gets or sets the size of the texture what stores the shadows
  30243. */
  30244. get mapSize(): number;
  30245. set mapSize(size: number);
  30246. /**
  30247. * Creates a ShadowGenerator object.
  30248. * A ShadowGenerator is the required tool to use the shadows.
  30249. * Each light casting shadows needs to use its own ShadowGenerator.
  30250. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  30251. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  30252. * @param light The light object generating the shadows.
  30253. * @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.
  30254. */
  30255. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  30256. protected _initializeGenerator(): void;
  30257. protected _createTargetRenderTexture(): void;
  30258. protected _initializeShadowMap(): void;
  30259. protected _initializeBlurRTTAndPostProcesses(): void;
  30260. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  30261. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  30262. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  30263. protected _applyFilterValues(): void;
  30264. /**
  30265. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30266. * @param onCompiled Callback triggered at the and of the effects compilation
  30267. * @param options Sets of optional options forcing the compilation with different modes
  30268. */
  30269. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  30270. useInstances: boolean;
  30271. }>): void;
  30272. /**
  30273. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30274. * @param options Sets of optional options forcing the compilation with different modes
  30275. * @returns A promise that resolves when the compilation completes
  30276. */
  30277. forceCompilationAsync(options?: Partial<{
  30278. useInstances: boolean;
  30279. }>): Promise<void>;
  30280. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  30281. private _prepareShadowDefines;
  30282. /**
  30283. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30284. * @param subMesh The submesh we want to render in the shadow map
  30285. * @param useInstances Defines wether will draw in the map using instances
  30286. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  30287. * @returns true if ready otherwise, false
  30288. */
  30289. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  30290. /**
  30291. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30292. * @param defines Defines of the material we want to update
  30293. * @param lightIndex Index of the light in the enabled light list of the material
  30294. */
  30295. prepareDefines(defines: any, lightIndex: number): void;
  30296. /**
  30297. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30298. * defined in the generator but impacting the effect).
  30299. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30300. * @param effect The effect we are binfing the information for
  30301. */
  30302. bindShadowLight(lightIndex: string, effect: Effect): void;
  30303. /**
  30304. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30305. * (eq to shadow prjection matrix * light transform matrix)
  30306. * @returns The transform matrix used to create the shadow map
  30307. */
  30308. getTransformMatrix(): Matrix;
  30309. /**
  30310. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30311. * Cube and 2D textures for instance.
  30312. */
  30313. recreateShadowMap(): void;
  30314. protected _disposeBlurPostProcesses(): void;
  30315. protected _disposeRTTandPostProcesses(): void;
  30316. /**
  30317. * Disposes the ShadowGenerator.
  30318. * Returns nothing.
  30319. */
  30320. dispose(): void;
  30321. /**
  30322. * Serializes the shadow generator setup to a json object.
  30323. * @returns The serialized JSON object
  30324. */
  30325. serialize(): any;
  30326. /**
  30327. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  30328. * @param parsedShadowGenerator The JSON object to parse
  30329. * @param scene The scene to create the shadow map for
  30330. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  30331. * @returns The parsed shadow generator
  30332. */
  30333. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  30334. }
  30335. }
  30336. declare module "babylonjs/Materials/shadowDepthWrapper" {
  30337. import { Nullable } from "babylonjs/types";
  30338. import { Scene } from "babylonjs/scene";
  30339. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30340. import { Material } from "babylonjs/Materials/material";
  30341. import { Effect } from "babylonjs/Materials/effect";
  30342. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  30343. /**
  30344. * Options to be used when creating a shadow depth material
  30345. */
  30346. export interface IIOptionShadowDepthMaterial {
  30347. /** Variables in the vertex shader code that need to have their names remapped.
  30348. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  30349. * "var_name" should be either: worldPos or vNormalW
  30350. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  30351. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  30352. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  30353. */
  30354. remappedVariables?: string[];
  30355. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  30356. standalone?: boolean;
  30357. }
  30358. /**
  30359. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  30360. */
  30361. export class ShadowDepthWrapper {
  30362. private _scene;
  30363. private _options?;
  30364. private _baseMaterial;
  30365. private _onEffectCreatedObserver;
  30366. private _subMeshToEffect;
  30367. private _subMeshToDepthEffect;
  30368. private _meshes;
  30369. /** @hidden */
  30370. _matriceNames: any;
  30371. /** Gets the standalone status of the wrapper */
  30372. get standalone(): boolean;
  30373. /** Gets the base material the wrapper is built upon */
  30374. get baseMaterial(): Material;
  30375. /**
  30376. * Instantiate a new shadow depth wrapper.
  30377. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  30378. * generate the shadow depth map. For more information, please refer to the documentation:
  30379. * https://doc.babylonjs.com/babylon101/shadows
  30380. * @param baseMaterial Material to wrap
  30381. * @param scene Define the scene the material belongs to
  30382. * @param options Options used to create the wrapper
  30383. */
  30384. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  30385. /**
  30386. * Gets the effect to use to generate the depth map
  30387. * @param subMesh subMesh to get the effect for
  30388. * @param shadowGenerator shadow generator to get the effect for
  30389. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  30390. */
  30391. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  30392. /**
  30393. * Specifies that the submesh is ready to be used for depth rendering
  30394. * @param subMesh submesh to check
  30395. * @param defines the list of defines to take into account when checking the effect
  30396. * @param shadowGenerator combined with subMesh, it defines the effect to check
  30397. * @param useInstances specifies that instances should be used
  30398. * @returns a boolean indicating that the submesh is ready or not
  30399. */
  30400. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  30401. /**
  30402. * Disposes the resources
  30403. */
  30404. dispose(): void;
  30405. private _makeEffect;
  30406. }
  30407. }
  30408. declare module "babylonjs/Materials/material" {
  30409. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30410. import { SmartArray } from "babylonjs/Misc/smartArray";
  30411. import { Observable } from "babylonjs/Misc/observable";
  30412. import { Nullable } from "babylonjs/types";
  30413. import { Scene } from "babylonjs/scene";
  30414. import { Matrix } from "babylonjs/Maths/math.vector";
  30415. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30417. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30418. import { Effect } from "babylonjs/Materials/effect";
  30419. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30420. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30421. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30422. import { IInspectable } from "babylonjs/Misc/iInspectable";
  30423. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  30424. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  30425. import { Mesh } from "babylonjs/Meshes/mesh";
  30426. import { Animation } from "babylonjs/Animations/animation";
  30427. /**
  30428. * Options for compiling materials.
  30429. */
  30430. export interface IMaterialCompilationOptions {
  30431. /**
  30432. * Defines whether clip planes are enabled.
  30433. */
  30434. clipPlane: boolean;
  30435. /**
  30436. * Defines whether instances are enabled.
  30437. */
  30438. useInstances: boolean;
  30439. }
  30440. /**
  30441. * Options passed when calling customShaderNameResolve
  30442. */
  30443. export interface ICustomShaderNameResolveOptions {
  30444. /**
  30445. * 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
  30446. */
  30447. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30448. }
  30449. /**
  30450. * Base class for the main features of a material in Babylon.js
  30451. */
  30452. export class Material implements IAnimatable {
  30453. /**
  30454. * Returns the triangle fill mode
  30455. */
  30456. static readonly TriangleFillMode: number;
  30457. /**
  30458. * Returns the wireframe mode
  30459. */
  30460. static readonly WireFrameFillMode: number;
  30461. /**
  30462. * Returns the point fill mode
  30463. */
  30464. static readonly PointFillMode: number;
  30465. /**
  30466. * Returns the point list draw mode
  30467. */
  30468. static readonly PointListDrawMode: number;
  30469. /**
  30470. * Returns the line list draw mode
  30471. */
  30472. static readonly LineListDrawMode: number;
  30473. /**
  30474. * Returns the line loop draw mode
  30475. */
  30476. static readonly LineLoopDrawMode: number;
  30477. /**
  30478. * Returns the line strip draw mode
  30479. */
  30480. static readonly LineStripDrawMode: number;
  30481. /**
  30482. * Returns the triangle strip draw mode
  30483. */
  30484. static readonly TriangleStripDrawMode: number;
  30485. /**
  30486. * Returns the triangle fan draw mode
  30487. */
  30488. static readonly TriangleFanDrawMode: number;
  30489. /**
  30490. * Stores the clock-wise side orientation
  30491. */
  30492. static readonly ClockWiseSideOrientation: number;
  30493. /**
  30494. * Stores the counter clock-wise side orientation
  30495. */
  30496. static readonly CounterClockWiseSideOrientation: number;
  30497. /**
  30498. * The dirty texture flag value
  30499. */
  30500. static readonly TextureDirtyFlag: number;
  30501. /**
  30502. * The dirty light flag value
  30503. */
  30504. static readonly LightDirtyFlag: number;
  30505. /**
  30506. * The dirty fresnel flag value
  30507. */
  30508. static readonly FresnelDirtyFlag: number;
  30509. /**
  30510. * The dirty attribute flag value
  30511. */
  30512. static readonly AttributesDirtyFlag: number;
  30513. /**
  30514. * The dirty misc flag value
  30515. */
  30516. static readonly MiscDirtyFlag: number;
  30517. /**
  30518. * The dirty prepass flag value
  30519. */
  30520. static readonly PrePassDirtyFlag: number;
  30521. /**
  30522. * The all dirty flag value
  30523. */
  30524. static readonly AllDirtyFlag: number;
  30525. /**
  30526. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30527. */
  30528. static readonly MATERIAL_OPAQUE: number;
  30529. /**
  30530. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30531. */
  30532. static readonly MATERIAL_ALPHATEST: number;
  30533. /**
  30534. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30535. */
  30536. static readonly MATERIAL_ALPHABLEND: number;
  30537. /**
  30538. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30539. * They are also discarded below the alpha cutoff threshold to improve performances.
  30540. */
  30541. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30542. /**
  30543. * The Whiteout method is used to blend normals.
  30544. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30545. */
  30546. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30547. /**
  30548. * The Reoriented Normal Mapping method is used to blend normals.
  30549. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30550. */
  30551. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30552. /**
  30553. * Custom callback helping to override the default shader used in the material.
  30554. */
  30555. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30556. /**
  30557. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30558. */
  30559. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30560. /**
  30561. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30562. * This means that the material can keep using a previous shader while a new one is being compiled.
  30563. * This is mostly used when shader parallel compilation is supported (true by default)
  30564. */
  30565. allowShaderHotSwapping: boolean;
  30566. /**
  30567. * The ID of the material
  30568. */
  30569. id: string;
  30570. /**
  30571. * Gets or sets the unique id of the material
  30572. */
  30573. uniqueId: number;
  30574. /**
  30575. * The name of the material
  30576. */
  30577. name: string;
  30578. /**
  30579. * Gets or sets user defined metadata
  30580. */
  30581. metadata: any;
  30582. /**
  30583. * For internal use only. Please do not use.
  30584. */
  30585. reservedDataStore: any;
  30586. /**
  30587. * Specifies if the ready state should be checked on each call
  30588. */
  30589. checkReadyOnEveryCall: boolean;
  30590. /**
  30591. * Specifies if the ready state should be checked once
  30592. */
  30593. checkReadyOnlyOnce: boolean;
  30594. /**
  30595. * The state of the material
  30596. */
  30597. state: string;
  30598. /**
  30599. * If the material can be rendered to several textures with MRT extension
  30600. */
  30601. get canRenderToMRT(): boolean;
  30602. /**
  30603. * The alpha value of the material
  30604. */
  30605. protected _alpha: number;
  30606. /**
  30607. * List of inspectable custom properties (used by the Inspector)
  30608. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30609. */
  30610. inspectableCustomProperties: IInspectable[];
  30611. /**
  30612. * Sets the alpha value of the material
  30613. */
  30614. set alpha(value: number);
  30615. /**
  30616. * Gets the alpha value of the material
  30617. */
  30618. get alpha(): number;
  30619. /**
  30620. * Specifies if back face culling is enabled
  30621. */
  30622. protected _backFaceCulling: boolean;
  30623. /**
  30624. * Sets the back-face culling state
  30625. */
  30626. set backFaceCulling(value: boolean);
  30627. /**
  30628. * Gets the back-face culling state
  30629. */
  30630. get backFaceCulling(): boolean;
  30631. /**
  30632. * Stores the value for side orientation
  30633. */
  30634. sideOrientation: number;
  30635. /**
  30636. * Callback triggered when the material is compiled
  30637. */
  30638. onCompiled: Nullable<(effect: Effect) => void>;
  30639. /**
  30640. * Callback triggered when an error occurs
  30641. */
  30642. onError: Nullable<(effect: Effect, errors: string) => void>;
  30643. /**
  30644. * Callback triggered to get the render target textures
  30645. */
  30646. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30647. /**
  30648. * Gets a boolean indicating that current material needs to register RTT
  30649. */
  30650. get hasRenderTargetTextures(): boolean;
  30651. /**
  30652. * Specifies if the material should be serialized
  30653. */
  30654. doNotSerialize: boolean;
  30655. /**
  30656. * @hidden
  30657. */
  30658. _storeEffectOnSubMeshes: boolean;
  30659. /**
  30660. * Stores the animations for the material
  30661. */
  30662. animations: Nullable<Array<Animation>>;
  30663. /**
  30664. * An event triggered when the material is disposed
  30665. */
  30666. onDisposeObservable: Observable<Material>;
  30667. /**
  30668. * An observer which watches for dispose events
  30669. */
  30670. private _onDisposeObserver;
  30671. private _onUnBindObservable;
  30672. /**
  30673. * Called during a dispose event
  30674. */
  30675. set onDispose(callback: () => void);
  30676. private _onBindObservable;
  30677. /**
  30678. * An event triggered when the material is bound
  30679. */
  30680. get onBindObservable(): Observable<AbstractMesh>;
  30681. /**
  30682. * An observer which watches for bind events
  30683. */
  30684. private _onBindObserver;
  30685. /**
  30686. * Called during a bind event
  30687. */
  30688. set onBind(callback: (Mesh: AbstractMesh) => void);
  30689. /**
  30690. * An event triggered when the material is unbound
  30691. */
  30692. get onUnBindObservable(): Observable<Material>;
  30693. protected _onEffectCreatedObservable: Nullable<Observable<{
  30694. effect: Effect;
  30695. subMesh: Nullable<SubMesh>;
  30696. }>>;
  30697. /**
  30698. * An event triggered when the effect is (re)created
  30699. */
  30700. get onEffectCreatedObservable(): Observable<{
  30701. effect: Effect;
  30702. subMesh: Nullable<SubMesh>;
  30703. }>;
  30704. /**
  30705. * Stores the value of the alpha mode
  30706. */
  30707. private _alphaMode;
  30708. /**
  30709. * Sets the value of the alpha mode.
  30710. *
  30711. * | Value | Type | Description |
  30712. * | --- | --- | --- |
  30713. * | 0 | ALPHA_DISABLE | |
  30714. * | 1 | ALPHA_ADD | |
  30715. * | 2 | ALPHA_COMBINE | |
  30716. * | 3 | ALPHA_SUBTRACT | |
  30717. * | 4 | ALPHA_MULTIPLY | |
  30718. * | 5 | ALPHA_MAXIMIZED | |
  30719. * | 6 | ALPHA_ONEONE | |
  30720. * | 7 | ALPHA_PREMULTIPLIED | |
  30721. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30722. * | 9 | ALPHA_INTERPOLATE | |
  30723. * | 10 | ALPHA_SCREENMODE | |
  30724. *
  30725. */
  30726. set alphaMode(value: number);
  30727. /**
  30728. * Gets the value of the alpha mode
  30729. */
  30730. get alphaMode(): number;
  30731. /**
  30732. * Stores the state of the need depth pre-pass value
  30733. */
  30734. private _needDepthPrePass;
  30735. /**
  30736. * Sets the need depth pre-pass value
  30737. */
  30738. set needDepthPrePass(value: boolean);
  30739. /**
  30740. * Gets the depth pre-pass value
  30741. */
  30742. get needDepthPrePass(): boolean;
  30743. /**
  30744. * Specifies if depth writing should be disabled
  30745. */
  30746. disableDepthWrite: boolean;
  30747. /**
  30748. * Specifies if color writing should be disabled
  30749. */
  30750. disableColorWrite: boolean;
  30751. /**
  30752. * Specifies if depth writing should be forced
  30753. */
  30754. forceDepthWrite: boolean;
  30755. /**
  30756. * Specifies the depth function that should be used. 0 means the default engine function
  30757. */
  30758. depthFunction: number;
  30759. /**
  30760. * Specifies if there should be a separate pass for culling
  30761. */
  30762. separateCullingPass: boolean;
  30763. /**
  30764. * Stores the state specifing if fog should be enabled
  30765. */
  30766. private _fogEnabled;
  30767. /**
  30768. * Sets the state for enabling fog
  30769. */
  30770. set fogEnabled(value: boolean);
  30771. /**
  30772. * Gets the value of the fog enabled state
  30773. */
  30774. get fogEnabled(): boolean;
  30775. /**
  30776. * Stores the size of points
  30777. */
  30778. pointSize: number;
  30779. /**
  30780. * Stores the z offset value
  30781. */
  30782. zOffset: number;
  30783. get wireframe(): boolean;
  30784. /**
  30785. * Sets the state of wireframe mode
  30786. */
  30787. set wireframe(value: boolean);
  30788. /**
  30789. * Gets the value specifying if point clouds are enabled
  30790. */
  30791. get pointsCloud(): boolean;
  30792. /**
  30793. * Sets the state of point cloud mode
  30794. */
  30795. set pointsCloud(value: boolean);
  30796. /**
  30797. * Gets the material fill mode
  30798. */
  30799. get fillMode(): number;
  30800. /**
  30801. * Sets the material fill mode
  30802. */
  30803. set fillMode(value: number);
  30804. /**
  30805. * @hidden
  30806. * Stores the effects for the material
  30807. */
  30808. _effect: Nullable<Effect>;
  30809. /**
  30810. * Specifies if uniform buffers should be used
  30811. */
  30812. private _useUBO;
  30813. /**
  30814. * Stores a reference to the scene
  30815. */
  30816. private _scene;
  30817. /**
  30818. * Stores the fill mode state
  30819. */
  30820. private _fillMode;
  30821. /**
  30822. * Specifies if the depth write state should be cached
  30823. */
  30824. private _cachedDepthWriteState;
  30825. /**
  30826. * Specifies if the color write state should be cached
  30827. */
  30828. private _cachedColorWriteState;
  30829. /**
  30830. * Specifies if the depth function state should be cached
  30831. */
  30832. private _cachedDepthFunctionState;
  30833. /**
  30834. * Stores the uniform buffer
  30835. */
  30836. protected _uniformBuffer: UniformBuffer;
  30837. /** @hidden */
  30838. _indexInSceneMaterialArray: number;
  30839. /** @hidden */
  30840. meshMap: Nullable<{
  30841. [id: string]: AbstractMesh | undefined;
  30842. }>;
  30843. /**
  30844. * Creates a material instance
  30845. * @param name defines the name of the material
  30846. * @param scene defines the scene to reference
  30847. * @param doNotAdd specifies if the material should be added to the scene
  30848. */
  30849. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30850. /**
  30851. * Returns a string representation of the current material
  30852. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30853. * @returns a string with material information
  30854. */
  30855. toString(fullDetails?: boolean): string;
  30856. /**
  30857. * Gets the class name of the material
  30858. * @returns a string with the class name of the material
  30859. */
  30860. getClassName(): string;
  30861. /**
  30862. * Specifies if updates for the material been locked
  30863. */
  30864. get isFrozen(): boolean;
  30865. /**
  30866. * Locks updates for the material
  30867. */
  30868. freeze(): void;
  30869. /**
  30870. * Unlocks updates for the material
  30871. */
  30872. unfreeze(): void;
  30873. /**
  30874. * Specifies if the material is ready to be used
  30875. * @param mesh defines the mesh to check
  30876. * @param useInstances specifies if instances should be used
  30877. * @returns a boolean indicating if the material is ready to be used
  30878. */
  30879. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30880. /**
  30881. * Specifies that the submesh is ready to be used
  30882. * @param mesh defines the mesh to check
  30883. * @param subMesh defines which submesh to check
  30884. * @param useInstances specifies that instances should be used
  30885. * @returns a boolean indicating that the submesh is ready or not
  30886. */
  30887. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30888. /**
  30889. * Returns the material effect
  30890. * @returns the effect associated with the material
  30891. */
  30892. getEffect(): Nullable<Effect>;
  30893. /**
  30894. * Returns the current scene
  30895. * @returns a Scene
  30896. */
  30897. getScene(): Scene;
  30898. /**
  30899. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30900. */
  30901. protected _forceAlphaTest: boolean;
  30902. /**
  30903. * The transparency mode of the material.
  30904. */
  30905. protected _transparencyMode: Nullable<number>;
  30906. /**
  30907. * Gets the current transparency mode.
  30908. */
  30909. get transparencyMode(): Nullable<number>;
  30910. /**
  30911. * Sets the transparency mode of the material.
  30912. *
  30913. * | Value | Type | Description |
  30914. * | ----- | ----------------------------------- | ----------- |
  30915. * | 0 | OPAQUE | |
  30916. * | 1 | ALPHATEST | |
  30917. * | 2 | ALPHABLEND | |
  30918. * | 3 | ALPHATESTANDBLEND | |
  30919. *
  30920. */
  30921. set transparencyMode(value: Nullable<number>);
  30922. /**
  30923. * Returns true if alpha blending should be disabled.
  30924. */
  30925. protected get _disableAlphaBlending(): boolean;
  30926. /**
  30927. * Specifies whether or not this material should be rendered in alpha blend mode.
  30928. * @returns a boolean specifying if alpha blending is needed
  30929. */
  30930. needAlphaBlending(): boolean;
  30931. /**
  30932. * Specifies if the mesh will require alpha blending
  30933. * @param mesh defines the mesh to check
  30934. * @returns a boolean specifying if alpha blending is needed for the mesh
  30935. */
  30936. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30937. /**
  30938. * Specifies whether or not this material should be rendered in alpha test mode.
  30939. * @returns a boolean specifying if an alpha test is needed.
  30940. */
  30941. needAlphaTesting(): boolean;
  30942. /**
  30943. * Specifies if material alpha testing should be turned on for the mesh
  30944. * @param mesh defines the mesh to check
  30945. */
  30946. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30947. /**
  30948. * Gets the texture used for the alpha test
  30949. * @returns the texture to use for alpha testing
  30950. */
  30951. getAlphaTestTexture(): Nullable<BaseTexture>;
  30952. /**
  30953. * Marks the material to indicate that it needs to be re-calculated
  30954. */
  30955. markDirty(): void;
  30956. /** @hidden */
  30957. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30958. /**
  30959. * Binds the material to the mesh
  30960. * @param world defines the world transformation matrix
  30961. * @param mesh defines the mesh to bind the material to
  30962. */
  30963. bind(world: Matrix, mesh?: Mesh): void;
  30964. /**
  30965. * Binds the submesh to the material
  30966. * @param world defines the world transformation matrix
  30967. * @param mesh defines the mesh containing the submesh
  30968. * @param subMesh defines the submesh to bind the material to
  30969. */
  30970. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30971. /**
  30972. * Binds the world matrix to the material
  30973. * @param world defines the world transformation matrix
  30974. */
  30975. bindOnlyWorldMatrix(world: Matrix): void;
  30976. /**
  30977. * Binds the scene's uniform buffer to the effect.
  30978. * @param effect defines the effect to bind to the scene uniform buffer
  30979. * @param sceneUbo defines the uniform buffer storing scene data
  30980. */
  30981. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  30982. /**
  30983. * Binds the view matrix to the effect
  30984. * @param effect defines the effect to bind the view matrix to
  30985. */
  30986. bindView(effect: Effect): void;
  30987. /**
  30988. * Binds the view projection matrix to the effect
  30989. * @param effect defines the effect to bind the view projection matrix to
  30990. */
  30991. bindViewProjection(effect: Effect): void;
  30992. /**
  30993. * Processes to execute after binding the material to a mesh
  30994. * @param mesh defines the rendered mesh
  30995. */
  30996. protected _afterBind(mesh?: Mesh): void;
  30997. /**
  30998. * Unbinds the material from the mesh
  30999. */
  31000. unbind(): void;
  31001. /**
  31002. * Gets the active textures from the material
  31003. * @returns an array of textures
  31004. */
  31005. getActiveTextures(): BaseTexture[];
  31006. /**
  31007. * Specifies if the material uses a texture
  31008. * @param texture defines the texture to check against the material
  31009. * @returns a boolean specifying if the material uses the texture
  31010. */
  31011. hasTexture(texture: BaseTexture): boolean;
  31012. /**
  31013. * Makes a duplicate of the material, and gives it a new name
  31014. * @param name defines the new name for the duplicated material
  31015. * @returns the cloned material
  31016. */
  31017. clone(name: string): Nullable<Material>;
  31018. /**
  31019. * Gets the meshes bound to the material
  31020. * @returns an array of meshes bound to the material
  31021. */
  31022. getBindedMeshes(): AbstractMesh[];
  31023. /**
  31024. * Force shader compilation
  31025. * @param mesh defines the mesh associated with this material
  31026. * @param onCompiled defines a function to execute once the material is compiled
  31027. * @param options defines the options to configure the compilation
  31028. * @param onError defines a function to execute if the material fails compiling
  31029. */
  31030. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  31031. /**
  31032. * Force shader compilation
  31033. * @param mesh defines the mesh that will use this material
  31034. * @param options defines additional options for compiling the shaders
  31035. * @returns a promise that resolves when the compilation completes
  31036. */
  31037. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  31038. private static readonly _AllDirtyCallBack;
  31039. private static readonly _ImageProcessingDirtyCallBack;
  31040. private static readonly _TextureDirtyCallBack;
  31041. private static readonly _FresnelDirtyCallBack;
  31042. private static readonly _MiscDirtyCallBack;
  31043. private static readonly _PrePassDirtyCallBack;
  31044. private static readonly _LightsDirtyCallBack;
  31045. private static readonly _AttributeDirtyCallBack;
  31046. private static _FresnelAndMiscDirtyCallBack;
  31047. private static _TextureAndMiscDirtyCallBack;
  31048. private static readonly _DirtyCallbackArray;
  31049. private static readonly _RunDirtyCallBacks;
  31050. /**
  31051. * Marks a define in the material to indicate that it needs to be re-computed
  31052. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  31053. */
  31054. markAsDirty(flag: number): void;
  31055. /**
  31056. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  31057. * @param func defines a function which checks material defines against the submeshes
  31058. */
  31059. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  31060. /**
  31061. * Indicates that the scene should check if the rendering now needs a prepass
  31062. */
  31063. protected _markScenePrePassDirty(): void;
  31064. /**
  31065. * Indicates that we need to re-calculated for all submeshes
  31066. */
  31067. protected _markAllSubMeshesAsAllDirty(): void;
  31068. /**
  31069. * Indicates that image processing needs to be re-calculated for all submeshes
  31070. */
  31071. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  31072. /**
  31073. * Indicates that textures need to be re-calculated for all submeshes
  31074. */
  31075. protected _markAllSubMeshesAsTexturesDirty(): void;
  31076. /**
  31077. * Indicates that fresnel needs to be re-calculated for all submeshes
  31078. */
  31079. protected _markAllSubMeshesAsFresnelDirty(): void;
  31080. /**
  31081. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  31082. */
  31083. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  31084. /**
  31085. * Indicates that lights need to be re-calculated for all submeshes
  31086. */
  31087. protected _markAllSubMeshesAsLightsDirty(): void;
  31088. /**
  31089. * Indicates that attributes need to be re-calculated for all submeshes
  31090. */
  31091. protected _markAllSubMeshesAsAttributesDirty(): void;
  31092. /**
  31093. * Indicates that misc needs to be re-calculated for all submeshes
  31094. */
  31095. protected _markAllSubMeshesAsMiscDirty(): void;
  31096. /**
  31097. * Indicates that prepass needs to be re-calculated for all submeshes
  31098. */
  31099. protected _markAllSubMeshesAsPrePassDirty(): void;
  31100. /**
  31101. * Indicates that textures and misc need to be re-calculated for all submeshes
  31102. */
  31103. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  31104. /**
  31105. * Sets the required values to the prepass renderer.
  31106. * @param prePassRenderer defines the prepass renderer to setup.
  31107. * @returns true if the pre pass is needed.
  31108. */
  31109. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  31110. /**
  31111. * Disposes the material
  31112. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31113. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31114. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  31115. */
  31116. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  31117. /** @hidden */
  31118. private releaseVertexArrayObject;
  31119. /**
  31120. * Serializes this material
  31121. * @returns the serialized material object
  31122. */
  31123. serialize(): any;
  31124. /**
  31125. * Creates a material from parsed material data
  31126. * @param parsedMaterial defines parsed material data
  31127. * @param scene defines the hosting scene
  31128. * @param rootUrl defines the root URL to use to load textures
  31129. * @returns a new material
  31130. */
  31131. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  31132. }
  31133. }
  31134. declare module "babylonjs/Materials/multiMaterial" {
  31135. import { Nullable } from "babylonjs/types";
  31136. import { Scene } from "babylonjs/scene";
  31137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31138. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31139. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31140. import { Material } from "babylonjs/Materials/material";
  31141. /**
  31142. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31143. * separate meshes. This can be use to improve performances.
  31144. * @see https://doc.babylonjs.com/how_to/multi_materials
  31145. */
  31146. export class MultiMaterial extends Material {
  31147. private _subMaterials;
  31148. /**
  31149. * Gets or Sets the list of Materials used within the multi material.
  31150. * They need to be ordered according to the submeshes order in the associated mesh
  31151. */
  31152. get subMaterials(): Nullable<Material>[];
  31153. set subMaterials(value: Nullable<Material>[]);
  31154. /**
  31155. * Function used to align with Node.getChildren()
  31156. * @returns the list of Materials used within the multi material
  31157. */
  31158. getChildren(): Nullable<Material>[];
  31159. /**
  31160. * Instantiates a new Multi Material
  31161. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31162. * separate meshes. This can be use to improve performances.
  31163. * @see https://doc.babylonjs.com/how_to/multi_materials
  31164. * @param name Define the name in the scene
  31165. * @param scene Define the scene the material belongs to
  31166. */
  31167. constructor(name: string, scene: Scene);
  31168. private _hookArray;
  31169. /**
  31170. * Get one of the submaterial by its index in the submaterials array
  31171. * @param index The index to look the sub material at
  31172. * @returns The Material if the index has been defined
  31173. */
  31174. getSubMaterial(index: number): Nullable<Material>;
  31175. /**
  31176. * Get the list of active textures for the whole sub materials list.
  31177. * @returns All the textures that will be used during the rendering
  31178. */
  31179. getActiveTextures(): BaseTexture[];
  31180. /**
  31181. * Gets the current class name of the material e.g. "MultiMaterial"
  31182. * Mainly use in serialization.
  31183. * @returns the class name
  31184. */
  31185. getClassName(): string;
  31186. /**
  31187. * Checks if the material is ready to render the requested sub mesh
  31188. * @param mesh Define the mesh the submesh belongs to
  31189. * @param subMesh Define the sub mesh to look readyness for
  31190. * @param useInstances Define whether or not the material is used with instances
  31191. * @returns true if ready, otherwise false
  31192. */
  31193. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31194. /**
  31195. * Clones the current material and its related sub materials
  31196. * @param name Define the name of the newly cloned material
  31197. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  31198. * @returns the cloned material
  31199. */
  31200. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  31201. /**
  31202. * Serializes the materials into a JSON representation.
  31203. * @returns the JSON representation
  31204. */
  31205. serialize(): any;
  31206. /**
  31207. * Dispose the material and release its associated resources
  31208. * @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)
  31209. * @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)
  31210. * @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)
  31211. */
  31212. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  31213. /**
  31214. * Creates a MultiMaterial from parsed MultiMaterial data.
  31215. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  31216. * @param scene defines the hosting scene
  31217. * @returns a new MultiMaterial
  31218. */
  31219. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  31220. }
  31221. }
  31222. declare module "babylonjs/Meshes/subMesh" {
  31223. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  31224. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  31225. import { Engine } from "babylonjs/Engines/engine";
  31226. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  31227. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31228. import { Effect } from "babylonjs/Materials/effect";
  31229. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31230. import { Plane } from "babylonjs/Maths/math.plane";
  31231. import { Collider } from "babylonjs/Collisions/collider";
  31232. import { Material } from "babylonjs/Materials/material";
  31233. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31235. import { Mesh } from "babylonjs/Meshes/mesh";
  31236. import { Ray } from "babylonjs/Culling/ray";
  31237. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31238. /**
  31239. * Defines a subdivision inside a mesh
  31240. */
  31241. export class SubMesh implements ICullable {
  31242. /** the material index to use */
  31243. materialIndex: number;
  31244. /** vertex index start */
  31245. verticesStart: number;
  31246. /** vertices count */
  31247. verticesCount: number;
  31248. /** index start */
  31249. indexStart: number;
  31250. /** indices count */
  31251. indexCount: number;
  31252. /** @hidden */
  31253. _materialDefines: Nullable<MaterialDefines>;
  31254. /** @hidden */
  31255. _materialEffect: Nullable<Effect>;
  31256. /** @hidden */
  31257. _effectOverride: Nullable<Effect>;
  31258. /**
  31259. * Gets material defines used by the effect associated to the sub mesh
  31260. */
  31261. get materialDefines(): Nullable<MaterialDefines>;
  31262. /**
  31263. * Sets material defines used by the effect associated to the sub mesh
  31264. */
  31265. set materialDefines(defines: Nullable<MaterialDefines>);
  31266. /**
  31267. * Gets associated effect
  31268. */
  31269. get effect(): Nullable<Effect>;
  31270. /**
  31271. * Sets associated effect (effect used to render this submesh)
  31272. * @param effect defines the effect to associate with
  31273. * @param defines defines the set of defines used to compile this effect
  31274. */
  31275. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  31276. /** @hidden */
  31277. _linesIndexCount: number;
  31278. private _mesh;
  31279. private _renderingMesh;
  31280. private _boundingInfo;
  31281. private _linesIndexBuffer;
  31282. /** @hidden */
  31283. _lastColliderWorldVertices: Nullable<Vector3[]>;
  31284. /** @hidden */
  31285. _trianglePlanes: Plane[];
  31286. /** @hidden */
  31287. _lastColliderTransformMatrix: Nullable<Matrix>;
  31288. /** @hidden */
  31289. _renderId: number;
  31290. /** @hidden */
  31291. _alphaIndex: number;
  31292. /** @hidden */
  31293. _distanceToCamera: number;
  31294. /** @hidden */
  31295. _id: number;
  31296. private _currentMaterial;
  31297. /**
  31298. * Add a new submesh to a mesh
  31299. * @param materialIndex defines the material index to use
  31300. * @param verticesStart defines vertex index start
  31301. * @param verticesCount defines vertices count
  31302. * @param indexStart defines index start
  31303. * @param indexCount defines indices count
  31304. * @param mesh defines the parent mesh
  31305. * @param renderingMesh defines an optional rendering mesh
  31306. * @param createBoundingBox defines if bounding box should be created for this submesh
  31307. * @returns the new submesh
  31308. */
  31309. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  31310. /**
  31311. * Creates a new submesh
  31312. * @param materialIndex defines the material index to use
  31313. * @param verticesStart defines vertex index start
  31314. * @param verticesCount defines vertices count
  31315. * @param indexStart defines index start
  31316. * @param indexCount defines indices count
  31317. * @param mesh defines the parent mesh
  31318. * @param renderingMesh defines an optional rendering mesh
  31319. * @param createBoundingBox defines if bounding box should be created for this submesh
  31320. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  31321. */
  31322. constructor(
  31323. /** the material index to use */
  31324. materialIndex: number,
  31325. /** vertex index start */
  31326. verticesStart: number,
  31327. /** vertices count */
  31328. verticesCount: number,
  31329. /** index start */
  31330. indexStart: number,
  31331. /** indices count */
  31332. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  31333. /**
  31334. * Returns true if this submesh covers the entire parent mesh
  31335. * @ignorenaming
  31336. */
  31337. get IsGlobal(): boolean;
  31338. /**
  31339. * Returns the submesh BoudingInfo object
  31340. * @returns current bounding info (or mesh's one if the submesh is global)
  31341. */
  31342. getBoundingInfo(): BoundingInfo;
  31343. /**
  31344. * Sets the submesh BoundingInfo
  31345. * @param boundingInfo defines the new bounding info to use
  31346. * @returns the SubMesh
  31347. */
  31348. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  31349. /**
  31350. * Returns the mesh of the current submesh
  31351. * @return the parent mesh
  31352. */
  31353. getMesh(): AbstractMesh;
  31354. /**
  31355. * Returns the rendering mesh of the submesh
  31356. * @returns the rendering mesh (could be different from parent mesh)
  31357. */
  31358. getRenderingMesh(): Mesh;
  31359. /**
  31360. * Returns the replacement mesh of the submesh
  31361. * @returns the replacement mesh (could be different from parent mesh)
  31362. */
  31363. getReplacementMesh(): Nullable<AbstractMesh>;
  31364. /**
  31365. * Returns the effective mesh of the submesh
  31366. * @returns the effective mesh (could be different from parent mesh)
  31367. */
  31368. getEffectiveMesh(): AbstractMesh;
  31369. /**
  31370. * Returns the submesh material
  31371. * @returns null or the current material
  31372. */
  31373. getMaterial(): Nullable<Material>;
  31374. private _IsMultiMaterial;
  31375. /**
  31376. * Sets a new updated BoundingInfo object to the submesh
  31377. * @param data defines an optional position array to use to determine the bounding info
  31378. * @returns the SubMesh
  31379. */
  31380. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  31381. /** @hidden */
  31382. _checkCollision(collider: Collider): boolean;
  31383. /**
  31384. * Updates the submesh BoundingInfo
  31385. * @param world defines the world matrix to use to update the bounding info
  31386. * @returns the submesh
  31387. */
  31388. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  31389. /**
  31390. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  31391. * @param frustumPlanes defines the frustum planes
  31392. * @returns true if the submesh is intersecting with the frustum
  31393. */
  31394. isInFrustum(frustumPlanes: Plane[]): boolean;
  31395. /**
  31396. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  31397. * @param frustumPlanes defines the frustum planes
  31398. * @returns true if the submesh is inside the frustum
  31399. */
  31400. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31401. /**
  31402. * Renders the submesh
  31403. * @param enableAlphaMode defines if alpha needs to be used
  31404. * @returns the submesh
  31405. */
  31406. render(enableAlphaMode: boolean): SubMesh;
  31407. /**
  31408. * @hidden
  31409. */
  31410. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  31411. /**
  31412. * Checks if the submesh intersects with a ray
  31413. * @param ray defines the ray to test
  31414. * @returns true is the passed ray intersects the submesh bounding box
  31415. */
  31416. canIntersects(ray: Ray): boolean;
  31417. /**
  31418. * Intersects current submesh with a ray
  31419. * @param ray defines the ray to test
  31420. * @param positions defines mesh's positions array
  31421. * @param indices defines mesh's indices array
  31422. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31423. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31424. * @returns intersection info or null if no intersection
  31425. */
  31426. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31427. /** @hidden */
  31428. private _intersectLines;
  31429. /** @hidden */
  31430. private _intersectUnIndexedLines;
  31431. /** @hidden */
  31432. private _intersectTriangles;
  31433. /** @hidden */
  31434. private _intersectUnIndexedTriangles;
  31435. /** @hidden */
  31436. _rebuild(): void;
  31437. /**
  31438. * Creates a new submesh from the passed mesh
  31439. * @param newMesh defines the new hosting mesh
  31440. * @param newRenderingMesh defines an optional rendering mesh
  31441. * @returns the new submesh
  31442. */
  31443. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31444. /**
  31445. * Release associated resources
  31446. */
  31447. dispose(): void;
  31448. /**
  31449. * Gets the class name
  31450. * @returns the string "SubMesh".
  31451. */
  31452. getClassName(): string;
  31453. /**
  31454. * Creates a new submesh from indices data
  31455. * @param materialIndex the index of the main mesh material
  31456. * @param startIndex the index where to start the copy in the mesh indices array
  31457. * @param indexCount the number of indices to copy then from the startIndex
  31458. * @param mesh the main mesh to create the submesh from
  31459. * @param renderingMesh the optional rendering mesh
  31460. * @returns a new submesh
  31461. */
  31462. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31463. }
  31464. }
  31465. declare module "babylonjs/Loading/sceneLoaderFlags" {
  31466. /**
  31467. * Class used to represent data loading progression
  31468. */
  31469. export class SceneLoaderFlags {
  31470. private static _ForceFullSceneLoadingForIncremental;
  31471. private static _ShowLoadingScreen;
  31472. private static _CleanBoneMatrixWeights;
  31473. private static _loggingLevel;
  31474. /**
  31475. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31476. */
  31477. static get ForceFullSceneLoadingForIncremental(): boolean;
  31478. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31479. /**
  31480. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31481. */
  31482. static get ShowLoadingScreen(): boolean;
  31483. static set ShowLoadingScreen(value: boolean);
  31484. /**
  31485. * Defines the current logging level (while loading the scene)
  31486. * @ignorenaming
  31487. */
  31488. static get loggingLevel(): number;
  31489. static set loggingLevel(value: number);
  31490. /**
  31491. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31492. */
  31493. static get CleanBoneMatrixWeights(): boolean;
  31494. static set CleanBoneMatrixWeights(value: boolean);
  31495. }
  31496. }
  31497. declare module "babylonjs/Meshes/geometry" {
  31498. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  31499. import { Scene } from "babylonjs/scene";
  31500. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31501. import { Engine } from "babylonjs/Engines/engine";
  31502. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  31503. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31504. import { Effect } from "babylonjs/Materials/effect";
  31505. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31506. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31507. import { Mesh } from "babylonjs/Meshes/mesh";
  31508. /**
  31509. * Class used to store geometry data (vertex buffers + index buffer)
  31510. */
  31511. export class Geometry implements IGetSetVerticesData {
  31512. /**
  31513. * Gets or sets the ID of the geometry
  31514. */
  31515. id: string;
  31516. /**
  31517. * Gets or sets the unique ID of the geometry
  31518. */
  31519. uniqueId: number;
  31520. /**
  31521. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31522. */
  31523. delayLoadState: number;
  31524. /**
  31525. * Gets the file containing the data to load when running in delay load state
  31526. */
  31527. delayLoadingFile: Nullable<string>;
  31528. /**
  31529. * Callback called when the geometry is updated
  31530. */
  31531. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31532. private _scene;
  31533. private _engine;
  31534. private _meshes;
  31535. private _totalVertices;
  31536. /** @hidden */
  31537. _indices: IndicesArray;
  31538. /** @hidden */
  31539. _vertexBuffers: {
  31540. [key: string]: VertexBuffer;
  31541. };
  31542. private _isDisposed;
  31543. private _extend;
  31544. private _boundingBias;
  31545. /** @hidden */
  31546. _delayInfo: Array<string>;
  31547. private _indexBuffer;
  31548. private _indexBufferIsUpdatable;
  31549. /** @hidden */
  31550. _boundingInfo: Nullable<BoundingInfo>;
  31551. /** @hidden */
  31552. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31553. /** @hidden */
  31554. _softwareSkinningFrameId: number;
  31555. private _vertexArrayObjects;
  31556. private _updatable;
  31557. /** @hidden */
  31558. _positions: Nullable<Vector3[]>;
  31559. private _positionsCache;
  31560. /**
  31561. * 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
  31562. */
  31563. get boundingBias(): Vector2;
  31564. /**
  31565. * 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
  31566. */
  31567. set boundingBias(value: Vector2);
  31568. /**
  31569. * Static function used to attach a new empty geometry to a mesh
  31570. * @param mesh defines the mesh to attach the geometry to
  31571. * @returns the new Geometry
  31572. */
  31573. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31574. /** Get the list of meshes using this geometry */
  31575. get meshes(): Mesh[];
  31576. /**
  31577. * 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
  31578. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31579. */
  31580. useBoundingInfoFromGeometry: boolean;
  31581. /**
  31582. * Creates a new geometry
  31583. * @param id defines the unique ID
  31584. * @param scene defines the hosting scene
  31585. * @param vertexData defines the VertexData used to get geometry data
  31586. * @param updatable defines if geometry must be updatable (false by default)
  31587. * @param mesh defines the mesh that will be associated with the geometry
  31588. */
  31589. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31590. /**
  31591. * Gets the current extend of the geometry
  31592. */
  31593. get extend(): {
  31594. minimum: Vector3;
  31595. maximum: Vector3;
  31596. };
  31597. /**
  31598. * Gets the hosting scene
  31599. * @returns the hosting Scene
  31600. */
  31601. getScene(): Scene;
  31602. /**
  31603. * Gets the hosting engine
  31604. * @returns the hosting Engine
  31605. */
  31606. getEngine(): Engine;
  31607. /**
  31608. * Defines if the geometry is ready to use
  31609. * @returns true if the geometry is ready to be used
  31610. */
  31611. isReady(): boolean;
  31612. /**
  31613. * Gets a value indicating that the geometry should not be serialized
  31614. */
  31615. get doNotSerialize(): boolean;
  31616. /** @hidden */
  31617. _rebuild(): void;
  31618. /**
  31619. * Affects all geometry data in one call
  31620. * @param vertexData defines the geometry data
  31621. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31622. */
  31623. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31624. /**
  31625. * Set specific vertex data
  31626. * @param kind defines the data kind (Position, normal, etc...)
  31627. * @param data defines the vertex data to use
  31628. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31629. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31630. */
  31631. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31632. /**
  31633. * Removes a specific vertex data
  31634. * @param kind defines the data kind (Position, normal, etc...)
  31635. */
  31636. removeVerticesData(kind: string): void;
  31637. /**
  31638. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31639. * @param buffer defines the vertex buffer to use
  31640. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31641. */
  31642. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31643. /**
  31644. * Update a specific vertex buffer
  31645. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31646. * It will do nothing if the buffer is not updatable
  31647. * @param kind defines the data kind (Position, normal, etc...)
  31648. * @param data defines the data to use
  31649. * @param offset defines the offset in the target buffer where to store the data
  31650. * @param useBytes set to true if the offset is in bytes
  31651. */
  31652. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31653. /**
  31654. * Update a specific vertex buffer
  31655. * This function will create a new buffer if the current one is not updatable
  31656. * @param kind defines the data kind (Position, normal, etc...)
  31657. * @param data defines the data to use
  31658. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31659. */
  31660. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31661. private _updateBoundingInfo;
  31662. /** @hidden */
  31663. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  31664. /**
  31665. * Gets total number of vertices
  31666. * @returns the total number of vertices
  31667. */
  31668. getTotalVertices(): number;
  31669. /**
  31670. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31671. * @param kind defines the data kind (Position, normal, etc...)
  31672. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31673. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31674. * @returns a float array containing vertex data
  31675. */
  31676. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31677. /**
  31678. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31679. * @param kind defines the data kind (Position, normal, etc...)
  31680. * @returns true if the vertex buffer with the specified kind is updatable
  31681. */
  31682. isVertexBufferUpdatable(kind: string): boolean;
  31683. /**
  31684. * Gets a specific vertex buffer
  31685. * @param kind defines the data kind (Position, normal, etc...)
  31686. * @returns a VertexBuffer
  31687. */
  31688. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31689. /**
  31690. * Returns all vertex buffers
  31691. * @return an object holding all vertex buffers indexed by kind
  31692. */
  31693. getVertexBuffers(): Nullable<{
  31694. [key: string]: VertexBuffer;
  31695. }>;
  31696. /**
  31697. * Gets a boolean indicating if specific vertex buffer is present
  31698. * @param kind defines the data kind (Position, normal, etc...)
  31699. * @returns true if data is present
  31700. */
  31701. isVerticesDataPresent(kind: string): boolean;
  31702. /**
  31703. * Gets a list of all attached data kinds (Position, normal, etc...)
  31704. * @returns a list of string containing all kinds
  31705. */
  31706. getVerticesDataKinds(): string[];
  31707. /**
  31708. * Update index buffer
  31709. * @param indices defines the indices to store in the index buffer
  31710. * @param offset defines the offset in the target buffer where to store the data
  31711. * @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)
  31712. */
  31713. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31714. /**
  31715. * Creates a new index buffer
  31716. * @param indices defines the indices to store in the index buffer
  31717. * @param totalVertices defines the total number of vertices (could be null)
  31718. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31719. */
  31720. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31721. /**
  31722. * Return the total number of indices
  31723. * @returns the total number of indices
  31724. */
  31725. getTotalIndices(): number;
  31726. /**
  31727. * Gets the index buffer array
  31728. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31729. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31730. * @returns the index buffer array
  31731. */
  31732. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31733. /**
  31734. * Gets the index buffer
  31735. * @return the index buffer
  31736. */
  31737. getIndexBuffer(): Nullable<DataBuffer>;
  31738. /** @hidden */
  31739. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31740. /**
  31741. * Release the associated resources for a specific mesh
  31742. * @param mesh defines the source mesh
  31743. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31744. */
  31745. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31746. /**
  31747. * Apply current geometry to a given mesh
  31748. * @param mesh defines the mesh to apply geometry to
  31749. */
  31750. applyToMesh(mesh: Mesh): void;
  31751. private _updateExtend;
  31752. private _applyToMesh;
  31753. private notifyUpdate;
  31754. /**
  31755. * Load the geometry if it was flagged as delay loaded
  31756. * @param scene defines the hosting scene
  31757. * @param onLoaded defines a callback called when the geometry is loaded
  31758. */
  31759. load(scene: Scene, onLoaded?: () => void): void;
  31760. private _queueLoad;
  31761. /**
  31762. * Invert the geometry to move from a right handed system to a left handed one.
  31763. */
  31764. toLeftHanded(): void;
  31765. /** @hidden */
  31766. _resetPointsArrayCache(): void;
  31767. /** @hidden */
  31768. _generatePointsArray(): boolean;
  31769. /**
  31770. * Gets a value indicating if the geometry is disposed
  31771. * @returns true if the geometry was disposed
  31772. */
  31773. isDisposed(): boolean;
  31774. private _disposeVertexArrayObjects;
  31775. /**
  31776. * Free all associated resources
  31777. */
  31778. dispose(): void;
  31779. /**
  31780. * Clone the current geometry into a new geometry
  31781. * @param id defines the unique ID of the new geometry
  31782. * @returns a new geometry object
  31783. */
  31784. copy(id: string): Geometry;
  31785. /**
  31786. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31787. * @return a JSON representation of the current geometry data (without the vertices data)
  31788. */
  31789. serialize(): any;
  31790. private toNumberArray;
  31791. /**
  31792. * Serialize all vertices data into a JSON oject
  31793. * @returns a JSON representation of the current geometry data
  31794. */
  31795. serializeVerticeData(): any;
  31796. /**
  31797. * Extracts a clone of a mesh geometry
  31798. * @param mesh defines the source mesh
  31799. * @param id defines the unique ID of the new geometry object
  31800. * @returns the new geometry object
  31801. */
  31802. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31803. /**
  31804. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31805. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31806. * Be aware Math.random() could cause collisions, but:
  31807. * "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"
  31808. * @returns a string containing a new GUID
  31809. */
  31810. static RandomId(): string;
  31811. /** @hidden */
  31812. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31813. private static _CleanMatricesWeights;
  31814. /**
  31815. * Create a new geometry from persisted data (Using .babylon file format)
  31816. * @param parsedVertexData defines the persisted data
  31817. * @param scene defines the hosting scene
  31818. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31819. * @returns the new geometry object
  31820. */
  31821. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31822. }
  31823. }
  31824. declare module "babylonjs/Morph/morphTarget" {
  31825. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31826. import { Observable } from "babylonjs/Misc/observable";
  31827. import { Nullable, FloatArray } from "babylonjs/types";
  31828. import { Scene } from "babylonjs/scene";
  31829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31830. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31831. /**
  31832. * Defines a target to use with MorphTargetManager
  31833. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31834. */
  31835. export class MorphTarget implements IAnimatable {
  31836. /** defines the name of the target */
  31837. name: string;
  31838. /**
  31839. * Gets or sets the list of animations
  31840. */
  31841. animations: import("babylonjs/Animations/animation").Animation[];
  31842. private _scene;
  31843. private _positions;
  31844. private _normals;
  31845. private _tangents;
  31846. private _uvs;
  31847. private _influence;
  31848. private _uniqueId;
  31849. /**
  31850. * Observable raised when the influence changes
  31851. */
  31852. onInfluenceChanged: Observable<boolean>;
  31853. /** @hidden */
  31854. _onDataLayoutChanged: Observable<void>;
  31855. /**
  31856. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31857. */
  31858. get influence(): number;
  31859. set influence(influence: number);
  31860. /**
  31861. * Gets or sets the id of the morph Target
  31862. */
  31863. id: string;
  31864. private _animationPropertiesOverride;
  31865. /**
  31866. * Gets or sets the animation properties override
  31867. */
  31868. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31869. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31870. /**
  31871. * Creates a new MorphTarget
  31872. * @param name defines the name of the target
  31873. * @param influence defines the influence to use
  31874. * @param scene defines the scene the morphtarget belongs to
  31875. */
  31876. constructor(
  31877. /** defines the name of the target */
  31878. name: string, influence?: number, scene?: Nullable<Scene>);
  31879. /**
  31880. * Gets the unique ID of this manager
  31881. */
  31882. get uniqueId(): number;
  31883. /**
  31884. * Gets a boolean defining if the target contains position data
  31885. */
  31886. get hasPositions(): boolean;
  31887. /**
  31888. * Gets a boolean defining if the target contains normal data
  31889. */
  31890. get hasNormals(): boolean;
  31891. /**
  31892. * Gets a boolean defining if the target contains tangent data
  31893. */
  31894. get hasTangents(): boolean;
  31895. /**
  31896. * Gets a boolean defining if the target contains texture coordinates data
  31897. */
  31898. get hasUVs(): boolean;
  31899. /**
  31900. * Affects position data to this target
  31901. * @param data defines the position data to use
  31902. */
  31903. setPositions(data: Nullable<FloatArray>): void;
  31904. /**
  31905. * Gets the position data stored in this target
  31906. * @returns a FloatArray containing the position data (or null if not present)
  31907. */
  31908. getPositions(): Nullable<FloatArray>;
  31909. /**
  31910. * Affects normal data to this target
  31911. * @param data defines the normal data to use
  31912. */
  31913. setNormals(data: Nullable<FloatArray>): void;
  31914. /**
  31915. * Gets the normal data stored in this target
  31916. * @returns a FloatArray containing the normal data (or null if not present)
  31917. */
  31918. getNormals(): Nullable<FloatArray>;
  31919. /**
  31920. * Affects tangent data to this target
  31921. * @param data defines the tangent data to use
  31922. */
  31923. setTangents(data: Nullable<FloatArray>): void;
  31924. /**
  31925. * Gets the tangent data stored in this target
  31926. * @returns a FloatArray containing the tangent data (or null if not present)
  31927. */
  31928. getTangents(): Nullable<FloatArray>;
  31929. /**
  31930. * Affects texture coordinates data to this target
  31931. * @param data defines the texture coordinates data to use
  31932. */
  31933. setUVs(data: Nullable<FloatArray>): void;
  31934. /**
  31935. * Gets the texture coordinates data stored in this target
  31936. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31937. */
  31938. getUVs(): Nullable<FloatArray>;
  31939. /**
  31940. * Clone the current target
  31941. * @returns a new MorphTarget
  31942. */
  31943. clone(): MorphTarget;
  31944. /**
  31945. * Serializes the current target into a Serialization object
  31946. * @returns the serialized object
  31947. */
  31948. serialize(): any;
  31949. /**
  31950. * Returns the string "MorphTarget"
  31951. * @returns "MorphTarget"
  31952. */
  31953. getClassName(): string;
  31954. /**
  31955. * Creates a new target from serialized data
  31956. * @param serializationObject defines the serialized data to use
  31957. * @returns a new MorphTarget
  31958. */
  31959. static Parse(serializationObject: any): MorphTarget;
  31960. /**
  31961. * Creates a MorphTarget from mesh data
  31962. * @param mesh defines the source mesh
  31963. * @param name defines the name to use for the new target
  31964. * @param influence defines the influence to attach to the target
  31965. * @returns a new MorphTarget
  31966. */
  31967. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  31968. }
  31969. }
  31970. declare module "babylonjs/Morph/morphTargetManager" {
  31971. import { Nullable } from "babylonjs/types";
  31972. import { Scene } from "babylonjs/scene";
  31973. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31974. /**
  31975. * This class is used to deform meshes using morphing between different targets
  31976. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31977. */
  31978. export class MorphTargetManager {
  31979. private _targets;
  31980. private _targetInfluenceChangedObservers;
  31981. private _targetDataLayoutChangedObservers;
  31982. private _activeTargets;
  31983. private _scene;
  31984. private _influences;
  31985. private _supportsNormals;
  31986. private _supportsTangents;
  31987. private _supportsUVs;
  31988. private _vertexCount;
  31989. private _uniqueId;
  31990. private _tempInfluences;
  31991. /**
  31992. * Gets or sets a boolean indicating if normals must be morphed
  31993. */
  31994. enableNormalMorphing: boolean;
  31995. /**
  31996. * Gets or sets a boolean indicating if tangents must be morphed
  31997. */
  31998. enableTangentMorphing: boolean;
  31999. /**
  32000. * Gets or sets a boolean indicating if UV must be morphed
  32001. */
  32002. enableUVMorphing: boolean;
  32003. /**
  32004. * Creates a new MorphTargetManager
  32005. * @param scene defines the current scene
  32006. */
  32007. constructor(scene?: Nullable<Scene>);
  32008. /**
  32009. * Gets the unique ID of this manager
  32010. */
  32011. get uniqueId(): number;
  32012. /**
  32013. * Gets the number of vertices handled by this manager
  32014. */
  32015. get vertexCount(): number;
  32016. /**
  32017. * Gets a boolean indicating if this manager supports morphing of normals
  32018. */
  32019. get supportsNormals(): boolean;
  32020. /**
  32021. * Gets a boolean indicating if this manager supports morphing of tangents
  32022. */
  32023. get supportsTangents(): boolean;
  32024. /**
  32025. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32026. */
  32027. get supportsUVs(): boolean;
  32028. /**
  32029. * Gets the number of targets stored in this manager
  32030. */
  32031. get numTargets(): number;
  32032. /**
  32033. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32034. */
  32035. get numInfluencers(): number;
  32036. /**
  32037. * Gets the list of influences (one per target)
  32038. */
  32039. get influences(): Float32Array;
  32040. /**
  32041. * Gets the active target at specified index. An active target is a target with an influence > 0
  32042. * @param index defines the index to check
  32043. * @returns the requested target
  32044. */
  32045. getActiveTarget(index: number): MorphTarget;
  32046. /**
  32047. * Gets the target at specified index
  32048. * @param index defines the index to check
  32049. * @returns the requested target
  32050. */
  32051. getTarget(index: number): MorphTarget;
  32052. /**
  32053. * Add a new target to this manager
  32054. * @param target defines the target to add
  32055. */
  32056. addTarget(target: MorphTarget): void;
  32057. /**
  32058. * Removes a target from the manager
  32059. * @param target defines the target to remove
  32060. */
  32061. removeTarget(target: MorphTarget): void;
  32062. /**
  32063. * Clone the current manager
  32064. * @returns a new MorphTargetManager
  32065. */
  32066. clone(): MorphTargetManager;
  32067. /**
  32068. * Serializes the current manager into a Serialization object
  32069. * @returns the serialized object
  32070. */
  32071. serialize(): any;
  32072. private _syncActiveTargets;
  32073. /**
  32074. * Syncrhonize the targets with all the meshes using this morph target manager
  32075. */
  32076. synchronize(): void;
  32077. /**
  32078. * Creates a new MorphTargetManager from serialized data
  32079. * @param serializationObject defines the serialized data
  32080. * @param scene defines the hosting scene
  32081. * @returns the new MorphTargetManager
  32082. */
  32083. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32084. }
  32085. }
  32086. declare module "babylonjs/Meshes/meshLODLevel" {
  32087. import { Mesh } from "babylonjs/Meshes/mesh";
  32088. import { Nullable } from "babylonjs/types";
  32089. /**
  32090. * Class used to represent a specific level of detail of a mesh
  32091. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32092. */
  32093. export class MeshLODLevel {
  32094. /** Defines the distance where this level should start being displayed */
  32095. distance: number;
  32096. /** Defines the mesh to use to render this level */
  32097. mesh: Nullable<Mesh>;
  32098. /**
  32099. * Creates a new LOD level
  32100. * @param distance defines the distance where this level should star being displayed
  32101. * @param mesh defines the mesh to use to render this level
  32102. */
  32103. constructor(
  32104. /** Defines the distance where this level should start being displayed */
  32105. distance: number,
  32106. /** Defines the mesh to use to render this level */
  32107. mesh: Nullable<Mesh>);
  32108. }
  32109. }
  32110. declare module "babylonjs/Misc/canvasGenerator" {
  32111. /**
  32112. * Helper class used to generate a canvas to manipulate images
  32113. */
  32114. export class CanvasGenerator {
  32115. /**
  32116. * Create a new canvas (or offscreen canvas depending on the context)
  32117. * @param width defines the expected width
  32118. * @param height defines the expected height
  32119. * @return a new canvas or offscreen canvas
  32120. */
  32121. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32122. }
  32123. }
  32124. declare module "babylonjs/Meshes/groundMesh" {
  32125. import { Scene } from "babylonjs/scene";
  32126. import { Vector3 } from "babylonjs/Maths/math.vector";
  32127. import { Mesh } from "babylonjs/Meshes/mesh";
  32128. /**
  32129. * Mesh representing the gorund
  32130. */
  32131. export class GroundMesh extends Mesh {
  32132. /** If octree should be generated */
  32133. generateOctree: boolean;
  32134. private _heightQuads;
  32135. /** @hidden */
  32136. _subdivisionsX: number;
  32137. /** @hidden */
  32138. _subdivisionsY: number;
  32139. /** @hidden */
  32140. _width: number;
  32141. /** @hidden */
  32142. _height: number;
  32143. /** @hidden */
  32144. _minX: number;
  32145. /** @hidden */
  32146. _maxX: number;
  32147. /** @hidden */
  32148. _minZ: number;
  32149. /** @hidden */
  32150. _maxZ: number;
  32151. constructor(name: string, scene: Scene);
  32152. /**
  32153. * "GroundMesh"
  32154. * @returns "GroundMesh"
  32155. */
  32156. getClassName(): string;
  32157. /**
  32158. * The minimum of x and y subdivisions
  32159. */
  32160. get subdivisions(): number;
  32161. /**
  32162. * X subdivisions
  32163. */
  32164. get subdivisionsX(): number;
  32165. /**
  32166. * Y subdivisions
  32167. */
  32168. get subdivisionsY(): number;
  32169. /**
  32170. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32171. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32172. * @param chunksCount the number of subdivisions for x and y
  32173. * @param octreeBlocksSize (Default: 32)
  32174. */
  32175. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32176. /**
  32177. * Returns a height (y) value in the Worl system :
  32178. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32179. * @param x x coordinate
  32180. * @param z z coordinate
  32181. * @returns the ground y position if (x, z) are outside the ground surface.
  32182. */
  32183. getHeightAtCoordinates(x: number, z: number): number;
  32184. /**
  32185. * Returns a normalized vector (Vector3) orthogonal to the ground
  32186. * at the ground coordinates (x, z) expressed in the World system.
  32187. * @param x x coordinate
  32188. * @param z z coordinate
  32189. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32190. */
  32191. getNormalAtCoordinates(x: number, z: number): Vector3;
  32192. /**
  32193. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32194. * at the ground coordinates (x, z) expressed in the World system.
  32195. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  32196. * @param x x coordinate
  32197. * @param z z coordinate
  32198. * @param ref vector to store the result
  32199. * @returns the GroundMesh.
  32200. */
  32201. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32202. /**
  32203. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32204. * if the ground has been updated.
  32205. * This can be used in the render loop.
  32206. * @returns the GroundMesh.
  32207. */
  32208. updateCoordinateHeights(): GroundMesh;
  32209. private _getFacetAt;
  32210. private _initHeightQuads;
  32211. private _computeHeightQuads;
  32212. /**
  32213. * Serializes this ground mesh
  32214. * @param serializationObject object to write serialization to
  32215. */
  32216. serialize(serializationObject: any): void;
  32217. /**
  32218. * Parses a serialized ground mesh
  32219. * @param parsedMesh the serialized mesh
  32220. * @param scene the scene to create the ground mesh in
  32221. * @returns the created ground mesh
  32222. */
  32223. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32224. }
  32225. }
  32226. declare module "babylonjs/Physics/physicsJoint" {
  32227. import { Vector3 } from "babylonjs/Maths/math.vector";
  32228. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  32229. /**
  32230. * Interface for Physics-Joint data
  32231. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32232. */
  32233. export interface PhysicsJointData {
  32234. /**
  32235. * The main pivot of the joint
  32236. */
  32237. mainPivot?: Vector3;
  32238. /**
  32239. * The connected pivot of the joint
  32240. */
  32241. connectedPivot?: Vector3;
  32242. /**
  32243. * The main axis of the joint
  32244. */
  32245. mainAxis?: Vector3;
  32246. /**
  32247. * The connected axis of the joint
  32248. */
  32249. connectedAxis?: Vector3;
  32250. /**
  32251. * The collision of the joint
  32252. */
  32253. collision?: boolean;
  32254. /**
  32255. * Native Oimo/Cannon/Energy data
  32256. */
  32257. nativeParams?: any;
  32258. }
  32259. /**
  32260. * This is a holder class for the physics joint created by the physics plugin
  32261. * It holds a set of functions to control the underlying joint
  32262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32263. */
  32264. export class PhysicsJoint {
  32265. /**
  32266. * The type of the physics joint
  32267. */
  32268. type: number;
  32269. /**
  32270. * The data for the physics joint
  32271. */
  32272. jointData: PhysicsJointData;
  32273. private _physicsJoint;
  32274. protected _physicsPlugin: IPhysicsEnginePlugin;
  32275. /**
  32276. * Initializes the physics joint
  32277. * @param type The type of the physics joint
  32278. * @param jointData The data for the physics joint
  32279. */
  32280. constructor(
  32281. /**
  32282. * The type of the physics joint
  32283. */
  32284. type: number,
  32285. /**
  32286. * The data for the physics joint
  32287. */
  32288. jointData: PhysicsJointData);
  32289. /**
  32290. * Gets the physics joint
  32291. */
  32292. get physicsJoint(): any;
  32293. /**
  32294. * Sets the physics joint
  32295. */
  32296. set physicsJoint(newJoint: any);
  32297. /**
  32298. * Sets the physics plugin
  32299. */
  32300. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32301. /**
  32302. * Execute a function that is physics-plugin specific.
  32303. * @param {Function} func the function that will be executed.
  32304. * It accepts two parameters: the physics world and the physics joint
  32305. */
  32306. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32307. /**
  32308. * Distance-Joint type
  32309. */
  32310. static DistanceJoint: number;
  32311. /**
  32312. * Hinge-Joint type
  32313. */
  32314. static HingeJoint: number;
  32315. /**
  32316. * Ball-and-Socket joint type
  32317. */
  32318. static BallAndSocketJoint: number;
  32319. /**
  32320. * Wheel-Joint type
  32321. */
  32322. static WheelJoint: number;
  32323. /**
  32324. * Slider-Joint type
  32325. */
  32326. static SliderJoint: number;
  32327. /**
  32328. * Prismatic-Joint type
  32329. */
  32330. static PrismaticJoint: number;
  32331. /**
  32332. * Universal-Joint type
  32333. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32334. */
  32335. static UniversalJoint: number;
  32336. /**
  32337. * Hinge-Joint 2 type
  32338. */
  32339. static Hinge2Joint: number;
  32340. /**
  32341. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32342. */
  32343. static PointToPointJoint: number;
  32344. /**
  32345. * Spring-Joint type
  32346. */
  32347. static SpringJoint: number;
  32348. /**
  32349. * Lock-Joint type
  32350. */
  32351. static LockJoint: number;
  32352. }
  32353. /**
  32354. * A class representing a physics distance joint
  32355. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32356. */
  32357. export class DistanceJoint extends PhysicsJoint {
  32358. /**
  32359. *
  32360. * @param jointData The data for the Distance-Joint
  32361. */
  32362. constructor(jointData: DistanceJointData);
  32363. /**
  32364. * Update the predefined distance.
  32365. * @param maxDistance The maximum preferred distance
  32366. * @param minDistance The minimum preferred distance
  32367. */
  32368. updateDistance(maxDistance: number, minDistance?: number): void;
  32369. }
  32370. /**
  32371. * Represents a Motor-Enabled Joint
  32372. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32373. */
  32374. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32375. /**
  32376. * Initializes the Motor-Enabled Joint
  32377. * @param type The type of the joint
  32378. * @param jointData The physica joint data for the joint
  32379. */
  32380. constructor(type: number, jointData: PhysicsJointData);
  32381. /**
  32382. * Set the motor values.
  32383. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32384. * @param force the force to apply
  32385. * @param maxForce max force for this motor.
  32386. */
  32387. setMotor(force?: number, maxForce?: number): void;
  32388. /**
  32389. * Set the motor's limits.
  32390. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32391. * @param upperLimit The upper limit of the motor
  32392. * @param lowerLimit The lower limit of the motor
  32393. */
  32394. setLimit(upperLimit: number, lowerLimit?: number): void;
  32395. }
  32396. /**
  32397. * This class represents a single physics Hinge-Joint
  32398. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32399. */
  32400. export class HingeJoint extends MotorEnabledJoint {
  32401. /**
  32402. * Initializes the Hinge-Joint
  32403. * @param jointData The joint data for the Hinge-Joint
  32404. */
  32405. constructor(jointData: PhysicsJointData);
  32406. /**
  32407. * Set the motor values.
  32408. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32409. * @param {number} force the force to apply
  32410. * @param {number} maxForce max force for this motor.
  32411. */
  32412. setMotor(force?: number, maxForce?: number): void;
  32413. /**
  32414. * Set the motor's limits.
  32415. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32416. * @param upperLimit The upper limit of the motor
  32417. * @param lowerLimit The lower limit of the motor
  32418. */
  32419. setLimit(upperLimit: number, lowerLimit?: number): void;
  32420. }
  32421. /**
  32422. * This class represents a dual hinge physics joint (same as wheel joint)
  32423. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32424. */
  32425. export class Hinge2Joint extends MotorEnabledJoint {
  32426. /**
  32427. * Initializes the Hinge2-Joint
  32428. * @param jointData The joint data for the Hinge2-Joint
  32429. */
  32430. constructor(jointData: PhysicsJointData);
  32431. /**
  32432. * Set the motor values.
  32433. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32434. * @param {number} targetSpeed the speed the motor is to reach
  32435. * @param {number} maxForce max force for this motor.
  32436. * @param {motorIndex} the motor's index, 0 or 1.
  32437. */
  32438. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32439. /**
  32440. * Set the motor limits.
  32441. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32442. * @param {number} upperLimit the upper limit
  32443. * @param {number} lowerLimit lower limit
  32444. * @param {motorIndex} the motor's index, 0 or 1.
  32445. */
  32446. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32447. }
  32448. /**
  32449. * Interface for a motor enabled joint
  32450. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32451. */
  32452. export interface IMotorEnabledJoint {
  32453. /**
  32454. * Physics joint
  32455. */
  32456. physicsJoint: any;
  32457. /**
  32458. * Sets the motor of the motor-enabled joint
  32459. * @param force The force of the motor
  32460. * @param maxForce The maximum force of the motor
  32461. * @param motorIndex The index of the motor
  32462. */
  32463. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32464. /**
  32465. * Sets the limit of the motor
  32466. * @param upperLimit The upper limit of the motor
  32467. * @param lowerLimit The lower limit of the motor
  32468. * @param motorIndex The index of the motor
  32469. */
  32470. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32471. }
  32472. /**
  32473. * Joint data for a Distance-Joint
  32474. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32475. */
  32476. export interface DistanceJointData extends PhysicsJointData {
  32477. /**
  32478. * Max distance the 2 joint objects can be apart
  32479. */
  32480. maxDistance: number;
  32481. }
  32482. /**
  32483. * Joint data from a spring joint
  32484. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32485. */
  32486. export interface SpringJointData extends PhysicsJointData {
  32487. /**
  32488. * Length of the spring
  32489. */
  32490. length: number;
  32491. /**
  32492. * Stiffness of the spring
  32493. */
  32494. stiffness: number;
  32495. /**
  32496. * Damping of the spring
  32497. */
  32498. damping: number;
  32499. /** this callback will be called when applying the force to the impostors. */
  32500. forceApplicationCallback: () => void;
  32501. }
  32502. }
  32503. declare module "babylonjs/Physics/physicsRaycastResult" {
  32504. import { Vector3 } from "babylonjs/Maths/math.vector";
  32505. /**
  32506. * Holds the data for the raycast result
  32507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32508. */
  32509. export class PhysicsRaycastResult {
  32510. private _hasHit;
  32511. private _hitDistance;
  32512. private _hitNormalWorld;
  32513. private _hitPointWorld;
  32514. private _rayFromWorld;
  32515. private _rayToWorld;
  32516. /**
  32517. * Gets if there was a hit
  32518. */
  32519. get hasHit(): boolean;
  32520. /**
  32521. * Gets the distance from the hit
  32522. */
  32523. get hitDistance(): number;
  32524. /**
  32525. * Gets the hit normal/direction in the world
  32526. */
  32527. get hitNormalWorld(): Vector3;
  32528. /**
  32529. * Gets the hit point in the world
  32530. */
  32531. get hitPointWorld(): Vector3;
  32532. /**
  32533. * Gets the ray "start point" of the ray in the world
  32534. */
  32535. get rayFromWorld(): Vector3;
  32536. /**
  32537. * Gets the ray "end point" of the ray in the world
  32538. */
  32539. get rayToWorld(): Vector3;
  32540. /**
  32541. * Sets the hit data (normal & point in world space)
  32542. * @param hitNormalWorld defines the normal in world space
  32543. * @param hitPointWorld defines the point in world space
  32544. */
  32545. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32546. /**
  32547. * Sets the distance from the start point to the hit point
  32548. * @param distance
  32549. */
  32550. setHitDistance(distance: number): void;
  32551. /**
  32552. * Calculates the distance manually
  32553. */
  32554. calculateHitDistance(): void;
  32555. /**
  32556. * Resets all the values to default
  32557. * @param from The from point on world space
  32558. * @param to The to point on world space
  32559. */
  32560. reset(from?: Vector3, to?: Vector3): void;
  32561. }
  32562. /**
  32563. * Interface for the size containing width and height
  32564. */
  32565. interface IXYZ {
  32566. /**
  32567. * X
  32568. */
  32569. x: number;
  32570. /**
  32571. * Y
  32572. */
  32573. y: number;
  32574. /**
  32575. * Z
  32576. */
  32577. z: number;
  32578. }
  32579. }
  32580. declare module "babylonjs/Physics/IPhysicsEngine" {
  32581. import { Nullable } from "babylonjs/types";
  32582. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  32583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32584. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  32585. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  32586. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  32587. /**
  32588. * Interface used to describe a physics joint
  32589. */
  32590. export interface PhysicsImpostorJoint {
  32591. /** Defines the main impostor to which the joint is linked */
  32592. mainImpostor: PhysicsImpostor;
  32593. /** Defines the impostor that is connected to the main impostor using this joint */
  32594. connectedImpostor: PhysicsImpostor;
  32595. /** Defines the joint itself */
  32596. joint: PhysicsJoint;
  32597. }
  32598. /** @hidden */
  32599. export interface IPhysicsEnginePlugin {
  32600. world: any;
  32601. name: string;
  32602. setGravity(gravity: Vector3): void;
  32603. setTimeStep(timeStep: number): void;
  32604. getTimeStep(): number;
  32605. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32606. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32607. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32608. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32609. removePhysicsBody(impostor: PhysicsImpostor): void;
  32610. generateJoint(joint: PhysicsImpostorJoint): void;
  32611. removeJoint(joint: PhysicsImpostorJoint): void;
  32612. isSupported(): boolean;
  32613. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32614. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32615. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32616. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32617. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32618. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32619. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32620. getBodyMass(impostor: PhysicsImpostor): number;
  32621. getBodyFriction(impostor: PhysicsImpostor): number;
  32622. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32623. getBodyRestitution(impostor: PhysicsImpostor): number;
  32624. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32625. getBodyPressure?(impostor: PhysicsImpostor): number;
  32626. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32627. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32628. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32629. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32630. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32631. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32632. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32633. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32634. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32635. sleepBody(impostor: PhysicsImpostor): void;
  32636. wakeUpBody(impostor: PhysicsImpostor): void;
  32637. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32638. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32639. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32640. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32641. getRadius(impostor: PhysicsImpostor): number;
  32642. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32643. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32644. dispose(): void;
  32645. }
  32646. /**
  32647. * Interface used to define a physics engine
  32648. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32649. */
  32650. export interface IPhysicsEngine {
  32651. /**
  32652. * Gets the gravity vector used by the simulation
  32653. */
  32654. gravity: Vector3;
  32655. /**
  32656. * Sets the gravity vector used by the simulation
  32657. * @param gravity defines the gravity vector to use
  32658. */
  32659. setGravity(gravity: Vector3): void;
  32660. /**
  32661. * Set the time step of the physics engine.
  32662. * Default is 1/60.
  32663. * To slow it down, enter 1/600 for example.
  32664. * To speed it up, 1/30
  32665. * @param newTimeStep the new timestep to apply to this world.
  32666. */
  32667. setTimeStep(newTimeStep: number): void;
  32668. /**
  32669. * Get the time step of the physics engine.
  32670. * @returns the current time step
  32671. */
  32672. getTimeStep(): number;
  32673. /**
  32674. * Set the sub time step of the physics engine.
  32675. * Default is 0 meaning there is no sub steps
  32676. * To increase physics resolution precision, set a small value (like 1 ms)
  32677. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32678. */
  32679. setSubTimeStep(subTimeStep: number): void;
  32680. /**
  32681. * Get the sub time step of the physics engine.
  32682. * @returns the current sub time step
  32683. */
  32684. getSubTimeStep(): number;
  32685. /**
  32686. * Release all resources
  32687. */
  32688. dispose(): void;
  32689. /**
  32690. * Gets the name of the current physics plugin
  32691. * @returns the name of the plugin
  32692. */
  32693. getPhysicsPluginName(): string;
  32694. /**
  32695. * Adding a new impostor for the impostor tracking.
  32696. * This will be done by the impostor itself.
  32697. * @param impostor the impostor to add
  32698. */
  32699. addImpostor(impostor: PhysicsImpostor): void;
  32700. /**
  32701. * Remove an impostor from the engine.
  32702. * This impostor and its mesh will not longer be updated by the physics engine.
  32703. * @param impostor the impostor to remove
  32704. */
  32705. removeImpostor(impostor: PhysicsImpostor): void;
  32706. /**
  32707. * Add a joint to the physics engine
  32708. * @param mainImpostor defines the main impostor to which the joint is added.
  32709. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32710. * @param joint defines the joint that will connect both impostors.
  32711. */
  32712. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32713. /**
  32714. * Removes a joint from the simulation
  32715. * @param mainImpostor defines the impostor used with the joint
  32716. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32717. * @param joint defines the joint to remove
  32718. */
  32719. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32720. /**
  32721. * Gets the current plugin used to run the simulation
  32722. * @returns current plugin
  32723. */
  32724. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32725. /**
  32726. * Gets the list of physic impostors
  32727. * @returns an array of PhysicsImpostor
  32728. */
  32729. getImpostors(): Array<PhysicsImpostor>;
  32730. /**
  32731. * Gets the impostor for a physics enabled object
  32732. * @param object defines the object impersonated by the impostor
  32733. * @returns the PhysicsImpostor or null if not found
  32734. */
  32735. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32736. /**
  32737. * Gets the impostor for a physics body object
  32738. * @param body defines physics body used by the impostor
  32739. * @returns the PhysicsImpostor or null if not found
  32740. */
  32741. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32742. /**
  32743. * Does a raycast in the physics world
  32744. * @param from when should the ray start?
  32745. * @param to when should the ray end?
  32746. * @returns PhysicsRaycastResult
  32747. */
  32748. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32749. /**
  32750. * Called by the scene. No need to call it.
  32751. * @param delta defines the timespam between frames
  32752. */
  32753. _step(delta: number): void;
  32754. }
  32755. }
  32756. declare module "babylonjs/Physics/physicsImpostor" {
  32757. import { Nullable, IndicesArray } from "babylonjs/types";
  32758. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  32759. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32761. import { Scene } from "babylonjs/scene";
  32762. import { Bone } from "babylonjs/Bones/bone";
  32763. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32764. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  32765. import { Space } from "babylonjs/Maths/math.axis";
  32766. /**
  32767. * The interface for the physics imposter parameters
  32768. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32769. */
  32770. export interface PhysicsImpostorParameters {
  32771. /**
  32772. * The mass of the physics imposter
  32773. */
  32774. mass: number;
  32775. /**
  32776. * The friction of the physics imposter
  32777. */
  32778. friction?: number;
  32779. /**
  32780. * The coefficient of restitution of the physics imposter
  32781. */
  32782. restitution?: number;
  32783. /**
  32784. * The native options of the physics imposter
  32785. */
  32786. nativeOptions?: any;
  32787. /**
  32788. * Specifies if the parent should be ignored
  32789. */
  32790. ignoreParent?: boolean;
  32791. /**
  32792. * Specifies if bi-directional transformations should be disabled
  32793. */
  32794. disableBidirectionalTransformation?: boolean;
  32795. /**
  32796. * The pressure inside the physics imposter, soft object only
  32797. */
  32798. pressure?: number;
  32799. /**
  32800. * The stiffness the physics imposter, soft object only
  32801. */
  32802. stiffness?: number;
  32803. /**
  32804. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32805. */
  32806. velocityIterations?: number;
  32807. /**
  32808. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32809. */
  32810. positionIterations?: number;
  32811. /**
  32812. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32813. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32814. * Add to fix multiple points
  32815. */
  32816. fixedPoints?: number;
  32817. /**
  32818. * The collision margin around a soft object
  32819. */
  32820. margin?: number;
  32821. /**
  32822. * The collision margin around a soft object
  32823. */
  32824. damping?: number;
  32825. /**
  32826. * The path for a rope based on an extrusion
  32827. */
  32828. path?: any;
  32829. /**
  32830. * The shape of an extrusion used for a rope based on an extrusion
  32831. */
  32832. shape?: any;
  32833. }
  32834. /**
  32835. * Interface for a physics-enabled object
  32836. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32837. */
  32838. export interface IPhysicsEnabledObject {
  32839. /**
  32840. * The position of the physics-enabled object
  32841. */
  32842. position: Vector3;
  32843. /**
  32844. * The rotation of the physics-enabled object
  32845. */
  32846. rotationQuaternion: Nullable<Quaternion>;
  32847. /**
  32848. * The scale of the physics-enabled object
  32849. */
  32850. scaling: Vector3;
  32851. /**
  32852. * The rotation of the physics-enabled object
  32853. */
  32854. rotation?: Vector3;
  32855. /**
  32856. * The parent of the physics-enabled object
  32857. */
  32858. parent?: any;
  32859. /**
  32860. * The bounding info of the physics-enabled object
  32861. * @returns The bounding info of the physics-enabled object
  32862. */
  32863. getBoundingInfo(): BoundingInfo;
  32864. /**
  32865. * Computes the world matrix
  32866. * @param force Specifies if the world matrix should be computed by force
  32867. * @returns A world matrix
  32868. */
  32869. computeWorldMatrix(force: boolean): Matrix;
  32870. /**
  32871. * Gets the world matrix
  32872. * @returns A world matrix
  32873. */
  32874. getWorldMatrix?(): Matrix;
  32875. /**
  32876. * Gets the child meshes
  32877. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32878. * @returns An array of abstract meshes
  32879. */
  32880. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32881. /**
  32882. * Gets the vertex data
  32883. * @param kind The type of vertex data
  32884. * @returns A nullable array of numbers, or a float32 array
  32885. */
  32886. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32887. /**
  32888. * Gets the indices from the mesh
  32889. * @returns A nullable array of index arrays
  32890. */
  32891. getIndices?(): Nullable<IndicesArray>;
  32892. /**
  32893. * Gets the scene from the mesh
  32894. * @returns the indices array or null
  32895. */
  32896. getScene?(): Scene;
  32897. /**
  32898. * Gets the absolute position from the mesh
  32899. * @returns the absolute position
  32900. */
  32901. getAbsolutePosition(): Vector3;
  32902. /**
  32903. * Gets the absolute pivot point from the mesh
  32904. * @returns the absolute pivot point
  32905. */
  32906. getAbsolutePivotPoint(): Vector3;
  32907. /**
  32908. * Rotates the mesh
  32909. * @param axis The axis of rotation
  32910. * @param amount The amount of rotation
  32911. * @param space The space of the rotation
  32912. * @returns The rotation transform node
  32913. */
  32914. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32915. /**
  32916. * Translates the mesh
  32917. * @param axis The axis of translation
  32918. * @param distance The distance of translation
  32919. * @param space The space of the translation
  32920. * @returns The transform node
  32921. */
  32922. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32923. /**
  32924. * Sets the absolute position of the mesh
  32925. * @param absolutePosition The absolute position of the mesh
  32926. * @returns The transform node
  32927. */
  32928. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32929. /**
  32930. * Gets the class name of the mesh
  32931. * @returns The class name
  32932. */
  32933. getClassName(): string;
  32934. }
  32935. /**
  32936. * Represents a physics imposter
  32937. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32938. */
  32939. export class PhysicsImpostor {
  32940. /**
  32941. * The physics-enabled object used as the physics imposter
  32942. */
  32943. object: IPhysicsEnabledObject;
  32944. /**
  32945. * The type of the physics imposter
  32946. */
  32947. type: number;
  32948. private _options;
  32949. private _scene?;
  32950. /**
  32951. * The default object size of the imposter
  32952. */
  32953. static DEFAULT_OBJECT_SIZE: Vector3;
  32954. /**
  32955. * The identity quaternion of the imposter
  32956. */
  32957. static IDENTITY_QUATERNION: Quaternion;
  32958. /** @hidden */
  32959. _pluginData: any;
  32960. private _physicsEngine;
  32961. private _physicsBody;
  32962. private _bodyUpdateRequired;
  32963. private _onBeforePhysicsStepCallbacks;
  32964. private _onAfterPhysicsStepCallbacks;
  32965. /** @hidden */
  32966. _onPhysicsCollideCallbacks: Array<{
  32967. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  32968. otherImpostors: Array<PhysicsImpostor>;
  32969. }>;
  32970. private _deltaPosition;
  32971. private _deltaRotation;
  32972. private _deltaRotationConjugated;
  32973. /** @hidden */
  32974. _isFromLine: boolean;
  32975. private _parent;
  32976. private _isDisposed;
  32977. private static _tmpVecs;
  32978. private static _tmpQuat;
  32979. /**
  32980. * Specifies if the physics imposter is disposed
  32981. */
  32982. get isDisposed(): boolean;
  32983. /**
  32984. * Gets the mass of the physics imposter
  32985. */
  32986. get mass(): number;
  32987. set mass(value: number);
  32988. /**
  32989. * Gets the coefficient of friction
  32990. */
  32991. get friction(): number;
  32992. /**
  32993. * Sets the coefficient of friction
  32994. */
  32995. set friction(value: number);
  32996. /**
  32997. * Gets the coefficient of restitution
  32998. */
  32999. get restitution(): number;
  33000. /**
  33001. * Sets the coefficient of restitution
  33002. */
  33003. set restitution(value: number);
  33004. /**
  33005. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33006. */
  33007. get pressure(): number;
  33008. /**
  33009. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33010. */
  33011. set pressure(value: number);
  33012. /**
  33013. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33014. */
  33015. get stiffness(): number;
  33016. /**
  33017. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33018. */
  33019. set stiffness(value: number);
  33020. /**
  33021. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33022. */
  33023. get velocityIterations(): number;
  33024. /**
  33025. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33026. */
  33027. set velocityIterations(value: number);
  33028. /**
  33029. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33030. */
  33031. get positionIterations(): number;
  33032. /**
  33033. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33034. */
  33035. set positionIterations(value: number);
  33036. /**
  33037. * The unique id of the physics imposter
  33038. * set by the physics engine when adding this impostor to the array
  33039. */
  33040. uniqueId: number;
  33041. /**
  33042. * @hidden
  33043. */
  33044. soft: boolean;
  33045. /**
  33046. * @hidden
  33047. */
  33048. segments: number;
  33049. private _joints;
  33050. /**
  33051. * Initializes the physics imposter
  33052. * @param object The physics-enabled object used as the physics imposter
  33053. * @param type The type of the physics imposter
  33054. * @param _options The options for the physics imposter
  33055. * @param _scene The Babylon scene
  33056. */
  33057. constructor(
  33058. /**
  33059. * The physics-enabled object used as the physics imposter
  33060. */
  33061. object: IPhysicsEnabledObject,
  33062. /**
  33063. * The type of the physics imposter
  33064. */
  33065. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33066. /**
  33067. * This function will completly initialize this impostor.
  33068. * It will create a new body - but only if this mesh has no parent.
  33069. * If it has, this impostor will not be used other than to define the impostor
  33070. * of the child mesh.
  33071. * @hidden
  33072. */
  33073. _init(): void;
  33074. private _getPhysicsParent;
  33075. /**
  33076. * Should a new body be generated.
  33077. * @returns boolean specifying if body initialization is required
  33078. */
  33079. isBodyInitRequired(): boolean;
  33080. /**
  33081. * Sets the updated scaling
  33082. * @param updated Specifies if the scaling is updated
  33083. */
  33084. setScalingUpdated(): void;
  33085. /**
  33086. * Force a regeneration of this or the parent's impostor's body.
  33087. * Use under cautious - This will remove all joints already implemented.
  33088. */
  33089. forceUpdate(): void;
  33090. /**
  33091. * Gets the body that holds this impostor. Either its own, or its parent.
  33092. */
  33093. get physicsBody(): any;
  33094. /**
  33095. * Get the parent of the physics imposter
  33096. * @returns Physics imposter or null
  33097. */
  33098. get parent(): Nullable<PhysicsImpostor>;
  33099. /**
  33100. * Sets the parent of the physics imposter
  33101. */
  33102. set parent(value: Nullable<PhysicsImpostor>);
  33103. /**
  33104. * Set the physics body. Used mainly by the physics engine/plugin
  33105. */
  33106. set physicsBody(physicsBody: any);
  33107. /**
  33108. * Resets the update flags
  33109. */
  33110. resetUpdateFlags(): void;
  33111. /**
  33112. * Gets the object extend size
  33113. * @returns the object extend size
  33114. */
  33115. getObjectExtendSize(): Vector3;
  33116. /**
  33117. * Gets the object center
  33118. * @returns The object center
  33119. */
  33120. getObjectCenter(): Vector3;
  33121. /**
  33122. * Get a specific parameter from the options parameters
  33123. * @param paramName The object parameter name
  33124. * @returns The object parameter
  33125. */
  33126. getParam(paramName: string): any;
  33127. /**
  33128. * Sets a specific parameter in the options given to the physics plugin
  33129. * @param paramName The parameter name
  33130. * @param value The value of the parameter
  33131. */
  33132. setParam(paramName: string, value: number): void;
  33133. /**
  33134. * Specifically change the body's mass option. Won't recreate the physics body object
  33135. * @param mass The mass of the physics imposter
  33136. */
  33137. setMass(mass: number): void;
  33138. /**
  33139. * Gets the linear velocity
  33140. * @returns linear velocity or null
  33141. */
  33142. getLinearVelocity(): Nullable<Vector3>;
  33143. /**
  33144. * Sets the linear velocity
  33145. * @param velocity linear velocity or null
  33146. */
  33147. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33148. /**
  33149. * Gets the angular velocity
  33150. * @returns angular velocity or null
  33151. */
  33152. getAngularVelocity(): Nullable<Vector3>;
  33153. /**
  33154. * Sets the angular velocity
  33155. * @param velocity The velocity or null
  33156. */
  33157. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33158. /**
  33159. * Execute a function with the physics plugin native code
  33160. * Provide a function the will have two variables - the world object and the physics body object
  33161. * @param func The function to execute with the physics plugin native code
  33162. */
  33163. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33164. /**
  33165. * Register a function that will be executed before the physics world is stepping forward
  33166. * @param func The function to execute before the physics world is stepped forward
  33167. */
  33168. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33169. /**
  33170. * Unregister a function that will be executed before the physics world is stepping forward
  33171. * @param func The function to execute before the physics world is stepped forward
  33172. */
  33173. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33174. /**
  33175. * Register a function that will be executed after the physics step
  33176. * @param func The function to execute after physics step
  33177. */
  33178. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33179. /**
  33180. * Unregisters a function that will be executed after the physics step
  33181. * @param func The function to execute after physics step
  33182. */
  33183. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33184. /**
  33185. * register a function that will be executed when this impostor collides against a different body
  33186. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33187. * @param func Callback that is executed on collision
  33188. */
  33189. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33190. /**
  33191. * Unregisters the physics imposter on contact
  33192. * @param collideAgainst The physics object to collide against
  33193. * @param func Callback to execute on collision
  33194. */
  33195. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33196. private _tmpQuat;
  33197. private _tmpQuat2;
  33198. /**
  33199. * Get the parent rotation
  33200. * @returns The parent rotation
  33201. */
  33202. getParentsRotation(): Quaternion;
  33203. /**
  33204. * this function is executed by the physics engine.
  33205. */
  33206. beforeStep: () => void;
  33207. /**
  33208. * this function is executed by the physics engine
  33209. */
  33210. afterStep: () => void;
  33211. /**
  33212. * Legacy collision detection event support
  33213. */
  33214. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33215. /**
  33216. * event and body object due to cannon's event-based architecture.
  33217. */
  33218. onCollide: (e: {
  33219. body: any;
  33220. point: Nullable<Vector3>;
  33221. }) => void;
  33222. /**
  33223. * Apply a force
  33224. * @param force The force to apply
  33225. * @param contactPoint The contact point for the force
  33226. * @returns The physics imposter
  33227. */
  33228. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33229. /**
  33230. * Apply an impulse
  33231. * @param force The impulse force
  33232. * @param contactPoint The contact point for the impulse force
  33233. * @returns The physics imposter
  33234. */
  33235. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33236. /**
  33237. * A help function to create a joint
  33238. * @param otherImpostor A physics imposter used to create a joint
  33239. * @param jointType The type of joint
  33240. * @param jointData The data for the joint
  33241. * @returns The physics imposter
  33242. */
  33243. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33244. /**
  33245. * Add a joint to this impostor with a different impostor
  33246. * @param otherImpostor A physics imposter used to add a joint
  33247. * @param joint The joint to add
  33248. * @returns The physics imposter
  33249. */
  33250. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33251. /**
  33252. * Add an anchor to a cloth impostor
  33253. * @param otherImpostor rigid impostor to anchor to
  33254. * @param width ratio across width from 0 to 1
  33255. * @param height ratio up height from 0 to 1
  33256. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  33257. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33258. * @returns impostor the soft imposter
  33259. */
  33260. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33261. /**
  33262. * Add a hook to a rope impostor
  33263. * @param otherImpostor rigid impostor to anchor to
  33264. * @param length ratio across rope from 0 to 1
  33265. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  33266. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33267. * @returns impostor the rope imposter
  33268. */
  33269. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33270. /**
  33271. * Will keep this body still, in a sleep mode.
  33272. * @returns the physics imposter
  33273. */
  33274. sleep(): PhysicsImpostor;
  33275. /**
  33276. * Wake the body up.
  33277. * @returns The physics imposter
  33278. */
  33279. wakeUp(): PhysicsImpostor;
  33280. /**
  33281. * Clones the physics imposter
  33282. * @param newObject The physics imposter clones to this physics-enabled object
  33283. * @returns A nullable physics imposter
  33284. */
  33285. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33286. /**
  33287. * Disposes the physics imposter
  33288. */
  33289. dispose(): void;
  33290. /**
  33291. * Sets the delta position
  33292. * @param position The delta position amount
  33293. */
  33294. setDeltaPosition(position: Vector3): void;
  33295. /**
  33296. * Sets the delta rotation
  33297. * @param rotation The delta rotation amount
  33298. */
  33299. setDeltaRotation(rotation: Quaternion): void;
  33300. /**
  33301. * Gets the box size of the physics imposter and stores the result in the input parameter
  33302. * @param result Stores the box size
  33303. * @returns The physics imposter
  33304. */
  33305. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33306. /**
  33307. * Gets the radius of the physics imposter
  33308. * @returns Radius of the physics imposter
  33309. */
  33310. getRadius(): number;
  33311. /**
  33312. * Sync a bone with this impostor
  33313. * @param bone The bone to sync to the impostor.
  33314. * @param boneMesh The mesh that the bone is influencing.
  33315. * @param jointPivot The pivot of the joint / bone in local space.
  33316. * @param distToJoint Optional distance from the impostor to the joint.
  33317. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33318. */
  33319. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33320. /**
  33321. * Sync impostor to a bone
  33322. * @param bone The bone that the impostor will be synced to.
  33323. * @param boneMesh The mesh that the bone is influencing.
  33324. * @param jointPivot The pivot of the joint / bone in local space.
  33325. * @param distToJoint Optional distance from the impostor to the joint.
  33326. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33327. * @param boneAxis Optional vector3 axis the bone is aligned with
  33328. */
  33329. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33330. /**
  33331. * No-Imposter type
  33332. */
  33333. static NoImpostor: number;
  33334. /**
  33335. * Sphere-Imposter type
  33336. */
  33337. static SphereImpostor: number;
  33338. /**
  33339. * Box-Imposter type
  33340. */
  33341. static BoxImpostor: number;
  33342. /**
  33343. * Plane-Imposter type
  33344. */
  33345. static PlaneImpostor: number;
  33346. /**
  33347. * Mesh-imposter type
  33348. */
  33349. static MeshImpostor: number;
  33350. /**
  33351. * Capsule-Impostor type (Ammo.js plugin only)
  33352. */
  33353. static CapsuleImpostor: number;
  33354. /**
  33355. * Cylinder-Imposter type
  33356. */
  33357. static CylinderImpostor: number;
  33358. /**
  33359. * Particle-Imposter type
  33360. */
  33361. static ParticleImpostor: number;
  33362. /**
  33363. * Heightmap-Imposter type
  33364. */
  33365. static HeightmapImpostor: number;
  33366. /**
  33367. * ConvexHull-Impostor type (Ammo.js plugin only)
  33368. */
  33369. static ConvexHullImpostor: number;
  33370. /**
  33371. * Custom-Imposter type (Ammo.js plugin only)
  33372. */
  33373. static CustomImpostor: number;
  33374. /**
  33375. * Rope-Imposter type
  33376. */
  33377. static RopeImpostor: number;
  33378. /**
  33379. * Cloth-Imposter type
  33380. */
  33381. static ClothImpostor: number;
  33382. /**
  33383. * Softbody-Imposter type
  33384. */
  33385. static SoftbodyImpostor: number;
  33386. }
  33387. }
  33388. declare module "babylonjs/Meshes/mesh" {
  33389. import { Observable } from "babylonjs/Misc/observable";
  33390. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33391. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  33392. import { Camera } from "babylonjs/Cameras/camera";
  33393. import { Scene } from "babylonjs/scene";
  33394. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  33395. import { Color4 } from "babylonjs/Maths/math.color";
  33396. import { Engine } from "babylonjs/Engines/engine";
  33397. import { Node } from "babylonjs/node";
  33398. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  33399. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33400. import { Buffer } from "babylonjs/Meshes/buffer";
  33401. import { Geometry } from "babylonjs/Meshes/geometry";
  33402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33403. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33404. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  33405. import { Effect } from "babylonjs/Materials/effect";
  33406. import { Material } from "babylonjs/Materials/material";
  33407. import { Skeleton } from "babylonjs/Bones/skeleton";
  33408. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33409. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  33410. import { Path3D } from "babylonjs/Maths/math.path";
  33411. import { Plane } from "babylonjs/Maths/math.plane";
  33412. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33413. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  33414. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  33415. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  33416. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  33417. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33418. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  33419. /**
  33420. * @hidden
  33421. **/
  33422. export class _CreationDataStorage {
  33423. closePath?: boolean;
  33424. closeArray?: boolean;
  33425. idx: number[];
  33426. dashSize: number;
  33427. gapSize: number;
  33428. path3D: Path3D;
  33429. pathArray: Vector3[][];
  33430. arc: number;
  33431. radius: number;
  33432. cap: number;
  33433. tessellation: number;
  33434. }
  33435. /**
  33436. * @hidden
  33437. **/
  33438. class _InstanceDataStorage {
  33439. visibleInstances: any;
  33440. batchCache: _InstancesBatch;
  33441. instancesBufferSize: number;
  33442. instancesBuffer: Nullable<Buffer>;
  33443. instancesData: Float32Array;
  33444. overridenInstanceCount: number;
  33445. isFrozen: boolean;
  33446. previousBatch: Nullable<_InstancesBatch>;
  33447. hardwareInstancedRendering: boolean;
  33448. sideOrientation: number;
  33449. manualUpdate: boolean;
  33450. previousRenderId: number;
  33451. }
  33452. /**
  33453. * @hidden
  33454. **/
  33455. export class _InstancesBatch {
  33456. mustReturn: boolean;
  33457. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  33458. renderSelf: boolean[];
  33459. hardwareInstancedRendering: boolean[];
  33460. }
  33461. /**
  33462. * @hidden
  33463. **/
  33464. class _ThinInstanceDataStorage {
  33465. instancesCount: number;
  33466. matrixBuffer: Nullable<Buffer>;
  33467. matrixBufferSize: number;
  33468. matrixData: Nullable<Float32Array>;
  33469. boundingVectors: Array<Vector3>;
  33470. worldMatrices: Nullable<Matrix[]>;
  33471. }
  33472. /**
  33473. * Class used to represent renderable models
  33474. */
  33475. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33476. /**
  33477. * Mesh side orientation : usually the external or front surface
  33478. */
  33479. static readonly FRONTSIDE: number;
  33480. /**
  33481. * Mesh side orientation : usually the internal or back surface
  33482. */
  33483. static readonly BACKSIDE: number;
  33484. /**
  33485. * Mesh side orientation : both internal and external or front and back surfaces
  33486. */
  33487. static readonly DOUBLESIDE: number;
  33488. /**
  33489. * Mesh side orientation : by default, `FRONTSIDE`
  33490. */
  33491. static readonly DEFAULTSIDE: number;
  33492. /**
  33493. * Mesh cap setting : no cap
  33494. */
  33495. static readonly NO_CAP: number;
  33496. /**
  33497. * Mesh cap setting : one cap at the beginning of the mesh
  33498. */
  33499. static readonly CAP_START: number;
  33500. /**
  33501. * Mesh cap setting : one cap at the end of the mesh
  33502. */
  33503. static readonly CAP_END: number;
  33504. /**
  33505. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33506. */
  33507. static readonly CAP_ALL: number;
  33508. /**
  33509. * Mesh pattern setting : no flip or rotate
  33510. */
  33511. static readonly NO_FLIP: number;
  33512. /**
  33513. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33514. */
  33515. static readonly FLIP_TILE: number;
  33516. /**
  33517. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33518. */
  33519. static readonly ROTATE_TILE: number;
  33520. /**
  33521. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33522. */
  33523. static readonly FLIP_ROW: number;
  33524. /**
  33525. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33526. */
  33527. static readonly ROTATE_ROW: number;
  33528. /**
  33529. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33530. */
  33531. static readonly FLIP_N_ROTATE_TILE: number;
  33532. /**
  33533. * Mesh pattern setting : rotate pattern and rotate
  33534. */
  33535. static readonly FLIP_N_ROTATE_ROW: number;
  33536. /**
  33537. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33538. */
  33539. static readonly CENTER: number;
  33540. /**
  33541. * Mesh tile positioning : part tiles on left
  33542. */
  33543. static readonly LEFT: number;
  33544. /**
  33545. * Mesh tile positioning : part tiles on right
  33546. */
  33547. static readonly RIGHT: number;
  33548. /**
  33549. * Mesh tile positioning : part tiles on top
  33550. */
  33551. static readonly TOP: number;
  33552. /**
  33553. * Mesh tile positioning : part tiles on bottom
  33554. */
  33555. static readonly BOTTOM: number;
  33556. /**
  33557. * Gets the default side orientation.
  33558. * @param orientation the orientation to value to attempt to get
  33559. * @returns the default orientation
  33560. * @hidden
  33561. */
  33562. static _GetDefaultSideOrientation(orientation?: number): number;
  33563. private _internalMeshDataInfo;
  33564. get computeBonesUsingShaders(): boolean;
  33565. set computeBonesUsingShaders(value: boolean);
  33566. /**
  33567. * An event triggered before rendering the mesh
  33568. */
  33569. get onBeforeRenderObservable(): Observable<Mesh>;
  33570. /**
  33571. * An event triggered before binding the mesh
  33572. */
  33573. get onBeforeBindObservable(): Observable<Mesh>;
  33574. /**
  33575. * An event triggered after rendering the mesh
  33576. */
  33577. get onAfterRenderObservable(): Observable<Mesh>;
  33578. /**
  33579. * An event triggered before drawing the mesh
  33580. */
  33581. get onBeforeDrawObservable(): Observable<Mesh>;
  33582. private _onBeforeDrawObserver;
  33583. /**
  33584. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33585. */
  33586. set onBeforeDraw(callback: () => void);
  33587. get hasInstances(): boolean;
  33588. get hasThinInstances(): boolean;
  33589. /**
  33590. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33591. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33592. */
  33593. delayLoadState: number;
  33594. /**
  33595. * Gets the list of instances created from this mesh
  33596. * it is not supposed to be modified manually.
  33597. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33598. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33599. */
  33600. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  33601. /**
  33602. * Gets the file containing delay loading data for this mesh
  33603. */
  33604. delayLoadingFile: string;
  33605. /** @hidden */
  33606. _binaryInfo: any;
  33607. /**
  33608. * User defined function used to change how LOD level selection is done
  33609. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33610. */
  33611. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33612. /**
  33613. * Gets or sets the morph target manager
  33614. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33615. */
  33616. get morphTargetManager(): Nullable<MorphTargetManager>;
  33617. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33618. /** @hidden */
  33619. _creationDataStorage: Nullable<_CreationDataStorage>;
  33620. /** @hidden */
  33621. _geometry: Nullable<Geometry>;
  33622. /** @hidden */
  33623. _delayInfo: Array<string>;
  33624. /** @hidden */
  33625. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33626. /** @hidden */
  33627. _instanceDataStorage: _InstanceDataStorage;
  33628. /** @hidden */
  33629. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33630. private _effectiveMaterial;
  33631. /** @hidden */
  33632. _shouldGenerateFlatShading: boolean;
  33633. /** @hidden */
  33634. _originalBuilderSideOrientation: number;
  33635. /**
  33636. * Use this property to change the original side orientation defined at construction time
  33637. */
  33638. overrideMaterialSideOrientation: Nullable<number>;
  33639. /**
  33640. * Gets the source mesh (the one used to clone this one from)
  33641. */
  33642. get source(): Nullable<Mesh>;
  33643. /**
  33644. * Gets the list of clones of this mesh
  33645. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33646. * Note that useClonedMeshMap=true is the default setting
  33647. */
  33648. get cloneMeshMap(): Nullable<{
  33649. [id: string]: Mesh | undefined;
  33650. }>;
  33651. /**
  33652. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33653. */
  33654. get isUnIndexed(): boolean;
  33655. set isUnIndexed(value: boolean);
  33656. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33657. get worldMatrixInstancedBuffer(): Float32Array;
  33658. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33659. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33660. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33661. /**
  33662. * @constructor
  33663. * @param name The value used by scene.getMeshByName() to do a lookup.
  33664. * @param scene The scene to add this mesh to.
  33665. * @param parent The parent of this mesh, if it has one
  33666. * @param source An optional Mesh from which geometry is shared, cloned.
  33667. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33668. * When false, achieved by calling a clone(), also passing False.
  33669. * This will make creation of children, recursive.
  33670. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33671. */
  33672. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33673. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33674. doNotInstantiate: boolean;
  33675. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33676. /**
  33677. * Gets the class name
  33678. * @returns the string "Mesh".
  33679. */
  33680. getClassName(): string;
  33681. /** @hidden */
  33682. get _isMesh(): boolean;
  33683. /**
  33684. * Returns a description of this mesh
  33685. * @param fullDetails define if full details about this mesh must be used
  33686. * @returns a descriptive string representing this mesh
  33687. */
  33688. toString(fullDetails?: boolean): string;
  33689. /** @hidden */
  33690. _unBindEffect(): void;
  33691. /**
  33692. * Gets a boolean indicating if this mesh has LOD
  33693. */
  33694. get hasLODLevels(): boolean;
  33695. /**
  33696. * Gets the list of MeshLODLevel associated with the current mesh
  33697. * @returns an array of MeshLODLevel
  33698. */
  33699. getLODLevels(): MeshLODLevel[];
  33700. private _sortLODLevels;
  33701. /**
  33702. * Add a mesh as LOD level triggered at the given distance.
  33703. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33704. * @param distance The distance from the center of the object to show this level
  33705. * @param mesh The mesh to be added as LOD level (can be null)
  33706. * @return This mesh (for chaining)
  33707. */
  33708. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33709. /**
  33710. * Returns the LOD level mesh at the passed distance or null if not found.
  33711. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33712. * @param distance The distance from the center of the object to show this level
  33713. * @returns a Mesh or `null`
  33714. */
  33715. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33716. /**
  33717. * Remove a mesh from the LOD array
  33718. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33719. * @param mesh defines the mesh to be removed
  33720. * @return This mesh (for chaining)
  33721. */
  33722. removeLODLevel(mesh: Mesh): Mesh;
  33723. /**
  33724. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33725. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33726. * @param camera defines the camera to use to compute distance
  33727. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33728. * @return This mesh (for chaining)
  33729. */
  33730. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33731. /**
  33732. * Gets the mesh internal Geometry object
  33733. */
  33734. get geometry(): Nullable<Geometry>;
  33735. /**
  33736. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33737. * @returns the total number of vertices
  33738. */
  33739. getTotalVertices(): number;
  33740. /**
  33741. * Returns the content of an associated vertex buffer
  33742. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33743. * - VertexBuffer.PositionKind
  33744. * - VertexBuffer.UVKind
  33745. * - VertexBuffer.UV2Kind
  33746. * - VertexBuffer.UV3Kind
  33747. * - VertexBuffer.UV4Kind
  33748. * - VertexBuffer.UV5Kind
  33749. * - VertexBuffer.UV6Kind
  33750. * - VertexBuffer.ColorKind
  33751. * - VertexBuffer.MatricesIndicesKind
  33752. * - VertexBuffer.MatricesIndicesExtraKind
  33753. * - VertexBuffer.MatricesWeightsKind
  33754. * - VertexBuffer.MatricesWeightsExtraKind
  33755. * @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
  33756. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33757. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33758. */
  33759. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33760. /**
  33761. * Returns the mesh VertexBuffer object from the requested `kind`
  33762. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33763. * - VertexBuffer.PositionKind
  33764. * - VertexBuffer.NormalKind
  33765. * - VertexBuffer.UVKind
  33766. * - VertexBuffer.UV2Kind
  33767. * - VertexBuffer.UV3Kind
  33768. * - VertexBuffer.UV4Kind
  33769. * - VertexBuffer.UV5Kind
  33770. * - VertexBuffer.UV6Kind
  33771. * - VertexBuffer.ColorKind
  33772. * - VertexBuffer.MatricesIndicesKind
  33773. * - VertexBuffer.MatricesIndicesExtraKind
  33774. * - VertexBuffer.MatricesWeightsKind
  33775. * - VertexBuffer.MatricesWeightsExtraKind
  33776. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33777. */
  33778. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33779. /**
  33780. * Tests if a specific vertex buffer is associated with this mesh
  33781. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33782. * - VertexBuffer.PositionKind
  33783. * - VertexBuffer.NormalKind
  33784. * - VertexBuffer.UVKind
  33785. * - VertexBuffer.UV2Kind
  33786. * - VertexBuffer.UV3Kind
  33787. * - VertexBuffer.UV4Kind
  33788. * - VertexBuffer.UV5Kind
  33789. * - VertexBuffer.UV6Kind
  33790. * - VertexBuffer.ColorKind
  33791. * - VertexBuffer.MatricesIndicesKind
  33792. * - VertexBuffer.MatricesIndicesExtraKind
  33793. * - VertexBuffer.MatricesWeightsKind
  33794. * - VertexBuffer.MatricesWeightsExtraKind
  33795. * @returns a boolean
  33796. */
  33797. isVerticesDataPresent(kind: string): boolean;
  33798. /**
  33799. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33800. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33801. * - VertexBuffer.PositionKind
  33802. * - VertexBuffer.UVKind
  33803. * - VertexBuffer.UV2Kind
  33804. * - VertexBuffer.UV3Kind
  33805. * - VertexBuffer.UV4Kind
  33806. * - VertexBuffer.UV5Kind
  33807. * - VertexBuffer.UV6Kind
  33808. * - VertexBuffer.ColorKind
  33809. * - VertexBuffer.MatricesIndicesKind
  33810. * - VertexBuffer.MatricesIndicesExtraKind
  33811. * - VertexBuffer.MatricesWeightsKind
  33812. * - VertexBuffer.MatricesWeightsExtraKind
  33813. * @returns a boolean
  33814. */
  33815. isVertexBufferUpdatable(kind: string): boolean;
  33816. /**
  33817. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33818. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33819. * - VertexBuffer.PositionKind
  33820. * - VertexBuffer.NormalKind
  33821. * - VertexBuffer.UVKind
  33822. * - VertexBuffer.UV2Kind
  33823. * - VertexBuffer.UV3Kind
  33824. * - VertexBuffer.UV4Kind
  33825. * - VertexBuffer.UV5Kind
  33826. * - VertexBuffer.UV6Kind
  33827. * - VertexBuffer.ColorKind
  33828. * - VertexBuffer.MatricesIndicesKind
  33829. * - VertexBuffer.MatricesIndicesExtraKind
  33830. * - VertexBuffer.MatricesWeightsKind
  33831. * - VertexBuffer.MatricesWeightsExtraKind
  33832. * @returns an array of strings
  33833. */
  33834. getVerticesDataKinds(): string[];
  33835. /**
  33836. * Returns a positive integer : the total number of indices in this mesh geometry.
  33837. * @returns the numner of indices or zero if the mesh has no geometry.
  33838. */
  33839. getTotalIndices(): number;
  33840. /**
  33841. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33842. * @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.
  33843. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33844. * @returns the indices array or an empty array if the mesh has no geometry
  33845. */
  33846. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33847. get isBlocked(): boolean;
  33848. /**
  33849. * Determine if the current mesh is ready to be rendered
  33850. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33851. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33852. * @returns true if all associated assets are ready (material, textures, shaders)
  33853. */
  33854. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33855. /**
  33856. * 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.
  33857. */
  33858. get areNormalsFrozen(): boolean;
  33859. /**
  33860. * 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.
  33861. * @returns the current mesh
  33862. */
  33863. freezeNormals(): Mesh;
  33864. /**
  33865. * 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
  33866. * @returns the current mesh
  33867. */
  33868. unfreezeNormals(): Mesh;
  33869. /**
  33870. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33871. */
  33872. set overridenInstanceCount(count: number);
  33873. /** @hidden */
  33874. _preActivate(): Mesh;
  33875. /** @hidden */
  33876. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33877. /** @hidden */
  33878. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33879. protected _afterComputeWorldMatrix(): void;
  33880. /** @hidden */
  33881. _postActivate(): void;
  33882. /**
  33883. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33884. * This means the mesh underlying bounding box and sphere are recomputed.
  33885. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33886. * @returns the current mesh
  33887. */
  33888. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33889. /** @hidden */
  33890. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33891. /**
  33892. * This function will subdivide the mesh into multiple submeshes
  33893. * @param count defines the expected number of submeshes
  33894. */
  33895. subdivide(count: number): void;
  33896. /**
  33897. * Copy a FloatArray into a specific associated vertex buffer
  33898. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33899. * - VertexBuffer.PositionKind
  33900. * - VertexBuffer.UVKind
  33901. * - VertexBuffer.UV2Kind
  33902. * - VertexBuffer.UV3Kind
  33903. * - VertexBuffer.UV4Kind
  33904. * - VertexBuffer.UV5Kind
  33905. * - VertexBuffer.UV6Kind
  33906. * - VertexBuffer.ColorKind
  33907. * - VertexBuffer.MatricesIndicesKind
  33908. * - VertexBuffer.MatricesIndicesExtraKind
  33909. * - VertexBuffer.MatricesWeightsKind
  33910. * - VertexBuffer.MatricesWeightsExtraKind
  33911. * @param data defines the data source
  33912. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33913. * @param stride defines the data stride size (can be null)
  33914. * @returns the current mesh
  33915. */
  33916. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33917. /**
  33918. * Delete a vertex buffer associated with this mesh
  33919. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33920. * - VertexBuffer.PositionKind
  33921. * - VertexBuffer.UVKind
  33922. * - VertexBuffer.UV2Kind
  33923. * - VertexBuffer.UV3Kind
  33924. * - VertexBuffer.UV4Kind
  33925. * - VertexBuffer.UV5Kind
  33926. * - VertexBuffer.UV6Kind
  33927. * - VertexBuffer.ColorKind
  33928. * - VertexBuffer.MatricesIndicesKind
  33929. * - VertexBuffer.MatricesIndicesExtraKind
  33930. * - VertexBuffer.MatricesWeightsKind
  33931. * - VertexBuffer.MatricesWeightsExtraKind
  33932. */
  33933. removeVerticesData(kind: string): void;
  33934. /**
  33935. * Flags an associated vertex buffer as updatable
  33936. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33937. * - VertexBuffer.PositionKind
  33938. * - VertexBuffer.UVKind
  33939. * - VertexBuffer.UV2Kind
  33940. * - VertexBuffer.UV3Kind
  33941. * - VertexBuffer.UV4Kind
  33942. * - VertexBuffer.UV5Kind
  33943. * - VertexBuffer.UV6Kind
  33944. * - VertexBuffer.ColorKind
  33945. * - VertexBuffer.MatricesIndicesKind
  33946. * - VertexBuffer.MatricesIndicesExtraKind
  33947. * - VertexBuffer.MatricesWeightsKind
  33948. * - VertexBuffer.MatricesWeightsExtraKind
  33949. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33950. */
  33951. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33952. /**
  33953. * Sets the mesh global Vertex Buffer
  33954. * @param buffer defines the buffer to use
  33955. * @returns the current mesh
  33956. */
  33957. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33958. /**
  33959. * Update a specific associated vertex buffer
  33960. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33961. * - VertexBuffer.PositionKind
  33962. * - VertexBuffer.UVKind
  33963. * - VertexBuffer.UV2Kind
  33964. * - VertexBuffer.UV3Kind
  33965. * - VertexBuffer.UV4Kind
  33966. * - VertexBuffer.UV5Kind
  33967. * - VertexBuffer.UV6Kind
  33968. * - VertexBuffer.ColorKind
  33969. * - VertexBuffer.MatricesIndicesKind
  33970. * - VertexBuffer.MatricesIndicesExtraKind
  33971. * - VertexBuffer.MatricesWeightsKind
  33972. * - VertexBuffer.MatricesWeightsExtraKind
  33973. * @param data defines the data source
  33974. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33975. * @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)
  33976. * @returns the current mesh
  33977. */
  33978. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33979. /**
  33980. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  33981. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  33982. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  33983. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  33984. * @returns the current mesh
  33985. */
  33986. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  33987. /**
  33988. * Creates a un-shared specific occurence of the geometry for the mesh.
  33989. * @returns the current mesh
  33990. */
  33991. makeGeometryUnique(): Mesh;
  33992. /**
  33993. * Set the index buffer of this mesh
  33994. * @param indices defines the source data
  33995. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  33996. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  33997. * @returns the current mesh
  33998. */
  33999. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34000. /**
  34001. * Update the current index buffer
  34002. * @param indices defines the source data
  34003. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34004. * @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)
  34005. * @returns the current mesh
  34006. */
  34007. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34008. /**
  34009. * Invert the geometry to move from a right handed system to a left handed one.
  34010. * @returns the current mesh
  34011. */
  34012. toLeftHanded(): Mesh;
  34013. /** @hidden */
  34014. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34015. /** @hidden */
  34016. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34017. /**
  34018. * Registers for this mesh a javascript function called just before the rendering process
  34019. * @param func defines the function to call before rendering this mesh
  34020. * @returns the current mesh
  34021. */
  34022. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34023. /**
  34024. * Disposes a previously registered javascript function called before the rendering
  34025. * @param func defines the function to remove
  34026. * @returns the current mesh
  34027. */
  34028. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34029. /**
  34030. * Registers for this mesh a javascript function called just after the rendering is complete
  34031. * @param func defines the function to call after rendering this mesh
  34032. * @returns the current mesh
  34033. */
  34034. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34035. /**
  34036. * Disposes a previously registered javascript function called after the rendering.
  34037. * @param func defines the function to remove
  34038. * @returns the current mesh
  34039. */
  34040. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34041. /** @hidden */
  34042. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34043. /** @hidden */
  34044. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34045. /** @hidden */
  34046. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34047. /** @hidden */
  34048. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34049. /** @hidden */
  34050. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34051. /** @hidden */
  34052. _rebuild(): void;
  34053. /** @hidden */
  34054. _freeze(): void;
  34055. /** @hidden */
  34056. _unFreeze(): void;
  34057. /**
  34058. * 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
  34059. * @param subMesh defines the subMesh to render
  34060. * @param enableAlphaMode defines if alpha mode can be changed
  34061. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34062. * @returns the current mesh
  34063. */
  34064. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34065. private _onBeforeDraw;
  34066. /**
  34067. * Renormalize the mesh and patch it up if there are no weights
  34068. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34069. * However in the case of zero weights then we set just a single influence to 1.
  34070. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34071. */
  34072. cleanMatrixWeights(): void;
  34073. private normalizeSkinFourWeights;
  34074. private normalizeSkinWeightsAndExtra;
  34075. /**
  34076. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34077. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34078. * the user know there was an issue with importing the mesh
  34079. * @returns a validation object with skinned, valid and report string
  34080. */
  34081. validateSkinning(): {
  34082. skinned: boolean;
  34083. valid: boolean;
  34084. report: string;
  34085. };
  34086. /** @hidden */
  34087. _checkDelayState(): Mesh;
  34088. private _queueLoad;
  34089. /**
  34090. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34091. * A mesh is in the frustum if its bounding box intersects the frustum
  34092. * @param frustumPlanes defines the frustum to test
  34093. * @returns true if the mesh is in the frustum planes
  34094. */
  34095. isInFrustum(frustumPlanes: Plane[]): boolean;
  34096. /**
  34097. * Sets the mesh material by the material or multiMaterial `id` property
  34098. * @param id is a string identifying the material or the multiMaterial
  34099. * @returns the current mesh
  34100. */
  34101. setMaterialByID(id: string): Mesh;
  34102. /**
  34103. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34104. * @returns an array of IAnimatable
  34105. */
  34106. getAnimatables(): IAnimatable[];
  34107. /**
  34108. * Modifies the mesh geometry according to the passed transformation matrix.
  34109. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34110. * The mesh normals are modified using the same transformation.
  34111. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34112. * @param transform defines the transform matrix to use
  34113. * @see https://doc.babylonjs.com/resources/baking_transformations
  34114. * @returns the current mesh
  34115. */
  34116. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34117. /**
  34118. * Modifies the mesh geometry according to its own current World Matrix.
  34119. * The mesh World Matrix is then reset.
  34120. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34121. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34122. * @see https://doc.babylonjs.com/resources/baking_transformations
  34123. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34124. * @returns the current mesh
  34125. */
  34126. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34127. /** @hidden */
  34128. get _positions(): Nullable<Vector3[]>;
  34129. /** @hidden */
  34130. _resetPointsArrayCache(): Mesh;
  34131. /** @hidden */
  34132. _generatePointsArray(): boolean;
  34133. /**
  34134. * Returns a new Mesh object generated from the current mesh properties.
  34135. * This method must not get confused with createInstance()
  34136. * @param name is a string, the name given to the new mesh
  34137. * @param newParent can be any Node object (default `null`)
  34138. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34139. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34140. * @returns a new mesh
  34141. */
  34142. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34143. /**
  34144. * Releases resources associated with this mesh.
  34145. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34146. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34147. */
  34148. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34149. /** @hidden */
  34150. _disposeInstanceSpecificData(): void;
  34151. /** @hidden */
  34152. _disposeThinInstanceSpecificData(): void;
  34153. /**
  34154. * Modifies the mesh geometry according to a displacement map.
  34155. * 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.
  34156. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34157. * @param url is a string, the URL from the image file is to be downloaded.
  34158. * @param minHeight is the lower limit of the displacement.
  34159. * @param maxHeight is the upper limit of the displacement.
  34160. * @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.
  34161. * @param uvOffset is an optional vector2 used to offset UV.
  34162. * @param uvScale is an optional vector2 used to scale UV.
  34163. * @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.
  34164. * @returns the Mesh.
  34165. */
  34166. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34167. /**
  34168. * Modifies the mesh geometry according to a displacementMap buffer.
  34169. * 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.
  34170. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34171. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34172. * @param heightMapWidth is the width of the buffer image.
  34173. * @param heightMapHeight is the height of the buffer image.
  34174. * @param minHeight is the lower limit of the displacement.
  34175. * @param maxHeight is the upper limit of the displacement.
  34176. * @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.
  34177. * @param uvOffset is an optional vector2 used to offset UV.
  34178. * @param uvScale is an optional vector2 used to scale UV.
  34179. * @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.
  34180. * @returns the Mesh.
  34181. */
  34182. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34183. /**
  34184. * Modify the mesh to get a flat shading rendering.
  34185. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34186. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34187. * @returns current mesh
  34188. */
  34189. convertToFlatShadedMesh(): Mesh;
  34190. /**
  34191. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34192. * In other words, more vertices, no more indices and a single bigger VBO.
  34193. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34194. * @returns current mesh
  34195. */
  34196. convertToUnIndexedMesh(): Mesh;
  34197. /**
  34198. * Inverses facet orientations.
  34199. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34200. * @param flipNormals will also inverts the normals
  34201. * @returns current mesh
  34202. */
  34203. flipFaces(flipNormals?: boolean): Mesh;
  34204. /**
  34205. * Increase the number of facets and hence vertices in a mesh
  34206. * Vertex normals are interpolated from existing vertex normals
  34207. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34208. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34209. */
  34210. increaseVertices(numberPerEdge: number): void;
  34211. /**
  34212. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34213. * This will undo any application of covertToFlatShadedMesh
  34214. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34215. */
  34216. forceSharedVertices(): void;
  34217. /** @hidden */
  34218. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34219. /** @hidden */
  34220. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34221. /**
  34222. * Creates a new InstancedMesh object from the mesh model.
  34223. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34224. * @param name defines the name of the new instance
  34225. * @returns a new InstancedMesh
  34226. */
  34227. createInstance(name: string): InstancedMesh;
  34228. /**
  34229. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34230. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34231. * @returns the current mesh
  34232. */
  34233. synchronizeInstances(): Mesh;
  34234. /**
  34235. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34236. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34237. * This should be used together with the simplification to avoid disappearing triangles.
  34238. * @param successCallback an optional success callback to be called after the optimization finished.
  34239. * @returns the current mesh
  34240. */
  34241. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34242. /**
  34243. * Serialize current mesh
  34244. * @param serializationObject defines the object which will receive the serialization data
  34245. */
  34246. serialize(serializationObject: any): void;
  34247. /** @hidden */
  34248. _syncGeometryWithMorphTargetManager(): void;
  34249. /** @hidden */
  34250. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34251. /**
  34252. * Returns a new Mesh object parsed from the source provided.
  34253. * @param parsedMesh is the source
  34254. * @param scene defines the hosting scene
  34255. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34256. * @returns a new Mesh
  34257. */
  34258. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34259. /**
  34260. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34261. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34262. * @param name defines the name of the mesh to create
  34263. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34264. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34265. * @param closePath creates a seam between the first and the last points of each path of the path array
  34266. * @param offset is taken in account only if the `pathArray` is containing a single path
  34267. * @param scene defines the hosting scene
  34268. * @param updatable defines if the mesh must be flagged as updatable
  34269. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34270. * @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)
  34271. * @returns a new Mesh
  34272. */
  34273. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34274. /**
  34275. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34276. * @param name defines the name of the mesh to create
  34277. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34278. * @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
  34279. * @param scene defines the hosting scene
  34280. * @param updatable defines if the mesh must be flagged as updatable
  34281. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34282. * @returns a new Mesh
  34283. */
  34284. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34285. /**
  34286. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34287. * @param name defines the name of the mesh to create
  34288. * @param size sets the size (float) of each box side (default 1)
  34289. * @param scene defines the hosting scene
  34290. * @param updatable defines if the mesh must be flagged as updatable
  34291. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34292. * @returns a new Mesh
  34293. */
  34294. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34295. /**
  34296. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34297. * @param name defines the name of the mesh to create
  34298. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34299. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34300. * @param scene defines the hosting scene
  34301. * @param updatable defines if the mesh must be flagged as updatable
  34302. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34303. * @returns a new Mesh
  34304. */
  34305. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34306. /**
  34307. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34308. * @param name defines the name of the mesh to create
  34309. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34310. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34311. * @param scene defines the hosting scene
  34312. * @returns a new Mesh
  34313. */
  34314. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34315. /**
  34316. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34317. * @param name defines the name of the mesh to create
  34318. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34319. * @param diameterTop set the top cap diameter (floats, default 1)
  34320. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34321. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34322. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34323. * @param scene defines the hosting scene
  34324. * @param updatable defines if the mesh must be flagged as updatable
  34325. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34326. * @returns a new Mesh
  34327. */
  34328. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34329. /**
  34330. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34331. * @param name defines the name of the mesh to create
  34332. * @param diameter sets the diameter size (float) of the torus (default 1)
  34333. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34334. * @param tessellation sets the number of torus sides (postive integer, default 16)
  34335. * @param scene defines the hosting scene
  34336. * @param updatable defines if the mesh must be flagged as updatable
  34337. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34338. * @returns a new Mesh
  34339. */
  34340. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34341. /**
  34342. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34343. * @param name defines the name of the mesh to create
  34344. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34345. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34346. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34347. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34348. * @param p the number of windings on X axis (positive integers, default 2)
  34349. * @param q the number of windings on Y axis (positive integers, default 3)
  34350. * @param scene defines the hosting scene
  34351. * @param updatable defines if the mesh must be flagged as updatable
  34352. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34353. * @returns a new Mesh
  34354. */
  34355. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34356. /**
  34357. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34358. * @param name defines the name of the mesh to create
  34359. * @param points is an array successive Vector3
  34360. * @param scene defines the hosting scene
  34361. * @param updatable defines if the mesh must be flagged as updatable
  34362. * @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).
  34363. * @returns a new Mesh
  34364. */
  34365. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34366. /**
  34367. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34368. * @param name defines the name of the mesh to create
  34369. * @param points is an array successive Vector3
  34370. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34371. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34372. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34373. * @param scene defines the hosting scene
  34374. * @param updatable defines if the mesh must be flagged as updatable
  34375. * @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)
  34376. * @returns a new Mesh
  34377. */
  34378. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34379. /**
  34380. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34381. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34382. * 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.
  34383. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34384. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34385. * Remember you can only change the shape positions, not their number when updating a polygon.
  34386. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34387. * @param name defines the name of the mesh to create
  34388. * @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
  34389. * @param scene defines the hosting scene
  34390. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34391. * @param updatable defines if the mesh must be flagged as updatable
  34392. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34393. * @param earcutInjection can be used to inject your own earcut reference
  34394. * @returns a new Mesh
  34395. */
  34396. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34397. /**
  34398. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34399. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34400. * @param name defines the name of the mesh to create
  34401. * @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
  34402. * @param depth defines the height of extrusion
  34403. * @param scene defines the hosting scene
  34404. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34405. * @param updatable defines if the mesh must be flagged as updatable
  34406. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34407. * @param earcutInjection can be used to inject your own earcut reference
  34408. * @returns a new Mesh
  34409. */
  34410. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34411. /**
  34412. * Creates an extruded shape mesh.
  34413. * 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
  34414. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34415. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34416. * @param name defines the name of the mesh to create
  34417. * @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
  34418. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34419. * @param scale is the value to scale the shape
  34420. * @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
  34421. * @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
  34422. * @param scene defines the hosting scene
  34423. * @param updatable defines if the mesh must be flagged as updatable
  34424. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34425. * @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)
  34426. * @returns a new Mesh
  34427. */
  34428. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34429. /**
  34430. * Creates an custom extruded shape mesh.
  34431. * The custom extrusion is a parametric shape.
  34432. * It has no predefined shape. Its final shape will depend on the input parameters.
  34433. * Please consider using the same method from the MeshBuilder class instead
  34434. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34435. * @param name defines the name of the mesh to create
  34436. * @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
  34437. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34438. * @param scaleFunction is a custom Javascript function called on each path point
  34439. * @param rotationFunction is a custom Javascript function called on each path point
  34440. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34441. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34442. * @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
  34443. * @param scene defines the hosting scene
  34444. * @param updatable defines if the mesh must be flagged as updatable
  34445. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34446. * @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)
  34447. * @returns a new Mesh
  34448. */
  34449. 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;
  34450. /**
  34451. * Creates lathe mesh.
  34452. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34453. * Please consider using the same method from the MeshBuilder class instead
  34454. * @param name defines the name of the mesh to create
  34455. * @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
  34456. * @param radius is the radius value of the lathe
  34457. * @param tessellation is the side number of the lathe.
  34458. * @param scene defines the hosting scene
  34459. * @param updatable defines if the mesh must be flagged as updatable
  34460. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34461. * @returns a new Mesh
  34462. */
  34463. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34464. /**
  34465. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34466. * @param name defines the name of the mesh to create
  34467. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34468. * @param scene defines the hosting scene
  34469. * @param updatable defines if the mesh must be flagged as updatable
  34470. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34471. * @returns a new Mesh
  34472. */
  34473. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34474. /**
  34475. * Creates a ground mesh.
  34476. * Please consider using the same method from the MeshBuilder class instead
  34477. * @param name defines the name of the mesh to create
  34478. * @param width set the width of the ground
  34479. * @param height set the height of the ground
  34480. * @param subdivisions sets the number of subdivisions per side
  34481. * @param scene defines the hosting scene
  34482. * @param updatable defines if the mesh must be flagged as updatable
  34483. * @returns a new Mesh
  34484. */
  34485. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34486. /**
  34487. * Creates a tiled ground mesh.
  34488. * Please consider using the same method from the MeshBuilder class instead
  34489. * @param name defines the name of the mesh to create
  34490. * @param xmin set the ground minimum X coordinate
  34491. * @param zmin set the ground minimum Y coordinate
  34492. * @param xmax set the ground maximum X coordinate
  34493. * @param zmax set the ground maximum Z coordinate
  34494. * @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
  34495. * @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
  34496. * @param scene defines the hosting scene
  34497. * @param updatable defines if the mesh must be flagged as updatable
  34498. * @returns a new Mesh
  34499. */
  34500. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34501. w: number;
  34502. h: number;
  34503. }, precision: {
  34504. w: number;
  34505. h: number;
  34506. }, scene: Scene, updatable?: boolean): Mesh;
  34507. /**
  34508. * Creates a ground mesh from a height map.
  34509. * Please consider using the same method from the MeshBuilder class instead
  34510. * @see https://doc.babylonjs.com/babylon101/height_map
  34511. * @param name defines the name of the mesh to create
  34512. * @param url sets the URL of the height map image resource
  34513. * @param width set the ground width size
  34514. * @param height set the ground height size
  34515. * @param subdivisions sets the number of subdivision per side
  34516. * @param minHeight is the minimum altitude on the ground
  34517. * @param maxHeight is the maximum altitude on the ground
  34518. * @param scene defines the hosting scene
  34519. * @param updatable defines if the mesh must be flagged as updatable
  34520. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34521. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34522. * @returns a new Mesh
  34523. */
  34524. 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;
  34525. /**
  34526. * Creates a tube mesh.
  34527. * The tube is a parametric shape.
  34528. * It has no predefined shape. Its final shape will depend on the input parameters.
  34529. * Please consider using the same method from the MeshBuilder class instead
  34530. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34531. * @param name defines the name of the mesh to create
  34532. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34533. * @param radius sets the tube radius size
  34534. * @param tessellation is the number of sides on the tubular surface
  34535. * @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
  34536. * @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
  34537. * @param scene defines the hosting scene
  34538. * @param updatable defines if the mesh must be flagged as updatable
  34539. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34540. * @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)
  34541. * @returns a new Mesh
  34542. */
  34543. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34544. (i: number, distance: number): number;
  34545. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34546. /**
  34547. * Creates a polyhedron mesh.
  34548. * Please consider using the same method from the MeshBuilder class instead.
  34549. * * 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
  34550. * * The parameter `size` (positive float, default 1) sets the polygon size
  34551. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34552. * * 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`
  34553. * * 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
  34554. * * 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)`)
  34555. * * 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
  34556. * * 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
  34557. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34558. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34560. * @param name defines the name of the mesh to create
  34561. * @param options defines the options used to create the mesh
  34562. * @param scene defines the hosting scene
  34563. * @returns a new Mesh
  34564. */
  34565. static CreatePolyhedron(name: string, options: {
  34566. type?: number;
  34567. size?: number;
  34568. sizeX?: number;
  34569. sizeY?: number;
  34570. sizeZ?: number;
  34571. custom?: any;
  34572. faceUV?: Vector4[];
  34573. faceColors?: Color4[];
  34574. updatable?: boolean;
  34575. sideOrientation?: number;
  34576. }, scene: Scene): Mesh;
  34577. /**
  34578. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34579. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34580. * * 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`)
  34581. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34582. * * 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
  34583. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34584. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34586. * @param name defines the name of the mesh
  34587. * @param options defines the options used to create the mesh
  34588. * @param scene defines the hosting scene
  34589. * @returns a new Mesh
  34590. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34591. */
  34592. static CreateIcoSphere(name: string, options: {
  34593. radius?: number;
  34594. flat?: boolean;
  34595. subdivisions?: number;
  34596. sideOrientation?: number;
  34597. updatable?: boolean;
  34598. }, scene: Scene): Mesh;
  34599. /**
  34600. * Creates a decal mesh.
  34601. * Please consider using the same method from the MeshBuilder class instead.
  34602. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34603. * @param name defines the name of the mesh
  34604. * @param sourceMesh defines the mesh receiving the decal
  34605. * @param position sets the position of the decal in world coordinates
  34606. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34607. * @param size sets the decal scaling
  34608. * @param angle sets the angle to rotate the decal
  34609. * @returns a new Mesh
  34610. */
  34611. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34612. /** Creates a Capsule Mesh
  34613. * @param name defines the name of the mesh.
  34614. * @param options the constructors options used to shape the mesh.
  34615. * @param scene defines the scene the mesh is scoped to.
  34616. * @returns the capsule mesh
  34617. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34618. */
  34619. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34620. /**
  34621. * Prepare internal position array for software CPU skinning
  34622. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34623. */
  34624. setPositionsForCPUSkinning(): Float32Array;
  34625. /**
  34626. * Prepare internal normal array for software CPU skinning
  34627. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34628. */
  34629. setNormalsForCPUSkinning(): Float32Array;
  34630. /**
  34631. * Updates the vertex buffer by applying transformation from the bones
  34632. * @param skeleton defines the skeleton to apply to current mesh
  34633. * @returns the current mesh
  34634. */
  34635. applySkeleton(skeleton: Skeleton): Mesh;
  34636. /**
  34637. * 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
  34638. * @param meshes defines the list of meshes to scan
  34639. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34640. */
  34641. static MinMax(meshes: AbstractMesh[]): {
  34642. min: Vector3;
  34643. max: Vector3;
  34644. };
  34645. /**
  34646. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34647. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34648. * @returns a vector3
  34649. */
  34650. static Center(meshesOrMinMaxVector: {
  34651. min: Vector3;
  34652. max: Vector3;
  34653. } | AbstractMesh[]): Vector3;
  34654. /**
  34655. * Merge the array of meshes into a single mesh for performance reasons.
  34656. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34657. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34658. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34659. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34660. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34661. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34662. * @returns a new mesh
  34663. */
  34664. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34665. /** @hidden */
  34666. addInstance(instance: InstancedMesh): void;
  34667. /** @hidden */
  34668. removeInstance(instance: InstancedMesh): void;
  34669. }
  34670. }
  34671. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  34672. import { Vector3 } from "babylonjs/Maths/math.vector";
  34673. import { Mesh } from "babylonjs/Meshes/mesh";
  34674. /**
  34675. * The options Interface for creating a Capsule Mesh
  34676. */
  34677. export interface ICreateCapsuleOptions {
  34678. /** The Orientation of the capsule. Default : Vector3.Up() */
  34679. orientation?: Vector3;
  34680. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  34681. subdivisions: number;
  34682. /** Number of cylindrical segments on the capsule. */
  34683. tessellation: number;
  34684. /** Height or Length of the capsule. */
  34685. height: number;
  34686. /** Radius of the capsule. */
  34687. radius: number;
  34688. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  34689. capSubdivisions: number;
  34690. /** Overwrite for the top radius. */
  34691. radiusTop?: number;
  34692. /** Overwrite for the bottom radius. */
  34693. radiusBottom?: number;
  34694. /** Overwrite for the top capSubdivisions. */
  34695. topCapSubdivisions?: number;
  34696. /** Overwrite for the bottom capSubdivisions. */
  34697. bottomCapSubdivisions?: number;
  34698. }
  34699. /**
  34700. * Class containing static functions to help procedurally build meshes
  34701. */
  34702. export class CapsuleBuilder {
  34703. /**
  34704. * Creates a capsule or a pill mesh
  34705. * @param name defines the name of the mesh
  34706. * @param options The constructors options.
  34707. * @param scene The scene the mesh is scoped to.
  34708. * @returns Capsule Mesh
  34709. */
  34710. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  34711. }
  34712. }
  34713. declare module "babylonjs/Meshes/mesh.vertexData" {
  34714. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  34715. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  34716. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  34717. import { Geometry } from "babylonjs/Meshes/geometry";
  34718. import { Mesh } from "babylonjs/Meshes/mesh";
  34719. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  34720. /**
  34721. * Define an interface for all classes that will get and set the data on vertices
  34722. */
  34723. export interface IGetSetVerticesData {
  34724. /**
  34725. * Gets a boolean indicating if specific vertex data is present
  34726. * @param kind defines the vertex data kind to use
  34727. * @returns true is data kind is present
  34728. */
  34729. isVerticesDataPresent(kind: string): boolean;
  34730. /**
  34731. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  34732. * @param kind defines the data kind (Position, normal, etc...)
  34733. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  34734. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34735. * @returns a float array containing vertex data
  34736. */
  34737. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34738. /**
  34739. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34740. * @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.
  34741. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34742. * @returns the indices array or an empty array if the mesh has no geometry
  34743. */
  34744. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34745. /**
  34746. * Set specific vertex data
  34747. * @param kind defines the data kind (Position, normal, etc...)
  34748. * @param data defines the vertex data to use
  34749. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  34750. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  34751. */
  34752. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  34753. /**
  34754. * Update a specific associated vertex buffer
  34755. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34756. * - VertexBuffer.PositionKind
  34757. * - VertexBuffer.UVKind
  34758. * - VertexBuffer.UV2Kind
  34759. * - VertexBuffer.UV3Kind
  34760. * - VertexBuffer.UV4Kind
  34761. * - VertexBuffer.UV5Kind
  34762. * - VertexBuffer.UV6Kind
  34763. * - VertexBuffer.ColorKind
  34764. * - VertexBuffer.MatricesIndicesKind
  34765. * - VertexBuffer.MatricesIndicesExtraKind
  34766. * - VertexBuffer.MatricesWeightsKind
  34767. * - VertexBuffer.MatricesWeightsExtraKind
  34768. * @param data defines the data source
  34769. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34770. * @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)
  34771. */
  34772. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  34773. /**
  34774. * Creates a new index buffer
  34775. * @param indices defines the indices to store in the index buffer
  34776. * @param totalVertices defines the total number of vertices (could be null)
  34777. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  34778. */
  34779. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  34780. }
  34781. /**
  34782. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  34783. */
  34784. export class VertexData {
  34785. /**
  34786. * Mesh side orientation : usually the external or front surface
  34787. */
  34788. static readonly FRONTSIDE: number;
  34789. /**
  34790. * Mesh side orientation : usually the internal or back surface
  34791. */
  34792. static readonly BACKSIDE: number;
  34793. /**
  34794. * Mesh side orientation : both internal and external or front and back surfaces
  34795. */
  34796. static readonly DOUBLESIDE: number;
  34797. /**
  34798. * Mesh side orientation : by default, `FRONTSIDE`
  34799. */
  34800. static readonly DEFAULTSIDE: number;
  34801. /**
  34802. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  34803. */
  34804. positions: Nullable<FloatArray>;
  34805. /**
  34806. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  34807. */
  34808. normals: Nullable<FloatArray>;
  34809. /**
  34810. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  34811. */
  34812. tangents: Nullable<FloatArray>;
  34813. /**
  34814. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34815. */
  34816. uvs: Nullable<FloatArray>;
  34817. /**
  34818. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34819. */
  34820. uvs2: Nullable<FloatArray>;
  34821. /**
  34822. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34823. */
  34824. uvs3: Nullable<FloatArray>;
  34825. /**
  34826. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34827. */
  34828. uvs4: Nullable<FloatArray>;
  34829. /**
  34830. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34831. */
  34832. uvs5: Nullable<FloatArray>;
  34833. /**
  34834. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34835. */
  34836. uvs6: Nullable<FloatArray>;
  34837. /**
  34838. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  34839. */
  34840. colors: Nullable<FloatArray>;
  34841. /**
  34842. * 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).
  34843. */
  34844. matricesIndices: Nullable<FloatArray>;
  34845. /**
  34846. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  34847. */
  34848. matricesWeights: Nullable<FloatArray>;
  34849. /**
  34850. * An array extending the number of possible indices
  34851. */
  34852. matricesIndicesExtra: Nullable<FloatArray>;
  34853. /**
  34854. * An array extending the number of possible weights when the number of indices is extended
  34855. */
  34856. matricesWeightsExtra: Nullable<FloatArray>;
  34857. /**
  34858. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  34859. */
  34860. indices: Nullable<IndicesArray>;
  34861. /**
  34862. * Uses the passed data array to set the set the values for the specified kind of data
  34863. * @param data a linear array of floating numbers
  34864. * @param kind the type of data that is being set, eg positions, colors etc
  34865. */
  34866. set(data: FloatArray, kind: string): void;
  34867. /**
  34868. * Associates the vertexData to the passed Mesh.
  34869. * Sets it as updatable or not (default `false`)
  34870. * @param mesh the mesh the vertexData is applied to
  34871. * @param updatable when used and having the value true allows new data to update the vertexData
  34872. * @returns the VertexData
  34873. */
  34874. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  34875. /**
  34876. * Associates the vertexData to the passed Geometry.
  34877. * Sets it as updatable or not (default `false`)
  34878. * @param geometry the geometry the vertexData is applied to
  34879. * @param updatable when used and having the value true allows new data to update the vertexData
  34880. * @returns VertexData
  34881. */
  34882. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  34883. /**
  34884. * Updates the associated mesh
  34885. * @param mesh the mesh to be updated
  34886. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34887. * @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
  34888. * @returns VertexData
  34889. */
  34890. updateMesh(mesh: Mesh): VertexData;
  34891. /**
  34892. * Updates the associated geometry
  34893. * @param geometry the geometry to be updated
  34894. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34895. * @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
  34896. * @returns VertexData.
  34897. */
  34898. updateGeometry(geometry: Geometry): VertexData;
  34899. private _applyTo;
  34900. private _update;
  34901. /**
  34902. * Transforms each position and each normal of the vertexData according to the passed Matrix
  34903. * @param matrix the transforming matrix
  34904. * @returns the VertexData
  34905. */
  34906. transform(matrix: Matrix): VertexData;
  34907. /**
  34908. * Merges the passed VertexData into the current one
  34909. * @param other the VertexData to be merged into the current one
  34910. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  34911. * @returns the modified VertexData
  34912. */
  34913. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  34914. private _mergeElement;
  34915. private _validate;
  34916. /**
  34917. * Serializes the VertexData
  34918. * @returns a serialized object
  34919. */
  34920. serialize(): any;
  34921. /**
  34922. * Extracts the vertexData from a mesh
  34923. * @param mesh the mesh from which to extract the VertexData
  34924. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  34925. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34926. * @returns the object VertexData associated to the passed mesh
  34927. */
  34928. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34929. /**
  34930. * Extracts the vertexData from the geometry
  34931. * @param geometry the geometry from which to extract the VertexData
  34932. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  34933. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34934. * @returns the object VertexData associated to the passed mesh
  34935. */
  34936. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34937. private static _ExtractFrom;
  34938. /**
  34939. * Creates the VertexData for a Ribbon
  34940. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  34941. * * pathArray array of paths, each of which an array of successive Vector3
  34942. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  34943. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  34944. * * 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
  34945. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34946. * * 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)
  34947. * * 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)
  34948. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  34949. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  34950. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  34951. * @returns the VertexData of the ribbon
  34952. */
  34953. static CreateRibbon(options: {
  34954. pathArray: Vector3[][];
  34955. closeArray?: boolean;
  34956. closePath?: boolean;
  34957. offset?: number;
  34958. sideOrientation?: number;
  34959. frontUVs?: Vector4;
  34960. backUVs?: Vector4;
  34961. invertUV?: boolean;
  34962. uvs?: Vector2[];
  34963. colors?: Color4[];
  34964. }): VertexData;
  34965. /**
  34966. * Creates the VertexData for a box
  34967. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34968. * * size sets the width, height and depth of the box to the value of size, optional default 1
  34969. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  34970. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  34971. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  34972. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34973. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34974. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34975. * * 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)
  34976. * * 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)
  34977. * @returns the VertexData of the box
  34978. */
  34979. static CreateBox(options: {
  34980. size?: number;
  34981. width?: number;
  34982. height?: number;
  34983. depth?: number;
  34984. faceUV?: Vector4[];
  34985. faceColors?: Color4[];
  34986. sideOrientation?: number;
  34987. frontUVs?: Vector4;
  34988. backUVs?: Vector4;
  34989. }): VertexData;
  34990. /**
  34991. * Creates the VertexData for a tiled box
  34992. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34993. * * faceTiles sets the pattern, tile size and number of tiles for a face
  34994. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34995. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34996. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34997. * @returns the VertexData of the box
  34998. */
  34999. static CreateTiledBox(options: {
  35000. pattern?: number;
  35001. width?: number;
  35002. height?: number;
  35003. depth?: number;
  35004. tileSize?: number;
  35005. tileWidth?: number;
  35006. tileHeight?: number;
  35007. alignHorizontal?: number;
  35008. alignVertical?: number;
  35009. faceUV?: Vector4[];
  35010. faceColors?: Color4[];
  35011. sideOrientation?: number;
  35012. }): VertexData;
  35013. /**
  35014. * Creates the VertexData for a tiled plane
  35015. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35016. * * pattern a limited pattern arrangement depending on the number
  35017. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  35018. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  35019. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  35020. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35021. * * 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)
  35022. * * 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)
  35023. * @returns the VertexData of the tiled plane
  35024. */
  35025. static CreateTiledPlane(options: {
  35026. pattern?: number;
  35027. tileSize?: number;
  35028. tileWidth?: number;
  35029. tileHeight?: number;
  35030. size?: number;
  35031. width?: number;
  35032. height?: number;
  35033. alignHorizontal?: number;
  35034. alignVertical?: number;
  35035. sideOrientation?: number;
  35036. frontUVs?: Vector4;
  35037. backUVs?: Vector4;
  35038. }): VertexData;
  35039. /**
  35040. * Creates the VertexData for an ellipsoid, defaults to a sphere
  35041. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35042. * * segments sets the number of horizontal strips optional, default 32
  35043. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  35044. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  35045. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  35046. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  35047. * * 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
  35048. * * 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
  35049. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35050. * * 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)
  35051. * * 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)
  35052. * @returns the VertexData of the ellipsoid
  35053. */
  35054. static CreateSphere(options: {
  35055. segments?: number;
  35056. diameter?: number;
  35057. diameterX?: number;
  35058. diameterY?: number;
  35059. diameterZ?: number;
  35060. arc?: number;
  35061. slice?: number;
  35062. sideOrientation?: number;
  35063. frontUVs?: Vector4;
  35064. backUVs?: Vector4;
  35065. }): VertexData;
  35066. /**
  35067. * Creates the VertexData for a cylinder, cone or prism
  35068. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35069. * * height sets the height (y direction) of the cylinder, optional, default 2
  35070. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  35071. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  35072. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  35073. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35074. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  35075. * * 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
  35076. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35077. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35078. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  35079. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  35080. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35081. * * 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)
  35082. * * 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)
  35083. * @returns the VertexData of the cylinder, cone or prism
  35084. */
  35085. static CreateCylinder(options: {
  35086. height?: number;
  35087. diameterTop?: number;
  35088. diameterBottom?: number;
  35089. diameter?: number;
  35090. tessellation?: number;
  35091. subdivisions?: number;
  35092. arc?: number;
  35093. faceColors?: Color4[];
  35094. faceUV?: Vector4[];
  35095. hasRings?: boolean;
  35096. enclose?: boolean;
  35097. sideOrientation?: number;
  35098. frontUVs?: Vector4;
  35099. backUVs?: Vector4;
  35100. }): VertexData;
  35101. /**
  35102. * Creates the VertexData for a torus
  35103. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35104. * * diameter the diameter of the torus, optional default 1
  35105. * * thickness the diameter of the tube forming the torus, optional default 0.5
  35106. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35107. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35108. * * 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)
  35109. * * 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)
  35110. * @returns the VertexData of the torus
  35111. */
  35112. static CreateTorus(options: {
  35113. diameter?: number;
  35114. thickness?: number;
  35115. tessellation?: number;
  35116. sideOrientation?: number;
  35117. frontUVs?: Vector4;
  35118. backUVs?: Vector4;
  35119. }): VertexData;
  35120. /**
  35121. * Creates the VertexData of the LineSystem
  35122. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  35123. * - lines an array of lines, each line being an array of successive Vector3
  35124. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  35125. * @returns the VertexData of the LineSystem
  35126. */
  35127. static CreateLineSystem(options: {
  35128. lines: Vector3[][];
  35129. colors?: Nullable<Color4[][]>;
  35130. }): VertexData;
  35131. /**
  35132. * Create the VertexData for a DashedLines
  35133. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  35134. * - points an array successive Vector3
  35135. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  35136. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  35137. * - dashNb the intended total number of dashes, optional, default 200
  35138. * @returns the VertexData for the DashedLines
  35139. */
  35140. static CreateDashedLines(options: {
  35141. points: Vector3[];
  35142. dashSize?: number;
  35143. gapSize?: number;
  35144. dashNb?: number;
  35145. }): VertexData;
  35146. /**
  35147. * Creates the VertexData for a Ground
  35148. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35149. * - width the width (x direction) of the ground, optional, default 1
  35150. * - height the height (z direction) of the ground, optional, default 1
  35151. * - subdivisions the number of subdivisions per side, optional, default 1
  35152. * @returns the VertexData of the Ground
  35153. */
  35154. static CreateGround(options: {
  35155. width?: number;
  35156. height?: number;
  35157. subdivisions?: number;
  35158. subdivisionsX?: number;
  35159. subdivisionsY?: number;
  35160. }): VertexData;
  35161. /**
  35162. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  35163. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35164. * * xmin the ground minimum X coordinate, optional, default -1
  35165. * * zmin the ground minimum Z coordinate, optional, default -1
  35166. * * xmax the ground maximum X coordinate, optional, default 1
  35167. * * zmax the ground maximum Z coordinate, optional, default 1
  35168. * * 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}
  35169. * * 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}
  35170. * @returns the VertexData of the TiledGround
  35171. */
  35172. static CreateTiledGround(options: {
  35173. xmin: number;
  35174. zmin: number;
  35175. xmax: number;
  35176. zmax: number;
  35177. subdivisions?: {
  35178. w: number;
  35179. h: number;
  35180. };
  35181. precision?: {
  35182. w: number;
  35183. h: number;
  35184. };
  35185. }): VertexData;
  35186. /**
  35187. * Creates the VertexData of the Ground designed from a heightmap
  35188. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  35189. * * width the width (x direction) of the ground
  35190. * * height the height (z direction) of the ground
  35191. * * subdivisions the number of subdivisions per side
  35192. * * minHeight the minimum altitude on the ground, optional, default 0
  35193. * * maxHeight the maximum altitude on the ground, optional default 1
  35194. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  35195. * * buffer the array holding the image color data
  35196. * * bufferWidth the width of image
  35197. * * bufferHeight the height of image
  35198. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  35199. * @returns the VertexData of the Ground designed from a heightmap
  35200. */
  35201. static CreateGroundFromHeightMap(options: {
  35202. width: number;
  35203. height: number;
  35204. subdivisions: number;
  35205. minHeight: number;
  35206. maxHeight: number;
  35207. colorFilter: Color3;
  35208. buffer: Uint8Array;
  35209. bufferWidth: number;
  35210. bufferHeight: number;
  35211. alphaFilter: number;
  35212. }): VertexData;
  35213. /**
  35214. * Creates the VertexData for a Plane
  35215. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  35216. * * size sets the width and height of the plane to the value of size, optional default 1
  35217. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  35218. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  35219. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35220. * * 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)
  35221. * * 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)
  35222. * @returns the VertexData of the box
  35223. */
  35224. static CreatePlane(options: {
  35225. size?: number;
  35226. width?: number;
  35227. height?: number;
  35228. sideOrientation?: number;
  35229. frontUVs?: Vector4;
  35230. backUVs?: Vector4;
  35231. }): VertexData;
  35232. /**
  35233. * Creates the VertexData of the Disc or regular Polygon
  35234. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  35235. * * radius the radius of the disc, optional default 0.5
  35236. * * tessellation the number of polygon sides, optional, default 64
  35237. * * 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
  35238. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35239. * * 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)
  35240. * * 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)
  35241. * @returns the VertexData of the box
  35242. */
  35243. static CreateDisc(options: {
  35244. radius?: number;
  35245. tessellation?: number;
  35246. arc?: number;
  35247. sideOrientation?: number;
  35248. frontUVs?: Vector4;
  35249. backUVs?: Vector4;
  35250. }): VertexData;
  35251. /**
  35252. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  35253. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  35254. * @param polygon a mesh built from polygonTriangulation.build()
  35255. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35256. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35257. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35258. * @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)
  35259. * @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)
  35260. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  35261. * @returns the VertexData of the Polygon
  35262. */
  35263. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  35264. /**
  35265. * Creates the VertexData of the IcoSphere
  35266. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  35267. * * radius the radius of the IcoSphere, optional default 1
  35268. * * radiusX allows stretching in the x direction, optional, default radius
  35269. * * radiusY allows stretching in the y direction, optional, default radius
  35270. * * radiusZ allows stretching in the z direction, optional, default radius
  35271. * * flat when true creates a flat shaded mesh, optional, default true
  35272. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35273. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35274. * * 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)
  35275. * * 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)
  35276. * @returns the VertexData of the IcoSphere
  35277. */
  35278. static CreateIcoSphere(options: {
  35279. radius?: number;
  35280. radiusX?: number;
  35281. radiusY?: number;
  35282. radiusZ?: number;
  35283. flat?: boolean;
  35284. subdivisions?: number;
  35285. sideOrientation?: number;
  35286. frontUVs?: Vector4;
  35287. backUVs?: Vector4;
  35288. }): VertexData;
  35289. /**
  35290. * Creates the VertexData for a Polyhedron
  35291. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  35292. * * type provided types are:
  35293. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  35294. * * 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)
  35295. * * size the size of the IcoSphere, optional default 1
  35296. * * sizeX allows stretching in the x direction, optional, default size
  35297. * * sizeY allows stretching in the y direction, optional, default size
  35298. * * sizeZ allows stretching in the z direction, optional, default size
  35299. * * 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
  35300. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35301. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35302. * * flat when true creates a flat shaded mesh, optional, default true
  35303. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35304. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35305. * * 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)
  35306. * * 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)
  35307. * @returns the VertexData of the Polyhedron
  35308. */
  35309. static CreatePolyhedron(options: {
  35310. type?: number;
  35311. size?: number;
  35312. sizeX?: number;
  35313. sizeY?: number;
  35314. sizeZ?: number;
  35315. custom?: any;
  35316. faceUV?: Vector4[];
  35317. faceColors?: Color4[];
  35318. flat?: boolean;
  35319. sideOrientation?: number;
  35320. frontUVs?: Vector4;
  35321. backUVs?: Vector4;
  35322. }): VertexData;
  35323. /**
  35324. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  35325. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  35326. * @returns the VertexData of the Capsule
  35327. */
  35328. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  35329. /**
  35330. * Creates the VertexData for a TorusKnot
  35331. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  35332. * * radius the radius of the torus knot, optional, default 2
  35333. * * tube the thickness of the tube, optional, default 0.5
  35334. * * radialSegments the number of sides on each tube segments, optional, default 32
  35335. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  35336. * * p the number of windings around the z axis, optional, default 2
  35337. * * q the number of windings around the x axis, optional, default 3
  35338. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35339. * * 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)
  35340. * * 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)
  35341. * @returns the VertexData of the Torus Knot
  35342. */
  35343. static CreateTorusKnot(options: {
  35344. radius?: number;
  35345. tube?: number;
  35346. radialSegments?: number;
  35347. tubularSegments?: number;
  35348. p?: number;
  35349. q?: number;
  35350. sideOrientation?: number;
  35351. frontUVs?: Vector4;
  35352. backUVs?: Vector4;
  35353. }): VertexData;
  35354. /**
  35355. * Compute normals for given positions and indices
  35356. * @param positions an array of vertex positions, [...., x, y, z, ......]
  35357. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  35358. * @param normals an array of vertex normals, [...., x, y, z, ......]
  35359. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  35360. * * facetNormals : optional array of facet normals (vector3)
  35361. * * facetPositions : optional array of facet positions (vector3)
  35362. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  35363. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  35364. * * bInfo : optional bounding info, required for facetPartitioning computation
  35365. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  35366. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  35367. * * useRightHandedSystem: optional boolean to for right handed system computation
  35368. * * depthSort : optional boolean to enable the facet depth sort computation
  35369. * * distanceTo : optional Vector3 to compute the facet depth from this location
  35370. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  35371. */
  35372. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  35373. facetNormals?: any;
  35374. facetPositions?: any;
  35375. facetPartitioning?: any;
  35376. ratio?: number;
  35377. bInfo?: any;
  35378. bbSize?: Vector3;
  35379. subDiv?: any;
  35380. useRightHandedSystem?: boolean;
  35381. depthSort?: boolean;
  35382. distanceTo?: Vector3;
  35383. depthSortedFacets?: any;
  35384. }): void;
  35385. /** @hidden */
  35386. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  35387. /**
  35388. * Applies VertexData created from the imported parameters to the geometry
  35389. * @param parsedVertexData the parsed data from an imported file
  35390. * @param geometry the geometry to apply the VertexData to
  35391. */
  35392. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  35393. }
  35394. }
  35395. declare module "babylonjs/Meshes/Builders/discBuilder" {
  35396. import { Nullable } from "babylonjs/types";
  35397. import { Scene } from "babylonjs/scene";
  35398. import { Vector4 } from "babylonjs/Maths/math.vector";
  35399. import { Mesh } from "babylonjs/Meshes/mesh";
  35400. /**
  35401. * Class containing static functions to help procedurally build meshes
  35402. */
  35403. export class DiscBuilder {
  35404. /**
  35405. * Creates a plane polygonal mesh. By default, this is a disc
  35406. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35407. * * 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
  35408. * * 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
  35409. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35410. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35412. * @param name defines the name of the mesh
  35413. * @param options defines the options used to create the mesh
  35414. * @param scene defines the hosting scene
  35415. * @returns the plane polygonal mesh
  35416. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35417. */
  35418. static CreateDisc(name: string, options: {
  35419. radius?: number;
  35420. tessellation?: number;
  35421. arc?: number;
  35422. updatable?: boolean;
  35423. sideOrientation?: number;
  35424. frontUVs?: Vector4;
  35425. backUVs?: Vector4;
  35426. }, scene?: Nullable<Scene>): Mesh;
  35427. }
  35428. }
  35429. declare module "babylonjs/Particles/solidParticleSystem" {
  35430. import { Nullable } from "babylonjs/types";
  35431. import { Mesh } from "babylonjs/Meshes/mesh";
  35432. import { Scene, IDisposable } from "babylonjs/scene";
  35433. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  35434. import { Material } from "babylonjs/Materials/material";
  35435. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35436. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35437. /**
  35438. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35439. *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.
  35440. * The SPS is also a particle system. It provides some methods to manage the particles.
  35441. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35442. *
  35443. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35444. */
  35445. export class SolidParticleSystem implements IDisposable {
  35446. /**
  35447. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35448. * Example : var p = SPS.particles[i];
  35449. */
  35450. particles: SolidParticle[];
  35451. /**
  35452. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35453. */
  35454. nbParticles: number;
  35455. /**
  35456. * If the particles must ever face the camera (default false). Useful for planar particles.
  35457. */
  35458. billboard: boolean;
  35459. /**
  35460. * Recompute normals when adding a shape
  35461. */
  35462. recomputeNormals: boolean;
  35463. /**
  35464. * This a counter ofr your own usage. It's not set by any SPS functions.
  35465. */
  35466. counter: number;
  35467. /**
  35468. * The SPS name. This name is also given to the underlying mesh.
  35469. */
  35470. name: string;
  35471. /**
  35472. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  35473. */
  35474. mesh: Mesh;
  35475. /**
  35476. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35477. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35478. */
  35479. vars: any;
  35480. /**
  35481. * This array is populated when the SPS is set as 'pickable'.
  35482. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35483. * Each element of this array is an object `{idx: int, faceId: int}`.
  35484. * `idx` is the picked particle index in the `SPS.particles` array
  35485. * `faceId` is the picked face index counted within this particle.
  35486. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35487. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35488. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35489. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35490. */
  35491. pickedParticles: {
  35492. idx: number;
  35493. faceId: number;
  35494. }[];
  35495. /**
  35496. * This array is populated when the SPS is set as 'pickable'
  35497. * Each key of this array is a submesh index.
  35498. * Each element of this array is a second array defined like this :
  35499. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35500. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35501. * `idx` is the picked particle index in the `SPS.particles` array
  35502. * `faceId` is the picked face index counted within this particle.
  35503. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35504. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35505. */
  35506. pickedBySubMesh: {
  35507. idx: number;
  35508. faceId: number;
  35509. }[][];
  35510. /**
  35511. * This array is populated when `enableDepthSort` is set to true.
  35512. * Each element of this array is an instance of the class DepthSortedParticle.
  35513. */
  35514. depthSortedParticles: DepthSortedParticle[];
  35515. /**
  35516. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35517. * @hidden
  35518. */
  35519. _bSphereOnly: boolean;
  35520. /**
  35521. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35522. * @hidden
  35523. */
  35524. _bSphereRadiusFactor: number;
  35525. private _scene;
  35526. private _positions;
  35527. private _indices;
  35528. private _normals;
  35529. private _colors;
  35530. private _uvs;
  35531. private _indices32;
  35532. private _positions32;
  35533. private _normals32;
  35534. private _fixedNormal32;
  35535. private _colors32;
  35536. private _uvs32;
  35537. private _index;
  35538. private _updatable;
  35539. private _pickable;
  35540. private _isVisibilityBoxLocked;
  35541. private _alwaysVisible;
  35542. private _depthSort;
  35543. private _expandable;
  35544. private _shapeCounter;
  35545. private _copy;
  35546. private _color;
  35547. private _computeParticleColor;
  35548. private _computeParticleTexture;
  35549. private _computeParticleRotation;
  35550. private _computeParticleVertex;
  35551. private _computeBoundingBox;
  35552. private _depthSortParticles;
  35553. private _camera;
  35554. private _mustUnrotateFixedNormals;
  35555. private _particlesIntersect;
  35556. private _needs32Bits;
  35557. private _isNotBuilt;
  35558. private _lastParticleId;
  35559. private _idxOfId;
  35560. private _multimaterialEnabled;
  35561. private _useModelMaterial;
  35562. private _indicesByMaterial;
  35563. private _materialIndexes;
  35564. private _depthSortFunction;
  35565. private _materialSortFunction;
  35566. private _materials;
  35567. private _multimaterial;
  35568. private _materialIndexesById;
  35569. private _defaultMaterial;
  35570. private _autoUpdateSubMeshes;
  35571. private _tmpVertex;
  35572. /**
  35573. * Creates a SPS (Solid Particle System) object.
  35574. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35575. * @param scene (Scene) is the scene in which the SPS is added.
  35576. * @param options defines the options of the sps e.g.
  35577. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35578. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35579. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35580. * * 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.
  35581. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35582. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35583. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35584. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35585. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35586. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35587. */
  35588. constructor(name: string, scene: Scene, options?: {
  35589. updatable?: boolean;
  35590. isPickable?: boolean;
  35591. enableDepthSort?: boolean;
  35592. particleIntersection?: boolean;
  35593. boundingSphereOnly?: boolean;
  35594. bSphereRadiusFactor?: number;
  35595. expandable?: boolean;
  35596. useModelMaterial?: boolean;
  35597. enableMultiMaterial?: boolean;
  35598. });
  35599. /**
  35600. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35601. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35602. * @returns the created mesh
  35603. */
  35604. buildMesh(): Mesh;
  35605. /**
  35606. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35607. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35608. * Thus the particles generated from `digest()` have their property `position` set yet.
  35609. * @param mesh ( Mesh ) is the mesh to be digested
  35610. * @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
  35611. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35612. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35613. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35614. * @returns the current SPS
  35615. */
  35616. digest(mesh: Mesh, options?: {
  35617. facetNb?: number;
  35618. number?: number;
  35619. delta?: number;
  35620. storage?: [];
  35621. }): SolidParticleSystem;
  35622. /**
  35623. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35624. * @hidden
  35625. */
  35626. private _unrotateFixedNormals;
  35627. /**
  35628. * Resets the temporary working copy particle
  35629. * @hidden
  35630. */
  35631. private _resetCopy;
  35632. /**
  35633. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35634. * @param p the current index in the positions array to be updated
  35635. * @param ind the current index in the indices array
  35636. * @param shape a Vector3 array, the shape geometry
  35637. * @param positions the positions array to be updated
  35638. * @param meshInd the shape indices array
  35639. * @param indices the indices array to be updated
  35640. * @param meshUV the shape uv array
  35641. * @param uvs the uv array to be updated
  35642. * @param meshCol the shape color array
  35643. * @param colors the color array to be updated
  35644. * @param meshNor the shape normals array
  35645. * @param normals the normals array to be updated
  35646. * @param idx the particle index
  35647. * @param idxInShape the particle index in its shape
  35648. * @param options the addShape() method passed options
  35649. * @model the particle model
  35650. * @hidden
  35651. */
  35652. private _meshBuilder;
  35653. /**
  35654. * Returns a shape Vector3 array from positions float array
  35655. * @param positions float array
  35656. * @returns a vector3 array
  35657. * @hidden
  35658. */
  35659. private _posToShape;
  35660. /**
  35661. * Returns a shapeUV array from a float uvs (array deep copy)
  35662. * @param uvs as a float array
  35663. * @returns a shapeUV array
  35664. * @hidden
  35665. */
  35666. private _uvsToShapeUV;
  35667. /**
  35668. * Adds a new particle object in the particles array
  35669. * @param idx particle index in particles array
  35670. * @param id particle id
  35671. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35672. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35673. * @param model particle ModelShape object
  35674. * @param shapeId model shape identifier
  35675. * @param idxInShape index of the particle in the current model
  35676. * @param bInfo model bounding info object
  35677. * @param storage target storage array, if any
  35678. * @hidden
  35679. */
  35680. private _addParticle;
  35681. /**
  35682. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35683. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35684. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35685. * @param nb (positive integer) the number of particles to be created from this model
  35686. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35687. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35688. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35689. * @returns the number of shapes in the system
  35690. */
  35691. addShape(mesh: Mesh, nb: number, options?: {
  35692. positionFunction?: any;
  35693. vertexFunction?: any;
  35694. storage?: [];
  35695. }): number;
  35696. /**
  35697. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35698. * @hidden
  35699. */
  35700. private _rebuildParticle;
  35701. /**
  35702. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35703. * @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.
  35704. * @returns the SPS.
  35705. */
  35706. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35707. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35708. * Returns an array with the removed particles.
  35709. * 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.
  35710. * The SPS can't be empty so at least one particle needs to remain in place.
  35711. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35712. * @param start index of the first particle to remove
  35713. * @param end index of the last particle to remove (included)
  35714. * @returns an array populated with the removed particles
  35715. */
  35716. removeParticles(start: number, end: number): SolidParticle[];
  35717. /**
  35718. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35719. * @param solidParticleArray an array populated with Solid Particles objects
  35720. * @returns the SPS
  35721. */
  35722. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35723. /**
  35724. * Creates a new particle and modifies the SPS mesh geometry :
  35725. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35726. * - calls _addParticle() to populate the particle array
  35727. * factorized code from addShape() and insertParticlesFromArray()
  35728. * @param idx particle index in the particles array
  35729. * @param i particle index in its shape
  35730. * @param modelShape particle ModelShape object
  35731. * @param shape shape vertex array
  35732. * @param meshInd shape indices array
  35733. * @param meshUV shape uv array
  35734. * @param meshCol shape color array
  35735. * @param meshNor shape normals array
  35736. * @param bbInfo shape bounding info
  35737. * @param storage target particle storage
  35738. * @options addShape() passed options
  35739. * @hidden
  35740. */
  35741. private _insertNewParticle;
  35742. /**
  35743. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35744. * This method calls `updateParticle()` for each particle of the SPS.
  35745. * For an animated SPS, it is usually called within the render loop.
  35746. * 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.
  35747. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35748. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35749. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35750. * @returns the SPS.
  35751. */
  35752. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35753. /**
  35754. * Disposes the SPS.
  35755. */
  35756. dispose(): void;
  35757. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  35758. * idx is the particle index in the SPS
  35759. * faceId is the picked face index counted within this particle.
  35760. * Returns null if the pickInfo can't identify a picked particle.
  35761. * @param pickingInfo (PickingInfo object)
  35762. * @returns {idx: number, faceId: number} or null
  35763. */
  35764. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35765. idx: number;
  35766. faceId: number;
  35767. }>;
  35768. /**
  35769. * Returns a SolidParticle object from its identifier : particle.id
  35770. * @param id (integer) the particle Id
  35771. * @returns the searched particle or null if not found in the SPS.
  35772. */
  35773. getParticleById(id: number): Nullable<SolidParticle>;
  35774. /**
  35775. * Returns a new array populated with the particles having the passed shapeId.
  35776. * @param shapeId (integer) the shape identifier
  35777. * @returns a new solid particle array
  35778. */
  35779. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35780. /**
  35781. * Populates the passed array "ref" with the particles having the passed shapeId.
  35782. * @param shapeId the shape identifier
  35783. * @returns the SPS
  35784. * @param ref
  35785. */
  35786. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35787. /**
  35788. * Computes the required SubMeshes according the materials assigned to the particles.
  35789. * @returns the solid particle system.
  35790. * Does nothing if called before the SPS mesh is built.
  35791. */
  35792. computeSubMeshes(): SolidParticleSystem;
  35793. /**
  35794. * Sorts the solid particles by material when MultiMaterial is enabled.
  35795. * Updates the indices32 array.
  35796. * Updates the indicesByMaterial array.
  35797. * Updates the mesh indices array.
  35798. * @returns the SPS
  35799. * @hidden
  35800. */
  35801. private _sortParticlesByMaterial;
  35802. /**
  35803. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35804. * @hidden
  35805. */
  35806. private _setMaterialIndexesById;
  35807. /**
  35808. * Returns an array with unique values of Materials from the passed array
  35809. * @param array the material array to be checked and filtered
  35810. * @hidden
  35811. */
  35812. private _filterUniqueMaterialId;
  35813. /**
  35814. * Sets a new Standard Material as _defaultMaterial if not already set.
  35815. * @hidden
  35816. */
  35817. private _setDefaultMaterial;
  35818. /**
  35819. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  35820. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35821. * @returns the SPS.
  35822. */
  35823. refreshVisibleSize(): SolidParticleSystem;
  35824. /**
  35825. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35826. * @param size the size (float) of the visibility box
  35827. * note : this doesn't lock the SPS mesh bounding box.
  35828. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35829. */
  35830. setVisibilityBox(size: number): void;
  35831. /**
  35832. * Gets whether the SPS as always visible or not
  35833. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35834. */
  35835. get isAlwaysVisible(): boolean;
  35836. /**
  35837. * Sets the SPS as always visible or not
  35838. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35839. */
  35840. set isAlwaysVisible(val: boolean);
  35841. /**
  35842. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35843. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35844. */
  35845. set isVisibilityBoxLocked(val: boolean);
  35846. /**
  35847. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35848. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35849. */
  35850. get isVisibilityBoxLocked(): boolean;
  35851. /**
  35852. * Tells to `setParticles()` to compute the particle rotations or not.
  35853. * Default value : true. The SPS is faster when it's set to false.
  35854. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35855. */
  35856. set computeParticleRotation(val: boolean);
  35857. /**
  35858. * Tells to `setParticles()` to compute the particle colors or not.
  35859. * Default value : true. The SPS is faster when it's set to false.
  35860. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35861. */
  35862. set computeParticleColor(val: boolean);
  35863. set computeParticleTexture(val: boolean);
  35864. /**
  35865. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35866. * Default value : false. The SPS is faster when it's set to false.
  35867. * Note : the particle custom vertex positions aren't stored values.
  35868. */
  35869. set computeParticleVertex(val: boolean);
  35870. /**
  35871. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35872. */
  35873. set computeBoundingBox(val: boolean);
  35874. /**
  35875. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35876. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35877. * Default : `true`
  35878. */
  35879. set depthSortParticles(val: boolean);
  35880. /**
  35881. * Gets if `setParticles()` computes the particle rotations or not.
  35882. * Default value : true. The SPS is faster when it's set to false.
  35883. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35884. */
  35885. get computeParticleRotation(): boolean;
  35886. /**
  35887. * Gets if `setParticles()` computes the particle colors or not.
  35888. * Default value : true. The SPS is faster when it's set to false.
  35889. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35890. */
  35891. get computeParticleColor(): boolean;
  35892. /**
  35893. * Gets if `setParticles()` computes the particle textures or not.
  35894. * Default value : true. The SPS is faster when it's set to false.
  35895. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35896. */
  35897. get computeParticleTexture(): boolean;
  35898. /**
  35899. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35900. * Default value : false. The SPS is faster when it's set to false.
  35901. * Note : the particle custom vertex positions aren't stored values.
  35902. */
  35903. get computeParticleVertex(): boolean;
  35904. /**
  35905. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35906. */
  35907. get computeBoundingBox(): boolean;
  35908. /**
  35909. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35910. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35911. * Default : `true`
  35912. */
  35913. get depthSortParticles(): boolean;
  35914. /**
  35915. * Gets if the SPS is created as expandable at construction time.
  35916. * Default : `false`
  35917. */
  35918. get expandable(): boolean;
  35919. /**
  35920. * Gets if the SPS supports the Multi Materials
  35921. */
  35922. get multimaterialEnabled(): boolean;
  35923. /**
  35924. * Gets if the SPS uses the model materials for its own multimaterial.
  35925. */
  35926. get useModelMaterial(): boolean;
  35927. /**
  35928. * The SPS used material array.
  35929. */
  35930. get materials(): Material[];
  35931. /**
  35932. * Sets the SPS MultiMaterial from the passed materials.
  35933. * Note : the passed array is internally copied and not used then by reference.
  35934. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35935. */
  35936. setMultiMaterial(materials: Material[]): void;
  35937. /**
  35938. * The SPS computed multimaterial object
  35939. */
  35940. get multimaterial(): MultiMaterial;
  35941. set multimaterial(mm: MultiMaterial);
  35942. /**
  35943. * If the subMeshes must be updated on the next call to setParticles()
  35944. */
  35945. get autoUpdateSubMeshes(): boolean;
  35946. set autoUpdateSubMeshes(val: boolean);
  35947. /**
  35948. * This function does nothing. It may be overwritten to set all the particle first values.
  35949. * The SPS doesn't call this function, you may have to call it by your own.
  35950. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35951. */
  35952. initParticles(): void;
  35953. /**
  35954. * This function does nothing. It may be overwritten to recycle a particle.
  35955. * The SPS doesn't call this function, you may have to call it by your own.
  35956. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35957. * @param particle The particle to recycle
  35958. * @returns the recycled particle
  35959. */
  35960. recycleParticle(particle: SolidParticle): SolidParticle;
  35961. /**
  35962. * Updates a particle : this function should be overwritten by the user.
  35963. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35964. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35965. * @example : just set a particle position or velocity and recycle conditions
  35966. * @param particle The particle to update
  35967. * @returns the updated particle
  35968. */
  35969. updateParticle(particle: SolidParticle): SolidParticle;
  35970. /**
  35971. * Updates a vertex of a particle : it can be overwritten by the user.
  35972. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35973. * @param particle the current particle
  35974. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35975. * @param pt the index of the current vertex in the particle shape
  35976. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35977. * @example : just set a vertex particle position or color
  35978. * @returns the sps
  35979. */
  35980. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35981. /**
  35982. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35983. * This does nothing and may be overwritten by the user.
  35984. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35985. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35986. * @param update the boolean update value actually passed to setParticles()
  35987. */
  35988. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35989. /**
  35990. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35991. * This will be passed three parameters.
  35992. * This does nothing and may be overwritten by the user.
  35993. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35994. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35995. * @param update the boolean update value actually passed to setParticles()
  35996. */
  35997. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35998. }
  35999. }
  36000. declare module "babylonjs/Particles/solidParticle" {
  36001. import { Nullable } from "babylonjs/types";
  36002. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  36003. import { Color4 } from "babylonjs/Maths/math.color";
  36004. import { Mesh } from "babylonjs/Meshes/mesh";
  36005. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36006. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  36007. import { Plane } from "babylonjs/Maths/math.plane";
  36008. import { Material } from "babylonjs/Materials/material";
  36009. /**
  36010. * Represents one particle of a solid particle system.
  36011. */
  36012. export class SolidParticle {
  36013. /**
  36014. * particle global index
  36015. */
  36016. idx: number;
  36017. /**
  36018. * particle identifier
  36019. */
  36020. id: number;
  36021. /**
  36022. * The color of the particle
  36023. */
  36024. color: Nullable<Color4>;
  36025. /**
  36026. * The world space position of the particle.
  36027. */
  36028. position: Vector3;
  36029. /**
  36030. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36031. */
  36032. rotation: Vector3;
  36033. /**
  36034. * The world space rotation quaternion of the particle.
  36035. */
  36036. rotationQuaternion: Nullable<Quaternion>;
  36037. /**
  36038. * The scaling of the particle.
  36039. */
  36040. scaling: Vector3;
  36041. /**
  36042. * The uvs of the particle.
  36043. */
  36044. uvs: Vector4;
  36045. /**
  36046. * The current speed of the particle.
  36047. */
  36048. velocity: Vector3;
  36049. /**
  36050. * The pivot point in the particle local space.
  36051. */
  36052. pivot: Vector3;
  36053. /**
  36054. * Must the particle be translated from its pivot point in its local space ?
  36055. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36056. * Default : false
  36057. */
  36058. translateFromPivot: boolean;
  36059. /**
  36060. * Is the particle active or not ?
  36061. */
  36062. alive: boolean;
  36063. /**
  36064. * Is the particle visible or not ?
  36065. */
  36066. isVisible: boolean;
  36067. /**
  36068. * Index of this particle in the global "positions" array (Internal use)
  36069. * @hidden
  36070. */
  36071. _pos: number;
  36072. /**
  36073. * @hidden Index of this particle in the global "indices" array (Internal use)
  36074. */
  36075. _ind: number;
  36076. /**
  36077. * @hidden ModelShape of this particle (Internal use)
  36078. */
  36079. _model: ModelShape;
  36080. /**
  36081. * ModelShape id of this particle
  36082. */
  36083. shapeId: number;
  36084. /**
  36085. * Index of the particle in its shape id
  36086. */
  36087. idxInShape: number;
  36088. /**
  36089. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36090. */
  36091. _modelBoundingInfo: BoundingInfo;
  36092. /**
  36093. * @hidden Particle BoundingInfo object (Internal use)
  36094. */
  36095. _boundingInfo: BoundingInfo;
  36096. /**
  36097. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36098. */
  36099. _sps: SolidParticleSystem;
  36100. /**
  36101. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36102. */
  36103. _stillInvisible: boolean;
  36104. /**
  36105. * @hidden Last computed particle rotation matrix
  36106. */
  36107. _rotationMatrix: number[];
  36108. /**
  36109. * Parent particle Id, if any.
  36110. * Default null.
  36111. */
  36112. parentId: Nullable<number>;
  36113. /**
  36114. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36115. */
  36116. materialIndex: Nullable<number>;
  36117. /**
  36118. * Custom object or properties.
  36119. */
  36120. props: Nullable<any>;
  36121. /**
  36122. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36123. * The possible values are :
  36124. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36125. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36126. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36127. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36128. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36129. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36130. * */
  36131. cullingStrategy: number;
  36132. /**
  36133. * @hidden Internal global position in the SPS.
  36134. */
  36135. _globalPosition: Vector3;
  36136. /**
  36137. * Creates a Solid Particle object.
  36138. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36139. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36140. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36141. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36142. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36143. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36144. * @param shapeId (integer) is the model shape identifier in the SPS.
  36145. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36146. * @param sps defines the sps it is associated to
  36147. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36148. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36149. */
  36150. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36151. /**
  36152. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36153. * @param target the particle target
  36154. * @returns the current particle
  36155. */
  36156. copyToRef(target: SolidParticle): SolidParticle;
  36157. /**
  36158. * Legacy support, changed scale to scaling
  36159. */
  36160. get scale(): Vector3;
  36161. /**
  36162. * Legacy support, changed scale to scaling
  36163. */
  36164. set scale(scale: Vector3);
  36165. /**
  36166. * Legacy support, changed quaternion to rotationQuaternion
  36167. */
  36168. get quaternion(): Nullable<Quaternion>;
  36169. /**
  36170. * Legacy support, changed quaternion to rotationQuaternion
  36171. */
  36172. set quaternion(q: Nullable<Quaternion>);
  36173. /**
  36174. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36175. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36176. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36177. * @returns true if it intersects
  36178. */
  36179. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36180. /**
  36181. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36182. * A particle is in the frustum if its bounding box intersects the frustum
  36183. * @param frustumPlanes defines the frustum to test
  36184. * @returns true if the particle is in the frustum planes
  36185. */
  36186. isInFrustum(frustumPlanes: Plane[]): boolean;
  36187. /**
  36188. * get the rotation matrix of the particle
  36189. * @hidden
  36190. */
  36191. getRotationMatrix(m: Matrix): void;
  36192. }
  36193. /**
  36194. * Represents the shape of the model used by one particle of a solid particle system.
  36195. * SPS internal tool, don't use it manually.
  36196. */
  36197. export class ModelShape {
  36198. /**
  36199. * The shape id
  36200. * @hidden
  36201. */
  36202. shapeID: number;
  36203. /**
  36204. * flat array of model positions (internal use)
  36205. * @hidden
  36206. */
  36207. _shape: Vector3[];
  36208. /**
  36209. * flat array of model UVs (internal use)
  36210. * @hidden
  36211. */
  36212. _shapeUV: number[];
  36213. /**
  36214. * color array of the model
  36215. * @hidden
  36216. */
  36217. _shapeColors: number[];
  36218. /**
  36219. * indices array of the model
  36220. * @hidden
  36221. */
  36222. _indices: number[];
  36223. /**
  36224. * normals array of the model
  36225. * @hidden
  36226. */
  36227. _normals: number[];
  36228. /**
  36229. * length of the shape in the model indices array (internal use)
  36230. * @hidden
  36231. */
  36232. _indicesLength: number;
  36233. /**
  36234. * Custom position function (internal use)
  36235. * @hidden
  36236. */
  36237. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36238. /**
  36239. * Custom vertex function (internal use)
  36240. * @hidden
  36241. */
  36242. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36243. /**
  36244. * Model material (internal use)
  36245. * @hidden
  36246. */
  36247. _material: Nullable<Material>;
  36248. /**
  36249. * 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.
  36250. * SPS internal tool, don't use it manually.
  36251. * @hidden
  36252. */
  36253. 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>);
  36254. }
  36255. /**
  36256. * Represents a Depth Sorted Particle in the solid particle system.
  36257. * @hidden
  36258. */
  36259. export class DepthSortedParticle {
  36260. /**
  36261. * Particle index
  36262. */
  36263. idx: number;
  36264. /**
  36265. * Index of the particle in the "indices" array
  36266. */
  36267. ind: number;
  36268. /**
  36269. * Length of the particle shape in the "indices" array
  36270. */
  36271. indicesLength: number;
  36272. /**
  36273. * Squared distance from the particle to the camera
  36274. */
  36275. sqDistance: number;
  36276. /**
  36277. * Material index when used with MultiMaterials
  36278. */
  36279. materialIndex: number;
  36280. /**
  36281. * Creates a new sorted particle
  36282. * @param materialIndex
  36283. */
  36284. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36285. }
  36286. /**
  36287. * Represents a solid particle vertex
  36288. */
  36289. export class SolidParticleVertex {
  36290. /**
  36291. * Vertex position
  36292. */
  36293. position: Vector3;
  36294. /**
  36295. * Vertex color
  36296. */
  36297. color: Color4;
  36298. /**
  36299. * Vertex UV
  36300. */
  36301. uv: Vector2;
  36302. /**
  36303. * Creates a new solid particle vertex
  36304. */
  36305. constructor();
  36306. /** Vertex x coordinate */
  36307. get x(): number;
  36308. set x(val: number);
  36309. /** Vertex y coordinate */
  36310. get y(): number;
  36311. set y(val: number);
  36312. /** Vertex z coordinate */
  36313. get z(): number;
  36314. set z(val: number);
  36315. }
  36316. }
  36317. declare module "babylonjs/Collisions/meshCollisionData" {
  36318. import { Collider } from "babylonjs/Collisions/collider";
  36319. import { Vector3 } from "babylonjs/Maths/math.vector";
  36320. import { Nullable } from "babylonjs/types";
  36321. import { Observer } from "babylonjs/Misc/observable";
  36322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36323. /**
  36324. * @hidden
  36325. */
  36326. export class _MeshCollisionData {
  36327. _checkCollisions: boolean;
  36328. _collisionMask: number;
  36329. _collisionGroup: number;
  36330. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36331. _collider: Nullable<Collider>;
  36332. _oldPositionForCollisions: Vector3;
  36333. _diffPositionForCollisions: Vector3;
  36334. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36335. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36336. _collisionResponse: boolean;
  36337. }
  36338. }
  36339. declare module "babylonjs/Meshes/abstractMesh" {
  36340. import { Observable } from "babylonjs/Misc/observable";
  36341. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  36342. import { Camera } from "babylonjs/Cameras/camera";
  36343. import { Scene, IDisposable } from "babylonjs/scene";
  36344. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36345. import { Node } from "babylonjs/node";
  36346. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  36347. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36348. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36349. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36350. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36351. import { Material } from "babylonjs/Materials/material";
  36352. import { Light } from "babylonjs/Lights/light";
  36353. import { Skeleton } from "babylonjs/Bones/skeleton";
  36354. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  36355. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  36356. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36357. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  36358. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  36359. import { Plane } from "babylonjs/Maths/math.plane";
  36360. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36361. import { Ray } from "babylonjs/Culling/ray";
  36362. import { Collider } from "babylonjs/Collisions/collider";
  36363. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36364. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  36365. import { IEdgesRendererOptions } from "babylonjs/Rendering/edgesRenderer";
  36366. /** @hidden */
  36367. class _FacetDataStorage {
  36368. facetPositions: Vector3[];
  36369. facetNormals: Vector3[];
  36370. facetPartitioning: number[][];
  36371. facetNb: number;
  36372. partitioningSubdivisions: number;
  36373. partitioningBBoxRatio: number;
  36374. facetDataEnabled: boolean;
  36375. facetParameters: any;
  36376. bbSize: Vector3;
  36377. subDiv: {
  36378. max: number;
  36379. X: number;
  36380. Y: number;
  36381. Z: number;
  36382. };
  36383. facetDepthSort: boolean;
  36384. facetDepthSortEnabled: boolean;
  36385. depthSortedIndices: IndicesArray;
  36386. depthSortedFacets: {
  36387. ind: number;
  36388. sqDistance: number;
  36389. }[];
  36390. facetDepthSortFunction: (f1: {
  36391. ind: number;
  36392. sqDistance: number;
  36393. }, f2: {
  36394. ind: number;
  36395. sqDistance: number;
  36396. }) => number;
  36397. facetDepthSortFrom: Vector3;
  36398. facetDepthSortOrigin: Vector3;
  36399. invertedMatrix: Matrix;
  36400. }
  36401. /**
  36402. * @hidden
  36403. **/
  36404. class _InternalAbstractMeshDataInfo {
  36405. _hasVertexAlpha: boolean;
  36406. _useVertexColors: boolean;
  36407. _numBoneInfluencers: number;
  36408. _applyFog: boolean;
  36409. _receiveShadows: boolean;
  36410. _facetData: _FacetDataStorage;
  36411. _visibility: number;
  36412. _skeleton: Nullable<Skeleton>;
  36413. _layerMask: number;
  36414. _computeBonesUsingShaders: boolean;
  36415. _isActive: boolean;
  36416. _onlyForInstances: boolean;
  36417. _isActiveIntermediate: boolean;
  36418. _onlyForInstancesIntermediate: boolean;
  36419. _actAsRegularMesh: boolean;
  36420. _currentLOD: Nullable<AbstractMesh>;
  36421. }
  36422. /**
  36423. * Class used to store all common mesh properties
  36424. */
  36425. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36426. /** No occlusion */
  36427. static OCCLUSION_TYPE_NONE: number;
  36428. /** Occlusion set to optimisitic */
  36429. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36430. /** Occlusion set to strict */
  36431. static OCCLUSION_TYPE_STRICT: number;
  36432. /** Use an accurante occlusion algorithm */
  36433. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36434. /** Use a conservative occlusion algorithm */
  36435. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36436. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36437. * Test order :
  36438. * Is the bounding sphere outside the frustum ?
  36439. * If not, are the bounding box vertices outside the frustum ?
  36440. * It not, then the cullable object is in the frustum.
  36441. */
  36442. static readonly CULLINGSTRATEGY_STANDARD: number;
  36443. /** Culling strategy : Bounding Sphere Only.
  36444. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36445. * It's also less accurate than the standard because some not visible objects can still be selected.
  36446. * Test : is the bounding sphere outside the frustum ?
  36447. * If not, then the cullable object is in the frustum.
  36448. */
  36449. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36450. /** Culling strategy : Optimistic Inclusion.
  36451. * This in an inclusion test first, then the standard exclusion test.
  36452. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36453. * 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.
  36454. * Anyway, it's as accurate as the standard strategy.
  36455. * Test :
  36456. * Is the cullable object bounding sphere center in the frustum ?
  36457. * If not, apply the default culling strategy.
  36458. */
  36459. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36460. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36461. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36462. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36463. * 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.
  36464. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36465. * Test :
  36466. * Is the cullable object bounding sphere center in the frustum ?
  36467. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36468. */
  36469. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36470. /**
  36471. * No billboard
  36472. */
  36473. static get BILLBOARDMODE_NONE(): number;
  36474. /** Billboard on X axis */
  36475. static get BILLBOARDMODE_X(): number;
  36476. /** Billboard on Y axis */
  36477. static get BILLBOARDMODE_Y(): number;
  36478. /** Billboard on Z axis */
  36479. static get BILLBOARDMODE_Z(): number;
  36480. /** Billboard on all axes */
  36481. static get BILLBOARDMODE_ALL(): number;
  36482. /** Billboard on using position instead of orientation */
  36483. static get BILLBOARDMODE_USE_POSITION(): number;
  36484. /** @hidden */
  36485. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36486. /**
  36487. * The culling strategy to use to check whether the mesh must be rendered or not.
  36488. * This value can be changed at any time and will be used on the next render mesh selection.
  36489. * The possible values are :
  36490. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36491. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36492. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36493. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36494. * Please read each static variable documentation to get details about the culling process.
  36495. * */
  36496. cullingStrategy: number;
  36497. /**
  36498. * Gets the number of facets in the mesh
  36499. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36500. */
  36501. get facetNb(): number;
  36502. /**
  36503. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  36504. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36505. */
  36506. get partitioningSubdivisions(): number;
  36507. set partitioningSubdivisions(nb: number);
  36508. /**
  36509. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  36510. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  36511. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36512. */
  36513. get partitioningBBoxRatio(): number;
  36514. set partitioningBBoxRatio(ratio: number);
  36515. /**
  36516. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36517. * Works only for updatable meshes.
  36518. * Doesn't work with multi-materials
  36519. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36520. */
  36521. get mustDepthSortFacets(): boolean;
  36522. set mustDepthSortFacets(sort: boolean);
  36523. /**
  36524. * The location (Vector3) where the facet depth sort must be computed from.
  36525. * By default, the active camera position.
  36526. * Used only when facet depth sort is enabled
  36527. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36528. */
  36529. get facetDepthSortFrom(): Vector3;
  36530. set facetDepthSortFrom(location: Vector3);
  36531. /**
  36532. * gets a boolean indicating if facetData is enabled
  36533. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36534. */
  36535. get isFacetDataEnabled(): boolean;
  36536. /** @hidden */
  36537. _updateNonUniformScalingState(value: boolean): boolean;
  36538. /**
  36539. * An event triggered when this mesh collides with another one
  36540. */
  36541. onCollideObservable: Observable<AbstractMesh>;
  36542. /** Set a function to call when this mesh collides with another one */
  36543. set onCollide(callback: () => void);
  36544. /**
  36545. * An event triggered when the collision's position changes
  36546. */
  36547. onCollisionPositionChangeObservable: Observable<Vector3>;
  36548. /** Set a function to call when the collision's position changes */
  36549. set onCollisionPositionChange(callback: () => void);
  36550. /**
  36551. * An event triggered when material is changed
  36552. */
  36553. onMaterialChangedObservable: Observable<AbstractMesh>;
  36554. /**
  36555. * Gets or sets the orientation for POV movement & rotation
  36556. */
  36557. definedFacingForward: boolean;
  36558. /** @hidden */
  36559. _occlusionQuery: Nullable<WebGLQuery>;
  36560. /** @hidden */
  36561. _renderingGroup: Nullable<RenderingGroup>;
  36562. /**
  36563. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36564. */
  36565. get visibility(): number;
  36566. /**
  36567. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36568. */
  36569. set visibility(value: number);
  36570. /** Gets or sets the alpha index used to sort transparent meshes
  36571. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36572. */
  36573. alphaIndex: number;
  36574. /**
  36575. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36576. */
  36577. isVisible: boolean;
  36578. /**
  36579. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36580. */
  36581. isPickable: boolean;
  36582. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36583. showSubMeshesBoundingBox: boolean;
  36584. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36585. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36586. */
  36587. isBlocker: boolean;
  36588. /**
  36589. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36590. */
  36591. enablePointerMoveEvents: boolean;
  36592. private _renderingGroupId;
  36593. /**
  36594. * Specifies the rendering group id for this mesh (0 by default)
  36595. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36596. */
  36597. get renderingGroupId(): number;
  36598. set renderingGroupId(value: number);
  36599. private _material;
  36600. /** Gets or sets current material */
  36601. get material(): Nullable<Material>;
  36602. set material(value: Nullable<Material>);
  36603. /**
  36604. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36605. * @see https://doc.babylonjs.com/babylon101/shadows
  36606. */
  36607. get receiveShadows(): boolean;
  36608. set receiveShadows(value: boolean);
  36609. /** Defines color to use when rendering outline */
  36610. outlineColor: Color3;
  36611. /** Define width to use when rendering outline */
  36612. outlineWidth: number;
  36613. /** Defines color to use when rendering overlay */
  36614. overlayColor: Color3;
  36615. /** Defines alpha to use when rendering overlay */
  36616. overlayAlpha: number;
  36617. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36618. get hasVertexAlpha(): boolean;
  36619. set hasVertexAlpha(value: boolean);
  36620. /** 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) */
  36621. get useVertexColors(): boolean;
  36622. set useVertexColors(value: boolean);
  36623. /**
  36624. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36625. */
  36626. get computeBonesUsingShaders(): boolean;
  36627. set computeBonesUsingShaders(value: boolean);
  36628. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36629. get numBoneInfluencers(): number;
  36630. set numBoneInfluencers(value: number);
  36631. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36632. get applyFog(): boolean;
  36633. set applyFog(value: boolean);
  36634. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36635. useOctreeForRenderingSelection: boolean;
  36636. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36637. useOctreeForPicking: boolean;
  36638. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36639. useOctreeForCollisions: boolean;
  36640. /**
  36641. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36642. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36643. */
  36644. get layerMask(): number;
  36645. set layerMask(value: number);
  36646. /**
  36647. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36648. */
  36649. alwaysSelectAsActiveMesh: boolean;
  36650. /**
  36651. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36652. */
  36653. doNotSyncBoundingInfo: boolean;
  36654. /**
  36655. * Gets or sets the current action manager
  36656. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36657. */
  36658. actionManager: Nullable<AbstractActionManager>;
  36659. private _meshCollisionData;
  36660. /**
  36661. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36662. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36663. */
  36664. ellipsoid: Vector3;
  36665. /**
  36666. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36667. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36668. */
  36669. ellipsoidOffset: Vector3;
  36670. /**
  36671. * Gets or sets a collision mask used to mask collisions (default is -1).
  36672. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36673. */
  36674. get collisionMask(): number;
  36675. set collisionMask(mask: number);
  36676. /**
  36677. * Gets or sets a collision response flag (default is true).
  36678. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36679. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36680. * to respond to the collision.
  36681. */
  36682. get collisionResponse(): boolean;
  36683. set collisionResponse(response: boolean);
  36684. /**
  36685. * Gets or sets the current collision group mask (-1 by default).
  36686. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36687. */
  36688. get collisionGroup(): number;
  36689. set collisionGroup(mask: number);
  36690. /**
  36691. * Gets or sets current surrounding meshes (null by default).
  36692. *
  36693. * By default collision detection is tested against every mesh in the scene.
  36694. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36695. * meshes will be tested for the collision.
  36696. *
  36697. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36698. */
  36699. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36700. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36701. /**
  36702. * Defines edge width used when edgesRenderer is enabled
  36703. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36704. */
  36705. edgesWidth: number;
  36706. /**
  36707. * Defines edge color used when edgesRenderer is enabled
  36708. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36709. */
  36710. edgesColor: Color4;
  36711. /** @hidden */
  36712. _edgesRenderer: Nullable<IEdgesRenderer>;
  36713. /** @hidden */
  36714. _masterMesh: Nullable<AbstractMesh>;
  36715. /** @hidden */
  36716. _boundingInfo: Nullable<BoundingInfo>;
  36717. /** @hidden */
  36718. _renderId: number;
  36719. /**
  36720. * Gets or sets the list of subMeshes
  36721. * @see https://doc.babylonjs.com/how_to/multi_materials
  36722. */
  36723. subMeshes: SubMesh[];
  36724. /** @hidden */
  36725. _intersectionsInProgress: AbstractMesh[];
  36726. /** @hidden */
  36727. _unIndexed: boolean;
  36728. /** @hidden */
  36729. _lightSources: Light[];
  36730. /** Gets the list of lights affecting that mesh */
  36731. get lightSources(): Light[];
  36732. /** @hidden */
  36733. get _positions(): Nullable<Vector3[]>;
  36734. /** @hidden */
  36735. _waitingData: {
  36736. lods: Nullable<any>;
  36737. actions: Nullable<any>;
  36738. freezeWorldMatrix: Nullable<boolean>;
  36739. };
  36740. /** @hidden */
  36741. _bonesTransformMatrices: Nullable<Float32Array>;
  36742. /** @hidden */
  36743. _transformMatrixTexture: Nullable<RawTexture>;
  36744. /**
  36745. * Gets or sets a skeleton to apply skining transformations
  36746. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36747. */
  36748. set skeleton(value: Nullable<Skeleton>);
  36749. get skeleton(): Nullable<Skeleton>;
  36750. /**
  36751. * An event triggered when the mesh is rebuilt.
  36752. */
  36753. onRebuildObservable: Observable<AbstractMesh>;
  36754. /**
  36755. * Creates a new AbstractMesh
  36756. * @param name defines the name of the mesh
  36757. * @param scene defines the hosting scene
  36758. */
  36759. constructor(name: string, scene?: Nullable<Scene>);
  36760. /**
  36761. * Returns the string "AbstractMesh"
  36762. * @returns "AbstractMesh"
  36763. */
  36764. getClassName(): string;
  36765. /**
  36766. * Gets a string representation of the current mesh
  36767. * @param fullDetails defines a boolean indicating if full details must be included
  36768. * @returns a string representation of the current mesh
  36769. */
  36770. toString(fullDetails?: boolean): string;
  36771. /**
  36772. * @hidden
  36773. */
  36774. protected _getEffectiveParent(): Nullable<Node>;
  36775. /** @hidden */
  36776. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36777. /** @hidden */
  36778. _rebuild(): void;
  36779. /** @hidden */
  36780. _resyncLightSources(): void;
  36781. /** @hidden */
  36782. _resyncLightSource(light: Light): void;
  36783. /** @hidden */
  36784. _unBindEffect(): void;
  36785. /** @hidden */
  36786. _removeLightSource(light: Light, dispose: boolean): void;
  36787. private _markSubMeshesAsDirty;
  36788. /** @hidden */
  36789. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36790. /** @hidden */
  36791. _markSubMeshesAsAttributesDirty(): void;
  36792. /** @hidden */
  36793. _markSubMeshesAsMiscDirty(): void;
  36794. /**
  36795. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36796. */
  36797. get scaling(): Vector3;
  36798. set scaling(newScaling: Vector3);
  36799. /**
  36800. * Returns true if the mesh is blocked. Implemented by child classes
  36801. */
  36802. get isBlocked(): boolean;
  36803. /**
  36804. * Returns the mesh itself by default. Implemented by child classes
  36805. * @param camera defines the camera to use to pick the right LOD level
  36806. * @returns the currentAbstractMesh
  36807. */
  36808. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36809. /**
  36810. * Returns 0 by default. Implemented by child classes
  36811. * @returns an integer
  36812. */
  36813. getTotalVertices(): number;
  36814. /**
  36815. * Returns a positive integer : the total number of indices in this mesh geometry.
  36816. * @returns the numner of indices or zero if the mesh has no geometry.
  36817. */
  36818. getTotalIndices(): number;
  36819. /**
  36820. * Returns null by default. Implemented by child classes
  36821. * @returns null
  36822. */
  36823. getIndices(): Nullable<IndicesArray>;
  36824. /**
  36825. * Returns the array of the requested vertex data kind. Implemented by child classes
  36826. * @param kind defines the vertex data kind to use
  36827. * @returns null
  36828. */
  36829. getVerticesData(kind: string): Nullable<FloatArray>;
  36830. /**
  36831. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36832. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36833. * Note that a new underlying VertexBuffer object is created each call.
  36834. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36835. * @param kind defines vertex data kind:
  36836. * * VertexBuffer.PositionKind
  36837. * * VertexBuffer.UVKind
  36838. * * VertexBuffer.UV2Kind
  36839. * * VertexBuffer.UV3Kind
  36840. * * VertexBuffer.UV4Kind
  36841. * * VertexBuffer.UV5Kind
  36842. * * VertexBuffer.UV6Kind
  36843. * * VertexBuffer.ColorKind
  36844. * * VertexBuffer.MatricesIndicesKind
  36845. * * VertexBuffer.MatricesIndicesExtraKind
  36846. * * VertexBuffer.MatricesWeightsKind
  36847. * * VertexBuffer.MatricesWeightsExtraKind
  36848. * @param data defines the data source
  36849. * @param updatable defines if the data must be flagged as updatable (or static)
  36850. * @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
  36851. * @returns the current mesh
  36852. */
  36853. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36854. /**
  36855. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36856. * If the mesh has no geometry, it is simply returned as it is.
  36857. * @param kind defines vertex data kind:
  36858. * * VertexBuffer.PositionKind
  36859. * * VertexBuffer.UVKind
  36860. * * VertexBuffer.UV2Kind
  36861. * * VertexBuffer.UV3Kind
  36862. * * VertexBuffer.UV4Kind
  36863. * * VertexBuffer.UV5Kind
  36864. * * VertexBuffer.UV6Kind
  36865. * * VertexBuffer.ColorKind
  36866. * * VertexBuffer.MatricesIndicesKind
  36867. * * VertexBuffer.MatricesIndicesExtraKind
  36868. * * VertexBuffer.MatricesWeightsKind
  36869. * * VertexBuffer.MatricesWeightsExtraKind
  36870. * @param data defines the data source
  36871. * @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
  36872. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36873. * @returns the current mesh
  36874. */
  36875. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36876. /**
  36877. * Sets the mesh indices,
  36878. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36879. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36880. * @param totalVertices Defines the total number of vertices
  36881. * @returns the current mesh
  36882. */
  36883. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36884. /**
  36885. * Gets a boolean indicating if specific vertex data is present
  36886. * @param kind defines the vertex data kind to use
  36887. * @returns true is data kind is present
  36888. */
  36889. isVerticesDataPresent(kind: string): boolean;
  36890. /**
  36891. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36892. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36893. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36894. * @returns a BoundingInfo
  36895. */
  36896. getBoundingInfo(): BoundingInfo;
  36897. /**
  36898. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36899. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36900. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36901. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36902. * @returns the current mesh
  36903. */
  36904. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36905. /**
  36906. * Overwrite the current bounding info
  36907. * @param boundingInfo defines the new bounding info
  36908. * @returns the current mesh
  36909. */
  36910. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36911. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36912. get useBones(): boolean;
  36913. /** @hidden */
  36914. _preActivate(): void;
  36915. /** @hidden */
  36916. _preActivateForIntermediateRendering(renderId: number): void;
  36917. /** @hidden */
  36918. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36919. /** @hidden */
  36920. _postActivate(): void;
  36921. /** @hidden */
  36922. _freeze(): void;
  36923. /** @hidden */
  36924. _unFreeze(): void;
  36925. /**
  36926. * Gets the current world matrix
  36927. * @returns a Matrix
  36928. */
  36929. getWorldMatrix(): Matrix;
  36930. /** @hidden */
  36931. _getWorldMatrixDeterminant(): number;
  36932. /**
  36933. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36934. */
  36935. get isAnInstance(): boolean;
  36936. /**
  36937. * Gets a boolean indicating if this mesh has instances
  36938. */
  36939. get hasInstances(): boolean;
  36940. /**
  36941. * Gets a boolean indicating if this mesh has thin instances
  36942. */
  36943. get hasThinInstances(): boolean;
  36944. /**
  36945. * Perform relative position change from the point of view of behind the front of the mesh.
  36946. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36947. * Supports definition of mesh facing forward or backward
  36948. * @param amountRight defines the distance on the right axis
  36949. * @param amountUp defines the distance on the up axis
  36950. * @param amountForward defines the distance on the forward axis
  36951. * @returns the current mesh
  36952. */
  36953. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  36954. /**
  36955. * Calculate relative position change from the point of view of behind the front of the mesh.
  36956. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36957. * Supports definition of mesh facing forward or backward
  36958. * @param amountRight defines the distance on the right axis
  36959. * @param amountUp defines the distance on the up axis
  36960. * @param amountForward defines the distance on the forward axis
  36961. * @returns the new displacement vector
  36962. */
  36963. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  36964. /**
  36965. * Perform relative rotation change from the point of view of behind the front of the mesh.
  36966. * Supports definition of mesh facing forward or backward
  36967. * @param flipBack defines the flip
  36968. * @param twirlClockwise defines the twirl
  36969. * @param tiltRight defines the tilt
  36970. * @returns the current mesh
  36971. */
  36972. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  36973. /**
  36974. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  36975. * Supports definition of mesh facing forward or backward.
  36976. * @param flipBack defines the flip
  36977. * @param twirlClockwise defines the twirl
  36978. * @param tiltRight defines the tilt
  36979. * @returns the new rotation vector
  36980. */
  36981. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  36982. /**
  36983. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  36984. * This means the mesh underlying bounding box and sphere are recomputed.
  36985. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  36986. * @returns the current mesh
  36987. */
  36988. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  36989. /** @hidden */
  36990. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  36991. /** @hidden */
  36992. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  36993. /** @hidden */
  36994. _updateBoundingInfo(): AbstractMesh;
  36995. /** @hidden */
  36996. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  36997. /** @hidden */
  36998. protected _afterComputeWorldMatrix(): void;
  36999. /** @hidden */
  37000. get _effectiveMesh(): AbstractMesh;
  37001. /**
  37002. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  37003. * A mesh is in the frustum if its bounding box intersects the frustum
  37004. * @param frustumPlanes defines the frustum to test
  37005. * @returns true if the mesh is in the frustum planes
  37006. */
  37007. isInFrustum(frustumPlanes: Plane[]): boolean;
  37008. /**
  37009. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37010. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37011. * @param frustumPlanes defines the frustum to test
  37012. * @returns true if the mesh is completely in the frustum planes
  37013. */
  37014. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37015. /**
  37016. * True if the mesh intersects another mesh or a SolidParticle object
  37017. * @param mesh defines a target mesh or SolidParticle to test
  37018. * @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)
  37019. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37020. * @returns true if there is an intersection
  37021. */
  37022. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37023. /**
  37024. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37025. * @param point defines the point to test
  37026. * @returns true if there is an intersection
  37027. */
  37028. intersectsPoint(point: Vector3): boolean;
  37029. /**
  37030. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37031. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37032. */
  37033. get checkCollisions(): boolean;
  37034. set checkCollisions(collisionEnabled: boolean);
  37035. /**
  37036. * Gets Collider object used to compute collisions (not physics)
  37037. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37038. */
  37039. get collider(): Nullable<Collider>;
  37040. /**
  37041. * Move the mesh using collision engine
  37042. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37043. * @param displacement defines the requested displacement vector
  37044. * @returns the current mesh
  37045. */
  37046. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37047. private _onCollisionPositionChange;
  37048. /** @hidden */
  37049. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37050. /** @hidden */
  37051. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37052. /** @hidden */
  37053. _checkCollision(collider: Collider): AbstractMesh;
  37054. /** @hidden */
  37055. _generatePointsArray(): boolean;
  37056. /**
  37057. * Checks if the passed Ray intersects with the mesh
  37058. * @param ray defines the ray to use
  37059. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37060. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37061. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37062. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37063. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  37064. * @returns the picking info
  37065. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37066. */
  37067. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  37068. /**
  37069. * Clones the current mesh
  37070. * @param name defines the mesh name
  37071. * @param newParent defines the new mesh parent
  37072. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37073. * @returns the new mesh
  37074. */
  37075. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37076. /**
  37077. * Disposes all the submeshes of the current meshnp
  37078. * @returns the current mesh
  37079. */
  37080. releaseSubMeshes(): AbstractMesh;
  37081. /**
  37082. * Releases resources associated with this abstract mesh.
  37083. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37084. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37085. */
  37086. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37087. /**
  37088. * Adds the passed mesh as a child to the current mesh
  37089. * @param mesh defines the child mesh
  37090. * @returns the current mesh
  37091. */
  37092. addChild(mesh: AbstractMesh): AbstractMesh;
  37093. /**
  37094. * Removes the passed mesh from the current mesh children list
  37095. * @param mesh defines the child mesh
  37096. * @returns the current mesh
  37097. */
  37098. removeChild(mesh: AbstractMesh): AbstractMesh;
  37099. /** @hidden */
  37100. private _initFacetData;
  37101. /**
  37102. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37103. * This method can be called within the render loop.
  37104. * 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
  37105. * @returns the current mesh
  37106. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37107. */
  37108. updateFacetData(): AbstractMesh;
  37109. /**
  37110. * Returns the facetLocalNormals array.
  37111. * The normals are expressed in the mesh local spac
  37112. * @returns an array of Vector3
  37113. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37114. */
  37115. getFacetLocalNormals(): Vector3[];
  37116. /**
  37117. * Returns the facetLocalPositions array.
  37118. * The facet positions are expressed in the mesh local space
  37119. * @returns an array of Vector3
  37120. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37121. */
  37122. getFacetLocalPositions(): Vector3[];
  37123. /**
  37124. * Returns the facetLocalPartioning array
  37125. * @returns an array of array of numbers
  37126. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37127. */
  37128. getFacetLocalPartitioning(): number[][];
  37129. /**
  37130. * Returns the i-th facet position in the world system.
  37131. * This method allocates a new Vector3 per call
  37132. * @param i defines the facet index
  37133. * @returns a new Vector3
  37134. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37135. */
  37136. getFacetPosition(i: number): Vector3;
  37137. /**
  37138. * Sets the reference Vector3 with the i-th facet position in the world system
  37139. * @param i defines the facet index
  37140. * @param ref defines the target vector
  37141. * @returns the current mesh
  37142. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37143. */
  37144. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37145. /**
  37146. * Returns the i-th facet normal in the world system.
  37147. * This method allocates a new Vector3 per call
  37148. * @param i defines the facet index
  37149. * @returns a new Vector3
  37150. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37151. */
  37152. getFacetNormal(i: number): Vector3;
  37153. /**
  37154. * Sets the reference Vector3 with the i-th facet normal in the world system
  37155. * @param i defines the facet index
  37156. * @param ref defines the target vector
  37157. * @returns the current mesh
  37158. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37159. */
  37160. getFacetNormalToRef(i: number, ref: Vector3): this;
  37161. /**
  37162. * 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)
  37163. * @param x defines x coordinate
  37164. * @param y defines y coordinate
  37165. * @param z defines z coordinate
  37166. * @returns the array of facet indexes
  37167. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37168. */
  37169. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37170. /**
  37171. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37172. * @param projected sets as the (x,y,z) world projection on the facet
  37173. * @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
  37174. * @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
  37175. * @param x defines x coordinate
  37176. * @param y defines y coordinate
  37177. * @param z defines z coordinate
  37178. * @returns the face index if found (or null instead)
  37179. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37180. */
  37181. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37182. /**
  37183. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37184. * @param projected sets as the (x,y,z) local projection on the facet
  37185. * @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
  37186. * @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
  37187. * @param x defines x coordinate
  37188. * @param y defines y coordinate
  37189. * @param z defines z coordinate
  37190. * @returns the face index if found (or null instead)
  37191. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37192. */
  37193. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37194. /**
  37195. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37196. * @returns the parameters
  37197. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37198. */
  37199. getFacetDataParameters(): any;
  37200. /**
  37201. * Disables the feature FacetData and frees the related memory
  37202. * @returns the current mesh
  37203. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37204. */
  37205. disableFacetData(): AbstractMesh;
  37206. /**
  37207. * Updates the AbstractMesh indices array
  37208. * @param indices defines the data source
  37209. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37210. * @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)
  37211. * @returns the current mesh
  37212. */
  37213. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37214. /**
  37215. * Creates new normals data for the mesh
  37216. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37217. * @returns the current mesh
  37218. */
  37219. createNormals(updatable: boolean): AbstractMesh;
  37220. /**
  37221. * Align the mesh with a normal
  37222. * @param normal defines the normal to use
  37223. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37224. * @returns the current mesh
  37225. */
  37226. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37227. /** @hidden */
  37228. _checkOcclusionQuery(): boolean;
  37229. /**
  37230. * Disables the mesh edge rendering mode
  37231. * @returns the currentAbstractMesh
  37232. */
  37233. disableEdgesRendering(): AbstractMesh;
  37234. /**
  37235. * Enables the edge rendering mode on the mesh.
  37236. * This mode makes the mesh edges visible
  37237. * @param epsilon defines the maximal distance between two angles to detect a face
  37238. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37239. * @param options options to the edge renderer
  37240. * @returns the currentAbstractMesh
  37241. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37242. */
  37243. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  37244. /**
  37245. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37246. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37247. */
  37248. getConnectedParticleSystems(): IParticleSystem[];
  37249. }
  37250. }
  37251. declare module "babylonjs/Actions/actionEvent" {
  37252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37253. import { Nullable } from "babylonjs/types";
  37254. import { Sprite } from "babylonjs/Sprites/sprite";
  37255. import { Scene } from "babylonjs/scene";
  37256. import { Vector2 } from "babylonjs/Maths/math.vector";
  37257. /**
  37258. * Interface used to define ActionEvent
  37259. */
  37260. export interface IActionEvent {
  37261. /** The mesh or sprite that triggered the action */
  37262. source: any;
  37263. /** The X mouse cursor position at the time of the event */
  37264. pointerX: number;
  37265. /** The Y mouse cursor position at the time of the event */
  37266. pointerY: number;
  37267. /** The mesh that is currently pointed at (can be null) */
  37268. meshUnderPointer: Nullable<AbstractMesh>;
  37269. /** the original (browser) event that triggered the ActionEvent */
  37270. sourceEvent?: any;
  37271. /** additional data for the event */
  37272. additionalData?: any;
  37273. }
  37274. /**
  37275. * ActionEvent is the event being sent when an action is triggered.
  37276. */
  37277. export class ActionEvent implements IActionEvent {
  37278. /** The mesh or sprite that triggered the action */
  37279. source: any;
  37280. /** The X mouse cursor position at the time of the event */
  37281. pointerX: number;
  37282. /** The Y mouse cursor position at the time of the event */
  37283. pointerY: number;
  37284. /** The mesh that is currently pointed at (can be null) */
  37285. meshUnderPointer: Nullable<AbstractMesh>;
  37286. /** the original (browser) event that triggered the ActionEvent */
  37287. sourceEvent?: any;
  37288. /** additional data for the event */
  37289. additionalData?: any;
  37290. /**
  37291. * Creates a new ActionEvent
  37292. * @param source The mesh or sprite that triggered the action
  37293. * @param pointerX The X mouse cursor position at the time of the event
  37294. * @param pointerY The Y mouse cursor position at the time of the event
  37295. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37296. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37297. * @param additionalData additional data for the event
  37298. */
  37299. constructor(
  37300. /** The mesh or sprite that triggered the action */
  37301. source: any,
  37302. /** The X mouse cursor position at the time of the event */
  37303. pointerX: number,
  37304. /** The Y mouse cursor position at the time of the event */
  37305. pointerY: number,
  37306. /** The mesh that is currently pointed at (can be null) */
  37307. meshUnderPointer: Nullable<AbstractMesh>,
  37308. /** the original (browser) event that triggered the ActionEvent */
  37309. sourceEvent?: any,
  37310. /** additional data for the event */
  37311. additionalData?: any);
  37312. /**
  37313. * Helper function to auto-create an ActionEvent from a source mesh.
  37314. * @param source The source mesh that triggered the event
  37315. * @param evt The original (browser) event
  37316. * @param additionalData additional data for the event
  37317. * @returns the new ActionEvent
  37318. */
  37319. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37320. /**
  37321. * Helper function to auto-create an ActionEvent from a source sprite
  37322. * @param source The source sprite that triggered the event
  37323. * @param scene Scene associated with the sprite
  37324. * @param evt The original (browser) event
  37325. * @param additionalData additional data for the event
  37326. * @returns the new ActionEvent
  37327. */
  37328. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37329. /**
  37330. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37331. * @param scene the scene where the event occurred
  37332. * @param evt The original (browser) event
  37333. * @returns the new ActionEvent
  37334. */
  37335. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37336. /**
  37337. * Helper function to auto-create an ActionEvent from a primitive
  37338. * @param prim defines the target primitive
  37339. * @param pointerPos defines the pointer position
  37340. * @param evt The original (browser) event
  37341. * @param additionalData additional data for the event
  37342. * @returns the new ActionEvent
  37343. */
  37344. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37345. }
  37346. }
  37347. declare module "babylonjs/Actions/abstractActionManager" {
  37348. import { IDisposable } from "babylonjs/scene";
  37349. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  37350. import { IAction } from "babylonjs/Actions/action";
  37351. import { Nullable } from "babylonjs/types";
  37352. /**
  37353. * Abstract class used to decouple action Manager from scene and meshes.
  37354. * Do not instantiate.
  37355. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37356. */
  37357. export abstract class AbstractActionManager implements IDisposable {
  37358. /** Gets the list of active triggers */
  37359. static Triggers: {
  37360. [key: string]: number;
  37361. };
  37362. /** Gets the cursor to use when hovering items */
  37363. hoverCursor: string;
  37364. /** Gets the list of actions */
  37365. actions: IAction[];
  37366. /**
  37367. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37368. */
  37369. isRecursive: boolean;
  37370. /**
  37371. * Releases all associated resources
  37372. */
  37373. abstract dispose(): void;
  37374. /**
  37375. * Does this action manager has pointer triggers
  37376. */
  37377. abstract get hasPointerTriggers(): boolean;
  37378. /**
  37379. * Does this action manager has pick triggers
  37380. */
  37381. abstract get hasPickTriggers(): boolean;
  37382. /**
  37383. * Process a specific trigger
  37384. * @param trigger defines the trigger to process
  37385. * @param evt defines the event details to be processed
  37386. */
  37387. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37388. /**
  37389. * Does this action manager handles actions of any of the given triggers
  37390. * @param triggers defines the triggers to be tested
  37391. * @return a boolean indicating whether one (or more) of the triggers is handled
  37392. */
  37393. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37394. /**
  37395. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37396. * speed.
  37397. * @param triggerA defines the trigger to be tested
  37398. * @param triggerB defines the trigger to be tested
  37399. * @return a boolean indicating whether one (or more) of the triggers is handled
  37400. */
  37401. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37402. /**
  37403. * Does this action manager handles actions of a given trigger
  37404. * @param trigger defines the trigger to be tested
  37405. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37406. * @return whether the trigger is handled
  37407. */
  37408. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37409. /**
  37410. * Serialize this manager to a JSON object
  37411. * @param name defines the property name to store this manager
  37412. * @returns a JSON representation of this manager
  37413. */
  37414. abstract serialize(name: string): any;
  37415. /**
  37416. * Registers an action to this action manager
  37417. * @param action defines the action to be registered
  37418. * @return the action amended (prepared) after registration
  37419. */
  37420. abstract registerAction(action: IAction): Nullable<IAction>;
  37421. /**
  37422. * Unregisters an action to this action manager
  37423. * @param action defines the action to be unregistered
  37424. * @return a boolean indicating whether the action has been unregistered
  37425. */
  37426. abstract unregisterAction(action: IAction): Boolean;
  37427. /**
  37428. * Does exist one action manager with at least one trigger
  37429. **/
  37430. static get HasTriggers(): boolean;
  37431. /**
  37432. * Does exist one action manager with at least one pick trigger
  37433. **/
  37434. static get HasPickTriggers(): boolean;
  37435. /**
  37436. * Does exist one action manager that handles actions of a given trigger
  37437. * @param trigger defines the trigger to be tested
  37438. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  37439. **/
  37440. static HasSpecificTrigger(trigger: number): boolean;
  37441. }
  37442. }
  37443. declare module "babylonjs/node" {
  37444. import { Scene } from "babylonjs/scene";
  37445. import { Nullable } from "babylonjs/types";
  37446. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  37447. import { Engine } from "babylonjs/Engines/engine";
  37448. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  37449. import { Observable } from "babylonjs/Misc/observable";
  37450. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37451. import { IInspectable } from "babylonjs/Misc/iInspectable";
  37452. import { Animatable } from "babylonjs/Animations/animatable";
  37453. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  37454. import { Animation } from "babylonjs/Animations/animation";
  37455. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37457. /**
  37458. * Defines how a node can be built from a string name.
  37459. */
  37460. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37461. /**
  37462. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37463. */
  37464. export class Node implements IBehaviorAware<Node> {
  37465. /** @hidden */
  37466. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37467. private static _NodeConstructors;
  37468. /**
  37469. * Add a new node constructor
  37470. * @param type defines the type name of the node to construct
  37471. * @param constructorFunc defines the constructor function
  37472. */
  37473. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37474. /**
  37475. * Returns a node constructor based on type name
  37476. * @param type defines the type name
  37477. * @param name defines the new node name
  37478. * @param scene defines the hosting scene
  37479. * @param options defines optional options to transmit to constructors
  37480. * @returns the new constructor or null
  37481. */
  37482. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37483. /**
  37484. * Gets or sets the name of the node
  37485. */
  37486. name: string;
  37487. /**
  37488. * Gets or sets the id of the node
  37489. */
  37490. id: string;
  37491. /**
  37492. * Gets or sets the unique id of the node
  37493. */
  37494. uniqueId: number;
  37495. /**
  37496. * Gets or sets a string used to store user defined state for the node
  37497. */
  37498. state: string;
  37499. /**
  37500. * Gets or sets an object used to store user defined information for the node
  37501. */
  37502. metadata: any;
  37503. /**
  37504. * For internal use only. Please do not use.
  37505. */
  37506. reservedDataStore: any;
  37507. /**
  37508. * List of inspectable custom properties (used by the Inspector)
  37509. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37510. */
  37511. inspectableCustomProperties: IInspectable[];
  37512. private _doNotSerialize;
  37513. /**
  37514. * Gets or sets a boolean used to define if the node must be serialized
  37515. */
  37516. get doNotSerialize(): boolean;
  37517. set doNotSerialize(value: boolean);
  37518. /** @hidden */
  37519. _isDisposed: boolean;
  37520. /**
  37521. * Gets a list of Animations associated with the node
  37522. */
  37523. animations: import("babylonjs/Animations/animation").Animation[];
  37524. protected _ranges: {
  37525. [name: string]: Nullable<AnimationRange>;
  37526. };
  37527. /**
  37528. * Callback raised when the node is ready to be used
  37529. */
  37530. onReady: Nullable<(node: Node) => void>;
  37531. private _isEnabled;
  37532. private _isParentEnabled;
  37533. private _isReady;
  37534. /** @hidden */
  37535. _currentRenderId: number;
  37536. private _parentUpdateId;
  37537. /** @hidden */
  37538. _childUpdateId: number;
  37539. /** @hidden */
  37540. _waitingParentId: Nullable<string>;
  37541. /** @hidden */
  37542. _scene: Scene;
  37543. /** @hidden */
  37544. _cache: any;
  37545. private _parentNode;
  37546. private _children;
  37547. /** @hidden */
  37548. _worldMatrix: Matrix;
  37549. /** @hidden */
  37550. _worldMatrixDeterminant: number;
  37551. /** @hidden */
  37552. _worldMatrixDeterminantIsDirty: boolean;
  37553. /** @hidden */
  37554. private _sceneRootNodesIndex;
  37555. /**
  37556. * Gets a boolean indicating if the node has been disposed
  37557. * @returns true if the node was disposed
  37558. */
  37559. isDisposed(): boolean;
  37560. /**
  37561. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37562. * @see https://doc.babylonjs.com/how_to/parenting
  37563. */
  37564. set parent(parent: Nullable<Node>);
  37565. get parent(): Nullable<Node>;
  37566. /** @hidden */
  37567. _addToSceneRootNodes(): void;
  37568. /** @hidden */
  37569. _removeFromSceneRootNodes(): void;
  37570. private _animationPropertiesOverride;
  37571. /**
  37572. * Gets or sets the animation properties override
  37573. */
  37574. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37575. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37576. /**
  37577. * Gets a string identifying the name of the class
  37578. * @returns "Node" string
  37579. */
  37580. getClassName(): string;
  37581. /** @hidden */
  37582. readonly _isNode: boolean;
  37583. /**
  37584. * An event triggered when the mesh is disposed
  37585. */
  37586. onDisposeObservable: Observable<Node>;
  37587. private _onDisposeObserver;
  37588. /**
  37589. * Sets a callback that will be raised when the node will be disposed
  37590. */
  37591. set onDispose(callback: () => void);
  37592. /**
  37593. * Creates a new Node
  37594. * @param name the name and id to be given to this node
  37595. * @param scene the scene this node will be added to
  37596. */
  37597. constructor(name: string, scene?: Nullable<Scene>);
  37598. /**
  37599. * Gets the scene of the node
  37600. * @returns a scene
  37601. */
  37602. getScene(): Scene;
  37603. /**
  37604. * Gets the engine of the node
  37605. * @returns a Engine
  37606. */
  37607. getEngine(): Engine;
  37608. private _behaviors;
  37609. /**
  37610. * Attach a behavior to the node
  37611. * @see https://doc.babylonjs.com/features/behaviour
  37612. * @param behavior defines the behavior to attach
  37613. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37614. * @returns the current Node
  37615. */
  37616. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37617. /**
  37618. * Remove an attached behavior
  37619. * @see https://doc.babylonjs.com/features/behaviour
  37620. * @param behavior defines the behavior to attach
  37621. * @returns the current Node
  37622. */
  37623. removeBehavior(behavior: Behavior<Node>): Node;
  37624. /**
  37625. * Gets the list of attached behaviors
  37626. * @see https://doc.babylonjs.com/features/behaviour
  37627. */
  37628. get behaviors(): Behavior<Node>[];
  37629. /**
  37630. * Gets an attached behavior by name
  37631. * @param name defines the name of the behavior to look for
  37632. * @see https://doc.babylonjs.com/features/behaviour
  37633. * @returns null if behavior was not found else the requested behavior
  37634. */
  37635. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37636. /**
  37637. * Returns the latest update of the World matrix
  37638. * @returns a Matrix
  37639. */
  37640. getWorldMatrix(): Matrix;
  37641. /** @hidden */
  37642. _getWorldMatrixDeterminant(): number;
  37643. /**
  37644. * Returns directly the latest state of the mesh World matrix.
  37645. * A Matrix is returned.
  37646. */
  37647. get worldMatrixFromCache(): Matrix;
  37648. /** @hidden */
  37649. _initCache(): void;
  37650. /** @hidden */
  37651. updateCache(force?: boolean): void;
  37652. /** @hidden */
  37653. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37654. /** @hidden */
  37655. _updateCache(ignoreParentClass?: boolean): void;
  37656. /** @hidden */
  37657. _isSynchronized(): boolean;
  37658. /** @hidden */
  37659. _markSyncedWithParent(): void;
  37660. /** @hidden */
  37661. isSynchronizedWithParent(): boolean;
  37662. /** @hidden */
  37663. isSynchronized(): boolean;
  37664. /**
  37665. * Is this node ready to be used/rendered
  37666. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37667. * @return true if the node is ready
  37668. */
  37669. isReady(completeCheck?: boolean): boolean;
  37670. /**
  37671. * Is this node enabled?
  37672. * 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
  37673. * @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
  37674. * @return whether this node (and its parent) is enabled
  37675. */
  37676. isEnabled(checkAncestors?: boolean): boolean;
  37677. /** @hidden */
  37678. protected _syncParentEnabledState(): void;
  37679. /**
  37680. * Set the enabled state of this node
  37681. * @param value defines the new enabled state
  37682. */
  37683. setEnabled(value: boolean): void;
  37684. /**
  37685. * Is this node a descendant of the given node?
  37686. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37687. * @param ancestor defines the parent node to inspect
  37688. * @returns a boolean indicating if this node is a descendant of the given node
  37689. */
  37690. isDescendantOf(ancestor: Node): boolean;
  37691. /** @hidden */
  37692. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37693. /**
  37694. * Will return all nodes that have this node as ascendant
  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
  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. * @return all children nodes of all types
  37698. */
  37699. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37700. /**
  37701. * Get all child-meshes of this node
  37702. * @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)
  37703. * @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
  37704. * @returns an array of AbstractMesh
  37705. */
  37706. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37707. /**
  37708. * Get all direct children of this node
  37709. * @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
  37710. * @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)
  37711. * @returns an array of Node
  37712. */
  37713. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37714. /** @hidden */
  37715. _setReady(state: boolean): void;
  37716. /**
  37717. * Get an animation by name
  37718. * @param name defines the name of the animation to look for
  37719. * @returns null if not found else the requested animation
  37720. */
  37721. getAnimationByName(name: string): Nullable<Animation>;
  37722. /**
  37723. * Creates an animation range for this node
  37724. * @param name defines the name of the range
  37725. * @param from defines the starting key
  37726. * @param to defines the end key
  37727. */
  37728. createAnimationRange(name: string, from: number, to: number): void;
  37729. /**
  37730. * Delete a specific animation range
  37731. * @param name defines the name of the range to delete
  37732. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37733. */
  37734. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37735. /**
  37736. * Get an animation range by name
  37737. * @param name defines the name of the animation range to look for
  37738. * @returns null if not found else the requested animation range
  37739. */
  37740. getAnimationRange(name: string): Nullable<AnimationRange>;
  37741. /**
  37742. * Gets the list of all animation ranges defined on this node
  37743. * @returns an array
  37744. */
  37745. getAnimationRanges(): Nullable<AnimationRange>[];
  37746. /**
  37747. * Will start the animation sequence
  37748. * @param name defines the range frames for animation sequence
  37749. * @param loop defines if the animation should loop (false by default)
  37750. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37751. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37752. * @returns the object created for this animation. If range does not exist, it will return null
  37753. */
  37754. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37755. /**
  37756. * Serialize animation ranges into a JSON compatible object
  37757. * @returns serialization object
  37758. */
  37759. serializeAnimationRanges(): any;
  37760. /**
  37761. * Computes the world matrix of the node
  37762. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37763. * @returns the world matrix
  37764. */
  37765. computeWorldMatrix(force?: boolean): Matrix;
  37766. /**
  37767. * Releases resources associated with this node.
  37768. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37769. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37770. */
  37771. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37772. /**
  37773. * Parse animation range data from a serialization object and store them into a given node
  37774. * @param node defines where to store the animation ranges
  37775. * @param parsedNode defines the serialization object to read data from
  37776. * @param scene defines the hosting scene
  37777. */
  37778. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37779. /**
  37780. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37781. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37782. * @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
  37783. * @returns the new bounding vectors
  37784. */
  37785. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37786. min: Vector3;
  37787. max: Vector3;
  37788. };
  37789. }
  37790. }
  37791. declare module "babylonjs/Animations/animation" {
  37792. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  37793. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  37794. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  37795. import { Nullable } from "babylonjs/types";
  37796. import { Scene } from "babylonjs/scene";
  37797. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  37798. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37799. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  37800. import { Node } from "babylonjs/node";
  37801. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  37802. import { Size } from "babylonjs/Maths/math.size";
  37803. import { Animatable } from "babylonjs/Animations/animatable";
  37804. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  37805. /**
  37806. * @hidden
  37807. */
  37808. export class _IAnimationState {
  37809. key: number;
  37810. repeatCount: number;
  37811. workValue?: any;
  37812. loopMode?: number;
  37813. offsetValue?: any;
  37814. highLimitValue?: any;
  37815. }
  37816. /**
  37817. * Class used to store any kind of animation
  37818. */
  37819. export class Animation {
  37820. /**Name of the animation */
  37821. name: string;
  37822. /**Property to animate */
  37823. targetProperty: string;
  37824. /**The frames per second of the animation */
  37825. framePerSecond: number;
  37826. /**The data type of the animation */
  37827. dataType: number;
  37828. /**The loop mode of the animation */
  37829. loopMode?: number | undefined;
  37830. /**Specifies if blending should be enabled */
  37831. enableBlending?: boolean | undefined;
  37832. /**
  37833. * Use matrix interpolation instead of using direct key value when animating matrices
  37834. */
  37835. static AllowMatricesInterpolation: boolean;
  37836. /**
  37837. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37838. */
  37839. static AllowMatrixDecomposeForInterpolation: boolean;
  37840. /** Define the Url to load snippets */
  37841. static SnippetUrl: string;
  37842. /** Snippet ID if the animation was created from the snippet server */
  37843. snippetId: string;
  37844. /**
  37845. * Stores the key frames of the animation
  37846. */
  37847. private _keys;
  37848. /**
  37849. * Stores the easing function of the animation
  37850. */
  37851. private _easingFunction;
  37852. /**
  37853. * @hidden Internal use only
  37854. */
  37855. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  37856. /**
  37857. * The set of event that will be linked to this animation
  37858. */
  37859. private _events;
  37860. /**
  37861. * Stores an array of target property paths
  37862. */
  37863. targetPropertyPath: string[];
  37864. /**
  37865. * Stores the blending speed of the animation
  37866. */
  37867. blendingSpeed: number;
  37868. /**
  37869. * Stores the animation ranges for the animation
  37870. */
  37871. private _ranges;
  37872. /**
  37873. * @hidden Internal use
  37874. */
  37875. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37876. /**
  37877. * Sets up an animation
  37878. * @param property The property to animate
  37879. * @param animationType The animation type to apply
  37880. * @param framePerSecond The frames per second of the animation
  37881. * @param easingFunction The easing function used in the animation
  37882. * @returns The created animation
  37883. */
  37884. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37885. /**
  37886. * Create and start an animation on a node
  37887. * @param name defines the name of the global animation that will be run on all nodes
  37888. * @param node defines the root node where the animation will take place
  37889. * @param targetProperty defines property to animate
  37890. * @param framePerSecond defines the number of frame per second yo use
  37891. * @param totalFrame defines the number of frames in total
  37892. * @param from defines the initial value
  37893. * @param to defines the final value
  37894. * @param loopMode defines which loop mode you want to use (off by default)
  37895. * @param easingFunction defines the easing function to use (linear by default)
  37896. * @param onAnimationEnd defines the callback to call when animation end
  37897. * @returns the animatable created for this animation
  37898. */
  37899. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37900. /**
  37901. * Create and start an animation on a node and its descendants
  37902. * @param name defines the name of the global animation that will be run on all nodes
  37903. * @param node defines the root node where the animation will take place
  37904. * @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
  37905. * @param targetProperty defines property to animate
  37906. * @param framePerSecond defines the number of frame per second to use
  37907. * @param totalFrame defines the number of frames in total
  37908. * @param from defines the initial value
  37909. * @param to defines the final value
  37910. * @param loopMode defines which loop mode you want to use (off by default)
  37911. * @param easingFunction defines the easing function to use (linear by default)
  37912. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37913. * @returns the list of animatables created for all nodes
  37914. * @example https://www.babylonjs-playground.com/#MH0VLI
  37915. */
  37916. 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[]>;
  37917. /**
  37918. * Creates a new animation, merges it with the existing animations and starts it
  37919. * @param name Name of the animation
  37920. * @param node Node which contains the scene that begins the animations
  37921. * @param targetProperty Specifies which property to animate
  37922. * @param framePerSecond The frames per second of the animation
  37923. * @param totalFrame The total number of frames
  37924. * @param from The frame at the beginning of the animation
  37925. * @param to The frame at the end of the animation
  37926. * @param loopMode Specifies the loop mode of the animation
  37927. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37928. * @param onAnimationEnd Callback to run once the animation is complete
  37929. * @returns Nullable animation
  37930. */
  37931. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37932. /**
  37933. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37934. * @param sourceAnimation defines the Animation containing keyframes to convert
  37935. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37936. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37937. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37938. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37939. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37940. */
  37941. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37942. /**
  37943. * Transition property of an host to the target Value
  37944. * @param property The property to transition
  37945. * @param targetValue The target Value of the property
  37946. * @param host The object where the property to animate belongs
  37947. * @param scene Scene used to run the animation
  37948. * @param frameRate Framerate (in frame/s) to use
  37949. * @param transition The transition type we want to use
  37950. * @param duration The duration of the animation, in milliseconds
  37951. * @param onAnimationEnd Callback trigger at the end of the animation
  37952. * @returns Nullable animation
  37953. */
  37954. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  37955. /**
  37956. * Return the array of runtime animations currently using this animation
  37957. */
  37958. get runtimeAnimations(): RuntimeAnimation[];
  37959. /**
  37960. * Specifies if any of the runtime animations are currently running
  37961. */
  37962. get hasRunningRuntimeAnimations(): boolean;
  37963. /**
  37964. * Initializes the animation
  37965. * @param name Name of the animation
  37966. * @param targetProperty Property to animate
  37967. * @param framePerSecond The frames per second of the animation
  37968. * @param dataType The data type of the animation
  37969. * @param loopMode The loop mode of the animation
  37970. * @param enableBlending Specifies if blending should be enabled
  37971. */
  37972. constructor(
  37973. /**Name of the animation */
  37974. name: string,
  37975. /**Property to animate */
  37976. targetProperty: string,
  37977. /**The frames per second of the animation */
  37978. framePerSecond: number,
  37979. /**The data type of the animation */
  37980. dataType: number,
  37981. /**The loop mode of the animation */
  37982. loopMode?: number | undefined,
  37983. /**Specifies if blending should be enabled */
  37984. enableBlending?: boolean | undefined);
  37985. /**
  37986. * Converts the animation to a string
  37987. * @param fullDetails support for multiple levels of logging within scene loading
  37988. * @returns String form of the animation
  37989. */
  37990. toString(fullDetails?: boolean): string;
  37991. /**
  37992. * Add an event to this animation
  37993. * @param event Event to add
  37994. */
  37995. addEvent(event: AnimationEvent): void;
  37996. /**
  37997. * Remove all events found at the given frame
  37998. * @param frame The frame to remove events from
  37999. */
  38000. removeEvents(frame: number): void;
  38001. /**
  38002. * Retrieves all the events from the animation
  38003. * @returns Events from the animation
  38004. */
  38005. getEvents(): AnimationEvent[];
  38006. /**
  38007. * Creates an animation range
  38008. * @param name Name of the animation range
  38009. * @param from Starting frame of the animation range
  38010. * @param to Ending frame of the animation
  38011. */
  38012. createRange(name: string, from: number, to: number): void;
  38013. /**
  38014. * Deletes an animation range by name
  38015. * @param name Name of the animation range to delete
  38016. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38017. */
  38018. deleteRange(name: string, deleteFrames?: boolean): void;
  38019. /**
  38020. * Gets the animation range by name, or null if not defined
  38021. * @param name Name of the animation range
  38022. * @returns Nullable animation range
  38023. */
  38024. getRange(name: string): Nullable<AnimationRange>;
  38025. /**
  38026. * Gets the key frames from the animation
  38027. * @returns The key frames of the animation
  38028. */
  38029. getKeys(): Array<IAnimationKey>;
  38030. /**
  38031. * Gets the highest frame rate of the animation
  38032. * @returns Highest frame rate of the animation
  38033. */
  38034. getHighestFrame(): number;
  38035. /**
  38036. * Gets the easing function of the animation
  38037. * @returns Easing function of the animation
  38038. */
  38039. getEasingFunction(): IEasingFunction;
  38040. /**
  38041. * Sets the easing function of the animation
  38042. * @param easingFunction A custom mathematical formula for animation
  38043. */
  38044. setEasingFunction(easingFunction: EasingFunction): void;
  38045. /**
  38046. * Interpolates a scalar linearly
  38047. * @param startValue Start value of the animation curve
  38048. * @param endValue End value of the animation curve
  38049. * @param gradient Scalar amount to interpolate
  38050. * @returns Interpolated scalar value
  38051. */
  38052. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38053. /**
  38054. * Interpolates a scalar cubically
  38055. * @param startValue Start value of the animation curve
  38056. * @param outTangent End tangent of the animation
  38057. * @param endValue End value of the animation curve
  38058. * @param inTangent Start tangent of the animation curve
  38059. * @param gradient Scalar amount to interpolate
  38060. * @returns Interpolated scalar value
  38061. */
  38062. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38063. /**
  38064. * Interpolates a quaternion using a spherical linear interpolation
  38065. * @param startValue Start value of the animation curve
  38066. * @param endValue End value of the animation curve
  38067. * @param gradient Scalar amount to interpolate
  38068. * @returns Interpolated quaternion value
  38069. */
  38070. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38071. /**
  38072. * Interpolates a quaternion cubically
  38073. * @param startValue Start value of the animation curve
  38074. * @param outTangent End tangent of the animation curve
  38075. * @param endValue End value of the animation curve
  38076. * @param inTangent Start tangent of the animation curve
  38077. * @param gradient Scalar amount to interpolate
  38078. * @returns Interpolated quaternion value
  38079. */
  38080. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38081. /**
  38082. * Interpolates a Vector3 linearl
  38083. * @param startValue Start value of the animation curve
  38084. * @param endValue End value of the animation curve
  38085. * @param gradient Scalar amount to interpolate
  38086. * @returns Interpolated scalar value
  38087. */
  38088. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38089. /**
  38090. * Interpolates a Vector3 cubically
  38091. * @param startValue Start value of the animation curve
  38092. * @param outTangent End tangent of the animation
  38093. * @param endValue End value of the animation curve
  38094. * @param inTangent Start tangent of the animation curve
  38095. * @param gradient Scalar amount to interpolate
  38096. * @returns InterpolatedVector3 value
  38097. */
  38098. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38099. /**
  38100. * Interpolates a Vector2 linearly
  38101. * @param startValue Start value of the animation curve
  38102. * @param endValue End value of the animation curve
  38103. * @param gradient Scalar amount to interpolate
  38104. * @returns Interpolated Vector2 value
  38105. */
  38106. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38107. /**
  38108. * Interpolates a Vector2 cubically
  38109. * @param startValue Start value of the animation curve
  38110. * @param outTangent End tangent of the animation
  38111. * @param endValue End value of the animation curve
  38112. * @param inTangent Start tangent of the animation curve
  38113. * @param gradient Scalar amount to interpolate
  38114. * @returns Interpolated Vector2 value
  38115. */
  38116. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38117. /**
  38118. * Interpolates a size linearly
  38119. * @param startValue Start value of the animation curve
  38120. * @param endValue End value of the animation curve
  38121. * @param gradient Scalar amount to interpolate
  38122. * @returns Interpolated Size value
  38123. */
  38124. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38125. /**
  38126. * Interpolates a Color3 linearly
  38127. * @param startValue Start value of the animation curve
  38128. * @param endValue End value of the animation curve
  38129. * @param gradient Scalar amount to interpolate
  38130. * @returns Interpolated Color3 value
  38131. */
  38132. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38133. /**
  38134. * Interpolates a Color4 linearly
  38135. * @param startValue Start value of the animation curve
  38136. * @param endValue End value of the animation curve
  38137. * @param gradient Scalar amount to interpolate
  38138. * @returns Interpolated Color3 value
  38139. */
  38140. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  38141. /**
  38142. * @hidden Internal use only
  38143. */
  38144. _getKeyValue(value: any): any;
  38145. /**
  38146. * @hidden Internal use only
  38147. */
  38148. _interpolate(currentFrame: number, state: _IAnimationState): any;
  38149. /**
  38150. * Defines the function to use to interpolate matrices
  38151. * @param startValue defines the start matrix
  38152. * @param endValue defines the end matrix
  38153. * @param gradient defines the gradient between both matrices
  38154. * @param result defines an optional target matrix where to store the interpolation
  38155. * @returns the interpolated matrix
  38156. */
  38157. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  38158. /**
  38159. * Makes a copy of the animation
  38160. * @returns Cloned animation
  38161. */
  38162. clone(): Animation;
  38163. /**
  38164. * Sets the key frames of the animation
  38165. * @param values The animation key frames to set
  38166. */
  38167. setKeys(values: Array<IAnimationKey>): void;
  38168. /**
  38169. * Serializes the animation to an object
  38170. * @returns Serialized object
  38171. */
  38172. serialize(): any;
  38173. /**
  38174. * Float animation type
  38175. */
  38176. static readonly ANIMATIONTYPE_FLOAT: number;
  38177. /**
  38178. * Vector3 animation type
  38179. */
  38180. static readonly ANIMATIONTYPE_VECTOR3: number;
  38181. /**
  38182. * Quaternion animation type
  38183. */
  38184. static readonly ANIMATIONTYPE_QUATERNION: number;
  38185. /**
  38186. * Matrix animation type
  38187. */
  38188. static readonly ANIMATIONTYPE_MATRIX: number;
  38189. /**
  38190. * Color3 animation type
  38191. */
  38192. static readonly ANIMATIONTYPE_COLOR3: number;
  38193. /**
  38194. * Color3 animation type
  38195. */
  38196. static readonly ANIMATIONTYPE_COLOR4: number;
  38197. /**
  38198. * Vector2 animation type
  38199. */
  38200. static readonly ANIMATIONTYPE_VECTOR2: number;
  38201. /**
  38202. * Size animation type
  38203. */
  38204. static readonly ANIMATIONTYPE_SIZE: number;
  38205. /**
  38206. * Relative Loop Mode
  38207. */
  38208. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38209. /**
  38210. * Cycle Loop Mode
  38211. */
  38212. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38213. /**
  38214. * Constant Loop Mode
  38215. */
  38216. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38217. /** @hidden */
  38218. static _UniversalLerp(left: any, right: any, amount: number): any;
  38219. /**
  38220. * Parses an animation object and creates an animation
  38221. * @param parsedAnimation Parsed animation object
  38222. * @returns Animation object
  38223. */
  38224. static Parse(parsedAnimation: any): Animation;
  38225. /**
  38226. * Appends the serialized animations from the source animations
  38227. * @param source Source containing the animations
  38228. * @param destination Target to store the animations
  38229. */
  38230. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38231. /**
  38232. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38233. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38234. * @param url defines the url to load from
  38235. * @returns a promise that will resolve to the new animation or an array of animations
  38236. */
  38237. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38238. /**
  38239. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38240. * @param snippetId defines the snippet to load
  38241. * @returns a promise that will resolve to the new animation or a new array of animations
  38242. */
  38243. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38244. }
  38245. }
  38246. declare module "babylonjs/Animations/animatable.interface" {
  38247. import { Nullable } from "babylonjs/types";
  38248. import { Animation } from "babylonjs/Animations/animation";
  38249. /**
  38250. * Interface containing an array of animations
  38251. */
  38252. export interface IAnimatable {
  38253. /**
  38254. * Array of animations
  38255. */
  38256. animations: Nullable<Array<Animation>>;
  38257. }
  38258. }
  38259. declare module "babylonjs/Misc/decorators" {
  38260. import { Nullable } from "babylonjs/types";
  38261. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38262. import { Scene } from "babylonjs/scene";
  38263. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  38264. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38265. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38266. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38267. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38268. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38269. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38270. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38271. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38272. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38273. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38274. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38275. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38276. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38277. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38278. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38279. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38280. /**
  38281. * Decorator used to define property that can be serialized as reference to a camera
  38282. * @param sourceName defines the name of the property to decorate
  38283. */
  38284. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38285. /**
  38286. * Class used to help serialization objects
  38287. */
  38288. export class SerializationHelper {
  38289. /** @hidden */
  38290. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38291. /** @hidden */
  38292. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38293. /** @hidden */
  38294. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38295. /** @hidden */
  38296. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38297. /**
  38298. * Appends the serialized animations from the source animations
  38299. * @param source Source containing the animations
  38300. * @param destination Target to store the animations
  38301. */
  38302. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38303. /**
  38304. * Static function used to serialized a specific entity
  38305. * @param entity defines the entity to serialize
  38306. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38307. * @returns a JSON compatible object representing the serialization of the entity
  38308. */
  38309. static Serialize<T>(entity: T, serializationObject?: any): any;
  38310. /**
  38311. * Creates a new entity from a serialization data object
  38312. * @param creationFunction defines a function used to instanciated the new entity
  38313. * @param source defines the source serialization data
  38314. * @param scene defines the hosting scene
  38315. * @param rootUrl defines the root url for resources
  38316. * @returns a new entity
  38317. */
  38318. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38319. /**
  38320. * Clones an object
  38321. * @param creationFunction defines the function used to instanciate the new object
  38322. * @param source defines the source object
  38323. * @returns the cloned object
  38324. */
  38325. static Clone<T>(creationFunction: () => T, source: T): T;
  38326. /**
  38327. * Instanciates a new object based on a source one (some data will be shared between both object)
  38328. * @param creationFunction defines the function used to instanciate the new object
  38329. * @param source defines the source object
  38330. * @returns the new object
  38331. */
  38332. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38333. }
  38334. }
  38335. declare module "babylonjs/Cameras/camera" {
  38336. import { SmartArray } from "babylonjs/Misc/smartArray";
  38337. import { Observable } from "babylonjs/Misc/observable";
  38338. import { Nullable } from "babylonjs/types";
  38339. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38340. import { Scene } from "babylonjs/scene";
  38341. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38342. import { Node } from "babylonjs/node";
  38343. import { Mesh } from "babylonjs/Meshes/mesh";
  38344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38345. import { ICullable } from "babylonjs/Culling/boundingInfo";
  38346. import { Viewport } from "babylonjs/Maths/math.viewport";
  38347. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38348. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38349. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38350. import { Ray } from "babylonjs/Culling/ray";
  38351. /**
  38352. * This is the base class of all the camera used in the application.
  38353. * @see https://doc.babylonjs.com/features/cameras
  38354. */
  38355. export class Camera extends Node {
  38356. /** @hidden */
  38357. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  38358. /**
  38359. * This is the default projection mode used by the cameras.
  38360. * It helps recreating a feeling of perspective and better appreciate depth.
  38361. * This is the best way to simulate real life cameras.
  38362. */
  38363. static readonly PERSPECTIVE_CAMERA: number;
  38364. /**
  38365. * This helps creating camera with an orthographic mode.
  38366. * 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.
  38367. */
  38368. static readonly ORTHOGRAPHIC_CAMERA: number;
  38369. /**
  38370. * This is the default FOV mode for perspective cameras.
  38371. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  38372. */
  38373. static readonly FOVMODE_VERTICAL_FIXED: number;
  38374. /**
  38375. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  38376. */
  38377. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  38378. /**
  38379. * This specifies ther is no need for a camera rig.
  38380. * Basically only one eye is rendered corresponding to the camera.
  38381. */
  38382. static readonly RIG_MODE_NONE: number;
  38383. /**
  38384. * Simulates a camera Rig with one blue eye and one red eye.
  38385. * This can be use with 3d blue and red glasses.
  38386. */
  38387. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  38388. /**
  38389. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  38390. */
  38391. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  38392. /**
  38393. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  38394. */
  38395. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  38396. /**
  38397. * Defines that both eyes of the camera will be rendered over under each other.
  38398. */
  38399. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  38400. /**
  38401. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  38402. */
  38403. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  38404. /**
  38405. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  38406. */
  38407. static readonly RIG_MODE_VR: number;
  38408. /**
  38409. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  38410. */
  38411. static readonly RIG_MODE_WEBVR: number;
  38412. /**
  38413. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  38414. */
  38415. static readonly RIG_MODE_CUSTOM: number;
  38416. /**
  38417. * Defines if by default attaching controls should prevent the default javascript event to continue.
  38418. */
  38419. static ForceAttachControlToAlwaysPreventDefault: boolean;
  38420. /**
  38421. * Define the input manager associated with the camera.
  38422. */
  38423. inputs: CameraInputsManager<Camera>;
  38424. /** @hidden */
  38425. _position: Vector3;
  38426. /**
  38427. * Define the current local position of the camera in the scene
  38428. */
  38429. get position(): Vector3;
  38430. set position(newPosition: Vector3);
  38431. protected _upVector: Vector3;
  38432. /**
  38433. * The vector the camera should consider as up.
  38434. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  38435. */
  38436. set upVector(vec: Vector3);
  38437. get upVector(): Vector3;
  38438. /**
  38439. * Define the current limit on the left side for an orthographic camera
  38440. * In scene unit
  38441. */
  38442. orthoLeft: Nullable<number>;
  38443. /**
  38444. * Define the current limit on the right side for an orthographic camera
  38445. * In scene unit
  38446. */
  38447. orthoRight: Nullable<number>;
  38448. /**
  38449. * Define the current limit on the bottom side for an orthographic camera
  38450. * In scene unit
  38451. */
  38452. orthoBottom: Nullable<number>;
  38453. /**
  38454. * Define the current limit on the top side for an orthographic camera
  38455. * In scene unit
  38456. */
  38457. orthoTop: Nullable<number>;
  38458. /**
  38459. * Field Of View is set in Radians. (default is 0.8)
  38460. */
  38461. fov: number;
  38462. /**
  38463. * Define the minimum distance the camera can see from.
  38464. * This is important to note that the depth buffer are not infinite and the closer it starts
  38465. * the more your scene might encounter depth fighting issue.
  38466. */
  38467. minZ: number;
  38468. /**
  38469. * Define the maximum distance the camera can see to.
  38470. * This is important to note that the depth buffer are not infinite and the further it end
  38471. * the more your scene might encounter depth fighting issue.
  38472. */
  38473. maxZ: number;
  38474. /**
  38475. * Define the default inertia of the camera.
  38476. * This helps giving a smooth feeling to the camera movement.
  38477. */
  38478. inertia: number;
  38479. /**
  38480. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  38481. */
  38482. mode: number;
  38483. /**
  38484. * Define whether the camera is intermediate.
  38485. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  38486. */
  38487. isIntermediate: boolean;
  38488. /**
  38489. * Define the viewport of the camera.
  38490. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  38491. */
  38492. viewport: Viewport;
  38493. /**
  38494. * Restricts the camera to viewing objects with the same layerMask.
  38495. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  38496. */
  38497. layerMask: number;
  38498. /**
  38499. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  38500. */
  38501. fovMode: number;
  38502. /**
  38503. * Rig mode of the camera.
  38504. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  38505. * This is normally controlled byt the camera themselves as internal use.
  38506. */
  38507. cameraRigMode: number;
  38508. /**
  38509. * Defines the distance between both "eyes" in case of a RIG
  38510. */
  38511. interaxialDistance: number;
  38512. /**
  38513. * Defines if stereoscopic rendering is done side by side or over under.
  38514. */
  38515. isStereoscopicSideBySide: boolean;
  38516. /**
  38517. * 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
  38518. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  38519. * else in the scene. (Eg. security camera)
  38520. *
  38521. * 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)
  38522. */
  38523. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  38524. /**
  38525. * When set, the camera will render to this render target instead of the default canvas
  38526. *
  38527. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  38528. */
  38529. outputRenderTarget: Nullable<RenderTargetTexture>;
  38530. /**
  38531. * Observable triggered when the camera view matrix has changed.
  38532. */
  38533. onViewMatrixChangedObservable: Observable<Camera>;
  38534. /**
  38535. * Observable triggered when the camera Projection matrix has changed.
  38536. */
  38537. onProjectionMatrixChangedObservable: Observable<Camera>;
  38538. /**
  38539. * Observable triggered when the inputs have been processed.
  38540. */
  38541. onAfterCheckInputsObservable: Observable<Camera>;
  38542. /**
  38543. * Observable triggered when reset has been called and applied to the camera.
  38544. */
  38545. onRestoreStateObservable: Observable<Camera>;
  38546. /**
  38547. * Is this camera a part of a rig system?
  38548. */
  38549. isRigCamera: boolean;
  38550. /**
  38551. * If isRigCamera set to true this will be set with the parent camera.
  38552. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  38553. */
  38554. rigParent?: Camera;
  38555. /** @hidden */
  38556. _cameraRigParams: any;
  38557. /** @hidden */
  38558. _rigCameras: Camera[];
  38559. /** @hidden */
  38560. _rigPostProcess: Nullable<PostProcess>;
  38561. protected _webvrViewMatrix: Matrix;
  38562. /** @hidden */
  38563. _skipRendering: boolean;
  38564. /** @hidden */
  38565. _projectionMatrix: Matrix;
  38566. /** @hidden */
  38567. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  38568. /** @hidden */
  38569. _activeMeshes: SmartArray<AbstractMesh>;
  38570. protected _globalPosition: Vector3;
  38571. /** @hidden */
  38572. _computedViewMatrix: Matrix;
  38573. private _doNotComputeProjectionMatrix;
  38574. private _transformMatrix;
  38575. private _frustumPlanes;
  38576. private _refreshFrustumPlanes;
  38577. private _storedFov;
  38578. private _stateStored;
  38579. /**
  38580. * Instantiates a new camera object.
  38581. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  38582. * @see https://doc.babylonjs.com/features/cameras
  38583. * @param name Defines the name of the camera in the scene
  38584. * @param position Defines the position of the camera
  38585. * @param scene Defines the scene the camera belongs too
  38586. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  38587. */
  38588. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38589. /**
  38590. * Store current camera state (fov, position, etc..)
  38591. * @returns the camera
  38592. */
  38593. storeState(): Camera;
  38594. /**
  38595. * Restores the camera state values if it has been stored. You must call storeState() first
  38596. */
  38597. protected _restoreStateValues(): boolean;
  38598. /**
  38599. * Restored camera state. You must call storeState() first.
  38600. * @returns true if restored and false otherwise
  38601. */
  38602. restoreState(): boolean;
  38603. /**
  38604. * Gets the class name of the camera.
  38605. * @returns the class name
  38606. */
  38607. getClassName(): string;
  38608. /** @hidden */
  38609. readonly _isCamera: boolean;
  38610. /**
  38611. * Gets a string representation of the camera useful for debug purpose.
  38612. * @param fullDetails Defines that a more verboe level of logging is required
  38613. * @returns the string representation
  38614. */
  38615. toString(fullDetails?: boolean): string;
  38616. /**
  38617. * Gets the current world space position of the camera.
  38618. */
  38619. get globalPosition(): Vector3;
  38620. /**
  38621. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  38622. * @returns the active meshe list
  38623. */
  38624. getActiveMeshes(): SmartArray<AbstractMesh>;
  38625. /**
  38626. * Check whether a mesh is part of the current active mesh list of the camera
  38627. * @param mesh Defines the mesh to check
  38628. * @returns true if active, false otherwise
  38629. */
  38630. isActiveMesh(mesh: Mesh): boolean;
  38631. /**
  38632. * Is this camera ready to be used/rendered
  38633. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  38634. * @return true if the camera is ready
  38635. */
  38636. isReady(completeCheck?: boolean): boolean;
  38637. /** @hidden */
  38638. _initCache(): void;
  38639. /** @hidden */
  38640. _updateCache(ignoreParentClass?: boolean): void;
  38641. /** @hidden */
  38642. _isSynchronized(): boolean;
  38643. /** @hidden */
  38644. _isSynchronizedViewMatrix(): boolean;
  38645. /** @hidden */
  38646. _isSynchronizedProjectionMatrix(): boolean;
  38647. /**
  38648. * Attach the input controls to a specific dom element to get the input from.
  38649. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38650. */
  38651. attachControl(noPreventDefault?: boolean): void;
  38652. /**
  38653. * Attach the input controls to a specific dom element to get the input from.
  38654. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  38655. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38656. * BACK COMPAT SIGNATURE ONLY.
  38657. */
  38658. attachControl(ignored: any, noPreventDefault?: boolean): void;
  38659. /**
  38660. * Detach the current controls from the specified dom element.
  38661. */
  38662. detachControl(): void;
  38663. /**
  38664. * Detach the current controls from the specified dom element.
  38665. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  38666. */
  38667. detachControl(ignored: any): void;
  38668. /**
  38669. * Update the camera state according to the different inputs gathered during the frame.
  38670. */
  38671. update(): void;
  38672. /** @hidden */
  38673. _checkInputs(): void;
  38674. /** @hidden */
  38675. get rigCameras(): Camera[];
  38676. /**
  38677. * Gets the post process used by the rig cameras
  38678. */
  38679. get rigPostProcess(): Nullable<PostProcess>;
  38680. /**
  38681. * Internal, gets the first post proces.
  38682. * @returns the first post process to be run on this camera.
  38683. */
  38684. _getFirstPostProcess(): Nullable<PostProcess>;
  38685. private _cascadePostProcessesToRigCams;
  38686. /**
  38687. * Attach a post process to the camera.
  38688. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38689. * @param postProcess The post process to attach to the camera
  38690. * @param insertAt The position of the post process in case several of them are in use in the scene
  38691. * @returns the position the post process has been inserted at
  38692. */
  38693. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  38694. /**
  38695. * Detach a post process to the camera.
  38696. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38697. * @param postProcess The post process to detach from the camera
  38698. */
  38699. detachPostProcess(postProcess: PostProcess): void;
  38700. /**
  38701. * Gets the current world matrix of the camera
  38702. */
  38703. getWorldMatrix(): Matrix;
  38704. /** @hidden */
  38705. _getViewMatrix(): Matrix;
  38706. /**
  38707. * Gets the current view matrix of the camera.
  38708. * @param force forces the camera to recompute the matrix without looking at the cached state
  38709. * @returns the view matrix
  38710. */
  38711. getViewMatrix(force?: boolean): Matrix;
  38712. /**
  38713. * Freeze the projection matrix.
  38714. * It will prevent the cache check of the camera projection compute and can speed up perf
  38715. * if no parameter of the camera are meant to change
  38716. * @param projection Defines manually a projection if necessary
  38717. */
  38718. freezeProjectionMatrix(projection?: Matrix): void;
  38719. /**
  38720. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  38721. */
  38722. unfreezeProjectionMatrix(): void;
  38723. /**
  38724. * Gets the current projection matrix of the camera.
  38725. * @param force forces the camera to recompute the matrix without looking at the cached state
  38726. * @returns the projection matrix
  38727. */
  38728. getProjectionMatrix(force?: boolean): Matrix;
  38729. /**
  38730. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  38731. * @returns a Matrix
  38732. */
  38733. getTransformationMatrix(): Matrix;
  38734. private _updateFrustumPlanes;
  38735. /**
  38736. * Checks if a cullable object (mesh...) is in the camera frustum
  38737. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  38738. * @param target The object to check
  38739. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  38740. * @returns true if the object is in frustum otherwise false
  38741. */
  38742. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  38743. /**
  38744. * Checks if a cullable object (mesh...) is in the camera frustum
  38745. * Unlike isInFrustum this cheks the full bounding box
  38746. * @param target The object to check
  38747. * @returns true if the object is in frustum otherwise false
  38748. */
  38749. isCompletelyInFrustum(target: ICullable): boolean;
  38750. /**
  38751. * Gets a ray in the forward direction from the camera.
  38752. * @param length Defines the length of the ray to create
  38753. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38754. * @param origin Defines the start point of the ray which defaults to the camera position
  38755. * @returns the forward ray
  38756. */
  38757. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38758. /**
  38759. * Gets a ray in the forward direction from the camera.
  38760. * @param refRay the ray to (re)use when setting the values
  38761. * @param length Defines the length of the ray to create
  38762. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38763. * @param origin Defines the start point of the ray which defaults to the camera position
  38764. * @returns the forward ray
  38765. */
  38766. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38767. /**
  38768. * Releases resources associated with this node.
  38769. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38770. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38771. */
  38772. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38773. /** @hidden */
  38774. _isLeftCamera: boolean;
  38775. /**
  38776. * Gets the left camera of a rig setup in case of Rigged Camera
  38777. */
  38778. get isLeftCamera(): boolean;
  38779. /** @hidden */
  38780. _isRightCamera: boolean;
  38781. /**
  38782. * Gets the right camera of a rig setup in case of Rigged Camera
  38783. */
  38784. get isRightCamera(): boolean;
  38785. /**
  38786. * Gets the left camera of a rig setup in case of Rigged Camera
  38787. */
  38788. get leftCamera(): Nullable<FreeCamera>;
  38789. /**
  38790. * Gets the right camera of a rig setup in case of Rigged Camera
  38791. */
  38792. get rightCamera(): Nullable<FreeCamera>;
  38793. /**
  38794. * Gets the left camera target of a rig setup in case of Rigged Camera
  38795. * @returns the target position
  38796. */
  38797. getLeftTarget(): Nullable<Vector3>;
  38798. /**
  38799. * Gets the right camera target of a rig setup in case of Rigged Camera
  38800. * @returns the target position
  38801. */
  38802. getRightTarget(): Nullable<Vector3>;
  38803. /**
  38804. * @hidden
  38805. */
  38806. setCameraRigMode(mode: number, rigParams: any): void;
  38807. /** @hidden */
  38808. static _setStereoscopicRigMode(camera: Camera): void;
  38809. /** @hidden */
  38810. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  38811. /** @hidden */
  38812. static _setVRRigMode(camera: Camera, rigParams: any): void;
  38813. /** @hidden */
  38814. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  38815. /** @hidden */
  38816. _getVRProjectionMatrix(): Matrix;
  38817. protected _updateCameraRotationMatrix(): void;
  38818. protected _updateWebVRCameraRotationMatrix(): void;
  38819. /**
  38820. * This function MUST be overwritten by the different WebVR cameras available.
  38821. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38822. * @hidden
  38823. */
  38824. _getWebVRProjectionMatrix(): Matrix;
  38825. /**
  38826. * This function MUST be overwritten by the different WebVR cameras available.
  38827. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38828. * @hidden
  38829. */
  38830. _getWebVRViewMatrix(): Matrix;
  38831. /** @hidden */
  38832. setCameraRigParameter(name: string, value: any): void;
  38833. /**
  38834. * needs to be overridden by children so sub has required properties to be copied
  38835. * @hidden
  38836. */
  38837. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  38838. /**
  38839. * May need to be overridden by children
  38840. * @hidden
  38841. */
  38842. _updateRigCameras(): void;
  38843. /** @hidden */
  38844. _setupInputs(): void;
  38845. /**
  38846. * Serialiaze the camera setup to a json represention
  38847. * @returns the JSON representation
  38848. */
  38849. serialize(): any;
  38850. /**
  38851. * Clones the current camera.
  38852. * @param name The cloned camera name
  38853. * @returns the cloned camera
  38854. */
  38855. clone(name: string): Camera;
  38856. /**
  38857. * Gets the direction of the camera relative to a given local axis.
  38858. * @param localAxis Defines the reference axis to provide a relative direction.
  38859. * @return the direction
  38860. */
  38861. getDirection(localAxis: Vector3): Vector3;
  38862. /**
  38863. * Returns the current camera absolute rotation
  38864. */
  38865. get absoluteRotation(): Quaternion;
  38866. /**
  38867. * Gets the direction of the camera relative to a given local axis into a passed vector.
  38868. * @param localAxis Defines the reference axis to provide a relative direction.
  38869. * @param result Defines the vector to store the result in
  38870. */
  38871. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  38872. /**
  38873. * Gets a camera constructor for a given camera type
  38874. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  38875. * @param name The name of the camera the result will be able to instantiate
  38876. * @param scene The scene the result will construct the camera in
  38877. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  38878. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  38879. * @returns a factory method to construc the camera
  38880. */
  38881. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  38882. /**
  38883. * Compute the world matrix of the camera.
  38884. * @returns the camera world matrix
  38885. */
  38886. computeWorldMatrix(): Matrix;
  38887. /**
  38888. * Parse a JSON and creates the camera from the parsed information
  38889. * @param parsedCamera The JSON to parse
  38890. * @param scene The scene to instantiate the camera in
  38891. * @returns the newly constructed camera
  38892. */
  38893. static Parse(parsedCamera: any, scene: Scene): Camera;
  38894. }
  38895. }
  38896. declare module "babylonjs/PostProcesses/postProcessManager" {
  38897. import { Nullable } from "babylonjs/types";
  38898. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38899. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38900. import { Scene } from "babylonjs/scene";
  38901. /**
  38902. * PostProcessManager is used to manage one or more post processes or post process pipelines
  38903. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  38904. */
  38905. export class PostProcessManager {
  38906. private _scene;
  38907. private _indexBuffer;
  38908. private _vertexBuffers;
  38909. /**
  38910. * Creates a new instance PostProcess
  38911. * @param scene The scene that the post process is associated with.
  38912. */
  38913. constructor(scene: Scene);
  38914. private _prepareBuffers;
  38915. private _buildIndexBuffer;
  38916. /**
  38917. * Rebuilds the vertex buffers of the manager.
  38918. * @hidden
  38919. */
  38920. _rebuild(): void;
  38921. /**
  38922. * Prepares a frame to be run through a post process.
  38923. * @param sourceTexture The input texture to the post procesess. (default: null)
  38924. * @param postProcesses An array of post processes to be run. (default: null)
  38925. * @returns True if the post processes were able to be run.
  38926. * @hidden
  38927. */
  38928. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  38929. /**
  38930. * Manually render a set of post processes to a texture.
  38931. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  38932. * @param postProcesses An array of post processes to be run.
  38933. * @param targetTexture The target texture to render to.
  38934. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  38935. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  38936. * @param lodLevel defines which lod of the texture to render to
  38937. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  38938. */
  38939. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  38940. /**
  38941. * Finalize the result of the output of the postprocesses.
  38942. * @param doNotPresent If true the result will not be displayed to the screen.
  38943. * @param targetTexture The target texture to render to.
  38944. * @param faceIndex The index of the face to bind the target texture to.
  38945. * @param postProcesses The array of post processes to render.
  38946. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  38947. * @hidden
  38948. */
  38949. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  38950. /**
  38951. * Disposes of the post process manager.
  38952. */
  38953. dispose(): void;
  38954. }
  38955. }
  38956. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  38957. import { Observable } from "babylonjs/Misc/observable";
  38958. import { SmartArray } from "babylonjs/Misc/smartArray";
  38959. import { Nullable, Immutable } from "babylonjs/types";
  38960. import { Camera } from "babylonjs/Cameras/camera";
  38961. import { Scene } from "babylonjs/scene";
  38962. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  38963. import { Color4 } from "babylonjs/Maths/math.color";
  38964. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  38965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38966. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38967. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38968. import { Texture } from "babylonjs/Materials/Textures/texture";
  38969. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38970. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  38971. import "babylonjs/Engines/Extensions/engine.renderTarget";
  38972. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  38973. import { Engine } from "babylonjs/Engines/engine";
  38974. /**
  38975. * This Helps creating a texture that will be created from a camera in your scene.
  38976. * It is basically a dynamic texture that could be used to create special effects for instance.
  38977. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  38978. */
  38979. export class RenderTargetTexture extends Texture {
  38980. /**
  38981. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  38982. */
  38983. static readonly REFRESHRATE_RENDER_ONCE: number;
  38984. /**
  38985. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  38986. */
  38987. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  38988. /**
  38989. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  38990. * the central point of your effect and can save a lot of performances.
  38991. */
  38992. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  38993. /**
  38994. * Use this predicate to dynamically define the list of mesh you want to render.
  38995. * If set, the renderList property will be overwritten.
  38996. */
  38997. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  38998. private _renderList;
  38999. /**
  39000. * Use this list to define the list of mesh you want to render.
  39001. */
  39002. get renderList(): Nullable<Array<AbstractMesh>>;
  39003. set renderList(value: Nullable<Array<AbstractMesh>>);
  39004. /**
  39005. * Use this function to overload the renderList array at rendering time.
  39006. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  39007. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  39008. * the cube (if the RTT is a cube, else layerOrFace=0).
  39009. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  39010. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  39011. * hold dummy elements!
  39012. */
  39013. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  39014. private _hookArray;
  39015. /**
  39016. * Define if particles should be rendered in your texture.
  39017. */
  39018. renderParticles: boolean;
  39019. /**
  39020. * Define if sprites should be rendered in your texture.
  39021. */
  39022. renderSprites: boolean;
  39023. /**
  39024. * Define the camera used to render the texture.
  39025. */
  39026. activeCamera: Nullable<Camera>;
  39027. /**
  39028. * Override the mesh isReady function with your own one.
  39029. */
  39030. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  39031. /**
  39032. * Override the render function of the texture with your own one.
  39033. */
  39034. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  39035. /**
  39036. * Define if camera post processes should be use while rendering the texture.
  39037. */
  39038. useCameraPostProcesses: boolean;
  39039. /**
  39040. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  39041. */
  39042. ignoreCameraViewport: boolean;
  39043. private _postProcessManager;
  39044. private _postProcesses;
  39045. private _resizeObserver;
  39046. /**
  39047. * An event triggered when the texture is unbind.
  39048. */
  39049. onBeforeBindObservable: Observable<RenderTargetTexture>;
  39050. /**
  39051. * An event triggered when the texture is unbind.
  39052. */
  39053. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  39054. private _onAfterUnbindObserver;
  39055. /**
  39056. * Set a after unbind callback in the texture.
  39057. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  39058. */
  39059. set onAfterUnbind(callback: () => void);
  39060. /**
  39061. * An event triggered before rendering the texture
  39062. */
  39063. onBeforeRenderObservable: Observable<number>;
  39064. private _onBeforeRenderObserver;
  39065. /**
  39066. * Set a before render callback in the texture.
  39067. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  39068. */
  39069. set onBeforeRender(callback: (faceIndex: number) => void);
  39070. /**
  39071. * An event triggered after rendering the texture
  39072. */
  39073. onAfterRenderObservable: Observable<number>;
  39074. private _onAfterRenderObserver;
  39075. /**
  39076. * Set a after render callback in the texture.
  39077. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  39078. */
  39079. set onAfterRender(callback: (faceIndex: number) => void);
  39080. /**
  39081. * An event triggered after the texture clear
  39082. */
  39083. onClearObservable: Observable<Engine>;
  39084. private _onClearObserver;
  39085. /**
  39086. * Set a clear callback in the texture.
  39087. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  39088. */
  39089. set onClear(callback: (Engine: Engine) => void);
  39090. /**
  39091. * An event triggered when the texture is resized.
  39092. */
  39093. onResizeObservable: Observable<RenderTargetTexture>;
  39094. /**
  39095. * Define the clear color of the Render Target if it should be different from the scene.
  39096. */
  39097. clearColor: Color4;
  39098. protected _size: number | {
  39099. width: number;
  39100. height: number;
  39101. layers?: number;
  39102. };
  39103. protected _initialSizeParameter: number | {
  39104. width: number;
  39105. height: number;
  39106. } | {
  39107. ratio: number;
  39108. };
  39109. protected _sizeRatio: Nullable<number>;
  39110. /** @hidden */
  39111. _generateMipMaps: boolean;
  39112. protected _renderingManager: RenderingManager;
  39113. /** @hidden */
  39114. _waitingRenderList?: string[];
  39115. protected _doNotChangeAspectRatio: boolean;
  39116. protected _currentRefreshId: number;
  39117. protected _refreshRate: number;
  39118. protected _textureMatrix: Matrix;
  39119. protected _samples: number;
  39120. protected _renderTargetOptions: RenderTargetCreationOptions;
  39121. /**
  39122. * Gets render target creation options that were used.
  39123. */
  39124. get renderTargetOptions(): RenderTargetCreationOptions;
  39125. protected _onRatioRescale(): void;
  39126. /**
  39127. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  39128. * It must define where the camera used to render the texture is set
  39129. */
  39130. boundingBoxPosition: Vector3;
  39131. private _boundingBoxSize;
  39132. /**
  39133. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  39134. * When defined, the cubemap will switch to local mode
  39135. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  39136. * @example https://www.babylonjs-playground.com/#RNASML
  39137. */
  39138. set boundingBoxSize(value: Vector3);
  39139. get boundingBoxSize(): Vector3;
  39140. /**
  39141. * In case the RTT has been created with a depth texture, get the associated
  39142. * depth texture.
  39143. * Otherwise, return null.
  39144. */
  39145. get depthStencilTexture(): Nullable<InternalTexture>;
  39146. /**
  39147. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  39148. * or used a shadow, depth texture...
  39149. * @param name The friendly name of the texture
  39150. * @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)
  39151. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  39152. * @param generateMipMaps True if mip maps need to be generated after render.
  39153. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  39154. * @param type The type of the buffer in the RTT (int, half float, float...)
  39155. * @param isCube True if a cube texture needs to be created
  39156. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  39157. * @param generateDepthBuffer True to generate a depth buffer
  39158. * @param generateStencilBuffer True to generate a stencil buffer
  39159. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  39160. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  39161. * @param delayAllocation if the texture allocation should be delayed (default: false)
  39162. */
  39163. constructor(name: string, size: number | {
  39164. width: number;
  39165. height: number;
  39166. layers?: number;
  39167. } | {
  39168. ratio: number;
  39169. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  39170. /**
  39171. * Creates a depth stencil texture.
  39172. * This is only available in WebGL 2 or with the depth texture extension available.
  39173. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  39174. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  39175. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  39176. */
  39177. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  39178. private _processSizeParameter;
  39179. /**
  39180. * Define the number of samples to use in case of MSAA.
  39181. * It defaults to one meaning no MSAA has been enabled.
  39182. */
  39183. get samples(): number;
  39184. set samples(value: number);
  39185. /**
  39186. * Resets the refresh counter of the texture and start bak from scratch.
  39187. * Could be useful to regenerate the texture if it is setup to render only once.
  39188. */
  39189. resetRefreshCounter(): void;
  39190. /**
  39191. * Define the refresh rate of the texture or the rendering frequency.
  39192. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  39193. */
  39194. get refreshRate(): number;
  39195. set refreshRate(value: number);
  39196. /**
  39197. * Adds a post process to the render target rendering passes.
  39198. * @param postProcess define the post process to add
  39199. */
  39200. addPostProcess(postProcess: PostProcess): void;
  39201. /**
  39202. * Clear all the post processes attached to the render target
  39203. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  39204. */
  39205. clearPostProcesses(dispose?: boolean): void;
  39206. /**
  39207. * Remove one of the post process from the list of attached post processes to the texture
  39208. * @param postProcess define the post process to remove from the list
  39209. */
  39210. removePostProcess(postProcess: PostProcess): void;
  39211. /** @hidden */
  39212. _shouldRender(): boolean;
  39213. /**
  39214. * Gets the actual render size of the texture.
  39215. * @returns the width of the render size
  39216. */
  39217. getRenderSize(): number;
  39218. /**
  39219. * Gets the actual render width of the texture.
  39220. * @returns the width of the render size
  39221. */
  39222. getRenderWidth(): number;
  39223. /**
  39224. * Gets the actual render height of the texture.
  39225. * @returns the height of the render size
  39226. */
  39227. getRenderHeight(): number;
  39228. /**
  39229. * Gets the actual number of layers of the texture.
  39230. * @returns the number of layers
  39231. */
  39232. getRenderLayers(): number;
  39233. /**
  39234. * Get if the texture can be rescaled or not.
  39235. */
  39236. get canRescale(): boolean;
  39237. /**
  39238. * Resize the texture using a ratio.
  39239. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  39240. */
  39241. scale(ratio: number): void;
  39242. /**
  39243. * Get the texture reflection matrix used to rotate/transform the reflection.
  39244. * @returns the reflection matrix
  39245. */
  39246. getReflectionTextureMatrix(): Matrix;
  39247. /**
  39248. * Resize the texture to a new desired size.
  39249. * Be carrefull as it will recreate all the data in the new texture.
  39250. * @param size Define the new size. It can be:
  39251. * - a number for squared texture,
  39252. * - an object containing { width: number, height: number }
  39253. * - or an object containing a ratio { ratio: number }
  39254. */
  39255. resize(size: number | {
  39256. width: number;
  39257. height: number;
  39258. } | {
  39259. ratio: number;
  39260. }): void;
  39261. private _defaultRenderListPrepared;
  39262. /**
  39263. * Renders all the objects from the render list into the texture.
  39264. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  39265. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  39266. */
  39267. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  39268. private _bestReflectionRenderTargetDimension;
  39269. private _prepareRenderingManager;
  39270. /**
  39271. * @hidden
  39272. * @param faceIndex face index to bind to if this is a cubetexture
  39273. * @param layer defines the index of the texture to bind in the array
  39274. */
  39275. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  39276. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  39277. private renderToTarget;
  39278. /**
  39279. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  39280. * This allowed control for front to back rendering or reversly depending of the special needs.
  39281. *
  39282. * @param renderingGroupId The rendering group id corresponding to its index
  39283. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  39284. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  39285. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  39286. */
  39287. 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;
  39288. /**
  39289. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  39290. *
  39291. * @param renderingGroupId The rendering group id corresponding to its index
  39292. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  39293. */
  39294. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  39295. /**
  39296. * Clones the texture.
  39297. * @returns the cloned texture
  39298. */
  39299. clone(): RenderTargetTexture;
  39300. /**
  39301. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  39302. * @returns The JSON representation of the texture
  39303. */
  39304. serialize(): any;
  39305. /**
  39306. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  39307. */
  39308. disposeFramebufferObjects(): void;
  39309. /**
  39310. * Dispose the texture and release its associated resources.
  39311. */
  39312. dispose(): void;
  39313. /** @hidden */
  39314. _rebuild(): void;
  39315. /**
  39316. * Clear the info related to rendering groups preventing retention point in material dispose.
  39317. */
  39318. freeRenderingGroups(): void;
  39319. /**
  39320. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  39321. * @returns the view count
  39322. */
  39323. getViewCount(): number;
  39324. }
  39325. }
  39326. declare module "babylonjs/Materials/effect" {
  39327. import { Observable } from "babylonjs/Misc/observable";
  39328. import { Nullable } from "babylonjs/types";
  39329. import { IDisposable } from "babylonjs/scene";
  39330. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  39331. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  39332. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  39333. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  39334. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  39335. import { Engine } from "babylonjs/Engines/engine";
  39336. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39337. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  39338. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39339. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39340. /**
  39341. * Options to be used when creating an effect.
  39342. */
  39343. export interface IEffectCreationOptions {
  39344. /**
  39345. * Atrributes that will be used in the shader.
  39346. */
  39347. attributes: string[];
  39348. /**
  39349. * Uniform varible names that will be set in the shader.
  39350. */
  39351. uniformsNames: string[];
  39352. /**
  39353. * Uniform buffer variable names that will be set in the shader.
  39354. */
  39355. uniformBuffersNames: string[];
  39356. /**
  39357. * Sampler texture variable names that will be set in the shader.
  39358. */
  39359. samplers: string[];
  39360. /**
  39361. * Define statements that will be set in the shader.
  39362. */
  39363. defines: any;
  39364. /**
  39365. * Possible fallbacks for this effect to improve performance when needed.
  39366. */
  39367. fallbacks: Nullable<IEffectFallbacks>;
  39368. /**
  39369. * Callback that will be called when the shader is compiled.
  39370. */
  39371. onCompiled: Nullable<(effect: Effect) => void>;
  39372. /**
  39373. * Callback that will be called if an error occurs during shader compilation.
  39374. */
  39375. onError: Nullable<(effect: Effect, errors: string) => void>;
  39376. /**
  39377. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39378. */
  39379. indexParameters?: any;
  39380. /**
  39381. * Max number of lights that can be used in the shader.
  39382. */
  39383. maxSimultaneousLights?: number;
  39384. /**
  39385. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  39386. */
  39387. transformFeedbackVaryings?: Nullable<string[]>;
  39388. /**
  39389. * 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
  39390. */
  39391. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  39392. /**
  39393. * Is this effect rendering to several color attachments ?
  39394. */
  39395. multiTarget?: boolean;
  39396. }
  39397. /**
  39398. * Effect containing vertex and fragment shader that can be executed on an object.
  39399. */
  39400. export class Effect implements IDisposable {
  39401. /**
  39402. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39403. */
  39404. static ShadersRepository: string;
  39405. /**
  39406. * Enable logging of the shader code when a compilation error occurs
  39407. */
  39408. static LogShaderCodeOnCompilationError: boolean;
  39409. /**
  39410. * Name of the effect.
  39411. */
  39412. name: any;
  39413. /**
  39414. * String container all the define statements that should be set on the shader.
  39415. */
  39416. defines: string;
  39417. /**
  39418. * Callback that will be called when the shader is compiled.
  39419. */
  39420. onCompiled: Nullable<(effect: Effect) => void>;
  39421. /**
  39422. * Callback that will be called if an error occurs during shader compilation.
  39423. */
  39424. onError: Nullable<(effect: Effect, errors: string) => void>;
  39425. /**
  39426. * Callback that will be called when effect is bound.
  39427. */
  39428. onBind: Nullable<(effect: Effect) => void>;
  39429. /**
  39430. * Unique ID of the effect.
  39431. */
  39432. uniqueId: number;
  39433. /**
  39434. * Observable that will be called when the shader is compiled.
  39435. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  39436. */
  39437. onCompileObservable: Observable<Effect>;
  39438. /**
  39439. * Observable that will be called if an error occurs during shader compilation.
  39440. */
  39441. onErrorObservable: Observable<Effect>;
  39442. /** @hidden */
  39443. _onBindObservable: Nullable<Observable<Effect>>;
  39444. /**
  39445. * @hidden
  39446. * Specifies if the effect was previously ready
  39447. */
  39448. _wasPreviouslyReady: boolean;
  39449. /**
  39450. * Observable that will be called when effect is bound.
  39451. */
  39452. get onBindObservable(): Observable<Effect>;
  39453. /** @hidden */
  39454. _bonesComputationForcedToCPU: boolean;
  39455. /** @hidden */
  39456. _multiTarget: boolean;
  39457. private static _uniqueIdSeed;
  39458. private _engine;
  39459. private _uniformBuffersNames;
  39460. private _uniformBuffersNamesList;
  39461. private _uniformsNames;
  39462. private _samplerList;
  39463. private _samplers;
  39464. private _isReady;
  39465. private _compilationError;
  39466. private _allFallbacksProcessed;
  39467. private _attributesNames;
  39468. private _attributes;
  39469. private _attributeLocationByName;
  39470. private _uniforms;
  39471. /**
  39472. * Key for the effect.
  39473. * @hidden
  39474. */
  39475. _key: string;
  39476. private _indexParameters;
  39477. private _fallbacks;
  39478. private _vertexSourceCode;
  39479. private _fragmentSourceCode;
  39480. private _vertexSourceCodeOverride;
  39481. private _fragmentSourceCodeOverride;
  39482. private _transformFeedbackVaryings;
  39483. private _rawVertexSourceCode;
  39484. private _rawFragmentSourceCode;
  39485. /**
  39486. * Compiled shader to webGL program.
  39487. * @hidden
  39488. */
  39489. _pipelineContext: Nullable<IPipelineContext>;
  39490. private _valueCache;
  39491. private static _baseCache;
  39492. /**
  39493. * Instantiates an effect.
  39494. * An effect can be used to create/manage/execute vertex and fragment shaders.
  39495. * @param baseName Name of the effect.
  39496. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  39497. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  39498. * @param samplers List of sampler variables that will be passed to the shader.
  39499. * @param engine Engine to be used to render the effect
  39500. * @param defines Define statements to be added to the shader.
  39501. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  39502. * @param onCompiled Callback that will be called when the shader is compiled.
  39503. * @param onError Callback that will be called if an error occurs during shader compilation.
  39504. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39505. */
  39506. 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);
  39507. private _useFinalCode;
  39508. /**
  39509. * Unique key for this effect
  39510. */
  39511. get key(): string;
  39512. /**
  39513. * If the effect has been compiled and prepared.
  39514. * @returns if the effect is compiled and prepared.
  39515. */
  39516. isReady(): boolean;
  39517. private _isReadyInternal;
  39518. /**
  39519. * The engine the effect was initialized with.
  39520. * @returns the engine.
  39521. */
  39522. getEngine(): Engine;
  39523. /**
  39524. * The pipeline context for this effect
  39525. * @returns the associated pipeline context
  39526. */
  39527. getPipelineContext(): Nullable<IPipelineContext>;
  39528. /**
  39529. * The set of names of attribute variables for the shader.
  39530. * @returns An array of attribute names.
  39531. */
  39532. getAttributesNames(): string[];
  39533. /**
  39534. * Returns the attribute at the given index.
  39535. * @param index The index of the attribute.
  39536. * @returns The location of the attribute.
  39537. */
  39538. getAttributeLocation(index: number): number;
  39539. /**
  39540. * Returns the attribute based on the name of the variable.
  39541. * @param name of the attribute to look up.
  39542. * @returns the attribute location.
  39543. */
  39544. getAttributeLocationByName(name: string): number;
  39545. /**
  39546. * The number of attributes.
  39547. * @returns the numnber of attributes.
  39548. */
  39549. getAttributesCount(): number;
  39550. /**
  39551. * Gets the index of a uniform variable.
  39552. * @param uniformName of the uniform to look up.
  39553. * @returns the index.
  39554. */
  39555. getUniformIndex(uniformName: string): number;
  39556. /**
  39557. * Returns the attribute based on the name of the variable.
  39558. * @param uniformName of the uniform to look up.
  39559. * @returns the location of the uniform.
  39560. */
  39561. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39562. /**
  39563. * Returns an array of sampler variable names
  39564. * @returns The array of sampler variable names.
  39565. */
  39566. getSamplers(): string[];
  39567. /**
  39568. * Returns an array of uniform variable names
  39569. * @returns The array of uniform variable names.
  39570. */
  39571. getUniformNames(): string[];
  39572. /**
  39573. * Returns an array of uniform buffer variable names
  39574. * @returns The array of uniform buffer variable names.
  39575. */
  39576. getUniformBuffersNames(): string[];
  39577. /**
  39578. * Returns the index parameters used to create the effect
  39579. * @returns The index parameters object
  39580. */
  39581. getIndexParameters(): any;
  39582. /**
  39583. * The error from the last compilation.
  39584. * @returns the error string.
  39585. */
  39586. getCompilationError(): string;
  39587. /**
  39588. * Gets a boolean indicating that all fallbacks were used during compilation
  39589. * @returns true if all fallbacks were used
  39590. */
  39591. allFallbacksProcessed(): boolean;
  39592. /**
  39593. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  39594. * @param func The callback to be used.
  39595. */
  39596. executeWhenCompiled(func: (effect: Effect) => void): void;
  39597. private _checkIsReady;
  39598. private _loadShader;
  39599. /**
  39600. * Gets the vertex shader source code of this effect
  39601. */
  39602. get vertexSourceCode(): string;
  39603. /**
  39604. * Gets the fragment shader source code of this effect
  39605. */
  39606. get fragmentSourceCode(): string;
  39607. /**
  39608. * Gets the vertex shader source code before it has been processed by the preprocessor
  39609. */
  39610. get rawVertexSourceCode(): string;
  39611. /**
  39612. * Gets the fragment shader source code before it has been processed by the preprocessor
  39613. */
  39614. get rawFragmentSourceCode(): string;
  39615. /**
  39616. * Recompiles the webGL program
  39617. * @param vertexSourceCode The source code for the vertex shader.
  39618. * @param fragmentSourceCode The source code for the fragment shader.
  39619. * @param onCompiled Callback called when completed.
  39620. * @param onError Callback called on error.
  39621. * @hidden
  39622. */
  39623. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39624. /**
  39625. * Prepares the effect
  39626. * @hidden
  39627. */
  39628. _prepareEffect(): void;
  39629. private _getShaderCodeAndErrorLine;
  39630. private _processCompilationErrors;
  39631. /**
  39632. * Checks if the effect is supported. (Must be called after compilation)
  39633. */
  39634. get isSupported(): boolean;
  39635. /**
  39636. * Binds a texture to the engine to be used as output of the shader.
  39637. * @param channel Name of the output variable.
  39638. * @param texture Texture to bind.
  39639. * @hidden
  39640. */
  39641. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39642. /**
  39643. * Sets a texture on the engine to be used in the shader.
  39644. * @param channel Name of the sampler variable.
  39645. * @param texture Texture to set.
  39646. */
  39647. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  39648. /**
  39649. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39650. * @param channel Name of the sampler variable.
  39651. * @param texture Texture to set.
  39652. */
  39653. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39654. /**
  39655. * Sets an array of textures on the engine to be used in the shader.
  39656. * @param channel Name of the variable.
  39657. * @param textures Textures to set.
  39658. */
  39659. setTextureArray(channel: string, textures: ThinTexture[]): void;
  39660. /**
  39661. * 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)
  39662. * @param channel Name of the sampler variable.
  39663. * @param postProcess Post process to get the input texture from.
  39664. */
  39665. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39666. /**
  39667. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39668. * 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)
  39669. * @param channel Name of the sampler variable.
  39670. * @param postProcess Post process to get the output texture from.
  39671. */
  39672. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39673. /** @hidden */
  39674. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  39675. /** @hidden */
  39676. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  39677. /** @hidden */
  39678. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  39679. /** @hidden */
  39680. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  39681. /**
  39682. * Binds a buffer to a uniform.
  39683. * @param buffer Buffer to bind.
  39684. * @param name Name of the uniform variable to bind to.
  39685. */
  39686. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39687. /**
  39688. * Binds block to a uniform.
  39689. * @param blockName Name of the block to bind.
  39690. * @param index Index to bind.
  39691. */
  39692. bindUniformBlock(blockName: string, index: number): void;
  39693. /**
  39694. * Sets an interger value on a uniform variable.
  39695. * @param uniformName Name of the variable.
  39696. * @param value Value to be set.
  39697. * @returns this effect.
  39698. */
  39699. setInt(uniformName: string, value: number): Effect;
  39700. /**
  39701. * Sets an int array on a uniform variable.
  39702. * @param uniformName Name of the variable.
  39703. * @param array array to be set.
  39704. * @returns this effect.
  39705. */
  39706. setIntArray(uniformName: string, array: Int32Array): Effect;
  39707. /**
  39708. * 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)
  39709. * @param uniformName Name of the variable.
  39710. * @param array array to be set.
  39711. * @returns this effect.
  39712. */
  39713. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39714. /**
  39715. * 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)
  39716. * @param uniformName Name of the variable.
  39717. * @param array array to be set.
  39718. * @returns this effect.
  39719. */
  39720. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39721. /**
  39722. * 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)
  39723. * @param uniformName Name of the variable.
  39724. * @param array array to be set.
  39725. * @returns this effect.
  39726. */
  39727. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39728. /**
  39729. * Sets an float array on a uniform variable.
  39730. * @param uniformName Name of the variable.
  39731. * @param array array to be set.
  39732. * @returns this effect.
  39733. */
  39734. setFloatArray(uniformName: string, array: Float32Array): Effect;
  39735. /**
  39736. * 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)
  39737. * @param uniformName Name of the variable.
  39738. * @param array array to be set.
  39739. * @returns this effect.
  39740. */
  39741. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  39742. /**
  39743. * 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)
  39744. * @param uniformName Name of the variable.
  39745. * @param array array to be set.
  39746. * @returns this effect.
  39747. */
  39748. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  39749. /**
  39750. * 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)
  39751. * @param uniformName Name of the variable.
  39752. * @param array array to be set.
  39753. * @returns this effect.
  39754. */
  39755. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  39756. /**
  39757. * Sets an array on a uniform variable.
  39758. * @param uniformName Name of the variable.
  39759. * @param array array to be set.
  39760. * @returns this effect.
  39761. */
  39762. setArray(uniformName: string, array: number[]): Effect;
  39763. /**
  39764. * 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)
  39765. * @param uniformName Name of the variable.
  39766. * @param array array to be set.
  39767. * @returns this effect.
  39768. */
  39769. setArray2(uniformName: string, array: number[]): Effect;
  39770. /**
  39771. * 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)
  39772. * @param uniformName Name of the variable.
  39773. * @param array array to be set.
  39774. * @returns this effect.
  39775. */
  39776. setArray3(uniformName: string, array: number[]): Effect;
  39777. /**
  39778. * 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)
  39779. * @param uniformName Name of the variable.
  39780. * @param array array to be set.
  39781. * @returns this effect.
  39782. */
  39783. setArray4(uniformName: string, array: number[]): Effect;
  39784. /**
  39785. * Sets matrices on a uniform variable.
  39786. * @param uniformName Name of the variable.
  39787. * @param matrices matrices to be set.
  39788. * @returns this effect.
  39789. */
  39790. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39791. /**
  39792. * Sets matrix on a uniform variable.
  39793. * @param uniformName Name of the variable.
  39794. * @param matrix matrix to be set.
  39795. * @returns this effect.
  39796. */
  39797. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39798. /**
  39799. * 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)
  39800. * @param uniformName Name of the variable.
  39801. * @param matrix matrix to be set.
  39802. * @returns this effect.
  39803. */
  39804. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39805. /**
  39806. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39807. * @param uniformName Name of the variable.
  39808. * @param matrix matrix to be set.
  39809. * @returns this effect.
  39810. */
  39811. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39812. /**
  39813. * Sets a float on a uniform variable.
  39814. * @param uniformName Name of the variable.
  39815. * @param value value to be set.
  39816. * @returns this effect.
  39817. */
  39818. setFloat(uniformName: string, value: number): Effect;
  39819. /**
  39820. * Sets a boolean on a uniform variable.
  39821. * @param uniformName Name of the variable.
  39822. * @param bool value to be set.
  39823. * @returns this effect.
  39824. */
  39825. setBool(uniformName: string, bool: boolean): Effect;
  39826. /**
  39827. * Sets a Vector2 on a uniform variable.
  39828. * @param uniformName Name of the variable.
  39829. * @param vector2 vector2 to be set.
  39830. * @returns this effect.
  39831. */
  39832. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39833. /**
  39834. * Sets a float2 on a uniform variable.
  39835. * @param uniformName Name of the variable.
  39836. * @param x First float in float2.
  39837. * @param y Second float in float2.
  39838. * @returns this effect.
  39839. */
  39840. setFloat2(uniformName: string, x: number, y: number): Effect;
  39841. /**
  39842. * Sets a Vector3 on a uniform variable.
  39843. * @param uniformName Name of the variable.
  39844. * @param vector3 Value to be set.
  39845. * @returns this effect.
  39846. */
  39847. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39848. /**
  39849. * Sets a float3 on a uniform variable.
  39850. * @param uniformName Name of the variable.
  39851. * @param x First float in float3.
  39852. * @param y Second float in float3.
  39853. * @param z Third float in float3.
  39854. * @returns this effect.
  39855. */
  39856. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39857. /**
  39858. * Sets a Vector4 on a uniform variable.
  39859. * @param uniformName Name of the variable.
  39860. * @param vector4 Value to be set.
  39861. * @returns this effect.
  39862. */
  39863. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39864. /**
  39865. * Sets a float4 on a uniform variable.
  39866. * @param uniformName Name of the variable.
  39867. * @param x First float in float4.
  39868. * @param y Second float in float4.
  39869. * @param z Third float in float4.
  39870. * @param w Fourth float in float4.
  39871. * @returns this effect.
  39872. */
  39873. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39874. /**
  39875. * Sets a Color3 on a uniform variable.
  39876. * @param uniformName Name of the variable.
  39877. * @param color3 Value to be set.
  39878. * @returns this effect.
  39879. */
  39880. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39881. /**
  39882. * Sets a Color4 on a uniform variable.
  39883. * @param uniformName Name of the variable.
  39884. * @param color3 Value to be set.
  39885. * @param alpha Alpha value to be set.
  39886. * @returns this effect.
  39887. */
  39888. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39889. /**
  39890. * Sets a Color4 on a uniform variable
  39891. * @param uniformName defines the name of the variable
  39892. * @param color4 defines the value to be set
  39893. * @returns this effect.
  39894. */
  39895. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39896. /** Release all associated resources */
  39897. dispose(): void;
  39898. /**
  39899. * This function will add a new shader to the shader store
  39900. * @param name the name of the shader
  39901. * @param pixelShader optional pixel shader content
  39902. * @param vertexShader optional vertex shader content
  39903. */
  39904. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39905. /**
  39906. * Store of each shader (The can be looked up using effect.key)
  39907. */
  39908. static ShadersStore: {
  39909. [key: string]: string;
  39910. };
  39911. /**
  39912. * Store of each included file for a shader (The can be looked up using effect.key)
  39913. */
  39914. static IncludesShadersStore: {
  39915. [key: string]: string;
  39916. };
  39917. /**
  39918. * Resets the cache of effects.
  39919. */
  39920. static ResetCache(): void;
  39921. }
  39922. }
  39923. declare module "babylonjs/Engines/engineCapabilities" {
  39924. /**
  39925. * Interface used to describe the capabilities of the engine relatively to the current browser
  39926. */
  39927. export interface EngineCapabilities {
  39928. /** Maximum textures units per fragment shader */
  39929. maxTexturesImageUnits: number;
  39930. /** Maximum texture units per vertex shader */
  39931. maxVertexTextureImageUnits: number;
  39932. /** Maximum textures units in the entire pipeline */
  39933. maxCombinedTexturesImageUnits: number;
  39934. /** Maximum texture size */
  39935. maxTextureSize: number;
  39936. /** Maximum texture samples */
  39937. maxSamples?: number;
  39938. /** Maximum cube texture size */
  39939. maxCubemapTextureSize: number;
  39940. /** Maximum render texture size */
  39941. maxRenderTextureSize: number;
  39942. /** Maximum number of vertex attributes */
  39943. maxVertexAttribs: number;
  39944. /** Maximum number of varyings */
  39945. maxVaryingVectors: number;
  39946. /** Maximum number of uniforms per vertex shader */
  39947. maxVertexUniformVectors: number;
  39948. /** Maximum number of uniforms per fragment shader */
  39949. maxFragmentUniformVectors: number;
  39950. /** Defines if standard derivates (dx/dy) are supported */
  39951. standardDerivatives: boolean;
  39952. /** Defines if s3tc texture compression is supported */
  39953. s3tc?: WEBGL_compressed_texture_s3tc;
  39954. /** Defines if pvrtc texture compression is supported */
  39955. pvrtc: any;
  39956. /** Defines if etc1 texture compression is supported */
  39957. etc1: any;
  39958. /** Defines if etc2 texture compression is supported */
  39959. etc2: any;
  39960. /** Defines if astc texture compression is supported */
  39961. astc: any;
  39962. /** Defines if bptc texture compression is supported */
  39963. bptc: any;
  39964. /** Defines if float textures are supported */
  39965. textureFloat: boolean;
  39966. /** Defines if vertex array objects are supported */
  39967. vertexArrayObject: boolean;
  39968. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39969. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39970. /** Gets the maximum level of anisotropy supported */
  39971. maxAnisotropy: number;
  39972. /** Defines if instancing is supported */
  39973. instancedArrays: boolean;
  39974. /** Defines if 32 bits indices are supported */
  39975. uintIndices: boolean;
  39976. /** Defines if high precision shaders are supported */
  39977. highPrecisionShaderSupported: boolean;
  39978. /** Defines if depth reading in the fragment shader is supported */
  39979. fragmentDepthSupported: boolean;
  39980. /** Defines if float texture linear filtering is supported*/
  39981. textureFloatLinearFiltering: boolean;
  39982. /** Defines if rendering to float textures is supported */
  39983. textureFloatRender: boolean;
  39984. /** Defines if half float textures are supported*/
  39985. textureHalfFloat: boolean;
  39986. /** Defines if half float texture linear filtering is supported*/
  39987. textureHalfFloatLinearFiltering: boolean;
  39988. /** Defines if rendering to half float textures is supported */
  39989. textureHalfFloatRender: boolean;
  39990. /** Defines if textureLOD shader command is supported */
  39991. textureLOD: boolean;
  39992. /** Defines if draw buffers extension is supported */
  39993. drawBuffersExtension: boolean;
  39994. /** Defines if depth textures are supported */
  39995. depthTextureExtension: boolean;
  39996. /** Defines if float color buffer are supported */
  39997. colorBufferFloat: boolean;
  39998. /** Gets disjoint timer query extension (null if not supported) */
  39999. timerQuery?: EXT_disjoint_timer_query;
  40000. /** Defines if timestamp can be used with timer query */
  40001. canUseTimestampForTimerQuery: boolean;
  40002. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  40003. multiview?: any;
  40004. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  40005. oculusMultiview?: any;
  40006. /** Function used to let the system compiles shaders in background */
  40007. parallelShaderCompile?: {
  40008. COMPLETION_STATUS_KHR: number;
  40009. };
  40010. /** Max number of texture samples for MSAA */
  40011. maxMSAASamples: number;
  40012. /** Defines if the blend min max extension is supported */
  40013. blendMinMax: boolean;
  40014. }
  40015. }
  40016. declare module "babylonjs/States/depthCullingState" {
  40017. import { Nullable } from "babylonjs/types";
  40018. /**
  40019. * @hidden
  40020. **/
  40021. export class DepthCullingState {
  40022. private _isDepthTestDirty;
  40023. private _isDepthMaskDirty;
  40024. private _isDepthFuncDirty;
  40025. private _isCullFaceDirty;
  40026. private _isCullDirty;
  40027. private _isZOffsetDirty;
  40028. private _isFrontFaceDirty;
  40029. private _depthTest;
  40030. private _depthMask;
  40031. private _depthFunc;
  40032. private _cull;
  40033. private _cullFace;
  40034. private _zOffset;
  40035. private _frontFace;
  40036. /**
  40037. * Initializes the state.
  40038. */
  40039. constructor();
  40040. get isDirty(): boolean;
  40041. get zOffset(): number;
  40042. set zOffset(value: number);
  40043. get cullFace(): Nullable<number>;
  40044. set cullFace(value: Nullable<number>);
  40045. get cull(): Nullable<boolean>;
  40046. set cull(value: Nullable<boolean>);
  40047. get depthFunc(): Nullable<number>;
  40048. set depthFunc(value: Nullable<number>);
  40049. get depthMask(): boolean;
  40050. set depthMask(value: boolean);
  40051. get depthTest(): boolean;
  40052. set depthTest(value: boolean);
  40053. get frontFace(): Nullable<number>;
  40054. set frontFace(value: Nullable<number>);
  40055. reset(): void;
  40056. apply(gl: WebGLRenderingContext): void;
  40057. }
  40058. }
  40059. declare module "babylonjs/States/stencilState" {
  40060. /**
  40061. * @hidden
  40062. **/
  40063. export class StencilState {
  40064. /** 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 */
  40065. static readonly ALWAYS: number;
  40066. /** Passed to stencilOperation to specify that stencil value must be kept */
  40067. static readonly KEEP: number;
  40068. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40069. static readonly REPLACE: number;
  40070. private _isStencilTestDirty;
  40071. private _isStencilMaskDirty;
  40072. private _isStencilFuncDirty;
  40073. private _isStencilOpDirty;
  40074. private _stencilTest;
  40075. private _stencilMask;
  40076. private _stencilFunc;
  40077. private _stencilFuncRef;
  40078. private _stencilFuncMask;
  40079. private _stencilOpStencilFail;
  40080. private _stencilOpDepthFail;
  40081. private _stencilOpStencilDepthPass;
  40082. get isDirty(): boolean;
  40083. get stencilFunc(): number;
  40084. set stencilFunc(value: number);
  40085. get stencilFuncRef(): number;
  40086. set stencilFuncRef(value: number);
  40087. get stencilFuncMask(): number;
  40088. set stencilFuncMask(value: number);
  40089. get stencilOpStencilFail(): number;
  40090. set stencilOpStencilFail(value: number);
  40091. get stencilOpDepthFail(): number;
  40092. set stencilOpDepthFail(value: number);
  40093. get stencilOpStencilDepthPass(): number;
  40094. set stencilOpStencilDepthPass(value: number);
  40095. get stencilMask(): number;
  40096. set stencilMask(value: number);
  40097. get stencilTest(): boolean;
  40098. set stencilTest(value: boolean);
  40099. constructor();
  40100. reset(): void;
  40101. apply(gl: WebGLRenderingContext): void;
  40102. }
  40103. }
  40104. declare module "babylonjs/States/alphaCullingState" {
  40105. /**
  40106. * @hidden
  40107. **/
  40108. export class AlphaState {
  40109. private _isAlphaBlendDirty;
  40110. private _isBlendFunctionParametersDirty;
  40111. private _isBlendEquationParametersDirty;
  40112. private _isBlendConstantsDirty;
  40113. private _alphaBlend;
  40114. private _blendFunctionParameters;
  40115. private _blendEquationParameters;
  40116. private _blendConstants;
  40117. /**
  40118. * Initializes the state.
  40119. */
  40120. constructor();
  40121. get isDirty(): boolean;
  40122. get alphaBlend(): boolean;
  40123. set alphaBlend(value: boolean);
  40124. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  40125. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  40126. setAlphaEquationParameters(rgb: number, alpha: number): void;
  40127. reset(): void;
  40128. apply(gl: WebGLRenderingContext): void;
  40129. }
  40130. }
  40131. declare module "babylonjs/Engines/WebGL/webGLShaderProcessors" {
  40132. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  40133. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  40134. /** @hidden */
  40135. export class WebGLShaderProcessor implements IShaderProcessor {
  40136. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  40137. }
  40138. }
  40139. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  40140. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  40141. /** @hidden */
  40142. export class WebGL2ShaderProcessor implements IShaderProcessor {
  40143. attributeProcessor(attribute: string): string;
  40144. varyingProcessor(varying: string, isFragment: boolean): string;
  40145. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  40146. }
  40147. }
  40148. declare module "babylonjs/Engines/instancingAttributeInfo" {
  40149. /**
  40150. * Interface for attribute information associated with buffer instanciation
  40151. */
  40152. export interface InstancingAttributeInfo {
  40153. /**
  40154. * Name of the GLSL attribute
  40155. * if attribute index is not specified, this is used to retrieve the index from the effect
  40156. */
  40157. attributeName: string;
  40158. /**
  40159. * Index/offset of the attribute in the vertex shader
  40160. * if not specified, this will be computes from the name.
  40161. */
  40162. index?: number;
  40163. /**
  40164. * size of the attribute, 1, 2, 3 or 4
  40165. */
  40166. attributeSize: number;
  40167. /**
  40168. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  40169. */
  40170. offset: number;
  40171. /**
  40172. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  40173. * default to 1
  40174. */
  40175. divisor?: number;
  40176. /**
  40177. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  40178. * default is FLOAT
  40179. */
  40180. attributeType?: number;
  40181. /**
  40182. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  40183. */
  40184. normalized?: boolean;
  40185. }
  40186. }
  40187. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  40188. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40189. import { Nullable } from "babylonjs/types";
  40190. module "babylonjs/Engines/thinEngine" {
  40191. interface ThinEngine {
  40192. /**
  40193. * Update a video texture
  40194. * @param texture defines the texture to update
  40195. * @param video defines the video element to use
  40196. * @param invertY defines if data must be stored with Y axis inverted
  40197. */
  40198. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  40199. }
  40200. }
  40201. }
  40202. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  40203. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40204. import { Nullable } from "babylonjs/types";
  40205. module "babylonjs/Engines/thinEngine" {
  40206. interface ThinEngine {
  40207. /**
  40208. * Creates a dynamic texture
  40209. * @param width defines the width of the texture
  40210. * @param height defines the height of the texture
  40211. * @param generateMipMaps defines if the engine should generate the mip levels
  40212. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  40213. * @returns the dynamic texture inside an InternalTexture
  40214. */
  40215. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  40216. /**
  40217. * Update the content of a dynamic texture
  40218. * @param texture defines the texture to update
  40219. * @param canvas defines the canvas containing the source
  40220. * @param invertY defines if data must be stored with Y axis inverted
  40221. * @param premulAlpha defines if alpha is stored as premultiplied
  40222. * @param format defines the format of the data
  40223. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  40224. */
  40225. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  40226. }
  40227. }
  40228. }
  40229. declare module "babylonjs/Materials/Textures/videoTexture" {
  40230. import { Observable } from "babylonjs/Misc/observable";
  40231. import { Nullable } from "babylonjs/types";
  40232. import { Scene } from "babylonjs/scene";
  40233. import { Texture } from "babylonjs/Materials/Textures/texture";
  40234. import "babylonjs/Engines/Extensions/engine.videoTexture";
  40235. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  40236. /**
  40237. * Settings for finer control over video usage
  40238. */
  40239. export interface VideoTextureSettings {
  40240. /**
  40241. * Applies `autoplay` to video, if specified
  40242. */
  40243. autoPlay?: boolean;
  40244. /**
  40245. * Applies `muted` to video, if specified
  40246. */
  40247. muted?: boolean;
  40248. /**
  40249. * Applies `loop` to video, if specified
  40250. */
  40251. loop?: boolean;
  40252. /**
  40253. * Automatically updates internal texture from video at every frame in the render loop
  40254. */
  40255. autoUpdateTexture: boolean;
  40256. /**
  40257. * Image src displayed during the video loading or until the user interacts with the video.
  40258. */
  40259. poster?: string;
  40260. }
  40261. /**
  40262. * If you want to display a video in your scene, this is the special texture for that.
  40263. * This special texture works similar to other textures, with the exception of a few parameters.
  40264. * @see https://doc.babylonjs.com/how_to/video_texture
  40265. */
  40266. export class VideoTexture extends Texture {
  40267. /**
  40268. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  40269. */
  40270. readonly autoUpdateTexture: boolean;
  40271. /**
  40272. * The video instance used by the texture internally
  40273. */
  40274. readonly video: HTMLVideoElement;
  40275. private _onUserActionRequestedObservable;
  40276. /**
  40277. * Event triggerd when a dom action is required by the user to play the video.
  40278. * This happens due to recent changes in browser policies preventing video to auto start.
  40279. */
  40280. get onUserActionRequestedObservable(): Observable<Texture>;
  40281. private _generateMipMaps;
  40282. private _stillImageCaptured;
  40283. private _displayingPosterTexture;
  40284. private _settings;
  40285. private _createInternalTextureOnEvent;
  40286. private _frameId;
  40287. private _currentSrc;
  40288. /**
  40289. * Creates a video texture.
  40290. * If you want to display a video in your scene, this is the special texture for that.
  40291. * This special texture works similar to other textures, with the exception of a few parameters.
  40292. * @see https://doc.babylonjs.com/how_to/video_texture
  40293. * @param name optional name, will detect from video source, if not defined
  40294. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  40295. * @param scene is obviously the current scene.
  40296. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  40297. * @param invertY is false by default but can be used to invert video on Y axis
  40298. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  40299. * @param settings allows finer control over video usage
  40300. */
  40301. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  40302. private _getName;
  40303. private _getVideo;
  40304. private _createInternalTexture;
  40305. private reset;
  40306. /**
  40307. * @hidden Internal method to initiate `update`.
  40308. */
  40309. _rebuild(): void;
  40310. /**
  40311. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  40312. */
  40313. update(): void;
  40314. /**
  40315. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  40316. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  40317. */
  40318. updateTexture(isVisible: boolean): void;
  40319. protected _updateInternalTexture: () => void;
  40320. /**
  40321. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  40322. * @param url New url.
  40323. */
  40324. updateURL(url: string): void;
  40325. /**
  40326. * Clones the texture.
  40327. * @returns the cloned texture
  40328. */
  40329. clone(): VideoTexture;
  40330. /**
  40331. * Dispose the texture and release its associated resources.
  40332. */
  40333. dispose(): void;
  40334. /**
  40335. * Creates a video texture straight from a stream.
  40336. * @param scene Define the scene the texture should be created in
  40337. * @param stream Define the stream the texture should be created from
  40338. * @returns The created video texture as a promise
  40339. */
  40340. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  40341. /**
  40342. * Creates a video texture straight from your WebCam video feed.
  40343. * @param scene Define the scene the texture should be created in
  40344. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40345. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40346. * @returns The created video texture as a promise
  40347. */
  40348. static CreateFromWebCamAsync(scene: Scene, constraints: {
  40349. minWidth: number;
  40350. maxWidth: number;
  40351. minHeight: number;
  40352. maxHeight: number;
  40353. deviceId: string;
  40354. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  40355. /**
  40356. * Creates a video texture straight from your WebCam video feed.
  40357. * @param scene Define the scene the texture should be created in
  40358. * @param onReady Define a callback to triggered once the texture will be ready
  40359. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40360. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40361. */
  40362. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  40363. minWidth: number;
  40364. maxWidth: number;
  40365. minHeight: number;
  40366. maxHeight: number;
  40367. deviceId: string;
  40368. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  40369. }
  40370. }
  40371. declare module "babylonjs/Engines/thinEngine" {
  40372. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  40373. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  40374. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  40375. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40376. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  40377. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  40378. import { Observable } from "babylonjs/Misc/observable";
  40379. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  40380. import { StencilState } from "babylonjs/States/stencilState";
  40381. import { AlphaState } from "babylonjs/States/alphaCullingState";
  40382. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40383. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  40384. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  40385. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40386. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  40387. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  40388. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  40389. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  40390. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  40391. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40392. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  40393. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  40394. import { WebRequest } from "babylonjs/Misc/webRequest";
  40395. import { LoadFileError } from "babylonjs/Misc/fileTools";
  40396. /**
  40397. * Defines the interface used by objects working like Scene
  40398. * @hidden
  40399. */
  40400. export interface ISceneLike {
  40401. _addPendingData(data: any): void;
  40402. _removePendingData(data: any): void;
  40403. offlineProvider: IOfflineProvider;
  40404. }
  40405. /**
  40406. * Information about the current host
  40407. */
  40408. export interface HostInformation {
  40409. /**
  40410. * Defines if the current host is a mobile
  40411. */
  40412. isMobile: boolean;
  40413. }
  40414. /** Interface defining initialization parameters for Engine class */
  40415. export interface EngineOptions extends WebGLContextAttributes {
  40416. /**
  40417. * Defines if the engine should no exceed a specified device ratio
  40418. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  40419. */
  40420. limitDeviceRatio?: number;
  40421. /**
  40422. * Defines if webvr should be enabled automatically
  40423. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40424. */
  40425. autoEnableWebVR?: boolean;
  40426. /**
  40427. * Defines if webgl2 should be turned off even if supported
  40428. * @see https://doc.babylonjs.com/features/webgl2
  40429. */
  40430. disableWebGL2Support?: boolean;
  40431. /**
  40432. * Defines if webaudio should be initialized as well
  40433. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40434. */
  40435. audioEngine?: boolean;
  40436. /**
  40437. * Defines if animations should run using a deterministic lock step
  40438. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40439. */
  40440. deterministicLockstep?: boolean;
  40441. /** Defines the maximum steps to use with deterministic lock step mode */
  40442. lockstepMaxSteps?: number;
  40443. /** Defines the seconds between each deterministic lock step */
  40444. timeStep?: number;
  40445. /**
  40446. * Defines that engine should ignore context lost events
  40447. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  40448. */
  40449. doNotHandleContextLost?: boolean;
  40450. /**
  40451. * Defines that engine should ignore modifying touch action attribute and style
  40452. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  40453. */
  40454. doNotHandleTouchAction?: boolean;
  40455. /**
  40456. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  40457. */
  40458. useHighPrecisionFloats?: boolean;
  40459. /**
  40460. * Make the canvas XR Compatible for XR sessions
  40461. */
  40462. xrCompatible?: boolean;
  40463. /**
  40464. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  40465. */
  40466. useHighPrecisionMatrix?: boolean;
  40467. /**
  40468. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  40469. */
  40470. failIfMajorPerformanceCaveat?: boolean;
  40471. }
  40472. /**
  40473. * The base engine class (root of all engines)
  40474. */
  40475. export class ThinEngine {
  40476. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  40477. static ExceptionList: ({
  40478. key: string;
  40479. capture: string;
  40480. captureConstraint: number;
  40481. targets: string[];
  40482. } | {
  40483. key: string;
  40484. capture: null;
  40485. captureConstraint: null;
  40486. targets: string[];
  40487. })[];
  40488. /** @hidden */
  40489. static _TextureLoaders: IInternalTextureLoader[];
  40490. /**
  40491. * Returns the current npm package of the sdk
  40492. */
  40493. static get NpmPackage(): string;
  40494. /**
  40495. * Returns the current version of the framework
  40496. */
  40497. static get Version(): string;
  40498. /**
  40499. * Returns a string describing the current engine
  40500. */
  40501. get description(): string;
  40502. /**
  40503. * Gets or sets the epsilon value used by collision engine
  40504. */
  40505. static CollisionsEpsilon: number;
  40506. /**
  40507. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40508. */
  40509. static get ShadersRepository(): string;
  40510. static set ShadersRepository(value: string);
  40511. /** @hidden */
  40512. _shaderProcessor: IShaderProcessor;
  40513. /**
  40514. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  40515. */
  40516. forcePOTTextures: boolean;
  40517. /**
  40518. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  40519. */
  40520. isFullscreen: boolean;
  40521. /**
  40522. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  40523. */
  40524. cullBackFaces: boolean;
  40525. /**
  40526. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  40527. */
  40528. renderEvenInBackground: boolean;
  40529. /**
  40530. * Gets or sets a boolean indicating that cache can be kept between frames
  40531. */
  40532. preventCacheWipeBetweenFrames: boolean;
  40533. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  40534. validateShaderPrograms: boolean;
  40535. /**
  40536. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  40537. * This can provide greater z depth for distant objects.
  40538. */
  40539. useReverseDepthBuffer: boolean;
  40540. /**
  40541. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  40542. */
  40543. disableUniformBuffers: boolean;
  40544. /** @hidden */
  40545. _uniformBuffers: UniformBuffer[];
  40546. /**
  40547. * Gets a boolean indicating that the engine supports uniform buffers
  40548. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40549. */
  40550. get supportsUniformBuffers(): boolean;
  40551. /** @hidden */
  40552. _gl: WebGLRenderingContext;
  40553. /** @hidden */
  40554. _webGLVersion: number;
  40555. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40556. protected _windowIsBackground: boolean;
  40557. protected _creationOptions: EngineOptions;
  40558. protected _highPrecisionShadersAllowed: boolean;
  40559. /** @hidden */
  40560. get _shouldUseHighPrecisionShader(): boolean;
  40561. /**
  40562. * Gets a boolean indicating that only power of 2 textures are supported
  40563. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40564. */
  40565. get needPOTTextures(): boolean;
  40566. /** @hidden */
  40567. _badOS: boolean;
  40568. /** @hidden */
  40569. _badDesktopOS: boolean;
  40570. private _hardwareScalingLevel;
  40571. /** @hidden */
  40572. _caps: EngineCapabilities;
  40573. private _isStencilEnable;
  40574. private _glVersion;
  40575. private _glRenderer;
  40576. private _glVendor;
  40577. /** @hidden */
  40578. _videoTextureSupported: boolean;
  40579. protected _renderingQueueLaunched: boolean;
  40580. protected _activeRenderLoops: (() => void)[];
  40581. /**
  40582. * Observable signaled when a context lost event is raised
  40583. */
  40584. onContextLostObservable: Observable<ThinEngine>;
  40585. /**
  40586. * Observable signaled when a context restored event is raised
  40587. */
  40588. onContextRestoredObservable: Observable<ThinEngine>;
  40589. private _onContextLost;
  40590. private _onContextRestored;
  40591. protected _contextWasLost: boolean;
  40592. /** @hidden */
  40593. _doNotHandleContextLost: boolean;
  40594. /**
  40595. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40596. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40597. */
  40598. get doNotHandleContextLost(): boolean;
  40599. set doNotHandleContextLost(value: boolean);
  40600. /**
  40601. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40602. */
  40603. disableVertexArrayObjects: boolean;
  40604. /** @hidden */
  40605. protected _colorWrite: boolean;
  40606. /** @hidden */
  40607. protected _colorWriteChanged: boolean;
  40608. /** @hidden */
  40609. protected _depthCullingState: DepthCullingState;
  40610. /** @hidden */
  40611. protected _stencilState: StencilState;
  40612. /** @hidden */
  40613. _alphaState: AlphaState;
  40614. /** @hidden */
  40615. _alphaMode: number;
  40616. /** @hidden */
  40617. _alphaEquation: number;
  40618. /** @hidden */
  40619. _internalTexturesCache: InternalTexture[];
  40620. /** @hidden */
  40621. protected _activeChannel: number;
  40622. private _currentTextureChannel;
  40623. /** @hidden */
  40624. protected _boundTexturesCache: {
  40625. [key: string]: Nullable<InternalTexture>;
  40626. };
  40627. /** @hidden */
  40628. protected _currentEffect: Nullable<Effect>;
  40629. /** @hidden */
  40630. protected _currentProgram: Nullable<WebGLProgram>;
  40631. private _compiledEffects;
  40632. private _vertexAttribArraysEnabled;
  40633. /** @hidden */
  40634. protected _cachedViewport: Nullable<IViewportLike>;
  40635. private _cachedVertexArrayObject;
  40636. /** @hidden */
  40637. protected _cachedVertexBuffers: any;
  40638. /** @hidden */
  40639. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40640. /** @hidden */
  40641. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40642. /** @hidden */
  40643. _currentRenderTarget: Nullable<InternalTexture>;
  40644. private _uintIndicesCurrentlySet;
  40645. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40646. /** @hidden */
  40647. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40648. /** @hidden */
  40649. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40650. private _currentBufferPointers;
  40651. private _currentInstanceLocations;
  40652. private _currentInstanceBuffers;
  40653. private _textureUnits;
  40654. /** @hidden */
  40655. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40656. /** @hidden */
  40657. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40658. /** @hidden */
  40659. _boundRenderFunction: any;
  40660. private _vaoRecordInProgress;
  40661. private _mustWipeVertexAttributes;
  40662. private _emptyTexture;
  40663. private _emptyCubeTexture;
  40664. private _emptyTexture3D;
  40665. private _emptyTexture2DArray;
  40666. /** @hidden */
  40667. _frameHandler: number;
  40668. private _nextFreeTextureSlots;
  40669. private _maxSimultaneousTextures;
  40670. private _activeRequests;
  40671. /** @hidden */
  40672. _transformTextureUrl: Nullable<(url: string) => string>;
  40673. /**
  40674. * Gets information about the current host
  40675. */
  40676. hostInformation: HostInformation;
  40677. protected get _supportsHardwareTextureRescaling(): boolean;
  40678. private _framebufferDimensionsObject;
  40679. /**
  40680. * sets the object from which width and height will be taken from when getting render width and height
  40681. * Will fallback to the gl object
  40682. * @param dimensions the framebuffer width and height that will be used.
  40683. */
  40684. set framebufferDimensionsObject(dimensions: Nullable<{
  40685. framebufferWidth: number;
  40686. framebufferHeight: number;
  40687. }>);
  40688. /**
  40689. * Gets the current viewport
  40690. */
  40691. get currentViewport(): Nullable<IViewportLike>;
  40692. /**
  40693. * Gets the default empty texture
  40694. */
  40695. get emptyTexture(): InternalTexture;
  40696. /**
  40697. * Gets the default empty 3D texture
  40698. */
  40699. get emptyTexture3D(): InternalTexture;
  40700. /**
  40701. * Gets the default empty 2D array texture
  40702. */
  40703. get emptyTexture2DArray(): InternalTexture;
  40704. /**
  40705. * Gets the default empty cube texture
  40706. */
  40707. get emptyCubeTexture(): InternalTexture;
  40708. /**
  40709. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40710. */
  40711. readonly premultipliedAlpha: boolean;
  40712. /**
  40713. * Observable event triggered before each texture is initialized
  40714. */
  40715. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  40716. /**
  40717. * Creates a new engine
  40718. * @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
  40719. * @param antialias defines enable antialiasing (default: false)
  40720. * @param options defines further options to be sent to the getContext() function
  40721. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40722. */
  40723. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40724. private _rebuildInternalTextures;
  40725. private _rebuildEffects;
  40726. /**
  40727. * Gets a boolean indicating if all created effects are ready
  40728. * @returns true if all effects are ready
  40729. */
  40730. areAllEffectsReady(): boolean;
  40731. protected _rebuildBuffers(): void;
  40732. protected _initGLContext(): void;
  40733. /**
  40734. * Gets version of the current webGL context
  40735. */
  40736. get webGLVersion(): number;
  40737. /**
  40738. * Gets a string identifying the name of the class
  40739. * @returns "Engine" string
  40740. */
  40741. getClassName(): string;
  40742. /**
  40743. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40744. */
  40745. get isStencilEnable(): boolean;
  40746. /** @hidden */
  40747. _prepareWorkingCanvas(): void;
  40748. /**
  40749. * Reset the texture cache to empty state
  40750. */
  40751. resetTextureCache(): void;
  40752. /**
  40753. * Gets an object containing information about the current webGL context
  40754. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40755. */
  40756. getGlInfo(): {
  40757. vendor: string;
  40758. renderer: string;
  40759. version: string;
  40760. };
  40761. /**
  40762. * Defines the hardware scaling level.
  40763. * By default the hardware scaling level is computed from the window device ratio.
  40764. * 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.
  40765. * @param level defines the level to use
  40766. */
  40767. setHardwareScalingLevel(level: number): void;
  40768. /**
  40769. * Gets the current hardware scaling level.
  40770. * By default the hardware scaling level is computed from the window device ratio.
  40771. * 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.
  40772. * @returns a number indicating the current hardware scaling level
  40773. */
  40774. getHardwareScalingLevel(): number;
  40775. /**
  40776. * Gets the list of loaded textures
  40777. * @returns an array containing all loaded textures
  40778. */
  40779. getLoadedTexturesCache(): InternalTexture[];
  40780. /**
  40781. * Gets the object containing all engine capabilities
  40782. * @returns the EngineCapabilities object
  40783. */
  40784. getCaps(): EngineCapabilities;
  40785. /**
  40786. * stop executing a render loop function and remove it from the execution array
  40787. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40788. */
  40789. stopRenderLoop(renderFunction?: () => void): void;
  40790. /** @hidden */
  40791. _renderLoop(): void;
  40792. /**
  40793. * Gets the HTML canvas attached with the current webGL context
  40794. * @returns a HTML canvas
  40795. */
  40796. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40797. /**
  40798. * Gets host window
  40799. * @returns the host window object
  40800. */
  40801. getHostWindow(): Nullable<Window>;
  40802. /**
  40803. * Gets the current render width
  40804. * @param useScreen defines if screen size must be used (or the current render target if any)
  40805. * @returns a number defining the current render width
  40806. */
  40807. getRenderWidth(useScreen?: boolean): number;
  40808. /**
  40809. * Gets the current render height
  40810. * @param useScreen defines if screen size must be used (or the current render target if any)
  40811. * @returns a number defining the current render height
  40812. */
  40813. getRenderHeight(useScreen?: boolean): number;
  40814. /**
  40815. * Can be used to override the current requestAnimationFrame requester.
  40816. * @hidden
  40817. */
  40818. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40819. /**
  40820. * Register and execute a render loop. The engine can have more than one render function
  40821. * @param renderFunction defines the function to continuously execute
  40822. */
  40823. runRenderLoop(renderFunction: () => void): void;
  40824. /**
  40825. * Clear the current render buffer or the current render target (if any is set up)
  40826. * @param color defines the color to use
  40827. * @param backBuffer defines if the back buffer must be cleared
  40828. * @param depth defines if the depth buffer must be cleared
  40829. * @param stencil defines if the stencil buffer must be cleared
  40830. */
  40831. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40832. private _viewportCached;
  40833. /** @hidden */
  40834. _viewport(x: number, y: number, width: number, height: number): void;
  40835. /**
  40836. * Set the WebGL's viewport
  40837. * @param viewport defines the viewport element to be used
  40838. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40839. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40840. */
  40841. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40842. /**
  40843. * Begin a new frame
  40844. */
  40845. beginFrame(): void;
  40846. /**
  40847. * Enf the current frame
  40848. */
  40849. endFrame(): void;
  40850. /**
  40851. * Resize the view according to the canvas' size
  40852. */
  40853. resize(): void;
  40854. /**
  40855. * Force a specific size of the canvas
  40856. * @param width defines the new canvas' width
  40857. * @param height defines the new canvas' height
  40858. * @returns true if the size was changed
  40859. */
  40860. setSize(width: number, height: number): boolean;
  40861. /**
  40862. * Binds the frame buffer to the specified texture.
  40863. * @param texture The texture to render to or null for the default canvas
  40864. * @param faceIndex The face of the texture to render to in case of cube texture
  40865. * @param requiredWidth The width of the target to render to
  40866. * @param requiredHeight The height of the target to render to
  40867. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40868. * @param lodLevel defines the lod level to bind to the frame buffer
  40869. * @param layer defines the 2d array index to bind to frame buffer to
  40870. */
  40871. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40872. /** @hidden */
  40873. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40874. /**
  40875. * Unbind the current render target texture from the webGL context
  40876. * @param texture defines the render target texture to unbind
  40877. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40878. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40879. */
  40880. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40881. /**
  40882. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40883. */
  40884. flushFramebuffer(): void;
  40885. /**
  40886. * Unbind the current render target and bind the default framebuffer
  40887. */
  40888. restoreDefaultFramebuffer(): void;
  40889. /** @hidden */
  40890. protected _resetVertexBufferBinding(): void;
  40891. /**
  40892. * Creates a vertex buffer
  40893. * @param data the data for the vertex buffer
  40894. * @returns the new WebGL static buffer
  40895. */
  40896. createVertexBuffer(data: DataArray): DataBuffer;
  40897. private _createVertexBuffer;
  40898. /**
  40899. * Creates a dynamic vertex buffer
  40900. * @param data the data for the dynamic vertex buffer
  40901. * @returns the new WebGL dynamic buffer
  40902. */
  40903. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40904. protected _resetIndexBufferBinding(): void;
  40905. /**
  40906. * Creates a new index buffer
  40907. * @param indices defines the content of the index buffer
  40908. * @param updatable defines if the index buffer must be updatable
  40909. * @returns a new webGL buffer
  40910. */
  40911. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40912. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40913. /**
  40914. * Bind a webGL buffer to the webGL context
  40915. * @param buffer defines the buffer to bind
  40916. */
  40917. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40918. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40919. private bindBuffer;
  40920. /**
  40921. * update the bound buffer with the given data
  40922. * @param data defines the data to update
  40923. */
  40924. updateArrayBuffer(data: Float32Array): void;
  40925. private _vertexAttribPointer;
  40926. /** @hidden */
  40927. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40928. private _bindVertexBuffersAttributes;
  40929. /**
  40930. * Records a vertex array object
  40931. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40932. * @param vertexBuffers defines the list of vertex buffers to store
  40933. * @param indexBuffer defines the index buffer to store
  40934. * @param effect defines the effect to store
  40935. * @returns the new vertex array object
  40936. */
  40937. recordVertexArrayObject(vertexBuffers: {
  40938. [key: string]: VertexBuffer;
  40939. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  40940. /**
  40941. * Bind a specific vertex array object
  40942. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40943. * @param vertexArrayObject defines the vertex array object to bind
  40944. * @param indexBuffer defines the index buffer to bind
  40945. */
  40946. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40947. /**
  40948. * Bind webGl buffers directly to the webGL context
  40949. * @param vertexBuffer defines the vertex buffer to bind
  40950. * @param indexBuffer defines the index buffer to bind
  40951. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40952. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40953. * @param effect defines the effect associated with the vertex buffer
  40954. */
  40955. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40956. private _unbindVertexArrayObject;
  40957. /**
  40958. * Bind a list of vertex buffers to the webGL context
  40959. * @param vertexBuffers defines the list of vertex buffers to bind
  40960. * @param indexBuffer defines the index buffer to bind
  40961. * @param effect defines the effect associated with the vertex buffers
  40962. */
  40963. bindBuffers(vertexBuffers: {
  40964. [key: string]: Nullable<VertexBuffer>;
  40965. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  40966. /**
  40967. * Unbind all instance attributes
  40968. */
  40969. unbindInstanceAttributes(): void;
  40970. /**
  40971. * Release and free the memory of a vertex array object
  40972. * @param vao defines the vertex array object to delete
  40973. */
  40974. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40975. /** @hidden */
  40976. _releaseBuffer(buffer: DataBuffer): boolean;
  40977. protected _deleteBuffer(buffer: DataBuffer): void;
  40978. /**
  40979. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  40980. * @param instancesBuffer defines the webGL buffer to update and bind
  40981. * @param data defines the data to store in the buffer
  40982. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40983. */
  40984. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40985. /**
  40986. * Bind the content of a webGL buffer used with instantiation
  40987. * @param instancesBuffer defines the webGL buffer to bind
  40988. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40989. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40990. */
  40991. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40992. /**
  40993. * Disable the instance attribute corresponding to the name in parameter
  40994. * @param name defines the name of the attribute to disable
  40995. */
  40996. disableInstanceAttributeByName(name: string): void;
  40997. /**
  40998. * Disable the instance attribute corresponding to the location in parameter
  40999. * @param attributeLocation defines the attribute location of the attribute to disable
  41000. */
  41001. disableInstanceAttribute(attributeLocation: number): void;
  41002. /**
  41003. * Disable the attribute corresponding to the location in parameter
  41004. * @param attributeLocation defines the attribute location of the attribute to disable
  41005. */
  41006. disableAttributeByIndex(attributeLocation: number): void;
  41007. /**
  41008. * Send a draw order
  41009. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  41010. * @param indexStart defines the starting index
  41011. * @param indexCount defines the number of index to draw
  41012. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41013. */
  41014. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41015. /**
  41016. * Draw a list of points
  41017. * @param verticesStart defines the index of first vertex to draw
  41018. * @param verticesCount defines the count of vertices to draw
  41019. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41020. */
  41021. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41022. /**
  41023. * Draw a list of unindexed primitives
  41024. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  41025. * @param verticesStart defines the index of first vertex to draw
  41026. * @param verticesCount defines the count of vertices to draw
  41027. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41028. */
  41029. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41030. /**
  41031. * Draw a list of indexed primitives
  41032. * @param fillMode defines the primitive to use
  41033. * @param indexStart defines the starting index
  41034. * @param indexCount defines the number of index to draw
  41035. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41036. */
  41037. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41038. /**
  41039. * Draw a list of unindexed primitives
  41040. * @param fillMode defines the primitive to use
  41041. * @param verticesStart defines the index of first vertex to draw
  41042. * @param verticesCount defines the count of vertices to draw
  41043. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41044. */
  41045. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41046. private _drawMode;
  41047. /** @hidden */
  41048. protected _reportDrawCall(): void;
  41049. /** @hidden */
  41050. _releaseEffect(effect: Effect): void;
  41051. /** @hidden */
  41052. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41053. /**
  41054. * Create a new effect (used to store vertex/fragment shaders)
  41055. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  41056. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  41057. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  41058. * @param samplers defines an array of string used to represent textures
  41059. * @param defines defines the string containing the defines to use to compile the shaders
  41060. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  41061. * @param onCompiled defines a function to call when the effect creation is successful
  41062. * @param onError defines a function to call when the effect creation has failed
  41063. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  41064. * @returns the new Effect
  41065. */
  41066. 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;
  41067. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  41068. private _compileShader;
  41069. private _compileRawShader;
  41070. /** @hidden */
  41071. _getShaderSource(shader: WebGLShader): Nullable<string>;
  41072. /**
  41073. * Directly creates a webGL program
  41074. * @param pipelineContext defines the pipeline context to attach to
  41075. * @param vertexCode defines the vertex shader code to use
  41076. * @param fragmentCode defines the fragment shader code to use
  41077. * @param context defines the webGL context to use (if not set, the current one will be used)
  41078. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  41079. * @returns the new webGL program
  41080. */
  41081. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41082. /**
  41083. * Creates a webGL program
  41084. * @param pipelineContext defines the pipeline context to attach to
  41085. * @param vertexCode defines the vertex shader code to use
  41086. * @param fragmentCode defines the fragment shader code to use
  41087. * @param defines defines the string containing the defines to use to compile the shaders
  41088. * @param context defines the webGL context to use (if not set, the current one will be used)
  41089. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  41090. * @returns the new webGL program
  41091. */
  41092. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41093. /**
  41094. * Creates a new pipeline context
  41095. * @returns the new pipeline
  41096. */
  41097. createPipelineContext(): IPipelineContext;
  41098. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41099. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  41100. /** @hidden */
  41101. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  41102. /** @hidden */
  41103. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  41104. /** @hidden */
  41105. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  41106. /**
  41107. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  41108. * @param pipelineContext defines the pipeline context to use
  41109. * @param uniformsNames defines the list of uniform names
  41110. * @returns an array of webGL uniform locations
  41111. */
  41112. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41113. /**
  41114. * Gets the lsit of active attributes for a given webGL program
  41115. * @param pipelineContext defines the pipeline context to use
  41116. * @param attributesNames defines the list of attribute names to get
  41117. * @returns an array of indices indicating the offset of each attribute
  41118. */
  41119. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41120. /**
  41121. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  41122. * @param effect defines the effect to activate
  41123. */
  41124. enableEffect(effect: Nullable<Effect>): void;
  41125. /**
  41126. * Set the value of an uniform to a number (int)
  41127. * @param uniform defines the webGL uniform location where to store the value
  41128. * @param value defines the int number to store
  41129. * @returns true if the value was set
  41130. */
  41131. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41132. /**
  41133. * Set the value of an uniform to an array of int32
  41134. * @param uniform defines the webGL uniform location where to store the value
  41135. * @param array defines the array of int32 to store
  41136. * @returns true if the value was set
  41137. */
  41138. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41139. /**
  41140. * Set the value of an uniform to an array of int32 (stored as vec2)
  41141. * @param uniform defines the webGL uniform location where to store the value
  41142. * @param array defines the array of int32 to store
  41143. * @returns true if the value was set
  41144. */
  41145. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41146. /**
  41147. * Set the value of an uniform to an array of int32 (stored as vec3)
  41148. * @param uniform defines the webGL uniform location where to store the value
  41149. * @param array defines the array of int32 to store
  41150. * @returns true if the value was set
  41151. */
  41152. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41153. /**
  41154. * Set the value of an uniform to an array of int32 (stored as vec4)
  41155. * @param uniform defines the webGL uniform location where to store the value
  41156. * @param array defines the array of int32 to store
  41157. * @returns true if the value was set
  41158. */
  41159. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41160. /**
  41161. * Set the value of an uniform to an array of number
  41162. * @param uniform defines the webGL uniform location where to store the value
  41163. * @param array defines the array of number to store
  41164. * @returns true if the value was set
  41165. */
  41166. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41167. /**
  41168. * Set the value of an uniform to an array of number (stored as vec2)
  41169. * @param uniform defines the webGL uniform location where to store the value
  41170. * @param array defines the array of number to store
  41171. * @returns true if the value was set
  41172. */
  41173. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41174. /**
  41175. * Set the value of an uniform to an array of number (stored as vec3)
  41176. * @param uniform defines the webGL uniform location where to store the value
  41177. * @param array defines the array of number to store
  41178. * @returns true if the value was set
  41179. */
  41180. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41181. /**
  41182. * Set the value of an uniform to an array of number (stored as vec4)
  41183. * @param uniform defines the webGL uniform location where to store the value
  41184. * @param array defines the array of number to store
  41185. * @returns true if the value was set
  41186. */
  41187. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41188. /**
  41189. * Set the value of an uniform to an array of float32 (stored as matrices)
  41190. * @param uniform defines the webGL uniform location where to store the value
  41191. * @param matrices defines the array of float32 to store
  41192. * @returns true if the value was set
  41193. */
  41194. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  41195. /**
  41196. * Set the value of an uniform to a matrix (3x3)
  41197. * @param uniform defines the webGL uniform location where to store the value
  41198. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  41199. * @returns true if the value was set
  41200. */
  41201. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41202. /**
  41203. * Set the value of an uniform to a matrix (2x2)
  41204. * @param uniform defines the webGL uniform location where to store the value
  41205. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  41206. * @returns true if the value was set
  41207. */
  41208. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41209. /**
  41210. * Set the value of an uniform to a number (float)
  41211. * @param uniform defines the webGL uniform location where to store the value
  41212. * @param value defines the float number to store
  41213. * @returns true if the value was transfered
  41214. */
  41215. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41216. /**
  41217. * Set the value of an uniform to a vec2
  41218. * @param uniform defines the webGL uniform location where to store the value
  41219. * @param x defines the 1st component of the value
  41220. * @param y defines the 2nd component of the value
  41221. * @returns true if the value was set
  41222. */
  41223. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  41224. /**
  41225. * Set the value of an uniform to a vec3
  41226. * @param uniform defines the webGL uniform location where to store the value
  41227. * @param x defines the 1st component of the value
  41228. * @param y defines the 2nd component of the value
  41229. * @param z defines the 3rd component of the value
  41230. * @returns true if the value was set
  41231. */
  41232. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  41233. /**
  41234. * Set the value of an uniform to a vec4
  41235. * @param uniform defines the webGL uniform location where to store the value
  41236. * @param x defines the 1st component of the value
  41237. * @param y defines the 2nd component of the value
  41238. * @param z defines the 3rd component of the value
  41239. * @param w defines the 4th component of the value
  41240. * @returns true if the value was set
  41241. */
  41242. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  41243. /**
  41244. * Apply all cached states (depth, culling, stencil and alpha)
  41245. */
  41246. applyStates(): void;
  41247. /**
  41248. * Enable or disable color writing
  41249. * @param enable defines the state to set
  41250. */
  41251. setColorWrite(enable: boolean): void;
  41252. /**
  41253. * Gets a boolean indicating if color writing is enabled
  41254. * @returns the current color writing state
  41255. */
  41256. getColorWrite(): boolean;
  41257. /**
  41258. * Gets the depth culling state manager
  41259. */
  41260. get depthCullingState(): DepthCullingState;
  41261. /**
  41262. * Gets the alpha state manager
  41263. */
  41264. get alphaState(): AlphaState;
  41265. /**
  41266. * Gets the stencil state manager
  41267. */
  41268. get stencilState(): StencilState;
  41269. /**
  41270. * Clears the list of texture accessible through engine.
  41271. * This can help preventing texture load conflict due to name collision.
  41272. */
  41273. clearInternalTexturesCache(): void;
  41274. /**
  41275. * Force the entire cache to be cleared
  41276. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  41277. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  41278. */
  41279. wipeCaches(bruteForce?: boolean): void;
  41280. /** @hidden */
  41281. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  41282. min: number;
  41283. mag: number;
  41284. };
  41285. /** @hidden */
  41286. _createTexture(): WebGLTexture;
  41287. /**
  41288. * Usually called from Texture.ts.
  41289. * Passed information to create a WebGLTexture
  41290. * @param url defines a value which contains one of the following:
  41291. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  41292. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  41293. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  41294. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  41295. * @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)
  41296. * @param scene needed for loading to the correct scene
  41297. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  41298. * @param onLoad optional callback to be called upon successful completion
  41299. * @param onError optional callback to be called upon failure
  41300. * @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
  41301. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  41302. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  41303. * @param forcedExtension defines the extension to use to pick the right loader
  41304. * @param mimeType defines an optional mime type
  41305. * @param loaderOptions options to be passed to the loader
  41306. * @returns a InternalTexture for assignment back into BABYLON.Texture
  41307. */
  41308. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  41309. /**
  41310. * Loads an image as an HTMLImageElement.
  41311. * @param input url string, ArrayBuffer, or Blob to load
  41312. * @param onLoad callback called when the image successfully loads
  41313. * @param onError callback called when the image fails to load
  41314. * @param offlineProvider offline provider for caching
  41315. * @param mimeType optional mime type
  41316. * @returns the HTMLImageElement of the loaded image
  41317. * @hidden
  41318. */
  41319. 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>;
  41320. /**
  41321. * @hidden
  41322. */
  41323. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41324. private _unpackFlipYCached;
  41325. /**
  41326. * In case you are sharing the context with other applications, it might
  41327. * be interested to not cache the unpack flip y state to ensure a consistent
  41328. * value would be set.
  41329. */
  41330. enableUnpackFlipYCached: boolean;
  41331. /** @hidden */
  41332. _unpackFlipY(value: boolean): void;
  41333. /** @hidden */
  41334. _getUnpackAlignement(): number;
  41335. private _getTextureTarget;
  41336. /**
  41337. * Update the sampling mode of a given texture
  41338. * @param samplingMode defines the required sampling mode
  41339. * @param texture defines the texture to update
  41340. * @param generateMipMaps defines whether to generate mipmaps for the texture
  41341. */
  41342. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  41343. /**
  41344. * Update the sampling mode of a given texture
  41345. * @param texture defines the texture to update
  41346. * @param wrapU defines the texture wrap mode of the u coordinates
  41347. * @param wrapV defines the texture wrap mode of the v coordinates
  41348. * @param wrapR defines the texture wrap mode of the r coordinates
  41349. */
  41350. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  41351. /** @hidden */
  41352. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  41353. width: number;
  41354. height: number;
  41355. layers?: number;
  41356. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  41357. /** @hidden */
  41358. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41359. /** @hidden */
  41360. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  41361. /**
  41362. * Update a portion of an internal texture
  41363. * @param texture defines the texture to update
  41364. * @param imageData defines the data to store into the texture
  41365. * @param xOffset defines the x coordinates of the update rectangle
  41366. * @param yOffset defines the y coordinates of the update rectangle
  41367. * @param width defines the width of the update rectangle
  41368. * @param height defines the height of the update rectangle
  41369. * @param faceIndex defines the face index if texture is a cube (0 by default)
  41370. * @param lod defines the lod level to update (0 by default)
  41371. */
  41372. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  41373. /** @hidden */
  41374. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41375. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  41376. private _prepareWebGLTexture;
  41377. /** @hidden */
  41378. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  41379. private _getDepthStencilBuffer;
  41380. /** @hidden */
  41381. _releaseFramebufferObjects(texture: InternalTexture): void;
  41382. /** @hidden */
  41383. _releaseTexture(texture: InternalTexture): void;
  41384. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  41385. protected _setProgram(program: WebGLProgram): void;
  41386. protected _boundUniforms: {
  41387. [key: number]: WebGLUniformLocation;
  41388. };
  41389. /**
  41390. * Binds an effect to the webGL context
  41391. * @param effect defines the effect to bind
  41392. */
  41393. bindSamplers(effect: Effect): void;
  41394. private _activateCurrentTexture;
  41395. /** @hidden */
  41396. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  41397. /** @hidden */
  41398. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  41399. /**
  41400. * Unbind all textures from the webGL context
  41401. */
  41402. unbindAllTextures(): void;
  41403. /**
  41404. * Sets a texture to the according uniform.
  41405. * @param channel The texture channel
  41406. * @param uniform The uniform to set
  41407. * @param texture The texture to apply
  41408. */
  41409. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>): void;
  41410. private _bindSamplerUniformToChannel;
  41411. private _getTextureWrapMode;
  41412. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  41413. /**
  41414. * Sets an array of texture to the webGL context
  41415. * @param channel defines the channel where the texture array must be set
  41416. * @param uniform defines the associated uniform location
  41417. * @param textures defines the array of textures to bind
  41418. */
  41419. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[]): void;
  41420. /** @hidden */
  41421. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  41422. private _setTextureParameterFloat;
  41423. private _setTextureParameterInteger;
  41424. /**
  41425. * Unbind all vertex attributes from the webGL context
  41426. */
  41427. unbindAllAttributes(): void;
  41428. /**
  41429. * 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
  41430. */
  41431. releaseEffects(): void;
  41432. /**
  41433. * Dispose and release all associated resources
  41434. */
  41435. dispose(): void;
  41436. /**
  41437. * Attach a new callback raised when context lost event is fired
  41438. * @param callback defines the callback to call
  41439. */
  41440. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41441. /**
  41442. * Attach a new callback raised when context restored event is fired
  41443. * @param callback defines the callback to call
  41444. */
  41445. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41446. /**
  41447. * Get the current error code of the webGL context
  41448. * @returns the error code
  41449. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41450. */
  41451. getError(): number;
  41452. private _canRenderToFloatFramebuffer;
  41453. private _canRenderToHalfFloatFramebuffer;
  41454. private _canRenderToFramebuffer;
  41455. /** @hidden */
  41456. _getWebGLTextureType(type: number): number;
  41457. /** @hidden */
  41458. _getInternalFormat(format: number): number;
  41459. /** @hidden */
  41460. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41461. /** @hidden */
  41462. _getRGBAMultiSampleBufferFormat(type: number): number;
  41463. /** @hidden */
  41464. _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;
  41465. /**
  41466. * Loads a file from a url
  41467. * @param url url to load
  41468. * @param onSuccess callback called when the file successfully loads
  41469. * @param onProgress callback called while file is loading (if the server supports this mode)
  41470. * @param offlineProvider defines the offline provider for caching
  41471. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41472. * @param onError callback called when the file fails to load
  41473. * @returns a file request object
  41474. * @hidden
  41475. */
  41476. 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;
  41477. /**
  41478. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41479. * @param x defines the x coordinate of the rectangle where pixels must be read
  41480. * @param y defines the y coordinate of the rectangle where pixels must be read
  41481. * @param width defines the width of the rectangle where pixels must be read
  41482. * @param height defines the height of the rectangle where pixels must be read
  41483. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41484. * @returns a Uint8Array containing RGBA colors
  41485. */
  41486. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  41487. private static _IsSupported;
  41488. private static _HasMajorPerformanceCaveat;
  41489. /**
  41490. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41491. */
  41492. static get IsSupported(): boolean;
  41493. /**
  41494. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41495. * @returns true if the engine can be created
  41496. * @ignorenaming
  41497. */
  41498. static isSupported(): boolean;
  41499. /**
  41500. * 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)
  41501. */
  41502. static get HasMajorPerformanceCaveat(): boolean;
  41503. /**
  41504. * Find the next highest power of two.
  41505. * @param x Number to start search from.
  41506. * @return Next highest power of two.
  41507. */
  41508. static CeilingPOT(x: number): number;
  41509. /**
  41510. * Find the next lowest power of two.
  41511. * @param x Number to start search from.
  41512. * @return Next lowest power of two.
  41513. */
  41514. static FloorPOT(x: number): number;
  41515. /**
  41516. * Find the nearest power of two.
  41517. * @param x Number to start search from.
  41518. * @return Next nearest power of two.
  41519. */
  41520. static NearestPOT(x: number): number;
  41521. /**
  41522. * Get the closest exponent of two
  41523. * @param value defines the value to approximate
  41524. * @param max defines the maximum value to return
  41525. * @param mode defines how to define the closest value
  41526. * @returns closest exponent of two of the given value
  41527. */
  41528. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41529. /**
  41530. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41531. * @param func - the function to be called
  41532. * @param requester - the object that will request the next frame. Falls back to window.
  41533. * @returns frame number
  41534. */
  41535. static QueueNewFrame(func: () => void, requester?: any): number;
  41536. /**
  41537. * Gets host document
  41538. * @returns the host document object
  41539. */
  41540. getHostDocument(): Nullable<Document>;
  41541. }
  41542. }
  41543. declare module "babylonjs/Materials/Textures/internalTexture" {
  41544. import { Observable } from "babylonjs/Misc/observable";
  41545. import { Nullable, int } from "babylonjs/types";
  41546. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  41547. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41548. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  41549. /**
  41550. * Defines the source of the internal texture
  41551. */
  41552. export enum InternalTextureSource {
  41553. /**
  41554. * The source of the texture data is unknown
  41555. */
  41556. Unknown = 0,
  41557. /**
  41558. * Texture data comes from an URL
  41559. */
  41560. Url = 1,
  41561. /**
  41562. * Texture data is only used for temporary storage
  41563. */
  41564. Temp = 2,
  41565. /**
  41566. * Texture data comes from raw data (ArrayBuffer)
  41567. */
  41568. Raw = 3,
  41569. /**
  41570. * Texture content is dynamic (video or dynamic texture)
  41571. */
  41572. Dynamic = 4,
  41573. /**
  41574. * Texture content is generated by rendering to it
  41575. */
  41576. RenderTarget = 5,
  41577. /**
  41578. * Texture content is part of a multi render target process
  41579. */
  41580. MultiRenderTarget = 6,
  41581. /**
  41582. * Texture data comes from a cube data file
  41583. */
  41584. Cube = 7,
  41585. /**
  41586. * Texture data comes from a raw cube data
  41587. */
  41588. CubeRaw = 8,
  41589. /**
  41590. * Texture data come from a prefiltered cube data file
  41591. */
  41592. CubePrefiltered = 9,
  41593. /**
  41594. * Texture content is raw 3D data
  41595. */
  41596. Raw3D = 10,
  41597. /**
  41598. * Texture content is raw 2D array data
  41599. */
  41600. Raw2DArray = 11,
  41601. /**
  41602. * Texture content is a depth texture
  41603. */
  41604. Depth = 12,
  41605. /**
  41606. * Texture data comes from a raw cube data encoded with RGBD
  41607. */
  41608. CubeRawRGBD = 13
  41609. }
  41610. /**
  41611. * Class used to store data associated with WebGL texture data for the engine
  41612. * This class should not be used directly
  41613. */
  41614. export class InternalTexture {
  41615. /** @hidden */
  41616. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41617. /**
  41618. * Defines if the texture is ready
  41619. */
  41620. isReady: boolean;
  41621. /**
  41622. * Defines if the texture is a cube texture
  41623. */
  41624. isCube: boolean;
  41625. /**
  41626. * Defines if the texture contains 3D data
  41627. */
  41628. is3D: boolean;
  41629. /**
  41630. * Defines if the texture contains 2D array data
  41631. */
  41632. is2DArray: boolean;
  41633. /**
  41634. * Defines if the texture contains multiview data
  41635. */
  41636. isMultiview: boolean;
  41637. /**
  41638. * Gets the URL used to load this texture
  41639. */
  41640. url: string;
  41641. /**
  41642. * Gets the sampling mode of the texture
  41643. */
  41644. samplingMode: number;
  41645. /**
  41646. * Gets a boolean indicating if the texture needs mipmaps generation
  41647. */
  41648. generateMipMaps: boolean;
  41649. /**
  41650. * Gets the number of samples used by the texture (WebGL2+ only)
  41651. */
  41652. samples: number;
  41653. /**
  41654. * Gets the type of the texture (int, float...)
  41655. */
  41656. type: number;
  41657. /**
  41658. * Gets the format of the texture (RGB, RGBA...)
  41659. */
  41660. format: number;
  41661. /**
  41662. * Observable called when the texture is loaded
  41663. */
  41664. onLoadedObservable: Observable<InternalTexture>;
  41665. /**
  41666. * Gets the width of the texture
  41667. */
  41668. width: number;
  41669. /**
  41670. * Gets the height of the texture
  41671. */
  41672. height: number;
  41673. /**
  41674. * Gets the depth of the texture
  41675. */
  41676. depth: number;
  41677. /**
  41678. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41679. */
  41680. baseWidth: number;
  41681. /**
  41682. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41683. */
  41684. baseHeight: number;
  41685. /**
  41686. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41687. */
  41688. baseDepth: number;
  41689. /**
  41690. * Gets a boolean indicating if the texture is inverted on Y axis
  41691. */
  41692. invertY: boolean;
  41693. /** @hidden */
  41694. _invertVScale: boolean;
  41695. /** @hidden */
  41696. _associatedChannel: number;
  41697. /** @hidden */
  41698. _source: InternalTextureSource;
  41699. /** @hidden */
  41700. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41701. /** @hidden */
  41702. _bufferView: Nullable<ArrayBufferView>;
  41703. /** @hidden */
  41704. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41705. /** @hidden */
  41706. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41707. /** @hidden */
  41708. _size: number;
  41709. /** @hidden */
  41710. _extension: string;
  41711. /** @hidden */
  41712. _files: Nullable<string[]>;
  41713. /** @hidden */
  41714. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41715. /** @hidden */
  41716. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41717. /** @hidden */
  41718. _framebuffer: Nullable<WebGLFramebuffer>;
  41719. /** @hidden */
  41720. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41721. /** @hidden */
  41722. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41723. /** @hidden */
  41724. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41725. /** @hidden */
  41726. _attachments: Nullable<number[]>;
  41727. /** @hidden */
  41728. _textureArray: Nullable<InternalTexture[]>;
  41729. /** @hidden */
  41730. _cachedCoordinatesMode: Nullable<number>;
  41731. /** @hidden */
  41732. _cachedWrapU: Nullable<number>;
  41733. /** @hidden */
  41734. _cachedWrapV: Nullable<number>;
  41735. /** @hidden */
  41736. _cachedWrapR: Nullable<number>;
  41737. /** @hidden */
  41738. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41739. /** @hidden */
  41740. _isDisabled: boolean;
  41741. /** @hidden */
  41742. _compression: Nullable<string>;
  41743. /** @hidden */
  41744. _generateStencilBuffer: boolean;
  41745. /** @hidden */
  41746. _generateDepthBuffer: boolean;
  41747. /** @hidden */
  41748. _comparisonFunction: number;
  41749. /** @hidden */
  41750. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41751. /** @hidden */
  41752. _lodGenerationScale: number;
  41753. /** @hidden */
  41754. _lodGenerationOffset: number;
  41755. /** @hidden */
  41756. _depthStencilTexture: Nullable<InternalTexture>;
  41757. /** @hidden */
  41758. _colorTextureArray: Nullable<WebGLTexture>;
  41759. /** @hidden */
  41760. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41761. /** @hidden */
  41762. _lodTextureHigh: Nullable<BaseTexture>;
  41763. /** @hidden */
  41764. _lodTextureMid: Nullable<BaseTexture>;
  41765. /** @hidden */
  41766. _lodTextureLow: Nullable<BaseTexture>;
  41767. /** @hidden */
  41768. _isRGBD: boolean;
  41769. /** @hidden */
  41770. _linearSpecularLOD: boolean;
  41771. /** @hidden */
  41772. _irradianceTexture: Nullable<BaseTexture>;
  41773. /** @hidden */
  41774. _webGLTexture: Nullable<WebGLTexture>;
  41775. /** @hidden */
  41776. _references: number;
  41777. /** @hidden */
  41778. _gammaSpace: Nullable<boolean>;
  41779. private _engine;
  41780. /**
  41781. * Gets the Engine the texture belongs to.
  41782. * @returns The babylon engine
  41783. */
  41784. getEngine(): ThinEngine;
  41785. /**
  41786. * Gets the data source type of the texture
  41787. */
  41788. get source(): InternalTextureSource;
  41789. /**
  41790. * Creates a new InternalTexture
  41791. * @param engine defines the engine to use
  41792. * @param source defines the type of data that will be used
  41793. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41794. */
  41795. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41796. /**
  41797. * Increments the number of references (ie. the number of Texture that point to it)
  41798. */
  41799. incrementReferences(): void;
  41800. /**
  41801. * Change the size of the texture (not the size of the content)
  41802. * @param width defines the new width
  41803. * @param height defines the new height
  41804. * @param depth defines the new depth (1 by default)
  41805. */
  41806. updateSize(width: int, height: int, depth?: int): void;
  41807. /** @hidden */
  41808. _rebuild(): void;
  41809. /** @hidden */
  41810. _swapAndDie(target: InternalTexture): void;
  41811. /**
  41812. * Dispose the current allocated resources
  41813. */
  41814. dispose(): void;
  41815. }
  41816. }
  41817. declare module "babylonjs/Loading/loadingScreen" {
  41818. /**
  41819. * Interface used to present a loading screen while loading a scene
  41820. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41821. */
  41822. export interface ILoadingScreen {
  41823. /**
  41824. * Function called to display the loading screen
  41825. */
  41826. displayLoadingUI: () => void;
  41827. /**
  41828. * Function called to hide the loading screen
  41829. */
  41830. hideLoadingUI: () => void;
  41831. /**
  41832. * Gets or sets the color to use for the background
  41833. */
  41834. loadingUIBackgroundColor: string;
  41835. /**
  41836. * Gets or sets the text to display while loading
  41837. */
  41838. loadingUIText: string;
  41839. }
  41840. /**
  41841. * Class used for the default loading screen
  41842. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41843. */
  41844. export class DefaultLoadingScreen implements ILoadingScreen {
  41845. private _renderingCanvas;
  41846. private _loadingText;
  41847. private _loadingDivBackgroundColor;
  41848. private _loadingDiv;
  41849. private _loadingTextDiv;
  41850. /** Gets or sets the logo url to use for the default loading screen */
  41851. static DefaultLogoUrl: string;
  41852. /** Gets or sets the spinner url to use for the default loading screen */
  41853. static DefaultSpinnerUrl: string;
  41854. /**
  41855. * Creates a new default loading screen
  41856. * @param _renderingCanvas defines the canvas used to render the scene
  41857. * @param _loadingText defines the default text to display
  41858. * @param _loadingDivBackgroundColor defines the default background color
  41859. */
  41860. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41861. /**
  41862. * Function called to display the loading screen
  41863. */
  41864. displayLoadingUI(): void;
  41865. /**
  41866. * Function called to hide the loading screen
  41867. */
  41868. hideLoadingUI(): void;
  41869. /**
  41870. * Gets or sets the text to display while loading
  41871. */
  41872. set loadingUIText(text: string);
  41873. get loadingUIText(): string;
  41874. /**
  41875. * Gets or sets the color to use for the background
  41876. */
  41877. get loadingUIBackgroundColor(): string;
  41878. set loadingUIBackgroundColor(color: string);
  41879. private _resizeLoadingUI;
  41880. }
  41881. }
  41882. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  41883. /**
  41884. * Interface for any object that can request an animation frame
  41885. */
  41886. export interface ICustomAnimationFrameRequester {
  41887. /**
  41888. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41889. */
  41890. renderFunction?: Function;
  41891. /**
  41892. * Called to request the next frame to render to
  41893. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41894. */
  41895. requestAnimationFrame: Function;
  41896. /**
  41897. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41898. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41899. */
  41900. requestID?: number;
  41901. }
  41902. }
  41903. declare module "babylonjs/Misc/performanceMonitor" {
  41904. /**
  41905. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41906. */
  41907. export class PerformanceMonitor {
  41908. private _enabled;
  41909. private _rollingFrameTime;
  41910. private _lastFrameTimeMs;
  41911. /**
  41912. * constructor
  41913. * @param frameSampleSize The number of samples required to saturate the sliding window
  41914. */
  41915. constructor(frameSampleSize?: number);
  41916. /**
  41917. * Samples current frame
  41918. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41919. */
  41920. sampleFrame(timeMs?: number): void;
  41921. /**
  41922. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41923. */
  41924. get averageFrameTime(): number;
  41925. /**
  41926. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41927. */
  41928. get averageFrameTimeVariance(): number;
  41929. /**
  41930. * Returns the frame time of the most recent frame
  41931. */
  41932. get instantaneousFrameTime(): number;
  41933. /**
  41934. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41935. */
  41936. get averageFPS(): number;
  41937. /**
  41938. * Returns the average framerate in frames per second using the most recent frame time
  41939. */
  41940. get instantaneousFPS(): number;
  41941. /**
  41942. * Returns true if enough samples have been taken to completely fill the sliding window
  41943. */
  41944. get isSaturated(): boolean;
  41945. /**
  41946. * Enables contributions to the sliding window sample set
  41947. */
  41948. enable(): void;
  41949. /**
  41950. * Disables contributions to the sliding window sample set
  41951. * Samples will not be interpolated over the disabled period
  41952. */
  41953. disable(): void;
  41954. /**
  41955. * Returns true if sampling is enabled
  41956. */
  41957. get isEnabled(): boolean;
  41958. /**
  41959. * Resets performance monitor
  41960. */
  41961. reset(): void;
  41962. }
  41963. /**
  41964. * RollingAverage
  41965. *
  41966. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41967. */
  41968. export class RollingAverage {
  41969. /**
  41970. * Current average
  41971. */
  41972. average: number;
  41973. /**
  41974. * Current variance
  41975. */
  41976. variance: number;
  41977. protected _samples: Array<number>;
  41978. protected _sampleCount: number;
  41979. protected _pos: number;
  41980. protected _m2: number;
  41981. /**
  41982. * constructor
  41983. * @param length The number of samples required to saturate the sliding window
  41984. */
  41985. constructor(length: number);
  41986. /**
  41987. * Adds a sample to the sample set
  41988. * @param v The sample value
  41989. */
  41990. add(v: number): void;
  41991. /**
  41992. * Returns previously added values or null if outside of history or outside the sliding window domain
  41993. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41994. * @return Value previously recorded with add() or null if outside of range
  41995. */
  41996. history(i: number): number;
  41997. /**
  41998. * Returns true if enough samples have been taken to completely fill the sliding window
  41999. * @return true if sample-set saturated
  42000. */
  42001. isSaturated(): boolean;
  42002. /**
  42003. * Resets the rolling average (equivalent to 0 samples taken so far)
  42004. */
  42005. reset(): void;
  42006. /**
  42007. * Wraps a value around the sample range boundaries
  42008. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  42009. * @return Wrapped position in sample range
  42010. */
  42011. protected _wrapPosition(i: number): number;
  42012. }
  42013. }
  42014. declare module "babylonjs/Misc/perfCounter" {
  42015. /**
  42016. * This class is used to track a performance counter which is number based.
  42017. * The user has access to many properties which give statistics of different nature.
  42018. *
  42019. * The implementer can track two kinds of Performance Counter: time and count.
  42020. * 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.
  42021. * 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.
  42022. */
  42023. export class PerfCounter {
  42024. /**
  42025. * Gets or sets a global boolean to turn on and off all the counters
  42026. */
  42027. static Enabled: boolean;
  42028. /**
  42029. * Returns the smallest value ever
  42030. */
  42031. get min(): number;
  42032. /**
  42033. * Returns the biggest value ever
  42034. */
  42035. get max(): number;
  42036. /**
  42037. * Returns the average value since the performance counter is running
  42038. */
  42039. get average(): number;
  42040. /**
  42041. * Returns the average value of the last second the counter was monitored
  42042. */
  42043. get lastSecAverage(): number;
  42044. /**
  42045. * Returns the current value
  42046. */
  42047. get current(): number;
  42048. /**
  42049. * Gets the accumulated total
  42050. */
  42051. get total(): number;
  42052. /**
  42053. * Gets the total value count
  42054. */
  42055. get count(): number;
  42056. /**
  42057. * Creates a new counter
  42058. */
  42059. constructor();
  42060. /**
  42061. * Call this method to start monitoring a new frame.
  42062. * 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.
  42063. */
  42064. fetchNewFrame(): void;
  42065. /**
  42066. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  42067. * @param newCount the count value to add to the monitored count
  42068. * @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.
  42069. */
  42070. addCount(newCount: number, fetchResult: boolean): void;
  42071. /**
  42072. * Start monitoring this performance counter
  42073. */
  42074. beginMonitoring(): void;
  42075. /**
  42076. * Compute the time lapsed since the previous beginMonitoring() call.
  42077. * @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
  42078. */
  42079. endMonitoring(newFrame?: boolean): void;
  42080. private _fetchResult;
  42081. private _startMonitoringTime;
  42082. private _min;
  42083. private _max;
  42084. private _average;
  42085. private _current;
  42086. private _totalValueCount;
  42087. private _totalAccumulated;
  42088. private _lastSecAverage;
  42089. private _lastSecAccumulated;
  42090. private _lastSecTime;
  42091. private _lastSecValueCount;
  42092. }
  42093. }
  42094. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  42095. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42096. import { Nullable } from "babylonjs/types";
  42097. module "babylonjs/Engines/thinEngine" {
  42098. interface ThinEngine {
  42099. /** @hidden */
  42100. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  42101. }
  42102. }
  42103. }
  42104. declare module "babylonjs/Audio/analyser" {
  42105. import { Scene } from "babylonjs/scene";
  42106. /**
  42107. * Class used to work with sound analyzer using fast fourier transform (FFT)
  42108. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42109. */
  42110. export class Analyser {
  42111. /**
  42112. * Gets or sets the smoothing
  42113. * @ignorenaming
  42114. */
  42115. SMOOTHING: number;
  42116. /**
  42117. * Gets or sets the FFT table size
  42118. * @ignorenaming
  42119. */
  42120. FFT_SIZE: number;
  42121. /**
  42122. * Gets or sets the bar graph amplitude
  42123. * @ignorenaming
  42124. */
  42125. BARGRAPHAMPLITUDE: number;
  42126. /**
  42127. * Gets or sets the position of the debug canvas
  42128. * @ignorenaming
  42129. */
  42130. DEBUGCANVASPOS: {
  42131. x: number;
  42132. y: number;
  42133. };
  42134. /**
  42135. * Gets or sets the debug canvas size
  42136. * @ignorenaming
  42137. */
  42138. DEBUGCANVASSIZE: {
  42139. width: number;
  42140. height: number;
  42141. };
  42142. private _byteFreqs;
  42143. private _byteTime;
  42144. private _floatFreqs;
  42145. private _webAudioAnalyser;
  42146. private _debugCanvas;
  42147. private _debugCanvasContext;
  42148. private _scene;
  42149. private _registerFunc;
  42150. private _audioEngine;
  42151. /**
  42152. * Creates a new analyser
  42153. * @param scene defines hosting scene
  42154. */
  42155. constructor(scene: Scene);
  42156. /**
  42157. * Get the number of data values you will have to play with for the visualization
  42158. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  42159. * @returns a number
  42160. */
  42161. getFrequencyBinCount(): number;
  42162. /**
  42163. * Gets the current frequency data as a byte array
  42164. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42165. * @returns a Uint8Array
  42166. */
  42167. getByteFrequencyData(): Uint8Array;
  42168. /**
  42169. * Gets the current waveform as a byte array
  42170. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  42171. * @returns a Uint8Array
  42172. */
  42173. getByteTimeDomainData(): Uint8Array;
  42174. /**
  42175. * Gets the current frequency data as a float array
  42176. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42177. * @returns a Float32Array
  42178. */
  42179. getFloatFrequencyData(): Float32Array;
  42180. /**
  42181. * Renders the debug canvas
  42182. */
  42183. drawDebugCanvas(): void;
  42184. /**
  42185. * Stops rendering the debug canvas and removes it
  42186. */
  42187. stopDebugCanvas(): void;
  42188. /**
  42189. * Connects two audio nodes
  42190. * @param inputAudioNode defines first node to connect
  42191. * @param outputAudioNode defines second node to connect
  42192. */
  42193. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  42194. /**
  42195. * Releases all associated resources
  42196. */
  42197. dispose(): void;
  42198. }
  42199. }
  42200. declare module "babylonjs/Audio/Interfaces/IAudioEngine" {
  42201. import { Observable } from "babylonjs/Misc/observable";
  42202. import { IDisposable } from "babylonjs/scene";
  42203. import { Nullable } from "babylonjs/types";
  42204. import { Analyser } from "babylonjs/Audio/analyser";
  42205. /**
  42206. * This represents an audio engine and it is responsible
  42207. * to play, synchronize and analyse sounds throughout the application.
  42208. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42209. */
  42210. export interface IAudioEngine extends IDisposable {
  42211. /**
  42212. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  42213. */
  42214. readonly canUseWebAudio: boolean;
  42215. /**
  42216. * Gets the current AudioContext if available.
  42217. */
  42218. readonly audioContext: Nullable<AudioContext>;
  42219. /**
  42220. * The master gain node defines the global audio volume of your audio engine.
  42221. */
  42222. readonly masterGain: GainNode;
  42223. /**
  42224. * Gets whether or not mp3 are supported by your browser.
  42225. */
  42226. readonly isMP3supported: boolean;
  42227. /**
  42228. * Gets whether or not ogg are supported by your browser.
  42229. */
  42230. readonly isOGGsupported: boolean;
  42231. /**
  42232. * Defines if Babylon should emit a warning if WebAudio is not supported.
  42233. * @ignoreNaming
  42234. */
  42235. WarnedWebAudioUnsupported: boolean;
  42236. /**
  42237. * Defines if the audio engine relies on a custom unlocked button.
  42238. * In this case, the embedded button will not be displayed.
  42239. */
  42240. useCustomUnlockedButton: boolean;
  42241. /**
  42242. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  42243. */
  42244. readonly unlocked: boolean;
  42245. /**
  42246. * Event raised when audio has been unlocked on the browser.
  42247. */
  42248. onAudioUnlockedObservable: Observable<IAudioEngine>;
  42249. /**
  42250. * Event raised when audio has been locked on the browser.
  42251. */
  42252. onAudioLockedObservable: Observable<IAudioEngine>;
  42253. /**
  42254. * Flags the audio engine in Locked state.
  42255. * This happens due to new browser policies preventing audio to autoplay.
  42256. */
  42257. lock(): void;
  42258. /**
  42259. * Unlocks the audio engine once a user action has been done on the dom.
  42260. * This is helpful to resume play once browser policies have been satisfied.
  42261. */
  42262. unlock(): void;
  42263. /**
  42264. * Gets the global volume sets on the master gain.
  42265. * @returns the global volume if set or -1 otherwise
  42266. */
  42267. getGlobalVolume(): number;
  42268. /**
  42269. * Sets the global volume of your experience (sets on the master gain).
  42270. * @param newVolume Defines the new global volume of the application
  42271. */
  42272. setGlobalVolume(newVolume: number): void;
  42273. /**
  42274. * Connect the audio engine to an audio analyser allowing some amazing
  42275. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42276. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42277. * @param analyser The analyser to connect to the engine
  42278. */
  42279. connectToAnalyser(analyser: Analyser): void;
  42280. }
  42281. }
  42282. declare module "babylonjs/Engines/engine" {
  42283. import { Observable } from "babylonjs/Misc/observable";
  42284. import { Nullable } from "babylonjs/types";
  42285. import { Scene } from "babylonjs/scene";
  42286. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42287. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  42288. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  42289. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  42290. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  42291. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  42292. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  42293. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  42294. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42295. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  42296. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  42297. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  42298. import "babylonjs/Engines/Extensions/engine.alpha";
  42299. import "babylonjs/Engines/Extensions/engine.readTexture";
  42300. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  42301. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  42302. import { Material } from "babylonjs/Materials/material";
  42303. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42304. /**
  42305. * Defines the interface used by display changed events
  42306. */
  42307. export interface IDisplayChangedEventArgs {
  42308. /** Gets the vrDisplay object (if any) */
  42309. vrDisplay: Nullable<any>;
  42310. /** Gets a boolean indicating if webVR is supported */
  42311. vrSupported: boolean;
  42312. }
  42313. /**
  42314. * Defines the interface used by objects containing a viewport (like a camera)
  42315. */
  42316. interface IViewportOwnerLike {
  42317. /**
  42318. * Gets or sets the viewport
  42319. */
  42320. viewport: IViewportLike;
  42321. }
  42322. /**
  42323. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  42324. */
  42325. export class Engine extends ThinEngine {
  42326. /** Defines that alpha blending is disabled */
  42327. static readonly ALPHA_DISABLE: number;
  42328. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  42329. static readonly ALPHA_ADD: number;
  42330. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  42331. static readonly ALPHA_COMBINE: number;
  42332. /** Defines that alpha blending to DEST - SRC * DEST */
  42333. static readonly ALPHA_SUBTRACT: number;
  42334. /** Defines that alpha blending to SRC * DEST */
  42335. static readonly ALPHA_MULTIPLY: number;
  42336. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  42337. static readonly ALPHA_MAXIMIZED: number;
  42338. /** Defines that alpha blending to SRC + DEST */
  42339. static readonly ALPHA_ONEONE: number;
  42340. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  42341. static readonly ALPHA_PREMULTIPLIED: number;
  42342. /**
  42343. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  42344. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  42345. */
  42346. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  42347. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  42348. static readonly ALPHA_INTERPOLATE: number;
  42349. /**
  42350. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  42351. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  42352. */
  42353. static readonly ALPHA_SCREENMODE: number;
  42354. /** Defines that the ressource is not delayed*/
  42355. static readonly DELAYLOADSTATE_NONE: number;
  42356. /** Defines that the ressource was successfully delay loaded */
  42357. static readonly DELAYLOADSTATE_LOADED: number;
  42358. /** Defines that the ressource is currently delay loading */
  42359. static readonly DELAYLOADSTATE_LOADING: number;
  42360. /** Defines that the ressource is delayed and has not started loading */
  42361. static readonly DELAYLOADSTATE_NOTLOADED: number;
  42362. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  42363. static readonly NEVER: number;
  42364. /** 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 */
  42365. static readonly ALWAYS: number;
  42366. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  42367. static readonly LESS: number;
  42368. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  42369. static readonly EQUAL: number;
  42370. /** 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 */
  42371. static readonly LEQUAL: number;
  42372. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  42373. static readonly GREATER: number;
  42374. /** 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 */
  42375. static readonly GEQUAL: number;
  42376. /** 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 */
  42377. static readonly NOTEQUAL: number;
  42378. /** Passed to stencilOperation to specify that stencil value must be kept */
  42379. static readonly KEEP: number;
  42380. /** Passed to stencilOperation to specify that stencil value must be replaced */
  42381. static readonly REPLACE: number;
  42382. /** Passed to stencilOperation to specify that stencil value must be incremented */
  42383. static readonly INCR: number;
  42384. /** Passed to stencilOperation to specify that stencil value must be decremented */
  42385. static readonly DECR: number;
  42386. /** Passed to stencilOperation to specify that stencil value must be inverted */
  42387. static readonly INVERT: number;
  42388. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  42389. static readonly INCR_WRAP: number;
  42390. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  42391. static readonly DECR_WRAP: number;
  42392. /** Texture is not repeating outside of 0..1 UVs */
  42393. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  42394. /** Texture is repeating outside of 0..1 UVs */
  42395. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  42396. /** Texture is repeating and mirrored */
  42397. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  42398. /** ALPHA */
  42399. static readonly TEXTUREFORMAT_ALPHA: number;
  42400. /** LUMINANCE */
  42401. static readonly TEXTUREFORMAT_LUMINANCE: number;
  42402. /** LUMINANCE_ALPHA */
  42403. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  42404. /** RGB */
  42405. static readonly TEXTUREFORMAT_RGB: number;
  42406. /** RGBA */
  42407. static readonly TEXTUREFORMAT_RGBA: number;
  42408. /** RED */
  42409. static readonly TEXTUREFORMAT_RED: number;
  42410. /** RED (2nd reference) */
  42411. static readonly TEXTUREFORMAT_R: number;
  42412. /** RG */
  42413. static readonly TEXTUREFORMAT_RG: number;
  42414. /** RED_INTEGER */
  42415. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  42416. /** RED_INTEGER (2nd reference) */
  42417. static readonly TEXTUREFORMAT_R_INTEGER: number;
  42418. /** RG_INTEGER */
  42419. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  42420. /** RGB_INTEGER */
  42421. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  42422. /** RGBA_INTEGER */
  42423. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  42424. /** UNSIGNED_BYTE */
  42425. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  42426. /** UNSIGNED_BYTE (2nd reference) */
  42427. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  42428. /** FLOAT */
  42429. static readonly TEXTURETYPE_FLOAT: number;
  42430. /** HALF_FLOAT */
  42431. static readonly TEXTURETYPE_HALF_FLOAT: number;
  42432. /** BYTE */
  42433. static readonly TEXTURETYPE_BYTE: number;
  42434. /** SHORT */
  42435. static readonly TEXTURETYPE_SHORT: number;
  42436. /** UNSIGNED_SHORT */
  42437. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  42438. /** INT */
  42439. static readonly TEXTURETYPE_INT: number;
  42440. /** UNSIGNED_INT */
  42441. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  42442. /** UNSIGNED_SHORT_4_4_4_4 */
  42443. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42444. /** UNSIGNED_SHORT_5_5_5_1 */
  42445. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42446. /** UNSIGNED_SHORT_5_6_5 */
  42447. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42448. /** UNSIGNED_INT_2_10_10_10_REV */
  42449. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42450. /** UNSIGNED_INT_24_8 */
  42451. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42452. /** UNSIGNED_INT_10F_11F_11F_REV */
  42453. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42454. /** UNSIGNED_INT_5_9_9_9_REV */
  42455. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42456. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42457. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42458. /** nearest is mag = nearest and min = nearest and mip = linear */
  42459. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42460. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42461. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42462. /** Trilinear is mag = linear and min = linear and mip = linear */
  42463. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42464. /** nearest is mag = nearest and min = nearest and mip = linear */
  42465. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42466. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42467. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42468. /** Trilinear is mag = linear and min = linear and mip = linear */
  42469. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42470. /** mag = nearest and min = nearest and mip = nearest */
  42471. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42472. /** mag = nearest and min = linear and mip = nearest */
  42473. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42474. /** mag = nearest and min = linear and mip = linear */
  42475. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42476. /** mag = nearest and min = linear and mip = none */
  42477. static readonly TEXTURE_NEAREST_LINEAR: number;
  42478. /** mag = nearest and min = nearest and mip = none */
  42479. static readonly TEXTURE_NEAREST_NEAREST: number;
  42480. /** mag = linear and min = nearest and mip = nearest */
  42481. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42482. /** mag = linear and min = nearest and mip = linear */
  42483. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42484. /** mag = linear and min = linear and mip = none */
  42485. static readonly TEXTURE_LINEAR_LINEAR: number;
  42486. /** mag = linear and min = nearest and mip = none */
  42487. static readonly TEXTURE_LINEAR_NEAREST: number;
  42488. /** Explicit coordinates mode */
  42489. static readonly TEXTURE_EXPLICIT_MODE: number;
  42490. /** Spherical coordinates mode */
  42491. static readonly TEXTURE_SPHERICAL_MODE: number;
  42492. /** Planar coordinates mode */
  42493. static readonly TEXTURE_PLANAR_MODE: number;
  42494. /** Cubic coordinates mode */
  42495. static readonly TEXTURE_CUBIC_MODE: number;
  42496. /** Projection coordinates mode */
  42497. static readonly TEXTURE_PROJECTION_MODE: number;
  42498. /** Skybox coordinates mode */
  42499. static readonly TEXTURE_SKYBOX_MODE: number;
  42500. /** Inverse Cubic coordinates mode */
  42501. static readonly TEXTURE_INVCUBIC_MODE: number;
  42502. /** Equirectangular coordinates mode */
  42503. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42504. /** Equirectangular Fixed coordinates mode */
  42505. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42506. /** Equirectangular Fixed Mirrored coordinates mode */
  42507. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42508. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42509. static readonly SCALEMODE_FLOOR: number;
  42510. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42511. static readonly SCALEMODE_NEAREST: number;
  42512. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42513. static readonly SCALEMODE_CEILING: number;
  42514. /**
  42515. * Returns the current npm package of the sdk
  42516. */
  42517. static get NpmPackage(): string;
  42518. /**
  42519. * Returns the current version of the framework
  42520. */
  42521. static get Version(): string;
  42522. /** Gets the list of created engines */
  42523. static get Instances(): Engine[];
  42524. /**
  42525. * Gets the latest created engine
  42526. */
  42527. static get LastCreatedEngine(): Nullable<Engine>;
  42528. /**
  42529. * Gets the latest created scene
  42530. */
  42531. static get LastCreatedScene(): Nullable<Scene>;
  42532. /**
  42533. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42534. * @param flag defines which part of the materials must be marked as dirty
  42535. * @param predicate defines a predicate used to filter which materials should be affected
  42536. */
  42537. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42538. /**
  42539. * Method called to create the default loading screen.
  42540. * This can be overriden in your own app.
  42541. * @param canvas The rendering canvas element
  42542. * @returns The loading screen
  42543. */
  42544. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42545. /**
  42546. * Method called to create the default rescale post process on each engine.
  42547. */
  42548. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42549. /**
  42550. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42551. **/
  42552. enableOfflineSupport: boolean;
  42553. /**
  42554. * 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)
  42555. **/
  42556. disableManifestCheck: boolean;
  42557. /**
  42558. * Gets the list of created scenes
  42559. */
  42560. scenes: Scene[];
  42561. /**
  42562. * Event raised when a new scene is created
  42563. */
  42564. onNewSceneAddedObservable: Observable<Scene>;
  42565. /**
  42566. * Gets the list of created postprocesses
  42567. */
  42568. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42569. /**
  42570. * Gets a boolean indicating if the pointer is currently locked
  42571. */
  42572. isPointerLock: boolean;
  42573. /**
  42574. * Observable event triggered each time the rendering canvas is resized
  42575. */
  42576. onResizeObservable: Observable<Engine>;
  42577. /**
  42578. * Observable event triggered each time the canvas loses focus
  42579. */
  42580. onCanvasBlurObservable: Observable<Engine>;
  42581. /**
  42582. * Observable event triggered each time the canvas gains focus
  42583. */
  42584. onCanvasFocusObservable: Observable<Engine>;
  42585. /**
  42586. * Observable event triggered each time the canvas receives pointerout event
  42587. */
  42588. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42589. /**
  42590. * Observable raised when the engine begins a new frame
  42591. */
  42592. onBeginFrameObservable: Observable<Engine>;
  42593. /**
  42594. * If set, will be used to request the next animation frame for the render loop
  42595. */
  42596. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42597. /**
  42598. * Observable raised when the engine ends the current frame
  42599. */
  42600. onEndFrameObservable: Observable<Engine>;
  42601. /**
  42602. * Observable raised when the engine is about to compile a shader
  42603. */
  42604. onBeforeShaderCompilationObservable: Observable<Engine>;
  42605. /**
  42606. * Observable raised when the engine has jsut compiled a shader
  42607. */
  42608. onAfterShaderCompilationObservable: Observable<Engine>;
  42609. /**
  42610. * Gets the audio engine
  42611. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42612. * @ignorenaming
  42613. */
  42614. static audioEngine: IAudioEngine;
  42615. /**
  42616. * Default AudioEngine factory responsible of creating the Audio Engine.
  42617. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42618. */
  42619. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42620. /**
  42621. * Default offline support factory responsible of creating a tool used to store data locally.
  42622. * By default, this will create a Database object if the workload has been embedded.
  42623. */
  42624. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42625. private _loadingScreen;
  42626. private _pointerLockRequested;
  42627. private _rescalePostProcess;
  42628. private _deterministicLockstep;
  42629. private _lockstepMaxSteps;
  42630. private _timeStep;
  42631. protected get _supportsHardwareTextureRescaling(): boolean;
  42632. private _fps;
  42633. private _deltaTime;
  42634. /** @hidden */
  42635. _drawCalls: PerfCounter;
  42636. /** 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 */
  42637. canvasTabIndex: number;
  42638. /**
  42639. * Turn this value on if you want to pause FPS computation when in background
  42640. */
  42641. disablePerformanceMonitorInBackground: boolean;
  42642. private _performanceMonitor;
  42643. /**
  42644. * Gets the performance monitor attached to this engine
  42645. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42646. */
  42647. get performanceMonitor(): PerformanceMonitor;
  42648. private _onFocus;
  42649. private _onBlur;
  42650. private _onCanvasPointerOut;
  42651. private _onCanvasBlur;
  42652. private _onCanvasFocus;
  42653. private _onFullscreenChange;
  42654. private _onPointerLockChange;
  42655. /**
  42656. * Gets the HTML element used to attach event listeners
  42657. * @returns a HTML element
  42658. */
  42659. getInputElement(): Nullable<HTMLElement>;
  42660. /**
  42661. * Creates a new engine
  42662. * @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
  42663. * @param antialias defines enable antialiasing (default: false)
  42664. * @param options defines further options to be sent to the getContext() function
  42665. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42666. */
  42667. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42668. /**
  42669. * Gets current aspect ratio
  42670. * @param viewportOwner defines the camera to use to get the aspect ratio
  42671. * @param useScreen defines if screen size must be used (or the current render target if any)
  42672. * @returns a number defining the aspect ratio
  42673. */
  42674. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42675. /**
  42676. * Gets current screen aspect ratio
  42677. * @returns a number defining the aspect ratio
  42678. */
  42679. getScreenAspectRatio(): number;
  42680. /**
  42681. * Gets the client rect of the HTML canvas attached with the current webGL context
  42682. * @returns a client rectanglee
  42683. */
  42684. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42685. /**
  42686. * Gets the client rect of the HTML element used for events
  42687. * @returns a client rectanglee
  42688. */
  42689. getInputElementClientRect(): Nullable<ClientRect>;
  42690. /**
  42691. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42692. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42693. * @returns true if engine is in deterministic lock step mode
  42694. */
  42695. isDeterministicLockStep(): boolean;
  42696. /**
  42697. * Gets the max steps when engine is running in deterministic lock step
  42698. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42699. * @returns the max steps
  42700. */
  42701. getLockstepMaxSteps(): number;
  42702. /**
  42703. * Returns the time in ms between steps when using deterministic lock step.
  42704. * @returns time step in (ms)
  42705. */
  42706. getTimeStep(): number;
  42707. /**
  42708. * Force the mipmap generation for the given render target texture
  42709. * @param texture defines the render target texture to use
  42710. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42711. */
  42712. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42713. /** States */
  42714. /**
  42715. * Set various states to the webGL context
  42716. * @param culling defines backface culling state
  42717. * @param zOffset defines the value to apply to zOffset (0 by default)
  42718. * @param force defines if states must be applied even if cache is up to date
  42719. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42720. */
  42721. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42722. /**
  42723. * Set the z offset to apply to current rendering
  42724. * @param value defines the offset to apply
  42725. */
  42726. setZOffset(value: number): void;
  42727. /**
  42728. * Gets the current value of the zOffset
  42729. * @returns the current zOffset state
  42730. */
  42731. getZOffset(): number;
  42732. /**
  42733. * Enable or disable depth buffering
  42734. * @param enable defines the state to set
  42735. */
  42736. setDepthBuffer(enable: boolean): void;
  42737. /**
  42738. * Gets a boolean indicating if depth writing is enabled
  42739. * @returns the current depth writing state
  42740. */
  42741. getDepthWrite(): boolean;
  42742. /**
  42743. * Enable or disable depth writing
  42744. * @param enable defines the state to set
  42745. */
  42746. setDepthWrite(enable: boolean): void;
  42747. /**
  42748. * Gets a boolean indicating if stencil buffer is enabled
  42749. * @returns the current stencil buffer state
  42750. */
  42751. getStencilBuffer(): boolean;
  42752. /**
  42753. * Enable or disable the stencil buffer
  42754. * @param enable defines if the stencil buffer must be enabled or disabled
  42755. */
  42756. setStencilBuffer(enable: boolean): void;
  42757. /**
  42758. * Gets the current stencil mask
  42759. * @returns a number defining the new stencil mask to use
  42760. */
  42761. getStencilMask(): number;
  42762. /**
  42763. * Sets the current stencil mask
  42764. * @param mask defines the new stencil mask to use
  42765. */
  42766. setStencilMask(mask: number): void;
  42767. /**
  42768. * Gets the current stencil function
  42769. * @returns a number defining the stencil function to use
  42770. */
  42771. getStencilFunction(): number;
  42772. /**
  42773. * Gets the current stencil reference value
  42774. * @returns a number defining the stencil reference value to use
  42775. */
  42776. getStencilFunctionReference(): number;
  42777. /**
  42778. * Gets the current stencil mask
  42779. * @returns a number defining the stencil mask to use
  42780. */
  42781. getStencilFunctionMask(): number;
  42782. /**
  42783. * Sets the current stencil function
  42784. * @param stencilFunc defines the new stencil function to use
  42785. */
  42786. setStencilFunction(stencilFunc: number): void;
  42787. /**
  42788. * Sets the current stencil reference
  42789. * @param reference defines the new stencil reference to use
  42790. */
  42791. setStencilFunctionReference(reference: number): void;
  42792. /**
  42793. * Sets the current stencil mask
  42794. * @param mask defines the new stencil mask to use
  42795. */
  42796. setStencilFunctionMask(mask: number): void;
  42797. /**
  42798. * Gets the current stencil operation when stencil fails
  42799. * @returns a number defining stencil operation to use when stencil fails
  42800. */
  42801. getStencilOperationFail(): number;
  42802. /**
  42803. * Gets the current stencil operation when depth fails
  42804. * @returns a number defining stencil operation to use when depth fails
  42805. */
  42806. getStencilOperationDepthFail(): number;
  42807. /**
  42808. * Gets the current stencil operation when stencil passes
  42809. * @returns a number defining stencil operation to use when stencil passes
  42810. */
  42811. getStencilOperationPass(): number;
  42812. /**
  42813. * Sets the stencil operation to use when stencil fails
  42814. * @param operation defines the stencil operation to use when stencil fails
  42815. */
  42816. setStencilOperationFail(operation: number): void;
  42817. /**
  42818. * Sets the stencil operation to use when depth fails
  42819. * @param operation defines the stencil operation to use when depth fails
  42820. */
  42821. setStencilOperationDepthFail(operation: number): void;
  42822. /**
  42823. * Sets the stencil operation to use when stencil passes
  42824. * @param operation defines the stencil operation to use when stencil passes
  42825. */
  42826. setStencilOperationPass(operation: number): void;
  42827. /**
  42828. * Sets a boolean indicating if the dithering state is enabled or disabled
  42829. * @param value defines the dithering state
  42830. */
  42831. setDitheringState(value: boolean): void;
  42832. /**
  42833. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42834. * @param value defines the rasterizer state
  42835. */
  42836. setRasterizerState(value: boolean): void;
  42837. /**
  42838. * Gets the current depth function
  42839. * @returns a number defining the depth function
  42840. */
  42841. getDepthFunction(): Nullable<number>;
  42842. /**
  42843. * Sets the current depth function
  42844. * @param depthFunc defines the function to use
  42845. */
  42846. setDepthFunction(depthFunc: number): void;
  42847. /**
  42848. * Sets the current depth function to GREATER
  42849. */
  42850. setDepthFunctionToGreater(): void;
  42851. /**
  42852. * Sets the current depth function to GEQUAL
  42853. */
  42854. setDepthFunctionToGreaterOrEqual(): void;
  42855. /**
  42856. * Sets the current depth function to LESS
  42857. */
  42858. setDepthFunctionToLess(): void;
  42859. /**
  42860. * Sets the current depth function to LEQUAL
  42861. */
  42862. setDepthFunctionToLessOrEqual(): void;
  42863. private _cachedStencilBuffer;
  42864. private _cachedStencilFunction;
  42865. private _cachedStencilMask;
  42866. private _cachedStencilOperationPass;
  42867. private _cachedStencilOperationFail;
  42868. private _cachedStencilOperationDepthFail;
  42869. private _cachedStencilReference;
  42870. /**
  42871. * Caches the the state of the stencil buffer
  42872. */
  42873. cacheStencilState(): void;
  42874. /**
  42875. * Restores the state of the stencil buffer
  42876. */
  42877. restoreStencilState(): void;
  42878. /**
  42879. * Directly set the WebGL Viewport
  42880. * @param x defines the x coordinate of the viewport (in screen space)
  42881. * @param y defines the y coordinate of the viewport (in screen space)
  42882. * @param width defines the width of the viewport (in screen space)
  42883. * @param height defines the height of the viewport (in screen space)
  42884. * @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
  42885. */
  42886. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42887. /**
  42888. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42889. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42890. * @param y defines the y-coordinate of the corner of the clear rectangle
  42891. * @param width defines the width of the clear rectangle
  42892. * @param height defines the height of the clear rectangle
  42893. * @param clearColor defines the clear color
  42894. */
  42895. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42896. /**
  42897. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42898. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42899. * @param y defines the y-coordinate of the corner of the clear rectangle
  42900. * @param width defines the width of the clear rectangle
  42901. * @param height defines the height of the clear rectangle
  42902. */
  42903. enableScissor(x: number, y: number, width: number, height: number): void;
  42904. /**
  42905. * Disable previously set scissor test rectangle
  42906. */
  42907. disableScissor(): void;
  42908. protected _reportDrawCall(): void;
  42909. /**
  42910. * Initializes a webVR display and starts listening to display change events
  42911. * The onVRDisplayChangedObservable will be notified upon these changes
  42912. * @returns The onVRDisplayChangedObservable
  42913. */
  42914. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42915. /** @hidden */
  42916. _prepareVRComponent(): void;
  42917. /** @hidden */
  42918. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42919. /** @hidden */
  42920. _submitVRFrame(): void;
  42921. /**
  42922. * Call this function to leave webVR mode
  42923. * Will do nothing if webVR is not supported or if there is no webVR device
  42924. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42925. */
  42926. disableVR(): void;
  42927. /**
  42928. * Gets a boolean indicating that the system is in VR mode and is presenting
  42929. * @returns true if VR mode is engaged
  42930. */
  42931. isVRPresenting(): boolean;
  42932. /** @hidden */
  42933. _requestVRFrame(): void;
  42934. /** @hidden */
  42935. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42936. /**
  42937. * Gets the source code of the vertex shader associated with a specific webGL program
  42938. * @param program defines the program to use
  42939. * @returns a string containing the source code of the vertex shader associated with the program
  42940. */
  42941. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42942. /**
  42943. * Gets the source code of the fragment shader associated with a specific webGL program
  42944. * @param program defines the program to use
  42945. * @returns a string containing the source code of the fragment shader associated with the program
  42946. */
  42947. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42948. /**
  42949. * Sets a depth stencil texture from a render target to the according uniform.
  42950. * @param channel The texture channel
  42951. * @param uniform The uniform to set
  42952. * @param texture The render target texture containing the depth stencil texture to apply
  42953. */
  42954. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  42955. /**
  42956. * Sets a texture to the webGL context from a postprocess
  42957. * @param channel defines the channel to use
  42958. * @param postProcess defines the source postprocess
  42959. */
  42960. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  42961. /**
  42962. * Binds the output of the passed in post process to the texture channel specified
  42963. * @param channel The channel the texture should be bound to
  42964. * @param postProcess The post process which's output should be bound
  42965. */
  42966. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  42967. protected _rebuildBuffers(): void;
  42968. /** @hidden */
  42969. _renderFrame(): void;
  42970. _renderLoop(): void;
  42971. /** @hidden */
  42972. _renderViews(): boolean;
  42973. /**
  42974. * Toggle full screen mode
  42975. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42976. */
  42977. switchFullscreen(requestPointerLock: boolean): void;
  42978. /**
  42979. * Enters full screen mode
  42980. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42981. */
  42982. enterFullscreen(requestPointerLock: boolean): void;
  42983. /**
  42984. * Exits full screen mode
  42985. */
  42986. exitFullscreen(): void;
  42987. /**
  42988. * Enters Pointerlock mode
  42989. */
  42990. enterPointerlock(): void;
  42991. /**
  42992. * Exits Pointerlock mode
  42993. */
  42994. exitPointerlock(): void;
  42995. /**
  42996. * Begin a new frame
  42997. */
  42998. beginFrame(): void;
  42999. /**
  43000. * Enf the current frame
  43001. */
  43002. endFrame(): void;
  43003. resize(): void;
  43004. /**
  43005. * Force a specific size of the canvas
  43006. * @param width defines the new canvas' width
  43007. * @param height defines the new canvas' height
  43008. * @returns true if the size was changed
  43009. */
  43010. setSize(width: number, height: number): boolean;
  43011. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  43012. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  43013. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  43014. _releaseTexture(texture: InternalTexture): void;
  43015. /**
  43016. * @hidden
  43017. * Rescales a texture
  43018. * @param source input texutre
  43019. * @param destination destination texture
  43020. * @param scene scene to use to render the resize
  43021. * @param internalFormat format to use when resizing
  43022. * @param onComplete callback to be called when resize has completed
  43023. */
  43024. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  43025. /**
  43026. * Gets the current framerate
  43027. * @returns a number representing the framerate
  43028. */
  43029. getFps(): number;
  43030. /**
  43031. * Gets the time spent between current and previous frame
  43032. * @returns a number representing the delta time in ms
  43033. */
  43034. getDeltaTime(): number;
  43035. private _measureFps;
  43036. /** @hidden */
  43037. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  43038. /**
  43039. * Updates the sample count of a render target texture
  43040. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43041. * @param texture defines the texture to update
  43042. * @param samples defines the sample count to set
  43043. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43044. */
  43045. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  43046. /**
  43047. * Updates a depth texture Comparison Mode and Function.
  43048. * If the comparison Function is equal to 0, the mode will be set to none.
  43049. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  43050. * @param texture The texture to set the comparison function for
  43051. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  43052. */
  43053. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  43054. /**
  43055. * Creates a webGL buffer to use with instanciation
  43056. * @param capacity defines the size of the buffer
  43057. * @returns the webGL buffer
  43058. */
  43059. createInstancesBuffer(capacity: number): DataBuffer;
  43060. /**
  43061. * Delete a webGL buffer used with instanciation
  43062. * @param buffer defines the webGL buffer to delete
  43063. */
  43064. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  43065. private _clientWaitAsync;
  43066. /** @hidden */
  43067. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  43068. dispose(): void;
  43069. private _disableTouchAction;
  43070. /**
  43071. * Display the loading screen
  43072. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43073. */
  43074. displayLoadingUI(): void;
  43075. /**
  43076. * Hide the loading screen
  43077. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43078. */
  43079. hideLoadingUI(): void;
  43080. /**
  43081. * Gets the current loading screen object
  43082. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43083. */
  43084. get loadingScreen(): ILoadingScreen;
  43085. /**
  43086. * Sets the current loading screen object
  43087. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43088. */
  43089. set loadingScreen(loadingScreen: ILoadingScreen);
  43090. /**
  43091. * Sets the current loading screen text
  43092. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43093. */
  43094. set loadingUIText(text: string);
  43095. /**
  43096. * Sets the current loading screen background color
  43097. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43098. */
  43099. set loadingUIBackgroundColor(color: string);
  43100. /** Pointerlock and fullscreen */
  43101. /**
  43102. * Ask the browser to promote the current element to pointerlock mode
  43103. * @param element defines the DOM element to promote
  43104. */
  43105. static _RequestPointerlock(element: HTMLElement): void;
  43106. /**
  43107. * Asks the browser to exit pointerlock mode
  43108. */
  43109. static _ExitPointerlock(): void;
  43110. /**
  43111. * Ask the browser to promote the current element to fullscreen rendering mode
  43112. * @param element defines the DOM element to promote
  43113. */
  43114. static _RequestFullscreen(element: HTMLElement): void;
  43115. /**
  43116. * Asks the browser to exit fullscreen mode
  43117. */
  43118. static _ExitFullscreen(): void;
  43119. }
  43120. }
  43121. declare module "babylonjs/Engines/engineStore" {
  43122. import { Nullable } from "babylonjs/types";
  43123. import { Engine } from "babylonjs/Engines/engine";
  43124. import { Scene } from "babylonjs/scene";
  43125. /**
  43126. * The engine store class is responsible to hold all the instances of Engine and Scene created
  43127. * during the life time of the application.
  43128. */
  43129. export class EngineStore {
  43130. /** Gets the list of created engines */
  43131. static Instances: import("babylonjs/Engines/engine").Engine[];
  43132. /** @hidden */
  43133. static _LastCreatedScene: Nullable<Scene>;
  43134. /**
  43135. * Gets the latest created engine
  43136. */
  43137. static get LastCreatedEngine(): Nullable<Engine>;
  43138. /**
  43139. * Gets the latest created scene
  43140. */
  43141. static get LastCreatedScene(): Nullable<Scene>;
  43142. /**
  43143. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43144. * @ignorenaming
  43145. */
  43146. static UseFallbackTexture: boolean;
  43147. /**
  43148. * Texture content used if a texture cannot loaded
  43149. * @ignorenaming
  43150. */
  43151. static FallbackTexture: string;
  43152. }
  43153. }
  43154. declare module "babylonjs/Misc/promise" {
  43155. /**
  43156. * Helper class that provides a small promise polyfill
  43157. */
  43158. export class PromisePolyfill {
  43159. /**
  43160. * Static function used to check if the polyfill is required
  43161. * If this is the case then the function will inject the polyfill to window.Promise
  43162. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  43163. */
  43164. static Apply(force?: boolean): void;
  43165. }
  43166. }
  43167. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  43168. /**
  43169. * Interface for screenshot methods with describe argument called `size` as object with options
  43170. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  43171. */
  43172. export interface IScreenshotSize {
  43173. /**
  43174. * number in pixels for canvas height
  43175. */
  43176. height?: number;
  43177. /**
  43178. * multiplier allowing render at a higher or lower resolution
  43179. * If value is defined then height and width will be ignored and taken from camera
  43180. */
  43181. precision?: number;
  43182. /**
  43183. * number in pixels for canvas width
  43184. */
  43185. width?: number;
  43186. }
  43187. }
  43188. declare module "babylonjs/Misc/tools" {
  43189. import { Nullable, float } from "babylonjs/types";
  43190. import { DomManagement } from "babylonjs/Misc/domManagement";
  43191. import { WebRequest } from "babylonjs/Misc/webRequest";
  43192. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43193. import { ReadFileError } from "babylonjs/Misc/fileTools";
  43194. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  43195. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  43196. import { Camera } from "babylonjs/Cameras/camera";
  43197. import { Engine } from "babylonjs/Engines/engine";
  43198. interface IColor4Like {
  43199. r: float;
  43200. g: float;
  43201. b: float;
  43202. a: float;
  43203. }
  43204. /**
  43205. * Class containing a set of static utilities functions
  43206. */
  43207. export class Tools {
  43208. /**
  43209. * Gets or sets the base URL to use to load assets
  43210. */
  43211. static get BaseUrl(): string;
  43212. static set BaseUrl(value: string);
  43213. /**
  43214. * Enable/Disable Custom HTTP Request Headers globally.
  43215. * default = false
  43216. * @see CustomRequestHeaders
  43217. */
  43218. static UseCustomRequestHeaders: boolean;
  43219. /**
  43220. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  43221. * i.e. when loading files, where the server/service expects an Authorization header
  43222. */
  43223. static CustomRequestHeaders: {
  43224. [key: string]: string;
  43225. };
  43226. /**
  43227. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  43228. */
  43229. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  43230. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  43231. /**
  43232. * Default behaviour for cors in the application.
  43233. * It can be a string if the expected behavior is identical in the entire app.
  43234. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  43235. */
  43236. static get CorsBehavior(): string | ((url: string | string[]) => string);
  43237. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  43238. /**
  43239. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43240. * @ignorenaming
  43241. */
  43242. static get UseFallbackTexture(): boolean;
  43243. static set UseFallbackTexture(value: boolean);
  43244. /**
  43245. * Use this object to register external classes like custom textures or material
  43246. * to allow the laoders to instantiate them
  43247. */
  43248. static get RegisteredExternalClasses(): {
  43249. [key: string]: Object;
  43250. };
  43251. static set RegisteredExternalClasses(classes: {
  43252. [key: string]: Object;
  43253. });
  43254. /**
  43255. * Texture content used if a texture cannot loaded
  43256. * @ignorenaming
  43257. */
  43258. static get fallbackTexture(): string;
  43259. static set fallbackTexture(value: string);
  43260. /**
  43261. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  43262. * @param u defines the coordinate on X axis
  43263. * @param v defines the coordinate on Y axis
  43264. * @param width defines the width of the source data
  43265. * @param height defines the height of the source data
  43266. * @param pixels defines the source byte array
  43267. * @param color defines the output color
  43268. */
  43269. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  43270. /**
  43271. * Interpolates between a and b via alpha
  43272. * @param a The lower value (returned when alpha = 0)
  43273. * @param b The upper value (returned when alpha = 1)
  43274. * @param alpha The interpolation-factor
  43275. * @return The mixed value
  43276. */
  43277. static Mix(a: number, b: number, alpha: number): number;
  43278. /**
  43279. * Tries to instantiate a new object from a given class name
  43280. * @param className defines the class name to instantiate
  43281. * @returns the new object or null if the system was not able to do the instantiation
  43282. */
  43283. static Instantiate(className: string): any;
  43284. /**
  43285. * Provides a slice function that will work even on IE
  43286. * @param data defines the array to slice
  43287. * @param start defines the start of the data (optional)
  43288. * @param end defines the end of the data (optional)
  43289. * @returns the new sliced array
  43290. */
  43291. static Slice<T>(data: T, start?: number, end?: number): T;
  43292. /**
  43293. * Provides a slice function that will work even on IE
  43294. * The difference between this and Slice is that this will force-convert to array
  43295. * @param data defines the array to slice
  43296. * @param start defines the start of the data (optional)
  43297. * @param end defines the end of the data (optional)
  43298. * @returns the new sliced array
  43299. */
  43300. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  43301. /**
  43302. * Polyfill for setImmediate
  43303. * @param action defines the action to execute after the current execution block
  43304. */
  43305. static SetImmediate(action: () => void): void;
  43306. /**
  43307. * Function indicating if a number is an exponent of 2
  43308. * @param value defines the value to test
  43309. * @returns true if the value is an exponent of 2
  43310. */
  43311. static IsExponentOfTwo(value: number): boolean;
  43312. private static _tmpFloatArray;
  43313. /**
  43314. * Returns the nearest 32-bit single precision float representation of a Number
  43315. * @param value A Number. If the parameter is of a different type, it will get converted
  43316. * to a number or to NaN if it cannot be converted
  43317. * @returns number
  43318. */
  43319. static FloatRound(value: number): number;
  43320. /**
  43321. * Extracts the filename from a path
  43322. * @param path defines the path to use
  43323. * @returns the filename
  43324. */
  43325. static GetFilename(path: string): string;
  43326. /**
  43327. * Extracts the "folder" part of a path (everything before the filename).
  43328. * @param uri The URI to extract the info from
  43329. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  43330. * @returns The "folder" part of the path
  43331. */
  43332. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  43333. /**
  43334. * Extracts text content from a DOM element hierarchy
  43335. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  43336. */
  43337. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  43338. /**
  43339. * Convert an angle in radians to degrees
  43340. * @param angle defines the angle to convert
  43341. * @returns the angle in degrees
  43342. */
  43343. static ToDegrees(angle: number): number;
  43344. /**
  43345. * Convert an angle in degrees to radians
  43346. * @param angle defines the angle to convert
  43347. * @returns the angle in radians
  43348. */
  43349. static ToRadians(angle: number): number;
  43350. /**
  43351. * Returns an array if obj is not an array
  43352. * @param obj defines the object to evaluate as an array
  43353. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  43354. * @returns either obj directly if obj is an array or a new array containing obj
  43355. */
  43356. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  43357. /**
  43358. * Gets the pointer prefix to use
  43359. * @param engine defines the engine we are finding the prefix for
  43360. * @returns "pointer" if touch is enabled. Else returns "mouse"
  43361. */
  43362. static GetPointerPrefix(engine: Engine): string;
  43363. /**
  43364. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  43365. * @param url define the url we are trying
  43366. * @param element define the dom element where to configure the cors policy
  43367. */
  43368. static SetCorsBehavior(url: string | string[], element: {
  43369. crossOrigin: string | null;
  43370. }): void;
  43371. /**
  43372. * Removes unwanted characters from an url
  43373. * @param url defines the url to clean
  43374. * @returns the cleaned url
  43375. */
  43376. static CleanUrl(url: string): string;
  43377. /**
  43378. * Gets or sets a function used to pre-process url before using them to load assets
  43379. */
  43380. static get PreprocessUrl(): (url: string) => string;
  43381. static set PreprocessUrl(processor: (url: string) => string);
  43382. /**
  43383. * Loads an image as an HTMLImageElement.
  43384. * @param input url string, ArrayBuffer, or Blob to load
  43385. * @param onLoad callback called when the image successfully loads
  43386. * @param onError callback called when the image fails to load
  43387. * @param offlineProvider offline provider for caching
  43388. * @param mimeType optional mime type
  43389. * @returns the HTMLImageElement of the loaded image
  43390. */
  43391. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  43392. /**
  43393. * Loads a file from a url
  43394. * @param url url string, ArrayBuffer, or Blob to load
  43395. * @param onSuccess callback called when the file successfully loads
  43396. * @param onProgress callback called while file is loading (if the server supports this mode)
  43397. * @param offlineProvider defines the offline provider for caching
  43398. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43399. * @param onError callback called when the file fails to load
  43400. * @returns a file request object
  43401. */
  43402. 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;
  43403. /**
  43404. * Loads a file from a url
  43405. * @param url the file url to load
  43406. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43407. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  43408. */
  43409. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  43410. /**
  43411. * Load a script (identified by an url). When the url returns, the
  43412. * content of this file is added into a new script element, attached to the DOM (body element)
  43413. * @param scriptUrl defines the url of the script to laod
  43414. * @param onSuccess defines the callback called when the script is loaded
  43415. * @param onError defines the callback to call if an error occurs
  43416. * @param scriptId defines the id of the script element
  43417. */
  43418. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  43419. /**
  43420. * Load an asynchronous script (identified by an url). When the url returns, the
  43421. * content of this file is added into a new script element, attached to the DOM (body element)
  43422. * @param scriptUrl defines the url of the script to laod
  43423. * @param scriptId defines the id of the script element
  43424. * @returns a promise request object
  43425. */
  43426. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  43427. /**
  43428. * Loads a file from a blob
  43429. * @param fileToLoad defines the blob to use
  43430. * @param callback defines the callback to call when data is loaded
  43431. * @param progressCallback defines the callback to call during loading process
  43432. * @returns a file request object
  43433. */
  43434. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  43435. /**
  43436. * Reads a file from a File object
  43437. * @param file defines the file to load
  43438. * @param onSuccess defines the callback to call when data is loaded
  43439. * @param onProgress defines the callback to call during loading process
  43440. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43441. * @param onError defines the callback to call when an error occurs
  43442. * @returns a file request object
  43443. */
  43444. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  43445. /**
  43446. * Creates a data url from a given string content
  43447. * @param content defines the content to convert
  43448. * @returns the new data url link
  43449. */
  43450. static FileAsURL(content: string): string;
  43451. /**
  43452. * Format the given number to a specific decimal format
  43453. * @param value defines the number to format
  43454. * @param decimals defines the number of decimals to use
  43455. * @returns the formatted string
  43456. */
  43457. static Format(value: number, decimals?: number): string;
  43458. /**
  43459. * Tries to copy an object by duplicating every property
  43460. * @param source defines the source object
  43461. * @param destination defines the target object
  43462. * @param doNotCopyList defines a list of properties to avoid
  43463. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43464. */
  43465. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43466. /**
  43467. * Gets a boolean indicating if the given object has no own property
  43468. * @param obj defines the object to test
  43469. * @returns true if object has no own property
  43470. */
  43471. static IsEmpty(obj: any): boolean;
  43472. /**
  43473. * Function used to register events at window level
  43474. * @param windowElement defines the Window object to use
  43475. * @param events defines the events to register
  43476. */
  43477. static RegisterTopRootEvents(windowElement: Window, events: {
  43478. name: string;
  43479. handler: Nullable<(e: FocusEvent) => any>;
  43480. }[]): void;
  43481. /**
  43482. * Function used to unregister events from window level
  43483. * @param windowElement defines the Window object to use
  43484. * @param events defines the events to unregister
  43485. */
  43486. static UnregisterTopRootEvents(windowElement: Window, events: {
  43487. name: string;
  43488. handler: Nullable<(e: FocusEvent) => any>;
  43489. }[]): void;
  43490. /**
  43491. * @ignore
  43492. */
  43493. static _ScreenshotCanvas: HTMLCanvasElement;
  43494. /**
  43495. * Dumps the current bound framebuffer
  43496. * @param width defines the rendering width
  43497. * @param height defines the rendering height
  43498. * @param engine defines the hosting engine
  43499. * @param successCallback defines the callback triggered once the data are available
  43500. * @param mimeType defines the mime type of the result
  43501. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43502. */
  43503. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43504. /**
  43505. * Converts the canvas data to blob.
  43506. * This acts as a polyfill for browsers not supporting the to blob function.
  43507. * @param canvas Defines the canvas to extract the data from
  43508. * @param successCallback Defines the callback triggered once the data are available
  43509. * @param mimeType Defines the mime type of the result
  43510. */
  43511. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43512. /**
  43513. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43514. * @param successCallback defines the callback triggered once the data are available
  43515. * @param mimeType defines the mime type of the result
  43516. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43517. */
  43518. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43519. /**
  43520. * Downloads a blob in the browser
  43521. * @param blob defines the blob to download
  43522. * @param fileName defines the name of the downloaded file
  43523. */
  43524. static Download(blob: Blob, fileName: string): void;
  43525. /**
  43526. * Will return the right value of the noPreventDefault variable
  43527. * Needed to keep backwards compatibility to the old API.
  43528. *
  43529. * @param args arguments passed to the attachControl function
  43530. * @returns the correct value for noPreventDefault
  43531. */
  43532. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43533. /**
  43534. * Captures a screenshot of the current rendering
  43535. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43536. * @param engine defines the rendering engine
  43537. * @param camera defines the source camera
  43538. * @param size This parameter can be set to a single number or to an object with the
  43539. * following (optional) properties: precision, width, height. If a single number is passed,
  43540. * it will be used for both width and height. If an object is passed, the screenshot size
  43541. * will be derived from the parameters. The precision property is a multiplier allowing
  43542. * rendering at a higher or lower resolution
  43543. * @param successCallback defines the callback receives a single parameter which contains the
  43544. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43545. * src parameter of an <img> to display it
  43546. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43547. * Check your browser for supported MIME types
  43548. */
  43549. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43550. /**
  43551. * Captures a screenshot of the current rendering
  43552. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43553. * @param engine defines the rendering engine
  43554. * @param camera defines the source camera
  43555. * @param size This parameter can be set to a single number or to an object with the
  43556. * following (optional) properties: precision, width, height. If a single number is passed,
  43557. * it will be used for both width and height. If an object is passed, the screenshot size
  43558. * will be derived from the parameters. The precision property is a multiplier allowing
  43559. * rendering at a higher or lower resolution
  43560. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43561. * Check your browser for supported MIME types
  43562. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43563. * to the src parameter of an <img> to display it
  43564. */
  43565. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43566. /**
  43567. * Generates an image screenshot from the specified camera.
  43568. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43569. * @param engine The engine to use for rendering
  43570. * @param camera The camera to use for rendering
  43571. * @param size This parameter can be set to a single number or to an object with the
  43572. * following (optional) properties: precision, width, height. If a single number is passed,
  43573. * it will be used for both width and height. If an object is passed, the screenshot size
  43574. * will be derived from the parameters. The precision property is a multiplier allowing
  43575. * rendering at a higher or lower resolution
  43576. * @param successCallback The callback receives a single parameter which contains the
  43577. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43578. * src parameter of an <img> to display it
  43579. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43580. * Check your browser for supported MIME types
  43581. * @param samples Texture samples (default: 1)
  43582. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43583. * @param fileName A name for for the downloaded file.
  43584. */
  43585. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43586. /**
  43587. * Generates an image screenshot from the specified camera.
  43588. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43589. * @param engine The engine to use for rendering
  43590. * @param camera The camera to use for rendering
  43591. * @param size This parameter can be set to a single number or to an object with the
  43592. * following (optional) properties: precision, width, height. If a single number is passed,
  43593. * it will be used for both width and height. If an object is passed, the screenshot size
  43594. * will be derived from the parameters. The precision property is a multiplier allowing
  43595. * rendering at a higher or lower resolution
  43596. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43597. * Check your browser for supported MIME types
  43598. * @param samples Texture samples (default: 1)
  43599. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43600. * @param fileName A name for for the downloaded file.
  43601. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43602. * to the src parameter of an <img> to display it
  43603. */
  43604. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43605. /**
  43606. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43607. * Be aware Math.random() could cause collisions, but:
  43608. * "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"
  43609. * @returns a pseudo random id
  43610. */
  43611. static RandomId(): string;
  43612. /**
  43613. * Test if the given uri is a base64 string
  43614. * @param uri The uri to test
  43615. * @return True if the uri is a base64 string or false otherwise
  43616. */
  43617. static IsBase64(uri: string): boolean;
  43618. /**
  43619. * Decode the given base64 uri.
  43620. * @param uri The uri to decode
  43621. * @return The decoded base64 data.
  43622. */
  43623. static DecodeBase64(uri: string): ArrayBuffer;
  43624. /**
  43625. * Gets the absolute url.
  43626. * @param url the input url
  43627. * @return the absolute url
  43628. */
  43629. static GetAbsoluteUrl(url: string): string;
  43630. /**
  43631. * No log
  43632. */
  43633. static readonly NoneLogLevel: number;
  43634. /**
  43635. * Only message logs
  43636. */
  43637. static readonly MessageLogLevel: number;
  43638. /**
  43639. * Only warning logs
  43640. */
  43641. static readonly WarningLogLevel: number;
  43642. /**
  43643. * Only error logs
  43644. */
  43645. static readonly ErrorLogLevel: number;
  43646. /**
  43647. * All logs
  43648. */
  43649. static readonly AllLogLevel: number;
  43650. /**
  43651. * Gets a value indicating the number of loading errors
  43652. * @ignorenaming
  43653. */
  43654. static get errorsCount(): number;
  43655. /**
  43656. * Callback called when a new log is added
  43657. */
  43658. static OnNewCacheEntry: (entry: string) => void;
  43659. /**
  43660. * Log a message to the console
  43661. * @param message defines the message to log
  43662. */
  43663. static Log(message: string): void;
  43664. /**
  43665. * Write a warning message to the console
  43666. * @param message defines the message to log
  43667. */
  43668. static Warn(message: string): void;
  43669. /**
  43670. * Write an error message to the console
  43671. * @param message defines the message to log
  43672. */
  43673. static Error(message: string): void;
  43674. /**
  43675. * Gets current log cache (list of logs)
  43676. */
  43677. static get LogCache(): string;
  43678. /**
  43679. * Clears the log cache
  43680. */
  43681. static ClearLogCache(): void;
  43682. /**
  43683. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43684. */
  43685. static set LogLevels(level: number);
  43686. /**
  43687. * Checks if the window object exists
  43688. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43689. */
  43690. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43691. /**
  43692. * No performance log
  43693. */
  43694. static readonly PerformanceNoneLogLevel: number;
  43695. /**
  43696. * Use user marks to log performance
  43697. */
  43698. static readonly PerformanceUserMarkLogLevel: number;
  43699. /**
  43700. * Log performance to the console
  43701. */
  43702. static readonly PerformanceConsoleLogLevel: number;
  43703. private static _performance;
  43704. /**
  43705. * Sets the current performance log level
  43706. */
  43707. static set PerformanceLogLevel(level: number);
  43708. private static _StartPerformanceCounterDisabled;
  43709. private static _EndPerformanceCounterDisabled;
  43710. private static _StartUserMark;
  43711. private static _EndUserMark;
  43712. private static _StartPerformanceConsole;
  43713. private static _EndPerformanceConsole;
  43714. /**
  43715. * Starts a performance counter
  43716. */
  43717. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43718. /**
  43719. * Ends a specific performance coutner
  43720. */
  43721. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43722. /**
  43723. * Gets either window.performance.now() if supported or Date.now() else
  43724. */
  43725. static get Now(): number;
  43726. /**
  43727. * This method will return the name of the class used to create the instance of the given object.
  43728. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43729. * @param object the object to get the class name from
  43730. * @param isType defines if the object is actually a type
  43731. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43732. */
  43733. static GetClassName(object: any, isType?: boolean): string;
  43734. /**
  43735. * Gets the first element of an array satisfying a given predicate
  43736. * @param array defines the array to browse
  43737. * @param predicate defines the predicate to use
  43738. * @returns null if not found or the element
  43739. */
  43740. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43741. /**
  43742. * This method will return the name of the full name of the class, including its owning module (if any).
  43743. * 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).
  43744. * @param object the object to get the class name from
  43745. * @param isType defines if the object is actually a type
  43746. * @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.
  43747. * @ignorenaming
  43748. */
  43749. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43750. /**
  43751. * Returns a promise that resolves after the given amount of time.
  43752. * @param delay Number of milliseconds to delay
  43753. * @returns Promise that resolves after the given amount of time
  43754. */
  43755. static DelayAsync(delay: number): Promise<void>;
  43756. /**
  43757. * Utility function to detect if the current user agent is Safari
  43758. * @returns whether or not the current user agent is safari
  43759. */
  43760. static IsSafari(): boolean;
  43761. }
  43762. /**
  43763. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43764. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43765. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43766. * @param name The name of the class, case should be preserved
  43767. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43768. */
  43769. export function className(name: string, module?: string): (target: Object) => void;
  43770. /**
  43771. * An implementation of a loop for asynchronous functions.
  43772. */
  43773. export class AsyncLoop {
  43774. /**
  43775. * Defines the number of iterations for the loop
  43776. */
  43777. iterations: number;
  43778. /**
  43779. * Defines the current index of the loop.
  43780. */
  43781. index: number;
  43782. private _done;
  43783. private _fn;
  43784. private _successCallback;
  43785. /**
  43786. * Constructor.
  43787. * @param iterations the number of iterations.
  43788. * @param func the function to run each iteration
  43789. * @param successCallback the callback that will be called upon succesful execution
  43790. * @param offset starting offset.
  43791. */
  43792. constructor(
  43793. /**
  43794. * Defines the number of iterations for the loop
  43795. */
  43796. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43797. /**
  43798. * Execute the next iteration. Must be called after the last iteration was finished.
  43799. */
  43800. executeNext(): void;
  43801. /**
  43802. * Break the loop and run the success callback.
  43803. */
  43804. breakLoop(): void;
  43805. /**
  43806. * Create and run an async loop.
  43807. * @param iterations the number of iterations.
  43808. * @param fn the function to run each iteration
  43809. * @param successCallback the callback that will be called upon succesful execution
  43810. * @param offset starting offset.
  43811. * @returns the created async loop object
  43812. */
  43813. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43814. /**
  43815. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43816. * @param iterations total number of iterations
  43817. * @param syncedIterations number of synchronous iterations in each async iteration.
  43818. * @param fn the function to call each iteration.
  43819. * @param callback a success call back that will be called when iterating stops.
  43820. * @param breakFunction a break condition (optional)
  43821. * @param timeout timeout settings for the setTimeout function. default - 0.
  43822. * @returns the created async loop object
  43823. */
  43824. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43825. }
  43826. }
  43827. declare module "babylonjs/Misc/stringDictionary" {
  43828. import { Nullable } from "babylonjs/types";
  43829. /**
  43830. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43831. * The underlying implementation relies on an associative array to ensure the best performances.
  43832. * The value can be anything including 'null' but except 'undefined'
  43833. */
  43834. export class StringDictionary<T> {
  43835. /**
  43836. * This will clear this dictionary and copy the content from the 'source' one.
  43837. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43838. * @param source the dictionary to take the content from and copy to this dictionary
  43839. */
  43840. copyFrom(source: StringDictionary<T>): void;
  43841. /**
  43842. * Get a value based from its key
  43843. * @param key the given key to get the matching value from
  43844. * @return the value if found, otherwise undefined is returned
  43845. */
  43846. get(key: string): T | undefined;
  43847. /**
  43848. * Get a value from its key or add it if it doesn't exist.
  43849. * This method will ensure you that a given key/data will be present in the dictionary.
  43850. * @param key the given key to get the matching value from
  43851. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43852. * The factory will only be invoked if there's no data for the given key.
  43853. * @return the value corresponding to the key.
  43854. */
  43855. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43856. /**
  43857. * Get a value from its key if present in the dictionary otherwise add it
  43858. * @param key the key to get the value from
  43859. * @param val if there's no such key/value pair in the dictionary add it with this value
  43860. * @return the value corresponding to the key
  43861. */
  43862. getOrAdd(key: string, val: T): T;
  43863. /**
  43864. * Check if there's a given key in the dictionary
  43865. * @param key the key to check for
  43866. * @return true if the key is present, false otherwise
  43867. */
  43868. contains(key: string): boolean;
  43869. /**
  43870. * Add a new key and its corresponding value
  43871. * @param key the key to add
  43872. * @param value the value corresponding to the key
  43873. * @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
  43874. */
  43875. add(key: string, value: T): boolean;
  43876. /**
  43877. * Update a specific value associated to a key
  43878. * @param key defines the key to use
  43879. * @param value defines the value to store
  43880. * @returns true if the value was updated (or false if the key was not found)
  43881. */
  43882. set(key: string, value: T): boolean;
  43883. /**
  43884. * Get the element of the given key and remove it from the dictionary
  43885. * @param key defines the key to search
  43886. * @returns the value associated with the key or null if not found
  43887. */
  43888. getAndRemove(key: string): Nullable<T>;
  43889. /**
  43890. * Remove a key/value from the dictionary.
  43891. * @param key the key to remove
  43892. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43893. */
  43894. remove(key: string): boolean;
  43895. /**
  43896. * Clear the whole content of the dictionary
  43897. */
  43898. clear(): void;
  43899. /**
  43900. * Gets the current count
  43901. */
  43902. get count(): number;
  43903. /**
  43904. * Execute a callback on each key/val of the dictionary.
  43905. * Note that you can remove any element in this dictionary in the callback implementation
  43906. * @param callback the callback to execute on a given key/value pair
  43907. */
  43908. forEach(callback: (key: string, val: T) => void): void;
  43909. /**
  43910. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43911. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43912. * Note that you can remove any element in this dictionary in the callback implementation
  43913. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43914. * @returns the first item
  43915. */
  43916. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43917. private _count;
  43918. private _data;
  43919. }
  43920. }
  43921. declare module "babylonjs/Collisions/collisionCoordinator" {
  43922. import { Nullable } from "babylonjs/types";
  43923. import { Scene } from "babylonjs/scene";
  43924. import { Vector3 } from "babylonjs/Maths/math.vector";
  43925. import { Collider } from "babylonjs/Collisions/collider";
  43926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43927. /** @hidden */
  43928. export interface ICollisionCoordinator {
  43929. createCollider(): Collider;
  43930. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43931. init(scene: Scene): void;
  43932. }
  43933. /** @hidden */
  43934. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43935. private _scene;
  43936. private _scaledPosition;
  43937. private _scaledVelocity;
  43938. private _finalPosition;
  43939. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43940. createCollider(): Collider;
  43941. init(scene: Scene): void;
  43942. private _collideWithWorld;
  43943. }
  43944. }
  43945. declare module "babylonjs/Inputs/scene.inputManager" {
  43946. import { Nullable } from "babylonjs/types";
  43947. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43948. import { Vector2 } from "babylonjs/Maths/math.vector";
  43949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43950. import { Scene } from "babylonjs/scene";
  43951. /**
  43952. * Class used to manage all inputs for the scene.
  43953. */
  43954. export class InputManager {
  43955. /** The distance in pixel that you have to move to prevent some events */
  43956. static DragMovementThreshold: number;
  43957. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43958. static LongPressDelay: number;
  43959. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43960. static DoubleClickDelay: number;
  43961. /** If you need to check double click without raising a single click at first click, enable this flag */
  43962. static ExclusiveDoubleClickMode: boolean;
  43963. /** 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. */
  43964. private _alreadyAttached;
  43965. private _alreadyAttachedTo;
  43966. private _wheelEventName;
  43967. private _onPointerMove;
  43968. private _onPointerDown;
  43969. private _onPointerUp;
  43970. private _initClickEvent;
  43971. private _initActionManager;
  43972. private _delayedSimpleClick;
  43973. private _delayedSimpleClickTimeout;
  43974. private _previousDelayedSimpleClickTimeout;
  43975. private _meshPickProceed;
  43976. private _previousButtonPressed;
  43977. private _currentPickResult;
  43978. private _previousPickResult;
  43979. private _totalPointersPressed;
  43980. private _doubleClickOccured;
  43981. private _pointerOverMesh;
  43982. private _pickedDownMesh;
  43983. private _pickedUpMesh;
  43984. private _pointerX;
  43985. private _pointerY;
  43986. private _unTranslatedPointerX;
  43987. private _unTranslatedPointerY;
  43988. private _startingPointerPosition;
  43989. private _previousStartingPointerPosition;
  43990. private _startingPointerTime;
  43991. private _previousStartingPointerTime;
  43992. private _pointerCaptures;
  43993. private _meshUnderPointerId;
  43994. private _onKeyDown;
  43995. private _onKeyUp;
  43996. private _keyboardIsAttached;
  43997. private _onCanvasFocusObserver;
  43998. private _onCanvasBlurObserver;
  43999. private _scene;
  44000. /**
  44001. * Creates a new InputManager
  44002. * @param scene defines the hosting scene
  44003. */
  44004. constructor(scene: Scene);
  44005. /**
  44006. * Gets the mesh that is currently under the pointer
  44007. */
  44008. get meshUnderPointer(): Nullable<AbstractMesh>;
  44009. /**
  44010. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  44011. * @param pointerId the pointer id to use
  44012. * @returns The mesh under this pointer id or null if not found
  44013. */
  44014. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  44015. /**
  44016. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  44017. */
  44018. get unTranslatedPointer(): Vector2;
  44019. /**
  44020. * Gets or sets the current on-screen X position of the pointer
  44021. */
  44022. get pointerX(): number;
  44023. set pointerX(value: number);
  44024. /**
  44025. * Gets or sets the current on-screen Y position of the pointer
  44026. */
  44027. get pointerY(): number;
  44028. set pointerY(value: number);
  44029. private _updatePointerPosition;
  44030. private _processPointerMove;
  44031. private _setRayOnPointerInfo;
  44032. private _checkPrePointerObservable;
  44033. /**
  44034. * Use this method to simulate a pointer move on a mesh
  44035. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44036. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44037. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44038. */
  44039. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  44040. /**
  44041. * Use this method to simulate a pointer down on a mesh
  44042. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44043. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44044. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44045. */
  44046. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  44047. private _processPointerDown;
  44048. /** @hidden */
  44049. _isPointerSwiping(): boolean;
  44050. /**
  44051. * Use this method to simulate a pointer up on a mesh
  44052. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44053. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44054. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44055. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  44056. */
  44057. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  44058. private _processPointerUp;
  44059. /**
  44060. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  44061. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  44062. * @returns true if the pointer was captured
  44063. */
  44064. isPointerCaptured(pointerId?: number): boolean;
  44065. /**
  44066. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  44067. * @param attachUp defines if you want to attach events to pointerup
  44068. * @param attachDown defines if you want to attach events to pointerdown
  44069. * @param attachMove defines if you want to attach events to pointermove
  44070. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  44071. */
  44072. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  44073. /**
  44074. * Detaches all event handlers
  44075. */
  44076. detachControl(): void;
  44077. /**
  44078. * Force the value of meshUnderPointer
  44079. * @param mesh defines the mesh to use
  44080. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  44081. */
  44082. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44083. /**
  44084. * Gets the mesh under the pointer
  44085. * @returns a Mesh or null if no mesh is under the pointer
  44086. */
  44087. getPointerOverMesh(): Nullable<AbstractMesh>;
  44088. }
  44089. }
  44090. declare module "babylonjs/Animations/animationGroup" {
  44091. import { Animatable } from "babylonjs/Animations/animatable";
  44092. import { Animation } from "babylonjs/Animations/animation";
  44093. import { Scene, IDisposable } from "babylonjs/scene";
  44094. import { Observable } from "babylonjs/Misc/observable";
  44095. import { Nullable } from "babylonjs/types";
  44096. import "babylonjs/Animations/animatable";
  44097. /**
  44098. * This class defines the direct association between an animation and a target
  44099. */
  44100. export class TargetedAnimation {
  44101. /**
  44102. * Animation to perform
  44103. */
  44104. animation: Animation;
  44105. /**
  44106. * Target to animate
  44107. */
  44108. target: any;
  44109. /**
  44110. * Returns the string "TargetedAnimation"
  44111. * @returns "TargetedAnimation"
  44112. */
  44113. getClassName(): string;
  44114. /**
  44115. * Serialize the object
  44116. * @returns the JSON object representing the current entity
  44117. */
  44118. serialize(): any;
  44119. }
  44120. /**
  44121. * Use this class to create coordinated animations on multiple targets
  44122. */
  44123. export class AnimationGroup implements IDisposable {
  44124. /** The name of the animation group */
  44125. name: string;
  44126. private _scene;
  44127. private _targetedAnimations;
  44128. private _animatables;
  44129. private _from;
  44130. private _to;
  44131. private _isStarted;
  44132. private _isPaused;
  44133. private _speedRatio;
  44134. private _loopAnimation;
  44135. private _isAdditive;
  44136. /**
  44137. * Gets or sets the unique id of the node
  44138. */
  44139. uniqueId: number;
  44140. /**
  44141. * This observable will notify when one animation have ended
  44142. */
  44143. onAnimationEndObservable: Observable<TargetedAnimation>;
  44144. /**
  44145. * Observer raised when one animation loops
  44146. */
  44147. onAnimationLoopObservable: Observable<TargetedAnimation>;
  44148. /**
  44149. * Observer raised when all animations have looped
  44150. */
  44151. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  44152. /**
  44153. * This observable will notify when all animations have ended.
  44154. */
  44155. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  44156. /**
  44157. * This observable will notify when all animations have paused.
  44158. */
  44159. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  44160. /**
  44161. * This observable will notify when all animations are playing.
  44162. */
  44163. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  44164. /**
  44165. * Gets the first frame
  44166. */
  44167. get from(): number;
  44168. /**
  44169. * Gets the last frame
  44170. */
  44171. get to(): number;
  44172. /**
  44173. * Define if the animations are started
  44174. */
  44175. get isStarted(): boolean;
  44176. /**
  44177. * Gets a value indicating that the current group is playing
  44178. */
  44179. get isPlaying(): boolean;
  44180. /**
  44181. * Gets or sets the speed ratio to use for all animations
  44182. */
  44183. get speedRatio(): number;
  44184. /**
  44185. * Gets or sets the speed ratio to use for all animations
  44186. */
  44187. set speedRatio(value: number);
  44188. /**
  44189. * Gets or sets if all animations should loop or not
  44190. */
  44191. get loopAnimation(): boolean;
  44192. set loopAnimation(value: boolean);
  44193. /**
  44194. * Gets or sets if all animations should be evaluated additively
  44195. */
  44196. get isAdditive(): boolean;
  44197. set isAdditive(value: boolean);
  44198. /**
  44199. * Gets the targeted animations for this animation group
  44200. */
  44201. get targetedAnimations(): Array<TargetedAnimation>;
  44202. /**
  44203. * returning the list of animatables controlled by this animation group.
  44204. */
  44205. get animatables(): Array<Animatable>;
  44206. /**
  44207. * Gets the list of target animations
  44208. */
  44209. get children(): TargetedAnimation[];
  44210. /**
  44211. * Instantiates a new Animation Group.
  44212. * This helps managing several animations at once.
  44213. * @see https://doc.babylonjs.com/how_to/group
  44214. * @param name Defines the name of the group
  44215. * @param scene Defines the scene the group belongs to
  44216. */
  44217. constructor(
  44218. /** The name of the animation group */
  44219. name: string, scene?: Nullable<Scene>);
  44220. /**
  44221. * Add an animation (with its target) in the group
  44222. * @param animation defines the animation we want to add
  44223. * @param target defines the target of the animation
  44224. * @returns the TargetedAnimation object
  44225. */
  44226. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  44227. /**
  44228. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  44229. * It can add constant keys at begin or end
  44230. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  44231. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  44232. * @returns the animation group
  44233. */
  44234. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  44235. private _animationLoopCount;
  44236. private _animationLoopFlags;
  44237. private _processLoop;
  44238. /**
  44239. * Start all animations on given targets
  44240. * @param loop defines if animations must loop
  44241. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  44242. * @param from defines the from key (optional)
  44243. * @param to defines the to key (optional)
  44244. * @param isAdditive defines the additive state for the resulting animatables (optional)
  44245. * @returns the current animation group
  44246. */
  44247. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  44248. /**
  44249. * Pause all animations
  44250. * @returns the animation group
  44251. */
  44252. pause(): AnimationGroup;
  44253. /**
  44254. * Play all animations to initial state
  44255. * This function will start() the animations if they were not started or will restart() them if they were paused
  44256. * @param loop defines if animations must loop
  44257. * @returns the animation group
  44258. */
  44259. play(loop?: boolean): AnimationGroup;
  44260. /**
  44261. * Reset all animations to initial state
  44262. * @returns the animation group
  44263. */
  44264. reset(): AnimationGroup;
  44265. /**
  44266. * Restart animations from key 0
  44267. * @returns the animation group
  44268. */
  44269. restart(): AnimationGroup;
  44270. /**
  44271. * Stop all animations
  44272. * @returns the animation group
  44273. */
  44274. stop(): AnimationGroup;
  44275. /**
  44276. * Set animation weight for all animatables
  44277. * @param weight defines the weight to use
  44278. * @return the animationGroup
  44279. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44280. */
  44281. setWeightForAllAnimatables(weight: number): AnimationGroup;
  44282. /**
  44283. * Synchronize and normalize all animatables with a source animatable
  44284. * @param root defines the root animatable to synchronize with
  44285. * @return the animationGroup
  44286. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44287. */
  44288. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  44289. /**
  44290. * Goes to a specific frame in this animation group
  44291. * @param frame the frame number to go to
  44292. * @return the animationGroup
  44293. */
  44294. goToFrame(frame: number): AnimationGroup;
  44295. /**
  44296. * Dispose all associated resources
  44297. */
  44298. dispose(): void;
  44299. private _checkAnimationGroupEnded;
  44300. /**
  44301. * Clone the current animation group and returns a copy
  44302. * @param newName defines the name of the new group
  44303. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  44304. * @returns the new aniamtion group
  44305. */
  44306. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  44307. /**
  44308. * Serializes the animationGroup to an object
  44309. * @returns Serialized object
  44310. */
  44311. serialize(): any;
  44312. /**
  44313. * Returns a new AnimationGroup object parsed from the source provided.
  44314. * @param parsedAnimationGroup defines the source
  44315. * @param scene defines the scene that will receive the animationGroup
  44316. * @returns a new AnimationGroup
  44317. */
  44318. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  44319. /**
  44320. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  44321. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  44322. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  44323. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  44324. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  44325. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  44326. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  44327. */
  44328. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  44329. /**
  44330. * Returns the string "AnimationGroup"
  44331. * @returns "AnimationGroup"
  44332. */
  44333. getClassName(): string;
  44334. /**
  44335. * Creates a detailled string about the object
  44336. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  44337. * @returns a string representing the object
  44338. */
  44339. toString(fullDetails?: boolean): string;
  44340. }
  44341. }
  44342. declare module "babylonjs/scene" {
  44343. import { Nullable } from "babylonjs/types";
  44344. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  44345. import { Observable } from "babylonjs/Misc/observable";
  44346. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44347. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  44348. import { Geometry } from "babylonjs/Meshes/geometry";
  44349. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44350. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44352. import { Mesh } from "babylonjs/Meshes/mesh";
  44353. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44354. import { Bone } from "babylonjs/Bones/bone";
  44355. import { Skeleton } from "babylonjs/Bones/skeleton";
  44356. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  44357. import { Camera } from "babylonjs/Cameras/camera";
  44358. import { AbstractScene } from "babylonjs/abstractScene";
  44359. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44360. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44361. import { Material } from "babylonjs/Materials/material";
  44362. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44363. import { Effect } from "babylonjs/Materials/effect";
  44364. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44365. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  44366. import { Light } from "babylonjs/Lights/light";
  44367. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  44368. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  44369. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  44370. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  44371. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  44372. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  44373. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  44374. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, PreActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  44375. import { Engine } from "babylonjs/Engines/engine";
  44376. import { Node } from "babylonjs/node";
  44377. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  44378. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  44379. import { WebRequest } from "babylonjs/Misc/webRequest";
  44380. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  44381. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  44382. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44383. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  44384. import { Plane } from "babylonjs/Maths/math.plane";
  44385. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  44386. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  44387. import { Ray } from "babylonjs/Culling/ray";
  44388. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  44389. import { Animation } from "babylonjs/Animations/animation";
  44390. import { Animatable } from "babylonjs/Animations/animatable";
  44391. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44392. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  44393. import { Collider } from "babylonjs/Collisions/collider";
  44394. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  44395. /**
  44396. * Define an interface for all classes that will hold resources
  44397. */
  44398. export interface IDisposable {
  44399. /**
  44400. * Releases all held resources
  44401. */
  44402. dispose(): void;
  44403. }
  44404. /** Interface defining initialization parameters for Scene class */
  44405. export interface SceneOptions {
  44406. /**
  44407. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  44408. * It will improve performance when the number of geometries becomes important.
  44409. */
  44410. useGeometryUniqueIdsMap?: boolean;
  44411. /**
  44412. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  44413. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  44414. */
  44415. useMaterialMeshMap?: boolean;
  44416. /**
  44417. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  44418. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  44419. */
  44420. useClonedMeshMap?: boolean;
  44421. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  44422. virtual?: boolean;
  44423. }
  44424. /**
  44425. * Represents a scene to be rendered by the engine.
  44426. * @see https://doc.babylonjs.com/features/scene
  44427. */
  44428. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  44429. /** The fog is deactivated */
  44430. static readonly FOGMODE_NONE: number;
  44431. /** The fog density is following an exponential function */
  44432. static readonly FOGMODE_EXP: number;
  44433. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  44434. static readonly FOGMODE_EXP2: number;
  44435. /** The fog density is following a linear function. */
  44436. static readonly FOGMODE_LINEAR: number;
  44437. /**
  44438. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  44439. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44440. */
  44441. static MinDeltaTime: number;
  44442. /**
  44443. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  44444. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44445. */
  44446. static MaxDeltaTime: number;
  44447. /**
  44448. * Factory used to create the default material.
  44449. * @param name The name of the material to create
  44450. * @param scene The scene to create the material for
  44451. * @returns The default material
  44452. */
  44453. static DefaultMaterialFactory(scene: Scene): Material;
  44454. /**
  44455. * Factory used to create the a collision coordinator.
  44456. * @returns The collision coordinator
  44457. */
  44458. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  44459. /** @hidden */
  44460. _inputManager: InputManager;
  44461. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  44462. cameraToUseForPointers: Nullable<Camera>;
  44463. /** @hidden */
  44464. readonly _isScene: boolean;
  44465. /** @hidden */
  44466. _blockEntityCollection: boolean;
  44467. /**
  44468. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  44469. */
  44470. autoClear: boolean;
  44471. /**
  44472. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  44473. */
  44474. autoClearDepthAndStencil: boolean;
  44475. /**
  44476. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  44477. */
  44478. clearColor: Color4;
  44479. /**
  44480. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  44481. */
  44482. ambientColor: Color3;
  44483. /**
  44484. * This is use to store the default BRDF lookup for PBR materials in your scene.
  44485. * It should only be one of the following (if not the default embedded one):
  44486. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  44487. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  44488. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  44489. * The material properties need to be setup according to the type of texture in use.
  44490. */
  44491. environmentBRDFTexture: BaseTexture;
  44492. /**
  44493. * Texture used in all pbr material as the reflection texture.
  44494. * As in the majority of the scene they are the same (exception for multi room and so on),
  44495. * this is easier to reference from here than from all the materials.
  44496. */
  44497. get environmentTexture(): Nullable<BaseTexture>;
  44498. /**
  44499. * Texture used in all pbr material as the reflection texture.
  44500. * As in the majority of the scene they are the same (exception for multi room and so on),
  44501. * this is easier to set here than in all the materials.
  44502. */
  44503. set environmentTexture(value: Nullable<BaseTexture>);
  44504. /** @hidden */
  44505. protected _environmentIntensity: number;
  44506. /**
  44507. * Intensity of the environment in all pbr material.
  44508. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44509. * As in the majority of the scene they are the same (exception for multi room and so on),
  44510. * this is easier to reference from here than from all the materials.
  44511. */
  44512. get environmentIntensity(): number;
  44513. /**
  44514. * Intensity of the environment in all pbr material.
  44515. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44516. * As in the majority of the scene they are the same (exception for multi room and so on),
  44517. * this is easier to set here than in all the materials.
  44518. */
  44519. set environmentIntensity(value: number);
  44520. /** @hidden */
  44521. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44522. /**
  44523. * Default image processing configuration used either in the rendering
  44524. * Forward main pass or through the imageProcessingPostProcess if present.
  44525. * As in the majority of the scene they are the same (exception for multi camera),
  44526. * this is easier to reference from here than from all the materials and post process.
  44527. *
  44528. * No setter as we it is a shared configuration, you can set the values instead.
  44529. */
  44530. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44531. private _forceWireframe;
  44532. /**
  44533. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  44534. */
  44535. set forceWireframe(value: boolean);
  44536. get forceWireframe(): boolean;
  44537. private _skipFrustumClipping;
  44538. /**
  44539. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  44540. */
  44541. set skipFrustumClipping(value: boolean);
  44542. get skipFrustumClipping(): boolean;
  44543. private _forcePointsCloud;
  44544. /**
  44545. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  44546. */
  44547. set forcePointsCloud(value: boolean);
  44548. get forcePointsCloud(): boolean;
  44549. /**
  44550. * Gets or sets the active clipplane 1
  44551. */
  44552. clipPlane: Nullable<Plane>;
  44553. /**
  44554. * Gets or sets the active clipplane 2
  44555. */
  44556. clipPlane2: Nullable<Plane>;
  44557. /**
  44558. * Gets or sets the active clipplane 3
  44559. */
  44560. clipPlane3: Nullable<Plane>;
  44561. /**
  44562. * Gets or sets the active clipplane 4
  44563. */
  44564. clipPlane4: Nullable<Plane>;
  44565. /**
  44566. * Gets or sets the active clipplane 5
  44567. */
  44568. clipPlane5: Nullable<Plane>;
  44569. /**
  44570. * Gets or sets the active clipplane 6
  44571. */
  44572. clipPlane6: Nullable<Plane>;
  44573. /**
  44574. * Gets or sets a boolean indicating if animations are enabled
  44575. */
  44576. animationsEnabled: boolean;
  44577. private _animationPropertiesOverride;
  44578. /**
  44579. * Gets or sets the animation properties override
  44580. */
  44581. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  44582. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  44583. /**
  44584. * Gets or sets a boolean indicating if a constant deltatime has to be used
  44585. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  44586. */
  44587. useConstantAnimationDeltaTime: boolean;
  44588. /**
  44589. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  44590. * Please note that it requires to run a ray cast through the scene on every frame
  44591. */
  44592. constantlyUpdateMeshUnderPointer: boolean;
  44593. /**
  44594. * Defines the HTML cursor to use when hovering over interactive elements
  44595. */
  44596. hoverCursor: string;
  44597. /**
  44598. * Defines the HTML default cursor to use (empty by default)
  44599. */
  44600. defaultCursor: string;
  44601. /**
  44602. * Defines whether cursors are handled by the scene.
  44603. */
  44604. doNotHandleCursors: boolean;
  44605. /**
  44606. * This is used to call preventDefault() on pointer down
  44607. * in order to block unwanted artifacts like system double clicks
  44608. */
  44609. preventDefaultOnPointerDown: boolean;
  44610. /**
  44611. * This is used to call preventDefault() on pointer up
  44612. * in order to block unwanted artifacts like system double clicks
  44613. */
  44614. preventDefaultOnPointerUp: boolean;
  44615. /**
  44616. * Gets or sets user defined metadata
  44617. */
  44618. metadata: any;
  44619. /**
  44620. * For internal use only. Please do not use.
  44621. */
  44622. reservedDataStore: any;
  44623. /**
  44624. * Gets the name of the plugin used to load this scene (null by default)
  44625. */
  44626. loadingPluginName: string;
  44627. /**
  44628. * Use this array to add regular expressions used to disable offline support for specific urls
  44629. */
  44630. disableOfflineSupportExceptionRules: RegExp[];
  44631. /**
  44632. * An event triggered when the scene is disposed.
  44633. */
  44634. onDisposeObservable: Observable<Scene>;
  44635. private _onDisposeObserver;
  44636. /** Sets a function to be executed when this scene is disposed. */
  44637. set onDispose(callback: () => void);
  44638. /**
  44639. * An event triggered before rendering the scene (right after animations and physics)
  44640. */
  44641. onBeforeRenderObservable: Observable<Scene>;
  44642. private _onBeforeRenderObserver;
  44643. /** Sets a function to be executed before rendering this scene */
  44644. set beforeRender(callback: Nullable<() => void>);
  44645. /**
  44646. * An event triggered after rendering the scene
  44647. */
  44648. onAfterRenderObservable: Observable<Scene>;
  44649. /**
  44650. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  44651. */
  44652. onAfterRenderCameraObservable: Observable<Camera>;
  44653. private _onAfterRenderObserver;
  44654. /** Sets a function to be executed after rendering this scene */
  44655. set afterRender(callback: Nullable<() => void>);
  44656. /**
  44657. * An event triggered before animating the scene
  44658. */
  44659. onBeforeAnimationsObservable: Observable<Scene>;
  44660. /**
  44661. * An event triggered after animations processing
  44662. */
  44663. onAfterAnimationsObservable: Observable<Scene>;
  44664. /**
  44665. * An event triggered before draw calls are ready to be sent
  44666. */
  44667. onBeforeDrawPhaseObservable: Observable<Scene>;
  44668. /**
  44669. * An event triggered after draw calls have been sent
  44670. */
  44671. onAfterDrawPhaseObservable: Observable<Scene>;
  44672. /**
  44673. * An event triggered when the scene is ready
  44674. */
  44675. onReadyObservable: Observable<Scene>;
  44676. /**
  44677. * An event triggered before rendering a camera
  44678. */
  44679. onBeforeCameraRenderObservable: Observable<Camera>;
  44680. private _onBeforeCameraRenderObserver;
  44681. /** Sets a function to be executed before rendering a camera*/
  44682. set beforeCameraRender(callback: () => void);
  44683. /**
  44684. * An event triggered after rendering a camera
  44685. */
  44686. onAfterCameraRenderObservable: Observable<Camera>;
  44687. private _onAfterCameraRenderObserver;
  44688. /** Sets a function to be executed after rendering a camera*/
  44689. set afterCameraRender(callback: () => void);
  44690. /**
  44691. * An event triggered when active meshes evaluation is about to start
  44692. */
  44693. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  44694. /**
  44695. * An event triggered when active meshes evaluation is done
  44696. */
  44697. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  44698. /**
  44699. * An event triggered when particles rendering is about to start
  44700. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44701. */
  44702. onBeforeParticlesRenderingObservable: Observable<Scene>;
  44703. /**
  44704. * An event triggered when particles rendering is done
  44705. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44706. */
  44707. onAfterParticlesRenderingObservable: Observable<Scene>;
  44708. /**
  44709. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  44710. */
  44711. onDataLoadedObservable: Observable<Scene>;
  44712. /**
  44713. * An event triggered when a camera is created
  44714. */
  44715. onNewCameraAddedObservable: Observable<Camera>;
  44716. /**
  44717. * An event triggered when a camera is removed
  44718. */
  44719. onCameraRemovedObservable: Observable<Camera>;
  44720. /**
  44721. * An event triggered when a light is created
  44722. */
  44723. onNewLightAddedObservable: Observable<Light>;
  44724. /**
  44725. * An event triggered when a light is removed
  44726. */
  44727. onLightRemovedObservable: Observable<Light>;
  44728. /**
  44729. * An event triggered when a geometry is created
  44730. */
  44731. onNewGeometryAddedObservable: Observable<Geometry>;
  44732. /**
  44733. * An event triggered when a geometry is removed
  44734. */
  44735. onGeometryRemovedObservable: Observable<Geometry>;
  44736. /**
  44737. * An event triggered when a transform node is created
  44738. */
  44739. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  44740. /**
  44741. * An event triggered when a transform node is removed
  44742. */
  44743. onTransformNodeRemovedObservable: Observable<TransformNode>;
  44744. /**
  44745. * An event triggered when a mesh is created
  44746. */
  44747. onNewMeshAddedObservable: Observable<AbstractMesh>;
  44748. /**
  44749. * An event triggered when a mesh is removed
  44750. */
  44751. onMeshRemovedObservable: Observable<AbstractMesh>;
  44752. /**
  44753. * An event triggered when a skeleton is created
  44754. */
  44755. onNewSkeletonAddedObservable: Observable<Skeleton>;
  44756. /**
  44757. * An event triggered when a skeleton is removed
  44758. */
  44759. onSkeletonRemovedObservable: Observable<Skeleton>;
  44760. /**
  44761. * An event triggered when a material is created
  44762. */
  44763. onNewMaterialAddedObservable: Observable<Material>;
  44764. /**
  44765. * An event triggered when a multi material is created
  44766. */
  44767. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  44768. /**
  44769. * An event triggered when a material is removed
  44770. */
  44771. onMaterialRemovedObservable: Observable<Material>;
  44772. /**
  44773. * An event triggered when a multi material is removed
  44774. */
  44775. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  44776. /**
  44777. * An event triggered when a texture is created
  44778. */
  44779. onNewTextureAddedObservable: Observable<BaseTexture>;
  44780. /**
  44781. * An event triggered when a texture is removed
  44782. */
  44783. onTextureRemovedObservable: Observable<BaseTexture>;
  44784. /**
  44785. * An event triggered when render targets are about to be rendered
  44786. * Can happen multiple times per frame.
  44787. */
  44788. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  44789. /**
  44790. * An event triggered when render targets were rendered.
  44791. * Can happen multiple times per frame.
  44792. */
  44793. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  44794. /**
  44795. * An event triggered before calculating deterministic simulation step
  44796. */
  44797. onBeforeStepObservable: Observable<Scene>;
  44798. /**
  44799. * An event triggered after calculating deterministic simulation step
  44800. */
  44801. onAfterStepObservable: Observable<Scene>;
  44802. /**
  44803. * An event triggered when the activeCamera property is updated
  44804. */
  44805. onActiveCameraChanged: Observable<Scene>;
  44806. /**
  44807. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  44808. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44809. * 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)
  44810. */
  44811. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44812. /**
  44813. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  44814. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44815. * 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)
  44816. */
  44817. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44818. /**
  44819. * This Observable will when a mesh has been imported into the scene.
  44820. */
  44821. onMeshImportedObservable: Observable<AbstractMesh>;
  44822. /**
  44823. * This Observable will when an animation file has been imported into the scene.
  44824. */
  44825. onAnimationFileImportedObservable: Observable<Scene>;
  44826. /**
  44827. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  44828. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  44829. */
  44830. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  44831. /** @hidden */
  44832. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  44833. /**
  44834. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  44835. */
  44836. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  44837. /**
  44838. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  44839. */
  44840. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  44841. /**
  44842. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  44843. */
  44844. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  44845. /** Callback called when a pointer move is detected */
  44846. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44847. /** Callback called when a pointer down is detected */
  44848. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44849. /** Callback called when a pointer up is detected */
  44850. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  44851. /** Callback called when a pointer pick is detected */
  44852. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  44853. /**
  44854. * 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).
  44855. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  44856. */
  44857. onPrePointerObservable: Observable<PointerInfoPre>;
  44858. /**
  44859. * Observable event triggered each time an input event is received from the rendering canvas
  44860. */
  44861. onPointerObservable: Observable<PointerInfo>;
  44862. /**
  44863. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  44864. */
  44865. get unTranslatedPointer(): Vector2;
  44866. /**
  44867. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  44868. */
  44869. static get DragMovementThreshold(): number;
  44870. static set DragMovementThreshold(value: number);
  44871. /**
  44872. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  44873. */
  44874. static get LongPressDelay(): number;
  44875. static set LongPressDelay(value: number);
  44876. /**
  44877. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  44878. */
  44879. static get DoubleClickDelay(): number;
  44880. static set DoubleClickDelay(value: number);
  44881. /** If you need to check double click without raising a single click at first click, enable this flag */
  44882. static get ExclusiveDoubleClickMode(): boolean;
  44883. static set ExclusiveDoubleClickMode(value: boolean);
  44884. /** @hidden */
  44885. _mirroredCameraPosition: Nullable<Vector3>;
  44886. /**
  44887. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  44888. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  44889. */
  44890. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  44891. /**
  44892. * Observable event triggered each time an keyboard event is received from the hosting window
  44893. */
  44894. onKeyboardObservable: Observable<KeyboardInfo>;
  44895. private _useRightHandedSystem;
  44896. /**
  44897. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  44898. */
  44899. set useRightHandedSystem(value: boolean);
  44900. get useRightHandedSystem(): boolean;
  44901. private _timeAccumulator;
  44902. private _currentStepId;
  44903. private _currentInternalStep;
  44904. /**
  44905. * Sets the step Id used by deterministic lock step
  44906. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44907. * @param newStepId defines the step Id
  44908. */
  44909. setStepId(newStepId: number): void;
  44910. /**
  44911. * Gets the step Id used by deterministic lock step
  44912. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44913. * @returns the step Id
  44914. */
  44915. getStepId(): number;
  44916. /**
  44917. * Gets the internal step used by deterministic lock step
  44918. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44919. * @returns the internal step
  44920. */
  44921. getInternalStep(): number;
  44922. private _fogEnabled;
  44923. /**
  44924. * Gets or sets a boolean indicating if fog is enabled on this scene
  44925. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44926. * (Default is true)
  44927. */
  44928. set fogEnabled(value: boolean);
  44929. get fogEnabled(): boolean;
  44930. private _fogMode;
  44931. /**
  44932. * Gets or sets the fog mode to use
  44933. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44934. * | mode | value |
  44935. * | --- | --- |
  44936. * | FOGMODE_NONE | 0 |
  44937. * | FOGMODE_EXP | 1 |
  44938. * | FOGMODE_EXP2 | 2 |
  44939. * | FOGMODE_LINEAR | 3 |
  44940. */
  44941. set fogMode(value: number);
  44942. get fogMode(): number;
  44943. /**
  44944. * Gets or sets the fog color to use
  44945. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44946. * (Default is Color3(0.2, 0.2, 0.3))
  44947. */
  44948. fogColor: Color3;
  44949. /**
  44950. * Gets or sets the fog density to use
  44951. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44952. * (Default is 0.1)
  44953. */
  44954. fogDensity: number;
  44955. /**
  44956. * Gets or sets the fog start distance to use
  44957. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44958. * (Default is 0)
  44959. */
  44960. fogStart: number;
  44961. /**
  44962. * Gets or sets the fog end distance to use
  44963. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44964. * (Default is 1000)
  44965. */
  44966. fogEnd: number;
  44967. /**
  44968. * Flag indicating that the frame buffer binding is handled by another component
  44969. */
  44970. prePass: boolean;
  44971. private _shadowsEnabled;
  44972. /**
  44973. * Gets or sets a boolean indicating if shadows are enabled on this scene
  44974. */
  44975. set shadowsEnabled(value: boolean);
  44976. get shadowsEnabled(): boolean;
  44977. private _lightsEnabled;
  44978. /**
  44979. * Gets or sets a boolean indicating if lights are enabled on this scene
  44980. */
  44981. set lightsEnabled(value: boolean);
  44982. get lightsEnabled(): boolean;
  44983. /** All of the active cameras added to this scene. */
  44984. activeCameras: Camera[];
  44985. /** @hidden */
  44986. _activeCamera: Nullable<Camera>;
  44987. /** Gets or sets the current active camera */
  44988. get activeCamera(): Nullable<Camera>;
  44989. set activeCamera(value: Nullable<Camera>);
  44990. private _defaultMaterial;
  44991. /** The default material used on meshes when no material is affected */
  44992. get defaultMaterial(): Material;
  44993. /** The default material used on meshes when no material is affected */
  44994. set defaultMaterial(value: Material);
  44995. private _texturesEnabled;
  44996. /**
  44997. * Gets or sets a boolean indicating if textures are enabled on this scene
  44998. */
  44999. set texturesEnabled(value: boolean);
  45000. get texturesEnabled(): boolean;
  45001. /**
  45002. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  45003. */
  45004. physicsEnabled: boolean;
  45005. /**
  45006. * Gets or sets a boolean indicating if particles are enabled on this scene
  45007. */
  45008. particlesEnabled: boolean;
  45009. /**
  45010. * Gets or sets a boolean indicating if sprites are enabled on this scene
  45011. */
  45012. spritesEnabled: boolean;
  45013. private _skeletonsEnabled;
  45014. /**
  45015. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  45016. */
  45017. set skeletonsEnabled(value: boolean);
  45018. get skeletonsEnabled(): boolean;
  45019. /**
  45020. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  45021. */
  45022. lensFlaresEnabled: boolean;
  45023. /**
  45024. * Gets or sets a boolean indicating if collisions are enabled on this scene
  45025. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  45026. */
  45027. collisionsEnabled: boolean;
  45028. private _collisionCoordinator;
  45029. /** @hidden */
  45030. get collisionCoordinator(): ICollisionCoordinator;
  45031. /**
  45032. * Defines the gravity applied to this scene (used only for collisions)
  45033. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  45034. */
  45035. gravity: Vector3;
  45036. /**
  45037. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  45038. */
  45039. postProcessesEnabled: boolean;
  45040. /**
  45041. * Gets the current postprocess manager
  45042. */
  45043. postProcessManager: PostProcessManager;
  45044. /**
  45045. * Gets or sets a boolean indicating if render targets are enabled on this scene
  45046. */
  45047. renderTargetsEnabled: boolean;
  45048. /**
  45049. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  45050. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  45051. */
  45052. dumpNextRenderTargets: boolean;
  45053. /**
  45054. * The list of user defined render targets added to the scene
  45055. */
  45056. customRenderTargets: RenderTargetTexture[];
  45057. /**
  45058. * Defines if texture loading must be delayed
  45059. * If true, textures will only be loaded when they need to be rendered
  45060. */
  45061. useDelayedTextureLoading: boolean;
  45062. /**
  45063. * Gets the list of meshes imported to the scene through SceneLoader
  45064. */
  45065. importedMeshesFiles: String[];
  45066. /**
  45067. * Gets or sets a boolean indicating if probes are enabled on this scene
  45068. */
  45069. probesEnabled: boolean;
  45070. /**
  45071. * Gets or sets the current offline provider to use to store scene data
  45072. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  45073. */
  45074. offlineProvider: IOfflineProvider;
  45075. /**
  45076. * Gets or sets the action manager associated with the scene
  45077. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  45078. */
  45079. actionManager: AbstractActionManager;
  45080. private _meshesForIntersections;
  45081. /**
  45082. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  45083. */
  45084. proceduralTexturesEnabled: boolean;
  45085. private _engine;
  45086. private _totalVertices;
  45087. /** @hidden */
  45088. _activeIndices: PerfCounter;
  45089. /** @hidden */
  45090. _activeParticles: PerfCounter;
  45091. /** @hidden */
  45092. _activeBones: PerfCounter;
  45093. private _animationRatio;
  45094. /** @hidden */
  45095. _animationTimeLast: number;
  45096. /** @hidden */
  45097. _animationTime: number;
  45098. /**
  45099. * Gets or sets a general scale for animation speed
  45100. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  45101. */
  45102. animationTimeScale: number;
  45103. /** @hidden */
  45104. _cachedMaterial: Nullable<Material>;
  45105. /** @hidden */
  45106. _cachedEffect: Nullable<Effect>;
  45107. /** @hidden */
  45108. _cachedVisibility: Nullable<number>;
  45109. private _renderId;
  45110. private _frameId;
  45111. private _executeWhenReadyTimeoutId;
  45112. private _intermediateRendering;
  45113. private _viewUpdateFlag;
  45114. private _projectionUpdateFlag;
  45115. /** @hidden */
  45116. _toBeDisposed: Nullable<IDisposable>[];
  45117. private _activeRequests;
  45118. /** @hidden */
  45119. _pendingData: any[];
  45120. private _isDisposed;
  45121. /**
  45122. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  45123. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  45124. */
  45125. dispatchAllSubMeshesOfActiveMeshes: boolean;
  45126. private _activeMeshes;
  45127. private _processedMaterials;
  45128. private _renderTargets;
  45129. /** @hidden */
  45130. _activeParticleSystems: SmartArray<IParticleSystem>;
  45131. private _activeSkeletons;
  45132. private _softwareSkinnedMeshes;
  45133. private _renderingManager;
  45134. /** @hidden */
  45135. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  45136. private _transformMatrix;
  45137. private _sceneUbo;
  45138. /** @hidden */
  45139. _viewMatrix: Matrix;
  45140. private _projectionMatrix;
  45141. /** @hidden */
  45142. _forcedViewPosition: Nullable<Vector3>;
  45143. /** @hidden */
  45144. _frustumPlanes: Plane[];
  45145. /**
  45146. * Gets the list of frustum planes (built from the active camera)
  45147. */
  45148. get frustumPlanes(): Plane[];
  45149. /**
  45150. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  45151. * This is useful if there are more lights that the maximum simulteanous authorized
  45152. */
  45153. requireLightSorting: boolean;
  45154. /** @hidden */
  45155. readonly useMaterialMeshMap: boolean;
  45156. /** @hidden */
  45157. readonly useClonedMeshMap: boolean;
  45158. private _externalData;
  45159. private _uid;
  45160. /**
  45161. * @hidden
  45162. * Backing store of defined scene components.
  45163. */
  45164. _components: ISceneComponent[];
  45165. /**
  45166. * @hidden
  45167. * Backing store of defined scene components.
  45168. */
  45169. _serializableComponents: ISceneSerializableComponent[];
  45170. /**
  45171. * List of components to register on the next registration step.
  45172. */
  45173. private _transientComponents;
  45174. /**
  45175. * Registers the transient components if needed.
  45176. */
  45177. private _registerTransientComponents;
  45178. /**
  45179. * @hidden
  45180. * Add a component to the scene.
  45181. * Note that the ccomponent could be registered on th next frame if this is called after
  45182. * the register component stage.
  45183. * @param component Defines the component to add to the scene
  45184. */
  45185. _addComponent(component: ISceneComponent): void;
  45186. /**
  45187. * @hidden
  45188. * Gets a component from the scene.
  45189. * @param name defines the name of the component to retrieve
  45190. * @returns the component or null if not present
  45191. */
  45192. _getComponent(name: string): Nullable<ISceneComponent>;
  45193. /**
  45194. * @hidden
  45195. * Defines the actions happening before camera updates.
  45196. */
  45197. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  45198. /**
  45199. * @hidden
  45200. * Defines the actions happening before clear the canvas.
  45201. */
  45202. _beforeClearStage: Stage<SimpleStageAction>;
  45203. /**
  45204. * @hidden
  45205. * Defines the actions when collecting render targets for the frame.
  45206. */
  45207. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  45208. /**
  45209. * @hidden
  45210. * Defines the actions happening for one camera in the frame.
  45211. */
  45212. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  45213. /**
  45214. * @hidden
  45215. * Defines the actions happening during the per mesh ready checks.
  45216. */
  45217. _isReadyForMeshStage: Stage<MeshStageAction>;
  45218. /**
  45219. * @hidden
  45220. * Defines the actions happening before evaluate active mesh checks.
  45221. */
  45222. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  45223. /**
  45224. * @hidden
  45225. * Defines the actions happening during the evaluate sub mesh checks.
  45226. */
  45227. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  45228. /**
  45229. * @hidden
  45230. * Defines the actions happening during the active mesh stage.
  45231. */
  45232. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  45233. /**
  45234. * @hidden
  45235. * Defines the actions happening during the per camera render target step.
  45236. */
  45237. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  45238. /**
  45239. * @hidden
  45240. * Defines the actions happening just before the active camera is drawing.
  45241. */
  45242. _beforeCameraDrawStage: Stage<CameraStageAction>;
  45243. /**
  45244. * @hidden
  45245. * Defines the actions happening just before a render target is drawing.
  45246. */
  45247. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  45248. /**
  45249. * @hidden
  45250. * Defines the actions happening just before a rendering group is drawing.
  45251. */
  45252. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  45253. /**
  45254. * @hidden
  45255. * Defines the actions happening just before a mesh is drawing.
  45256. */
  45257. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  45258. /**
  45259. * @hidden
  45260. * Defines the actions happening just after a mesh has been drawn.
  45261. */
  45262. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  45263. /**
  45264. * @hidden
  45265. * Defines the actions happening just after a rendering group has been drawn.
  45266. */
  45267. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  45268. /**
  45269. * @hidden
  45270. * Defines the actions happening just after the active camera has been drawn.
  45271. */
  45272. _afterCameraDrawStage: Stage<CameraStageAction>;
  45273. /**
  45274. * @hidden
  45275. * Defines the actions happening just after a render target has been drawn.
  45276. */
  45277. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  45278. /**
  45279. * @hidden
  45280. * Defines the actions happening just after rendering all cameras and computing intersections.
  45281. */
  45282. _afterRenderStage: Stage<SimpleStageAction>;
  45283. /**
  45284. * @hidden
  45285. * Defines the actions happening when a pointer move event happens.
  45286. */
  45287. _pointerMoveStage: Stage<PointerMoveStageAction>;
  45288. /**
  45289. * @hidden
  45290. * Defines the actions happening when a pointer down event happens.
  45291. */
  45292. _pointerDownStage: Stage<PointerUpDownStageAction>;
  45293. /**
  45294. * @hidden
  45295. * Defines the actions happening when a pointer up event happens.
  45296. */
  45297. _pointerUpStage: Stage<PointerUpDownStageAction>;
  45298. /**
  45299. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  45300. */
  45301. private geometriesByUniqueId;
  45302. /**
  45303. * Creates a new Scene
  45304. * @param engine defines the engine to use to render this scene
  45305. * @param options defines the scene options
  45306. */
  45307. constructor(engine: Engine, options?: SceneOptions);
  45308. /**
  45309. * Gets a string identifying the name of the class
  45310. * @returns "Scene" string
  45311. */
  45312. getClassName(): string;
  45313. private _defaultMeshCandidates;
  45314. /**
  45315. * @hidden
  45316. */
  45317. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45318. private _defaultSubMeshCandidates;
  45319. /**
  45320. * @hidden
  45321. */
  45322. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45323. /**
  45324. * Sets the default candidate providers for the scene.
  45325. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  45326. * and getCollidingSubMeshCandidates to their default function
  45327. */
  45328. setDefaultCandidateProviders(): void;
  45329. /**
  45330. * Gets the mesh that is currently under the pointer
  45331. */
  45332. get meshUnderPointer(): Nullable<AbstractMesh>;
  45333. /**
  45334. * Gets or sets the current on-screen X position of the pointer
  45335. */
  45336. get pointerX(): number;
  45337. set pointerX(value: number);
  45338. /**
  45339. * Gets or sets the current on-screen Y position of the pointer
  45340. */
  45341. get pointerY(): number;
  45342. set pointerY(value: number);
  45343. /**
  45344. * Gets the cached material (ie. the latest rendered one)
  45345. * @returns the cached material
  45346. */
  45347. getCachedMaterial(): Nullable<Material>;
  45348. /**
  45349. * Gets the cached effect (ie. the latest rendered one)
  45350. * @returns the cached effect
  45351. */
  45352. getCachedEffect(): Nullable<Effect>;
  45353. /**
  45354. * Gets the cached visibility state (ie. the latest rendered one)
  45355. * @returns the cached visibility state
  45356. */
  45357. getCachedVisibility(): Nullable<number>;
  45358. /**
  45359. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  45360. * @param material defines the current material
  45361. * @param effect defines the current effect
  45362. * @param visibility defines the current visibility state
  45363. * @returns true if one parameter is not cached
  45364. */
  45365. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  45366. /**
  45367. * Gets the engine associated with the scene
  45368. * @returns an Engine
  45369. */
  45370. getEngine(): Engine;
  45371. /**
  45372. * Gets the total number of vertices rendered per frame
  45373. * @returns the total number of vertices rendered per frame
  45374. */
  45375. getTotalVertices(): number;
  45376. /**
  45377. * Gets the performance counter for total vertices
  45378. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45379. */
  45380. get totalVerticesPerfCounter(): PerfCounter;
  45381. /**
  45382. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  45383. * @returns the total number of active indices rendered per frame
  45384. */
  45385. getActiveIndices(): number;
  45386. /**
  45387. * Gets the performance counter for active indices
  45388. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45389. */
  45390. get totalActiveIndicesPerfCounter(): PerfCounter;
  45391. /**
  45392. * Gets the total number of active particles rendered per frame
  45393. * @returns the total number of active particles rendered per frame
  45394. */
  45395. getActiveParticles(): number;
  45396. /**
  45397. * Gets the performance counter for active particles
  45398. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45399. */
  45400. get activeParticlesPerfCounter(): PerfCounter;
  45401. /**
  45402. * Gets the total number of active bones rendered per frame
  45403. * @returns the total number of active bones rendered per frame
  45404. */
  45405. getActiveBones(): number;
  45406. /**
  45407. * Gets the performance counter for active bones
  45408. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45409. */
  45410. get activeBonesPerfCounter(): PerfCounter;
  45411. /**
  45412. * Gets the array of active meshes
  45413. * @returns an array of AbstractMesh
  45414. */
  45415. getActiveMeshes(): SmartArray<AbstractMesh>;
  45416. /**
  45417. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  45418. * @returns a number
  45419. */
  45420. getAnimationRatio(): number;
  45421. /**
  45422. * Gets an unique Id for the current render phase
  45423. * @returns a number
  45424. */
  45425. getRenderId(): number;
  45426. /**
  45427. * Gets an unique Id for the current frame
  45428. * @returns a number
  45429. */
  45430. getFrameId(): number;
  45431. /** Call this function if you want to manually increment the render Id*/
  45432. incrementRenderId(): void;
  45433. private _createUbo;
  45434. /**
  45435. * Use this method to simulate a pointer move on a mesh
  45436. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45437. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45438. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45439. * @returns the current scene
  45440. */
  45441. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  45442. /**
  45443. * Use this method to simulate a pointer down on a mesh
  45444. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45445. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45446. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45447. * @returns the current scene
  45448. */
  45449. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  45450. /**
  45451. * Use this method to simulate a pointer up on a mesh
  45452. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45453. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45454. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45455. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  45456. * @returns the current scene
  45457. */
  45458. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  45459. /**
  45460. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  45461. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  45462. * @returns true if the pointer was captured
  45463. */
  45464. isPointerCaptured(pointerId?: number): boolean;
  45465. /**
  45466. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  45467. * @param attachUp defines if you want to attach events to pointerup
  45468. * @param attachDown defines if you want to attach events to pointerdown
  45469. * @param attachMove defines if you want to attach events to pointermove
  45470. */
  45471. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  45472. /** Detaches all event handlers*/
  45473. detachControl(): void;
  45474. /**
  45475. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  45476. * Delay loaded resources are not taking in account
  45477. * @return true if all required resources are ready
  45478. */
  45479. isReady(): boolean;
  45480. /** Resets all cached information relative to material (including effect and visibility) */
  45481. resetCachedMaterial(): void;
  45482. /**
  45483. * Registers a function to be called before every frame render
  45484. * @param func defines the function to register
  45485. */
  45486. registerBeforeRender(func: () => void): void;
  45487. /**
  45488. * Unregisters a function called before every frame render
  45489. * @param func defines the function to unregister
  45490. */
  45491. unregisterBeforeRender(func: () => void): void;
  45492. /**
  45493. * Registers a function to be called after every frame render
  45494. * @param func defines the function to register
  45495. */
  45496. registerAfterRender(func: () => void): void;
  45497. /**
  45498. * Unregisters a function called after every frame render
  45499. * @param func defines the function to unregister
  45500. */
  45501. unregisterAfterRender(func: () => void): void;
  45502. private _executeOnceBeforeRender;
  45503. /**
  45504. * The provided function will run before render once and will be disposed afterwards.
  45505. * A timeout delay can be provided so that the function will be executed in N ms.
  45506. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  45507. * @param func The function to be executed.
  45508. * @param timeout optional delay in ms
  45509. */
  45510. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  45511. /** @hidden */
  45512. _addPendingData(data: any): void;
  45513. /** @hidden */
  45514. _removePendingData(data: any): void;
  45515. /**
  45516. * Returns the number of items waiting to be loaded
  45517. * @returns the number of items waiting to be loaded
  45518. */
  45519. getWaitingItemsCount(): number;
  45520. /**
  45521. * Returns a boolean indicating if the scene is still loading data
  45522. */
  45523. get isLoading(): boolean;
  45524. /**
  45525. * Registers a function to be executed when the scene is ready
  45526. * @param {Function} func - the function to be executed
  45527. */
  45528. executeWhenReady(func: () => void): void;
  45529. /**
  45530. * Returns a promise that resolves when the scene is ready
  45531. * @returns A promise that resolves when the scene is ready
  45532. */
  45533. whenReadyAsync(): Promise<void>;
  45534. /** @hidden */
  45535. _checkIsReady(): void;
  45536. /**
  45537. * Gets all animatable attached to the scene
  45538. */
  45539. get animatables(): Animatable[];
  45540. /**
  45541. * Resets the last animation time frame.
  45542. * Useful to override when animations start running when loading a scene for the first time.
  45543. */
  45544. resetLastAnimationTimeFrame(): void;
  45545. /**
  45546. * Gets the current view matrix
  45547. * @returns a Matrix
  45548. */
  45549. getViewMatrix(): Matrix;
  45550. /**
  45551. * Gets the current projection matrix
  45552. * @returns a Matrix
  45553. */
  45554. getProjectionMatrix(): Matrix;
  45555. /**
  45556. * Gets the current transform matrix
  45557. * @returns a Matrix made of View * Projection
  45558. */
  45559. getTransformMatrix(): Matrix;
  45560. /**
  45561. * Sets the current transform matrix
  45562. * @param viewL defines the View matrix to use
  45563. * @param projectionL defines the Projection matrix to use
  45564. * @param viewR defines the right View matrix to use (if provided)
  45565. * @param projectionR defines the right Projection matrix to use (if provided)
  45566. */
  45567. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  45568. /**
  45569. * Gets the uniform buffer used to store scene data
  45570. * @returns a UniformBuffer
  45571. */
  45572. getSceneUniformBuffer(): UniformBuffer;
  45573. /**
  45574. * Gets an unique (relatively to the current scene) Id
  45575. * @returns an unique number for the scene
  45576. */
  45577. getUniqueId(): number;
  45578. /**
  45579. * Add a mesh to the list of scene's meshes
  45580. * @param newMesh defines the mesh to add
  45581. * @param recursive if all child meshes should also be added to the scene
  45582. */
  45583. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  45584. /**
  45585. * Remove a mesh for the list of scene's meshes
  45586. * @param toRemove defines the mesh to remove
  45587. * @param recursive if all child meshes should also be removed from the scene
  45588. * @returns the index where the mesh was in the mesh list
  45589. */
  45590. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  45591. /**
  45592. * Add a transform node to the list of scene's transform nodes
  45593. * @param newTransformNode defines the transform node to add
  45594. */
  45595. addTransformNode(newTransformNode: TransformNode): void;
  45596. /**
  45597. * Remove a transform node for the list of scene's transform nodes
  45598. * @param toRemove defines the transform node to remove
  45599. * @returns the index where the transform node was in the transform node list
  45600. */
  45601. removeTransformNode(toRemove: TransformNode): number;
  45602. /**
  45603. * Remove a skeleton for the list of scene's skeletons
  45604. * @param toRemove defines the skeleton to remove
  45605. * @returns the index where the skeleton was in the skeleton list
  45606. */
  45607. removeSkeleton(toRemove: Skeleton): number;
  45608. /**
  45609. * Remove a morph target for the list of scene's morph targets
  45610. * @param toRemove defines the morph target to remove
  45611. * @returns the index where the morph target was in the morph target list
  45612. */
  45613. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  45614. /**
  45615. * Remove a light for the list of scene's lights
  45616. * @param toRemove defines the light to remove
  45617. * @returns the index where the light was in the light list
  45618. */
  45619. removeLight(toRemove: Light): number;
  45620. /**
  45621. * Remove a camera for the list of scene's cameras
  45622. * @param toRemove defines the camera to remove
  45623. * @returns the index where the camera was in the camera list
  45624. */
  45625. removeCamera(toRemove: Camera): number;
  45626. /**
  45627. * Remove a particle system for the list of scene's particle systems
  45628. * @param toRemove defines the particle system to remove
  45629. * @returns the index where the particle system was in the particle system list
  45630. */
  45631. removeParticleSystem(toRemove: IParticleSystem): number;
  45632. /**
  45633. * Remove a animation for the list of scene's animations
  45634. * @param toRemove defines the animation to remove
  45635. * @returns the index where the animation was in the animation list
  45636. */
  45637. removeAnimation(toRemove: Animation): number;
  45638. /**
  45639. * Will stop the animation of the given target
  45640. * @param target - the target
  45641. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  45642. * @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)
  45643. */
  45644. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  45645. /**
  45646. * Removes the given animation group from this scene.
  45647. * @param toRemove The animation group to remove
  45648. * @returns The index of the removed animation group
  45649. */
  45650. removeAnimationGroup(toRemove: AnimationGroup): number;
  45651. /**
  45652. * Removes the given multi-material from this scene.
  45653. * @param toRemove The multi-material to remove
  45654. * @returns The index of the removed multi-material
  45655. */
  45656. removeMultiMaterial(toRemove: MultiMaterial): number;
  45657. /**
  45658. * Removes the given material from this scene.
  45659. * @param toRemove The material to remove
  45660. * @returns The index of the removed material
  45661. */
  45662. removeMaterial(toRemove: Material): number;
  45663. /**
  45664. * Removes the given action manager from this scene.
  45665. * @param toRemove The action manager to remove
  45666. * @returns The index of the removed action manager
  45667. */
  45668. removeActionManager(toRemove: AbstractActionManager): number;
  45669. /**
  45670. * Removes the given texture from this scene.
  45671. * @param toRemove The texture to remove
  45672. * @returns The index of the removed texture
  45673. */
  45674. removeTexture(toRemove: BaseTexture): number;
  45675. /**
  45676. * Adds the given light to this scene
  45677. * @param newLight The light to add
  45678. */
  45679. addLight(newLight: Light): void;
  45680. /**
  45681. * Sorts the list list based on light priorities
  45682. */
  45683. sortLightsByPriority(): void;
  45684. /**
  45685. * Adds the given camera to this scene
  45686. * @param newCamera The camera to add
  45687. */
  45688. addCamera(newCamera: Camera): void;
  45689. /**
  45690. * Adds the given skeleton to this scene
  45691. * @param newSkeleton The skeleton to add
  45692. */
  45693. addSkeleton(newSkeleton: Skeleton): void;
  45694. /**
  45695. * Adds the given particle system to this scene
  45696. * @param newParticleSystem The particle system to add
  45697. */
  45698. addParticleSystem(newParticleSystem: IParticleSystem): void;
  45699. /**
  45700. * Adds the given animation to this scene
  45701. * @param newAnimation The animation to add
  45702. */
  45703. addAnimation(newAnimation: Animation): void;
  45704. /**
  45705. * Adds the given animation group to this scene.
  45706. * @param newAnimationGroup The animation group to add
  45707. */
  45708. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  45709. /**
  45710. * Adds the given multi-material to this scene
  45711. * @param newMultiMaterial The multi-material to add
  45712. */
  45713. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  45714. /**
  45715. * Adds the given material to this scene
  45716. * @param newMaterial The material to add
  45717. */
  45718. addMaterial(newMaterial: Material): void;
  45719. /**
  45720. * Adds the given morph target to this scene
  45721. * @param newMorphTargetManager The morph target to add
  45722. */
  45723. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  45724. /**
  45725. * Adds the given geometry to this scene
  45726. * @param newGeometry The geometry to add
  45727. */
  45728. addGeometry(newGeometry: Geometry): void;
  45729. /**
  45730. * Adds the given action manager to this scene
  45731. * @param newActionManager The action manager to add
  45732. */
  45733. addActionManager(newActionManager: AbstractActionManager): void;
  45734. /**
  45735. * Adds the given texture to this scene.
  45736. * @param newTexture The texture to add
  45737. */
  45738. addTexture(newTexture: BaseTexture): void;
  45739. /**
  45740. * Switch active camera
  45741. * @param newCamera defines the new active camera
  45742. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  45743. */
  45744. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  45745. /**
  45746. * sets the active camera of the scene using its ID
  45747. * @param id defines the camera's ID
  45748. * @return the new active camera or null if none found.
  45749. */
  45750. setActiveCameraByID(id: string): Nullable<Camera>;
  45751. /**
  45752. * sets the active camera of the scene using its name
  45753. * @param name defines the camera's name
  45754. * @returns the new active camera or null if none found.
  45755. */
  45756. setActiveCameraByName(name: string): Nullable<Camera>;
  45757. /**
  45758. * get an animation group using its name
  45759. * @param name defines the material's name
  45760. * @return the animation group or null if none found.
  45761. */
  45762. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  45763. /**
  45764. * Get a material using its unique id
  45765. * @param uniqueId defines the material's unique id
  45766. * @return the material or null if none found.
  45767. */
  45768. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  45769. /**
  45770. * get a material using its id
  45771. * @param id defines the material's ID
  45772. * @return the material or null if none found.
  45773. */
  45774. getMaterialByID(id: string): Nullable<Material>;
  45775. /**
  45776. * Gets a the last added material using a given id
  45777. * @param id defines the material's ID
  45778. * @return the last material with the given id or null if none found.
  45779. */
  45780. getLastMaterialByID(id: string): Nullable<Material>;
  45781. /**
  45782. * Gets a material using its name
  45783. * @param name defines the material's name
  45784. * @return the material or null if none found.
  45785. */
  45786. getMaterialByName(name: string): Nullable<Material>;
  45787. /**
  45788. * Get a texture using its unique id
  45789. * @param uniqueId defines the texture's unique id
  45790. * @return the texture or null if none found.
  45791. */
  45792. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  45793. /**
  45794. * Gets a camera using its id
  45795. * @param id defines the id to look for
  45796. * @returns the camera or null if not found
  45797. */
  45798. getCameraByID(id: string): Nullable<Camera>;
  45799. /**
  45800. * Gets a camera using its unique id
  45801. * @param uniqueId defines the unique id to look for
  45802. * @returns the camera or null if not found
  45803. */
  45804. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  45805. /**
  45806. * Gets a camera using its name
  45807. * @param name defines the camera's name
  45808. * @return the camera or null if none found.
  45809. */
  45810. getCameraByName(name: string): Nullable<Camera>;
  45811. /**
  45812. * Gets a bone using its id
  45813. * @param id defines the bone's id
  45814. * @return the bone or null if not found
  45815. */
  45816. getBoneByID(id: string): Nullable<Bone>;
  45817. /**
  45818. * Gets a bone using its id
  45819. * @param name defines the bone's name
  45820. * @return the bone or null if not found
  45821. */
  45822. getBoneByName(name: string): Nullable<Bone>;
  45823. /**
  45824. * Gets a light node using its name
  45825. * @param name defines the the light's name
  45826. * @return the light or null if none found.
  45827. */
  45828. getLightByName(name: string): Nullable<Light>;
  45829. /**
  45830. * Gets a light node using its id
  45831. * @param id defines the light's id
  45832. * @return the light or null if none found.
  45833. */
  45834. getLightByID(id: string): Nullable<Light>;
  45835. /**
  45836. * Gets a light node using its scene-generated unique ID
  45837. * @param uniqueId defines the light's unique id
  45838. * @return the light or null if none found.
  45839. */
  45840. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  45841. /**
  45842. * Gets a particle system by id
  45843. * @param id defines the particle system id
  45844. * @return the corresponding system or null if none found
  45845. */
  45846. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  45847. /**
  45848. * Gets a geometry using its ID
  45849. * @param id defines the geometry's id
  45850. * @return the geometry or null if none found.
  45851. */
  45852. getGeometryByID(id: string): Nullable<Geometry>;
  45853. private _getGeometryByUniqueID;
  45854. /**
  45855. * Add a new geometry to this scene
  45856. * @param geometry defines the geometry to be added to the scene.
  45857. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  45858. * @return a boolean defining if the geometry was added or not
  45859. */
  45860. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  45861. /**
  45862. * Removes an existing geometry
  45863. * @param geometry defines the geometry to be removed from the scene
  45864. * @return a boolean defining if the geometry was removed or not
  45865. */
  45866. removeGeometry(geometry: Geometry): boolean;
  45867. /**
  45868. * Gets the list of geometries attached to the scene
  45869. * @returns an array of Geometry
  45870. */
  45871. getGeometries(): Geometry[];
  45872. /**
  45873. * Gets the first added mesh found of a given ID
  45874. * @param id defines the id to search for
  45875. * @return the mesh found or null if not found at all
  45876. */
  45877. getMeshByID(id: string): Nullable<AbstractMesh>;
  45878. /**
  45879. * Gets a list of meshes using their id
  45880. * @param id defines the id to search for
  45881. * @returns a list of meshes
  45882. */
  45883. getMeshesByID(id: string): Array<AbstractMesh>;
  45884. /**
  45885. * Gets the first added transform node found of a given ID
  45886. * @param id defines the id to search for
  45887. * @return the found transform node or null if not found at all.
  45888. */
  45889. getTransformNodeByID(id: string): Nullable<TransformNode>;
  45890. /**
  45891. * Gets a transform node with its auto-generated unique id
  45892. * @param uniqueId efines the unique id to search for
  45893. * @return the found transform node or null if not found at all.
  45894. */
  45895. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  45896. /**
  45897. * Gets a list of transform nodes using their id
  45898. * @param id defines the id to search for
  45899. * @returns a list of transform nodes
  45900. */
  45901. getTransformNodesByID(id: string): Array<TransformNode>;
  45902. /**
  45903. * Gets a mesh with its auto-generated unique id
  45904. * @param uniqueId defines the unique id to search for
  45905. * @return the found mesh or null if not found at all.
  45906. */
  45907. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  45908. /**
  45909. * Gets a the last added mesh using a given id
  45910. * @param id defines the id to search for
  45911. * @return the found mesh or null if not found at all.
  45912. */
  45913. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  45914. /**
  45915. * Gets a the last added node (Mesh, Camera, Light) using a given id
  45916. * @param id defines the id to search for
  45917. * @return the found node or null if not found at all
  45918. */
  45919. getLastEntryByID(id: string): Nullable<Node>;
  45920. /**
  45921. * Gets a node (Mesh, Camera, Light) using a given id
  45922. * @param id defines the id to search for
  45923. * @return the found node or null if not found at all
  45924. */
  45925. getNodeByID(id: string): Nullable<Node>;
  45926. /**
  45927. * Gets a node (Mesh, Camera, Light) using a given name
  45928. * @param name defines the name to search for
  45929. * @return the found node or null if not found at all.
  45930. */
  45931. getNodeByName(name: string): Nullable<Node>;
  45932. /**
  45933. * Gets a mesh using a given name
  45934. * @param name defines the name to search for
  45935. * @return the found mesh or null if not found at all.
  45936. */
  45937. getMeshByName(name: string): Nullable<AbstractMesh>;
  45938. /**
  45939. * Gets a transform node using a given name
  45940. * @param name defines the name to search for
  45941. * @return the found transform node or null if not found at all.
  45942. */
  45943. getTransformNodeByName(name: string): Nullable<TransformNode>;
  45944. /**
  45945. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  45946. * @param id defines the id to search for
  45947. * @return the found skeleton or null if not found at all.
  45948. */
  45949. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  45950. /**
  45951. * Gets a skeleton using a given auto generated unique id
  45952. * @param uniqueId defines the unique id to search for
  45953. * @return the found skeleton or null if not found at all.
  45954. */
  45955. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  45956. /**
  45957. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  45958. * @param id defines the id to search for
  45959. * @return the found skeleton or null if not found at all.
  45960. */
  45961. getSkeletonById(id: string): Nullable<Skeleton>;
  45962. /**
  45963. * Gets a skeleton using a given name
  45964. * @param name defines the name to search for
  45965. * @return the found skeleton or null if not found at all.
  45966. */
  45967. getSkeletonByName(name: string): Nullable<Skeleton>;
  45968. /**
  45969. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  45970. * @param id defines the id to search for
  45971. * @return the found morph target manager or null if not found at all.
  45972. */
  45973. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  45974. /**
  45975. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  45976. * @param id defines the id to search for
  45977. * @return the found morph target or null if not found at all.
  45978. */
  45979. getMorphTargetById(id: string): Nullable<MorphTarget>;
  45980. /**
  45981. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  45982. * @param name defines the name to search for
  45983. * @return the found morph target or null if not found at all.
  45984. */
  45985. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  45986. /**
  45987. * Gets a post process using a given name (if many are found, this function will pick the first one)
  45988. * @param name defines the name to search for
  45989. * @return the found post process or null if not found at all.
  45990. */
  45991. getPostProcessByName(name: string): Nullable<PostProcess>;
  45992. /**
  45993. * Gets a boolean indicating if the given mesh is active
  45994. * @param mesh defines the mesh to look for
  45995. * @returns true if the mesh is in the active list
  45996. */
  45997. isActiveMesh(mesh: AbstractMesh): boolean;
  45998. /**
  45999. * Return a unique id as a string which can serve as an identifier for the scene
  46000. */
  46001. get uid(): string;
  46002. /**
  46003. * Add an externaly attached data from its key.
  46004. * This method call will fail and return false, if such key already exists.
  46005. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  46006. * @param key the unique key that identifies the data
  46007. * @param data the data object to associate to the key for this Engine instance
  46008. * @return true if no such key were already present and the data was added successfully, false otherwise
  46009. */
  46010. addExternalData<T>(key: string, data: T): boolean;
  46011. /**
  46012. * Get an externaly attached data from its key
  46013. * @param key the unique key that identifies the data
  46014. * @return the associated data, if present (can be null), or undefined if not present
  46015. */
  46016. getExternalData<T>(key: string): Nullable<T>;
  46017. /**
  46018. * Get an externaly attached data from its key, create it using a factory if it's not already present
  46019. * @param key the unique key that identifies the data
  46020. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  46021. * @return the associated data, can be null if the factory returned null.
  46022. */
  46023. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  46024. /**
  46025. * Remove an externaly attached data from the Engine instance
  46026. * @param key the unique key that identifies the data
  46027. * @return true if the data was successfully removed, false if it doesn't exist
  46028. */
  46029. removeExternalData(key: string): boolean;
  46030. private _evaluateSubMesh;
  46031. /**
  46032. * Clear the processed materials smart array preventing retention point in material dispose.
  46033. */
  46034. freeProcessedMaterials(): void;
  46035. private _preventFreeActiveMeshesAndRenderingGroups;
  46036. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  46037. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  46038. * when disposing several meshes in a row or a hierarchy of meshes.
  46039. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  46040. */
  46041. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  46042. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  46043. /**
  46044. * Clear the active meshes smart array preventing retention point in mesh dispose.
  46045. */
  46046. freeActiveMeshes(): void;
  46047. /**
  46048. * Clear the info related to rendering groups preventing retention points during dispose.
  46049. */
  46050. freeRenderingGroups(): void;
  46051. /** @hidden */
  46052. _isInIntermediateRendering(): boolean;
  46053. /**
  46054. * Lambda returning the list of potentially active meshes.
  46055. */
  46056. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  46057. /**
  46058. * Lambda returning the list of potentially active sub meshes.
  46059. */
  46060. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  46061. /**
  46062. * Lambda returning the list of potentially intersecting sub meshes.
  46063. */
  46064. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  46065. /**
  46066. * Lambda returning the list of potentially colliding sub meshes.
  46067. */
  46068. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  46069. private _activeMeshesFrozen;
  46070. private _skipEvaluateActiveMeshesCompletely;
  46071. /**
  46072. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  46073. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  46074. * @param onSuccess optional success callback
  46075. * @param onError optional error callback
  46076. * @returns the current scene
  46077. */
  46078. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  46079. /**
  46080. * Use this function to restart evaluating active meshes on every frame
  46081. * @returns the current scene
  46082. */
  46083. unfreezeActiveMeshes(): Scene;
  46084. private _evaluateActiveMeshes;
  46085. private _activeMesh;
  46086. /**
  46087. * Update the transform matrix to update from the current active camera
  46088. * @param force defines a boolean used to force the update even if cache is up to date
  46089. */
  46090. updateTransformMatrix(force?: boolean): void;
  46091. private _bindFrameBuffer;
  46092. /** @hidden */
  46093. _allowPostProcessClearColor: boolean;
  46094. /** @hidden */
  46095. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  46096. private _processSubCameras;
  46097. private _checkIntersections;
  46098. /** @hidden */
  46099. _advancePhysicsEngineStep(step: number): void;
  46100. /**
  46101. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  46102. */
  46103. getDeterministicFrameTime: () => number;
  46104. /** @hidden */
  46105. _animate(): void;
  46106. /** Execute all animations (for a frame) */
  46107. animate(): void;
  46108. /**
  46109. * Render the scene
  46110. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  46111. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  46112. */
  46113. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  46114. /**
  46115. * Freeze all materials
  46116. * A frozen material will not be updatable but should be faster to render
  46117. */
  46118. freezeMaterials(): void;
  46119. /**
  46120. * Unfreeze all materials
  46121. * A frozen material will not be updatable but should be faster to render
  46122. */
  46123. unfreezeMaterials(): void;
  46124. /**
  46125. * Releases all held ressources
  46126. */
  46127. dispose(): void;
  46128. /**
  46129. * Gets if the scene is already disposed
  46130. */
  46131. get isDisposed(): boolean;
  46132. /**
  46133. * Call this function to reduce memory footprint of the scene.
  46134. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  46135. */
  46136. clearCachedVertexData(): void;
  46137. /**
  46138. * This function will remove the local cached buffer data from texture.
  46139. * It will save memory but will prevent the texture from being rebuilt
  46140. */
  46141. cleanCachedTextureBuffer(): void;
  46142. /**
  46143. * Get the world extend vectors with an optional filter
  46144. *
  46145. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  46146. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  46147. */
  46148. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  46149. min: Vector3;
  46150. max: Vector3;
  46151. };
  46152. /**
  46153. * Creates a ray that can be used to pick in the scene
  46154. * @param x defines the x coordinate of the origin (on-screen)
  46155. * @param y defines the y coordinate of the origin (on-screen)
  46156. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  46157. * @param camera defines the camera to use for the picking
  46158. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  46159. * @returns a Ray
  46160. */
  46161. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  46162. /**
  46163. * Creates a ray that can be used to pick in the scene
  46164. * @param x defines the x coordinate of the origin (on-screen)
  46165. * @param y defines the y coordinate of the origin (on-screen)
  46166. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  46167. * @param result defines the ray where to store the picking ray
  46168. * @param camera defines the camera to use for the picking
  46169. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  46170. * @returns the current scene
  46171. */
  46172. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  46173. /**
  46174. * Creates a ray that can be used to pick in the scene
  46175. * @param x defines the x coordinate of the origin (on-screen)
  46176. * @param y defines the y coordinate of the origin (on-screen)
  46177. * @param camera defines the camera to use for the picking
  46178. * @returns a Ray
  46179. */
  46180. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  46181. /**
  46182. * Creates a ray that can be used to pick in the scene
  46183. * @param x defines the x coordinate of the origin (on-screen)
  46184. * @param y defines the y coordinate of the origin (on-screen)
  46185. * @param result defines the ray where to store the picking ray
  46186. * @param camera defines the camera to use for the picking
  46187. * @returns the current scene
  46188. */
  46189. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  46190. /** Launch a ray to try to pick a mesh in the scene
  46191. * @param x position on screen
  46192. * @param y position on screen
  46193. * @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
  46194. * @param fastCheck defines if the first intersection will be used (and not the closest)
  46195. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  46196. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46197. * @returns a PickingInfo
  46198. */
  46199. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  46200. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  46201. * @param x position on screen
  46202. * @param y position on screen
  46203. * @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
  46204. * @param fastCheck defines if the first intersection will be used (and not the closest)
  46205. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  46206. * @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)
  46207. */
  46208. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  46209. /** Use the given ray to pick a mesh in the scene
  46210. * @param ray The ray to use to pick meshes
  46211. * @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
  46212. * @param fastCheck defines if the first intersection will be used (and not the closest)
  46213. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46214. * @returns a PickingInfo
  46215. */
  46216. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  46217. /**
  46218. * Launch a ray to try to pick a mesh in the scene
  46219. * @param x X position on screen
  46220. * @param y Y position on screen
  46221. * @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
  46222. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  46223. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46224. * @returns an array of PickingInfo
  46225. */
  46226. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  46227. /**
  46228. * Launch a ray to try to pick a mesh in the scene
  46229. * @param ray Ray to use
  46230. * @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
  46231. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46232. * @returns an array of PickingInfo
  46233. */
  46234. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  46235. /**
  46236. * Force the value of meshUnderPointer
  46237. * @param mesh defines the mesh to use
  46238. * @param pointerId optional pointer id when using more than one pointer
  46239. */
  46240. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  46241. /**
  46242. * Gets the mesh under the pointer
  46243. * @returns a Mesh or null if no mesh is under the pointer
  46244. */
  46245. getPointerOverMesh(): Nullable<AbstractMesh>;
  46246. /** @hidden */
  46247. _rebuildGeometries(): void;
  46248. /** @hidden */
  46249. _rebuildTextures(): void;
  46250. private _getByTags;
  46251. /**
  46252. * Get a list of meshes by tags
  46253. * @param tagsQuery defines the tags query to use
  46254. * @param forEach defines a predicate used to filter results
  46255. * @returns an array of Mesh
  46256. */
  46257. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  46258. /**
  46259. * Get a list of cameras by tags
  46260. * @param tagsQuery defines the tags query to use
  46261. * @param forEach defines a predicate used to filter results
  46262. * @returns an array of Camera
  46263. */
  46264. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  46265. /**
  46266. * Get a list of lights by tags
  46267. * @param tagsQuery defines the tags query to use
  46268. * @param forEach defines a predicate used to filter results
  46269. * @returns an array of Light
  46270. */
  46271. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  46272. /**
  46273. * Get a list of materials by tags
  46274. * @param tagsQuery defines the tags query to use
  46275. * @param forEach defines a predicate used to filter results
  46276. * @returns an array of Material
  46277. */
  46278. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  46279. /**
  46280. * Get a list of transform nodes by tags
  46281. * @param tagsQuery defines the tags query to use
  46282. * @param forEach defines a predicate used to filter results
  46283. * @returns an array of TransformNode
  46284. */
  46285. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  46286. /**
  46287. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  46288. * This allowed control for front to back rendering or reversly depending of the special needs.
  46289. *
  46290. * @param renderingGroupId The rendering group id corresponding to its index
  46291. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  46292. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  46293. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  46294. */
  46295. 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;
  46296. /**
  46297. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  46298. *
  46299. * @param renderingGroupId The rendering group id corresponding to its index
  46300. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  46301. * @param depth Automatically clears depth between groups if true and autoClear is true.
  46302. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  46303. */
  46304. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  46305. /**
  46306. * Gets the current auto clear configuration for one rendering group of the rendering
  46307. * manager.
  46308. * @param index the rendering group index to get the information for
  46309. * @returns The auto clear setup for the requested rendering group
  46310. */
  46311. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  46312. private _blockMaterialDirtyMechanism;
  46313. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  46314. get blockMaterialDirtyMechanism(): boolean;
  46315. set blockMaterialDirtyMechanism(value: boolean);
  46316. /**
  46317. * Will flag all materials as dirty to trigger new shader compilation
  46318. * @param flag defines the flag used to specify which material part must be marked as dirty
  46319. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  46320. */
  46321. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  46322. /** @hidden */
  46323. _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;
  46324. /** @hidden */
  46325. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  46326. /** @hidden */
  46327. _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;
  46328. /** @hidden */
  46329. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  46330. /** @hidden */
  46331. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  46332. /** @hidden */
  46333. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  46334. }
  46335. }
  46336. declare module "babylonjs/assetContainer" {
  46337. import { AbstractScene } from "babylonjs/abstractScene";
  46338. import { Scene } from "babylonjs/scene";
  46339. import { Mesh } from "babylonjs/Meshes/mesh";
  46340. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46341. import { Skeleton } from "babylonjs/Bones/skeleton";
  46342. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  46343. import { Animatable } from "babylonjs/Animations/animatable";
  46344. import { Nullable } from "babylonjs/types";
  46345. import { Node } from "babylonjs/node";
  46346. /**
  46347. * Set of assets to keep when moving a scene into an asset container.
  46348. */
  46349. export class KeepAssets extends AbstractScene {
  46350. }
  46351. /**
  46352. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  46353. */
  46354. export class InstantiatedEntries {
  46355. /**
  46356. * List of new root nodes (eg. nodes with no parent)
  46357. */
  46358. rootNodes: TransformNode[];
  46359. /**
  46360. * List of new skeletons
  46361. */
  46362. skeletons: Skeleton[];
  46363. /**
  46364. * List of new animation groups
  46365. */
  46366. animationGroups: AnimationGroup[];
  46367. }
  46368. /**
  46369. * Container with a set of assets that can be added or removed from a scene.
  46370. */
  46371. export class AssetContainer extends AbstractScene {
  46372. private _wasAddedToScene;
  46373. /**
  46374. * The scene the AssetContainer belongs to.
  46375. */
  46376. scene: Scene;
  46377. /**
  46378. * Instantiates an AssetContainer.
  46379. * @param scene The scene the AssetContainer belongs to.
  46380. */
  46381. constructor(scene: Scene);
  46382. /**
  46383. * Instantiate or clone all meshes and add the new ones to the scene.
  46384. * Skeletons and animation groups will all be cloned
  46385. * @param nameFunction defines an optional function used to get new names for clones
  46386. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  46387. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  46388. */
  46389. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  46390. /**
  46391. * Adds all the assets from the container to the scene.
  46392. */
  46393. addAllToScene(): void;
  46394. /**
  46395. * Removes all the assets in the container from the scene
  46396. */
  46397. removeAllFromScene(): void;
  46398. /**
  46399. * Disposes all the assets in the container
  46400. */
  46401. dispose(): void;
  46402. private _moveAssets;
  46403. /**
  46404. * Removes all the assets contained in the scene and adds them to the container.
  46405. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  46406. */
  46407. moveAllFromScene(keepAssets?: KeepAssets): void;
  46408. /**
  46409. * 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.
  46410. * @returns the root mesh
  46411. */
  46412. createRootMesh(): Mesh;
  46413. /**
  46414. * Merge animations (direct and animation groups) from this asset container into a scene
  46415. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46416. * @param animatables set of animatables to retarget to a node from the scene
  46417. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  46418. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  46419. */
  46420. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  46421. }
  46422. }
  46423. declare module "babylonjs/abstractScene" {
  46424. import { Scene } from "babylonjs/scene";
  46425. import { Nullable } from "babylonjs/types";
  46426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46427. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46428. import { Geometry } from "babylonjs/Meshes/geometry";
  46429. import { Skeleton } from "babylonjs/Bones/skeleton";
  46430. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  46431. import { AssetContainer } from "babylonjs/assetContainer";
  46432. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  46433. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  46434. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46435. import { Material } from "babylonjs/Materials/material";
  46436. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  46437. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  46438. import { Camera } from "babylonjs/Cameras/camera";
  46439. import { Light } from "babylonjs/Lights/light";
  46440. import { Node } from "babylonjs/node";
  46441. import { Animation } from "babylonjs/Animations/animation";
  46442. /**
  46443. * Defines how the parser contract is defined.
  46444. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  46445. */
  46446. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  46447. /**
  46448. * Defines how the individual parser contract is defined.
  46449. * These parser can parse an individual asset
  46450. */
  46451. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  46452. /**
  46453. * Base class of the scene acting as a container for the different elements composing a scene.
  46454. * This class is dynamically extended by the different components of the scene increasing
  46455. * flexibility and reducing coupling
  46456. */
  46457. export abstract class AbstractScene {
  46458. /**
  46459. * Stores the list of available parsers in the application.
  46460. */
  46461. private static _BabylonFileParsers;
  46462. /**
  46463. * Stores the list of available individual parsers in the application.
  46464. */
  46465. private static _IndividualBabylonFileParsers;
  46466. /**
  46467. * Adds a parser in the list of available ones
  46468. * @param name Defines the name of the parser
  46469. * @param parser Defines the parser to add
  46470. */
  46471. static AddParser(name: string, parser: BabylonFileParser): void;
  46472. /**
  46473. * Gets a general parser from the list of avaialble ones
  46474. * @param name Defines the name of the parser
  46475. * @returns the requested parser or null
  46476. */
  46477. static GetParser(name: string): Nullable<BabylonFileParser>;
  46478. /**
  46479. * Adds n individual parser in the list of available ones
  46480. * @param name Defines the name of the parser
  46481. * @param parser Defines the parser to add
  46482. */
  46483. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  46484. /**
  46485. * Gets an individual parser from the list of avaialble ones
  46486. * @param name Defines the name of the parser
  46487. * @returns the requested parser or null
  46488. */
  46489. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  46490. /**
  46491. * Parser json data and populate both a scene and its associated container object
  46492. * @param jsonData Defines the data to parse
  46493. * @param scene Defines the scene to parse the data for
  46494. * @param container Defines the container attached to the parsing sequence
  46495. * @param rootUrl Defines the root url of the data
  46496. */
  46497. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  46498. /**
  46499. * Gets the list of root nodes (ie. nodes with no parent)
  46500. */
  46501. rootNodes: Node[];
  46502. /** All of the cameras added to this scene
  46503. * @see https://doc.babylonjs.com/babylon101/cameras
  46504. */
  46505. cameras: Camera[];
  46506. /**
  46507. * All of the lights added to this scene
  46508. * @see https://doc.babylonjs.com/babylon101/lights
  46509. */
  46510. lights: Light[];
  46511. /**
  46512. * All of the (abstract) meshes added to this scene
  46513. */
  46514. meshes: AbstractMesh[];
  46515. /**
  46516. * The list of skeletons added to the scene
  46517. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  46518. */
  46519. skeletons: Skeleton[];
  46520. /**
  46521. * All of the particle systems added to this scene
  46522. * @see https://doc.babylonjs.com/babylon101/particles
  46523. */
  46524. particleSystems: IParticleSystem[];
  46525. /**
  46526. * Gets a list of Animations associated with the scene
  46527. */
  46528. animations: Animation[];
  46529. /**
  46530. * All of the animation groups added to this scene
  46531. * @see https://doc.babylonjs.com/how_to/group
  46532. */
  46533. animationGroups: AnimationGroup[];
  46534. /**
  46535. * All of the multi-materials added to this scene
  46536. * @see https://doc.babylonjs.com/how_to/multi_materials
  46537. */
  46538. multiMaterials: MultiMaterial[];
  46539. /**
  46540. * All of the materials added to this scene
  46541. * In the context of a Scene, it is not supposed to be modified manually.
  46542. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  46543. * Note also that the order of the Material within the array is not significant and might change.
  46544. * @see https://doc.babylonjs.com/babylon101/materials
  46545. */
  46546. materials: Material[];
  46547. /**
  46548. * The list of morph target managers added to the scene
  46549. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  46550. */
  46551. morphTargetManagers: MorphTargetManager[];
  46552. /**
  46553. * The list of geometries used in the scene.
  46554. */
  46555. geometries: Geometry[];
  46556. /**
  46557. * All of the tranform nodes added to this scene
  46558. * In the context of a Scene, it is not supposed to be modified manually.
  46559. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  46560. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  46561. * @see https://doc.babylonjs.com/how_to/transformnode
  46562. */
  46563. transformNodes: TransformNode[];
  46564. /**
  46565. * ActionManagers available on the scene.
  46566. */
  46567. actionManagers: AbstractActionManager[];
  46568. /**
  46569. * Textures to keep.
  46570. */
  46571. textures: BaseTexture[];
  46572. /** @hidden */
  46573. protected _environmentTexture: Nullable<BaseTexture>;
  46574. /**
  46575. * Texture used in all pbr material as the reflection texture.
  46576. * As in the majority of the scene they are the same (exception for multi room and so on),
  46577. * this is easier to reference from here than from all the materials.
  46578. */
  46579. get environmentTexture(): Nullable<BaseTexture>;
  46580. set environmentTexture(value: Nullable<BaseTexture>);
  46581. /**
  46582. * The list of postprocesses added to the scene
  46583. */
  46584. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  46585. /**
  46586. * @returns all meshes, lights, cameras, transformNodes and bones
  46587. */
  46588. getNodes(): Array<Node>;
  46589. }
  46590. }
  46591. declare module "babylonjs/Audio/Interfaces/ISoundOptions" {
  46592. /**
  46593. * Interface used to define options for Sound class
  46594. */
  46595. export interface ISoundOptions {
  46596. /**
  46597. * Does the sound autoplay once loaded.
  46598. */
  46599. autoplay?: boolean;
  46600. /**
  46601. * Does the sound loop after it finishes playing once.
  46602. */
  46603. loop?: boolean;
  46604. /**
  46605. * Sound's volume
  46606. */
  46607. volume?: number;
  46608. /**
  46609. * Is it a spatial sound?
  46610. */
  46611. spatialSound?: boolean;
  46612. /**
  46613. * Maximum distance to hear that sound
  46614. */
  46615. maxDistance?: number;
  46616. /**
  46617. * Uses user defined attenuation function
  46618. */
  46619. useCustomAttenuation?: boolean;
  46620. /**
  46621. * Define the roll off factor of spatial sounds.
  46622. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46623. */
  46624. rolloffFactor?: number;
  46625. /**
  46626. * Define the reference distance the sound should be heard perfectly.
  46627. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46628. */
  46629. refDistance?: number;
  46630. /**
  46631. * Define the distance attenuation model the sound will follow.
  46632. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46633. */
  46634. distanceModel?: string;
  46635. /**
  46636. * Defines the playback speed (1 by default)
  46637. */
  46638. playbackRate?: number;
  46639. /**
  46640. * Defines if the sound is from a streaming source
  46641. */
  46642. streaming?: boolean;
  46643. /**
  46644. * Defines an optional length (in seconds) inside the sound file
  46645. */
  46646. length?: number;
  46647. /**
  46648. * Defines an optional offset (in seconds) inside the sound file
  46649. */
  46650. offset?: number;
  46651. /**
  46652. * If true, URLs will not be required to state the audio file codec to use.
  46653. */
  46654. skipCodecCheck?: boolean;
  46655. }
  46656. }
  46657. declare module "babylonjs/Audio/sound" {
  46658. import { Observable } from "babylonjs/Misc/observable";
  46659. import { Vector3 } from "babylonjs/Maths/math.vector";
  46660. import { Nullable } from "babylonjs/types";
  46661. import { Scene } from "babylonjs/scene";
  46662. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46663. import { ISoundOptions } from "babylonjs/Audio/Interfaces/ISoundOptions";
  46664. /**
  46665. * Defines a sound that can be played in the application.
  46666. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  46667. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46668. */
  46669. export class Sound {
  46670. /**
  46671. * The name of the sound in the scene.
  46672. */
  46673. name: string;
  46674. /**
  46675. * Does the sound autoplay once loaded.
  46676. */
  46677. autoplay: boolean;
  46678. /**
  46679. * Does the sound loop after it finishes playing once.
  46680. */
  46681. loop: boolean;
  46682. /**
  46683. * Does the sound use a custom attenuation curve to simulate the falloff
  46684. * happening when the source gets further away from the camera.
  46685. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46686. */
  46687. useCustomAttenuation: boolean;
  46688. /**
  46689. * The sound track id this sound belongs to.
  46690. */
  46691. soundTrackId: number;
  46692. /**
  46693. * Is this sound currently played.
  46694. */
  46695. isPlaying: boolean;
  46696. /**
  46697. * Is this sound currently paused.
  46698. */
  46699. isPaused: boolean;
  46700. /**
  46701. * Does this sound enables spatial sound.
  46702. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46703. */
  46704. spatialSound: boolean;
  46705. /**
  46706. * Define the reference distance the sound should be heard perfectly.
  46707. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46708. */
  46709. refDistance: number;
  46710. /**
  46711. * Define the roll off factor of spatial sounds.
  46712. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46713. */
  46714. rolloffFactor: number;
  46715. /**
  46716. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  46717. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46718. */
  46719. maxDistance: number;
  46720. /**
  46721. * Define the distance attenuation model the sound will follow.
  46722. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46723. */
  46724. distanceModel: string;
  46725. /**
  46726. * @hidden
  46727. * Back Compat
  46728. **/
  46729. onended: () => any;
  46730. /**
  46731. * Gets or sets an object used to store user defined information for the sound.
  46732. */
  46733. metadata: any;
  46734. /**
  46735. * Observable event when the current playing sound finishes.
  46736. */
  46737. onEndedObservable: Observable<Sound>;
  46738. /**
  46739. * Gets the current time for the sound.
  46740. */
  46741. get currentTime(): number;
  46742. private _panningModel;
  46743. private _playbackRate;
  46744. private _streaming;
  46745. private _startTime;
  46746. private _startOffset;
  46747. private _position;
  46748. /** @hidden */
  46749. _positionInEmitterSpace: boolean;
  46750. private _localDirection;
  46751. private _volume;
  46752. private _isReadyToPlay;
  46753. private _isDirectional;
  46754. private _readyToPlayCallback;
  46755. private _audioBuffer;
  46756. private _soundSource;
  46757. private _streamingSource;
  46758. private _soundPanner;
  46759. private _soundGain;
  46760. private _inputAudioNode;
  46761. private _outputAudioNode;
  46762. private _coneInnerAngle;
  46763. private _coneOuterAngle;
  46764. private _coneOuterGain;
  46765. private _scene;
  46766. private _connectedTransformNode;
  46767. private _customAttenuationFunction;
  46768. private _registerFunc;
  46769. private _isOutputConnected;
  46770. private _htmlAudioElement;
  46771. private _urlType;
  46772. private _length?;
  46773. private _offset?;
  46774. /** @hidden */
  46775. static _SceneComponentInitialization: (scene: Scene) => void;
  46776. /**
  46777. * Create a sound and attach it to a scene
  46778. * @param name Name of your sound
  46779. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  46780. * @param scene defines the scene the sound belongs to
  46781. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  46782. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  46783. */
  46784. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  46785. /**
  46786. * Release the sound and its associated resources
  46787. */
  46788. dispose(): void;
  46789. /**
  46790. * Gets if the sounds is ready to be played or not.
  46791. * @returns true if ready, otherwise false
  46792. */
  46793. isReady(): boolean;
  46794. private _soundLoaded;
  46795. /**
  46796. * Sets the data of the sound from an audiobuffer
  46797. * @param audioBuffer The audioBuffer containing the data
  46798. */
  46799. setAudioBuffer(audioBuffer: AudioBuffer): void;
  46800. /**
  46801. * Updates the current sounds options such as maxdistance, loop...
  46802. * @param options A JSON object containing values named as the object properties
  46803. */
  46804. updateOptions(options: ISoundOptions): void;
  46805. private _createSpatialParameters;
  46806. private _updateSpatialParameters;
  46807. /**
  46808. * Switch the panning model to HRTF:
  46809. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46810. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46811. */
  46812. switchPanningModelToHRTF(): void;
  46813. /**
  46814. * Switch the panning model to Equal Power:
  46815. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46816. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46817. */
  46818. switchPanningModelToEqualPower(): void;
  46819. private _switchPanningModel;
  46820. /**
  46821. * Connect this sound to a sound track audio node like gain...
  46822. * @param soundTrackAudioNode the sound track audio node to connect to
  46823. */
  46824. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  46825. /**
  46826. * Transform this sound into a directional source
  46827. * @param coneInnerAngle Size of the inner cone in degree
  46828. * @param coneOuterAngle Size of the outer cone in degree
  46829. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  46830. */
  46831. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  46832. /**
  46833. * Gets or sets the inner angle for the directional cone.
  46834. */
  46835. get directionalConeInnerAngle(): number;
  46836. /**
  46837. * Gets or sets the inner angle for the directional cone.
  46838. */
  46839. set directionalConeInnerAngle(value: number);
  46840. /**
  46841. * Gets or sets the outer angle for the directional cone.
  46842. */
  46843. get directionalConeOuterAngle(): number;
  46844. /**
  46845. * Gets or sets the outer angle for the directional cone.
  46846. */
  46847. set directionalConeOuterAngle(value: number);
  46848. /**
  46849. * Sets the position of the emitter if spatial sound is enabled
  46850. * @param newPosition Defines the new posisiton
  46851. */
  46852. setPosition(newPosition: Vector3): void;
  46853. /**
  46854. * Sets the local direction of the emitter if spatial sound is enabled
  46855. * @param newLocalDirection Defines the new local direction
  46856. */
  46857. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  46858. private _updateDirection;
  46859. /** @hidden */
  46860. updateDistanceFromListener(): void;
  46861. /**
  46862. * Sets a new custom attenuation function for the sound.
  46863. * @param callback Defines the function used for the attenuation
  46864. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46865. */
  46866. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  46867. /**
  46868. * Play the sound
  46869. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  46870. * @param offset (optional) Start the sound at a specific time in seconds
  46871. * @param length (optional) Sound duration (in seconds)
  46872. */
  46873. play(time?: number, offset?: number, length?: number): void;
  46874. private _onended;
  46875. /**
  46876. * Stop the sound
  46877. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  46878. */
  46879. stop(time?: number): void;
  46880. /**
  46881. * Put the sound in pause
  46882. */
  46883. pause(): void;
  46884. /**
  46885. * Sets a dedicated volume for this sounds
  46886. * @param newVolume Define the new volume of the sound
  46887. * @param time Define time for gradual change to new volume
  46888. */
  46889. setVolume(newVolume: number, time?: number): void;
  46890. /**
  46891. * Set the sound play back rate
  46892. * @param newPlaybackRate Define the playback rate the sound should be played at
  46893. */
  46894. setPlaybackRate(newPlaybackRate: number): void;
  46895. /**
  46896. * Gets the volume of the sound.
  46897. * @returns the volume of the sound
  46898. */
  46899. getVolume(): number;
  46900. /**
  46901. * Attach the sound to a dedicated mesh
  46902. * @param transformNode The transform node to connect the sound with
  46903. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46904. */
  46905. attachToMesh(transformNode: TransformNode): void;
  46906. /**
  46907. * Detach the sound from the previously attached mesh
  46908. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46909. */
  46910. detachFromMesh(): void;
  46911. private _onRegisterAfterWorldMatrixUpdate;
  46912. /**
  46913. * Clone the current sound in the scene.
  46914. * @returns the new sound clone
  46915. */
  46916. clone(): Nullable<Sound>;
  46917. /**
  46918. * Gets the current underlying audio buffer containing the data
  46919. * @returns the audio buffer
  46920. */
  46921. getAudioBuffer(): Nullable<AudioBuffer>;
  46922. /**
  46923. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  46924. * @returns the source node
  46925. */
  46926. getSoundSource(): Nullable<AudioBufferSourceNode>;
  46927. /**
  46928. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  46929. * @returns the gain node
  46930. */
  46931. getSoundGain(): Nullable<GainNode>;
  46932. /**
  46933. * Serializes the Sound in a JSON representation
  46934. * @returns the JSON representation of the sound
  46935. */
  46936. serialize(): any;
  46937. /**
  46938. * Parse a JSON representation of a sound to innstantiate in a given scene
  46939. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  46940. * @param scene Define the scene the new parsed sound should be created in
  46941. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  46942. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  46943. * @returns the newly parsed sound
  46944. */
  46945. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  46946. }
  46947. }
  46948. declare module "babylonjs/Actions/directAudioActions" {
  46949. import { Action } from "babylonjs/Actions/action";
  46950. import { Condition } from "babylonjs/Actions/condition";
  46951. import { Sound } from "babylonjs/Audio/sound";
  46952. /**
  46953. * This defines an action helpful to play a defined sound on a triggered action.
  46954. */
  46955. export class PlaySoundAction extends Action {
  46956. private _sound;
  46957. /**
  46958. * Instantiate the action
  46959. * @param triggerOptions defines the trigger options
  46960. * @param sound defines the sound to play
  46961. * @param condition defines the trigger related conditions
  46962. */
  46963. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46964. /** @hidden */
  46965. _prepare(): void;
  46966. /**
  46967. * Execute the action and play the sound.
  46968. */
  46969. execute(): void;
  46970. /**
  46971. * Serializes the actions and its related information.
  46972. * @param parent defines the object to serialize in
  46973. * @returns the serialized object
  46974. */
  46975. serialize(parent: any): any;
  46976. }
  46977. /**
  46978. * This defines an action helpful to stop a defined sound on a triggered action.
  46979. */
  46980. export class StopSoundAction extends Action {
  46981. private _sound;
  46982. /**
  46983. * Instantiate the action
  46984. * @param triggerOptions defines the trigger options
  46985. * @param sound defines the sound to stop
  46986. * @param condition defines the trigger related conditions
  46987. */
  46988. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46989. /** @hidden */
  46990. _prepare(): void;
  46991. /**
  46992. * Execute the action and stop the sound.
  46993. */
  46994. execute(): void;
  46995. /**
  46996. * Serializes the actions and its related information.
  46997. * @param parent defines the object to serialize in
  46998. * @returns the serialized object
  46999. */
  47000. serialize(parent: any): any;
  47001. }
  47002. }
  47003. declare module "babylonjs/Actions/interpolateValueAction" {
  47004. import { Action } from "babylonjs/Actions/action";
  47005. import { Condition } from "babylonjs/Actions/condition";
  47006. import { Observable } from "babylonjs/Misc/observable";
  47007. /**
  47008. * This defines an action responsible to change the value of a property
  47009. * by interpolating between its current value and the newly set one once triggered.
  47010. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  47011. */
  47012. export class InterpolateValueAction extends Action {
  47013. /**
  47014. * Defines the path of the property where the value should be interpolated
  47015. */
  47016. propertyPath: string;
  47017. /**
  47018. * Defines the target value at the end of the interpolation.
  47019. */
  47020. value: any;
  47021. /**
  47022. * Defines the time it will take for the property to interpolate to the value.
  47023. */
  47024. duration: number;
  47025. /**
  47026. * Defines if the other scene animations should be stopped when the action has been triggered
  47027. */
  47028. stopOtherAnimations?: boolean;
  47029. /**
  47030. * Defines a callback raised once the interpolation animation has been done.
  47031. */
  47032. onInterpolationDone?: () => void;
  47033. /**
  47034. * Observable triggered once the interpolation animation has been done.
  47035. */
  47036. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  47037. private _target;
  47038. private _effectiveTarget;
  47039. private _property;
  47040. /**
  47041. * Instantiate the action
  47042. * @param triggerOptions defines the trigger options
  47043. * @param target defines the object containing the value to interpolate
  47044. * @param propertyPath defines the path to the property in the target object
  47045. * @param value defines the target value at the end of the interpolation
  47046. * @param duration deines the time it will take for the property to interpolate to the value.
  47047. * @param condition defines the trigger related conditions
  47048. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  47049. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  47050. */
  47051. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  47052. /** @hidden */
  47053. _prepare(): void;
  47054. /**
  47055. * Execute the action starts the value interpolation.
  47056. */
  47057. execute(): void;
  47058. /**
  47059. * Serializes the actions and its related information.
  47060. * @param parent defines the object to serialize in
  47061. * @returns the serialized object
  47062. */
  47063. serialize(parent: any): any;
  47064. }
  47065. }
  47066. declare module "babylonjs/Actions/index" {
  47067. export * from "babylonjs/Actions/abstractActionManager";
  47068. export * from "babylonjs/Actions/action";
  47069. export * from "babylonjs/Actions/actionEvent";
  47070. export * from "babylonjs/Actions/actionManager";
  47071. export * from "babylonjs/Actions/condition";
  47072. export * from "babylonjs/Actions/directActions";
  47073. export * from "babylonjs/Actions/directAudioActions";
  47074. export * from "babylonjs/Actions/interpolateValueAction";
  47075. }
  47076. declare module "babylonjs/Animations/index" {
  47077. export * from "babylonjs/Animations/animatable";
  47078. export * from "babylonjs/Animations/animation";
  47079. export * from "babylonjs/Animations/animationGroup";
  47080. export * from "babylonjs/Animations/animationPropertiesOverride";
  47081. export * from "babylonjs/Animations/easing";
  47082. export * from "babylonjs/Animations/runtimeAnimation";
  47083. export * from "babylonjs/Animations/animationEvent";
  47084. export * from "babylonjs/Animations/animationGroup";
  47085. export * from "babylonjs/Animations/animationKey";
  47086. export * from "babylonjs/Animations/animationRange";
  47087. export * from "babylonjs/Animations/animatable.interface";
  47088. }
  47089. declare module "babylonjs/Audio/audioEngine" {
  47090. import { Analyser } from "babylonjs/Audio/analyser";
  47091. import { Nullable } from "babylonjs/types";
  47092. import { Observable } from "babylonjs/Misc/observable";
  47093. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  47094. /**
  47095. * This represents the default audio engine used in babylon.
  47096. * It is responsible to play, synchronize and analyse sounds throughout the application.
  47097. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47098. */
  47099. export class AudioEngine implements IAudioEngine {
  47100. private _audioContext;
  47101. private _audioContextInitialized;
  47102. private _muteButton;
  47103. private _hostElement;
  47104. /**
  47105. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  47106. */
  47107. canUseWebAudio: boolean;
  47108. /**
  47109. * The master gain node defines the global audio volume of your audio engine.
  47110. */
  47111. masterGain: GainNode;
  47112. /**
  47113. * Defines if Babylon should emit a warning if WebAudio is not supported.
  47114. * @ignoreNaming
  47115. */
  47116. WarnedWebAudioUnsupported: boolean;
  47117. /**
  47118. * Gets whether or not mp3 are supported by your browser.
  47119. */
  47120. isMP3supported: boolean;
  47121. /**
  47122. * Gets whether or not ogg are supported by your browser.
  47123. */
  47124. isOGGsupported: boolean;
  47125. /**
  47126. * Gets whether audio has been unlocked on the device.
  47127. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  47128. * a user interaction has happened.
  47129. */
  47130. unlocked: boolean;
  47131. /**
  47132. * Defines if the audio engine relies on a custom unlocked button.
  47133. * In this case, the embedded button will not be displayed.
  47134. */
  47135. useCustomUnlockedButton: boolean;
  47136. /**
  47137. * Event raised when audio has been unlocked on the browser.
  47138. */
  47139. onAudioUnlockedObservable: Observable<IAudioEngine>;
  47140. /**
  47141. * Event raised when audio has been locked on the browser.
  47142. */
  47143. onAudioLockedObservable: Observable<IAudioEngine>;
  47144. /**
  47145. * Gets the current AudioContext if available.
  47146. */
  47147. get audioContext(): Nullable<AudioContext>;
  47148. private _connectedAnalyser;
  47149. /**
  47150. * Instantiates a new audio engine.
  47151. *
  47152. * There should be only one per page as some browsers restrict the number
  47153. * of audio contexts you can create.
  47154. * @param hostElement defines the host element where to display the mute icon if necessary
  47155. */
  47156. constructor(hostElement?: Nullable<HTMLElement>);
  47157. /**
  47158. * Flags the audio engine in Locked state.
  47159. * This happens due to new browser policies preventing audio to autoplay.
  47160. */
  47161. lock(): void;
  47162. /**
  47163. * Unlocks the audio engine once a user action has been done on the dom.
  47164. * This is helpful to resume play once browser policies have been satisfied.
  47165. */
  47166. unlock(): void;
  47167. private _resumeAudioContext;
  47168. private _initializeAudioContext;
  47169. private _tryToRun;
  47170. private _triggerRunningState;
  47171. private _triggerSuspendedState;
  47172. private _displayMuteButton;
  47173. private _moveButtonToTopLeft;
  47174. private _onResize;
  47175. private _hideMuteButton;
  47176. /**
  47177. * Destroy and release the resources associated with the audio ccontext.
  47178. */
  47179. dispose(): void;
  47180. /**
  47181. * Gets the global volume sets on the master gain.
  47182. * @returns the global volume if set or -1 otherwise
  47183. */
  47184. getGlobalVolume(): number;
  47185. /**
  47186. * Sets the global volume of your experience (sets on the master gain).
  47187. * @param newVolume Defines the new global volume of the application
  47188. */
  47189. setGlobalVolume(newVolume: number): void;
  47190. /**
  47191. * Connect the audio engine to an audio analyser allowing some amazing
  47192. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  47193. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  47194. * @param analyser The analyser to connect to the engine
  47195. */
  47196. connectToAnalyser(analyser: Analyser): void;
  47197. }
  47198. }
  47199. declare module "babylonjs/Audio/soundTrack" {
  47200. import { Sound } from "babylonjs/Audio/sound";
  47201. import { Analyser } from "babylonjs/Audio/analyser";
  47202. import { Scene } from "babylonjs/scene";
  47203. /**
  47204. * Options allowed during the creation of a sound track.
  47205. */
  47206. export interface ISoundTrackOptions {
  47207. /**
  47208. * The volume the sound track should take during creation
  47209. */
  47210. volume?: number;
  47211. /**
  47212. * Define if the sound track is the main sound track of the scene
  47213. */
  47214. mainTrack?: boolean;
  47215. }
  47216. /**
  47217. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  47218. * It will be also used in a future release to apply effects on a specific track.
  47219. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  47220. */
  47221. export class SoundTrack {
  47222. /**
  47223. * The unique identifier of the sound track in the scene.
  47224. */
  47225. id: number;
  47226. /**
  47227. * The list of sounds included in the sound track.
  47228. */
  47229. soundCollection: Array<Sound>;
  47230. private _outputAudioNode;
  47231. private _scene;
  47232. private _connectedAnalyser;
  47233. private _options;
  47234. private _isInitialized;
  47235. /**
  47236. * Creates a new sound track.
  47237. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  47238. * @param scene Define the scene the sound track belongs to
  47239. * @param options
  47240. */
  47241. constructor(scene: Scene, options?: ISoundTrackOptions);
  47242. private _initializeSoundTrackAudioGraph;
  47243. /**
  47244. * Release the sound track and its associated resources
  47245. */
  47246. dispose(): void;
  47247. /**
  47248. * Adds a sound to this sound track
  47249. * @param sound define the cound to add
  47250. * @ignoreNaming
  47251. */
  47252. addSound(sound: Sound): void;
  47253. /**
  47254. * Removes a sound to this sound track
  47255. * @param sound define the cound to remove
  47256. * @ignoreNaming
  47257. */
  47258. removeSound(sound: Sound): void;
  47259. /**
  47260. * Set a global volume for the full sound track.
  47261. * @param newVolume Define the new volume of the sound track
  47262. */
  47263. setVolume(newVolume: number): void;
  47264. /**
  47265. * Switch the panning model to HRTF:
  47266. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  47267. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47268. */
  47269. switchPanningModelToHRTF(): void;
  47270. /**
  47271. * Switch the panning model to Equal Power:
  47272. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  47273. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47274. */
  47275. switchPanningModelToEqualPower(): void;
  47276. /**
  47277. * Connect the sound track to an audio analyser allowing some amazing
  47278. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  47279. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  47280. * @param analyser The analyser to connect to the engine
  47281. */
  47282. connectToAnalyser(analyser: Analyser): void;
  47283. }
  47284. }
  47285. declare module "babylonjs/Audio/audioSceneComponent" {
  47286. import { Sound } from "babylonjs/Audio/sound";
  47287. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  47288. import { Nullable } from "babylonjs/types";
  47289. import { Vector3 } from "babylonjs/Maths/math.vector";
  47290. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47291. import { Scene } from "babylonjs/scene";
  47292. import { AbstractScene } from "babylonjs/abstractScene";
  47293. import "babylonjs/Audio/audioEngine";
  47294. module "babylonjs/abstractScene" {
  47295. interface AbstractScene {
  47296. /**
  47297. * The list of sounds used in the scene.
  47298. */
  47299. sounds: Nullable<Array<Sound>>;
  47300. }
  47301. }
  47302. module "babylonjs/scene" {
  47303. interface Scene {
  47304. /**
  47305. * @hidden
  47306. * Backing field
  47307. */
  47308. _mainSoundTrack: SoundTrack;
  47309. /**
  47310. * The main sound track played by the scene.
  47311. * It cotains your primary collection of sounds.
  47312. */
  47313. mainSoundTrack: SoundTrack;
  47314. /**
  47315. * The list of sound tracks added to the scene
  47316. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47317. */
  47318. soundTracks: Nullable<Array<SoundTrack>>;
  47319. /**
  47320. * Gets a sound using a given name
  47321. * @param name defines the name to search for
  47322. * @return the found sound or null if not found at all.
  47323. */
  47324. getSoundByName(name: string): Nullable<Sound>;
  47325. /**
  47326. * Gets or sets if audio support is enabled
  47327. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47328. */
  47329. audioEnabled: boolean;
  47330. /**
  47331. * Gets or sets if audio will be output to headphones
  47332. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47333. */
  47334. headphone: boolean;
  47335. /**
  47336. * Gets or sets custom audio listener position provider
  47337. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47338. */
  47339. audioListenerPositionProvider: Nullable<() => Vector3>;
  47340. /**
  47341. * Gets or sets a refresh rate when using 3D audio positioning
  47342. */
  47343. audioPositioningRefreshRate: number;
  47344. }
  47345. }
  47346. /**
  47347. * Defines the sound scene component responsible to manage any sounds
  47348. * in a given scene.
  47349. */
  47350. export class AudioSceneComponent implements ISceneSerializableComponent {
  47351. private static _CameraDirectionLH;
  47352. private static _CameraDirectionRH;
  47353. /**
  47354. * The component name helpfull to identify the component in the list of scene components.
  47355. */
  47356. readonly name: string;
  47357. /**
  47358. * The scene the component belongs to.
  47359. */
  47360. scene: Scene;
  47361. private _audioEnabled;
  47362. /**
  47363. * Gets whether audio is enabled or not.
  47364. * Please use related enable/disable method to switch state.
  47365. */
  47366. get audioEnabled(): boolean;
  47367. private _headphone;
  47368. /**
  47369. * Gets whether audio is outputing to headphone or not.
  47370. * Please use the according Switch methods to change output.
  47371. */
  47372. get headphone(): boolean;
  47373. /**
  47374. * Gets or sets a refresh rate when using 3D audio positioning
  47375. */
  47376. audioPositioningRefreshRate: number;
  47377. private _audioListenerPositionProvider;
  47378. /**
  47379. * Gets the current audio listener position provider
  47380. */
  47381. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  47382. /**
  47383. * Sets a custom listener position for all sounds in the scene
  47384. * By default, this is the position of the first active camera
  47385. */
  47386. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  47387. /**
  47388. * Creates a new instance of the component for the given scene
  47389. * @param scene Defines the scene to register the component in
  47390. */
  47391. constructor(scene: Scene);
  47392. /**
  47393. * Registers the component in a given scene
  47394. */
  47395. register(): void;
  47396. /**
  47397. * Rebuilds the elements related to this component in case of
  47398. * context lost for instance.
  47399. */
  47400. rebuild(): void;
  47401. /**
  47402. * Serializes the component data to the specified json object
  47403. * @param serializationObject The object to serialize to
  47404. */
  47405. serialize(serializationObject: any): void;
  47406. /**
  47407. * Adds all the elements from the container to the scene
  47408. * @param container the container holding the elements
  47409. */
  47410. addFromContainer(container: AbstractScene): void;
  47411. /**
  47412. * Removes all the elements in the container from the scene
  47413. * @param container contains the elements to remove
  47414. * @param dispose if the removed element should be disposed (default: false)
  47415. */
  47416. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47417. /**
  47418. * Disposes the component and the associated ressources.
  47419. */
  47420. dispose(): void;
  47421. /**
  47422. * Disables audio in the associated scene.
  47423. */
  47424. disableAudio(): void;
  47425. /**
  47426. * Enables audio in the associated scene.
  47427. */
  47428. enableAudio(): void;
  47429. /**
  47430. * Switch audio to headphone output.
  47431. */
  47432. switchAudioModeForHeadphones(): void;
  47433. /**
  47434. * Switch audio to normal speakers.
  47435. */
  47436. switchAudioModeForNormalSpeakers(): void;
  47437. private _cachedCameraDirection;
  47438. private _cachedCameraPosition;
  47439. private _lastCheck;
  47440. private _afterRender;
  47441. }
  47442. }
  47443. declare module "babylonjs/Audio/weightedsound" {
  47444. import { Sound } from "babylonjs/Audio/sound";
  47445. /**
  47446. * Wraps one or more Sound objects and selects one with random weight for playback.
  47447. */
  47448. export class WeightedSound {
  47449. /** When true a Sound will be selected and played when the current playing Sound completes. */
  47450. loop: boolean;
  47451. private _coneInnerAngle;
  47452. private _coneOuterAngle;
  47453. private _volume;
  47454. /** A Sound is currently playing. */
  47455. isPlaying: boolean;
  47456. /** A Sound is currently paused. */
  47457. isPaused: boolean;
  47458. private _sounds;
  47459. private _weights;
  47460. private _currentIndex?;
  47461. /**
  47462. * Creates a new WeightedSound from the list of sounds given.
  47463. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  47464. * @param sounds Array of Sounds that will be selected from.
  47465. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  47466. */
  47467. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  47468. /**
  47469. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  47470. */
  47471. get directionalConeInnerAngle(): number;
  47472. /**
  47473. * The size of cone in degress for a directional sound in which there will be no attenuation.
  47474. */
  47475. set directionalConeInnerAngle(value: number);
  47476. /**
  47477. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  47478. * Listener angles between innerAngle and outerAngle will falloff linearly.
  47479. */
  47480. get directionalConeOuterAngle(): number;
  47481. /**
  47482. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  47483. * Listener angles between innerAngle and outerAngle will falloff linearly.
  47484. */
  47485. set directionalConeOuterAngle(value: number);
  47486. /**
  47487. * Playback volume.
  47488. */
  47489. get volume(): number;
  47490. /**
  47491. * Playback volume.
  47492. */
  47493. set volume(value: number);
  47494. private _onended;
  47495. /**
  47496. * Suspend playback
  47497. */
  47498. pause(): void;
  47499. /**
  47500. * Stop playback
  47501. */
  47502. stop(): void;
  47503. /**
  47504. * Start playback.
  47505. * @param startOffset Position the clip head at a specific time in seconds.
  47506. */
  47507. play(startOffset?: number): void;
  47508. }
  47509. }
  47510. declare module "babylonjs/Audio/index" {
  47511. export * from "babylonjs/Audio/Interfaces/IAudioEngine";
  47512. export * from "babylonjs/Audio/Interfaces/ISoundOptions";
  47513. export * from "babylonjs/Audio/analyser";
  47514. export * from "babylonjs/Audio/audioEngine";
  47515. export * from "babylonjs/Audio/audioSceneComponent";
  47516. export * from "babylonjs/Audio/sound";
  47517. export * from "babylonjs/Audio/soundTrack";
  47518. export * from "babylonjs/Audio/weightedsound";
  47519. }
  47520. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  47521. import { Behavior } from "babylonjs/Behaviors/behavior";
  47522. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47523. import { BackEase } from "babylonjs/Animations/easing";
  47524. /**
  47525. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  47526. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47527. */
  47528. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  47529. /**
  47530. * Gets the name of the behavior.
  47531. */
  47532. get name(): string;
  47533. /**
  47534. * The easing function used by animations
  47535. */
  47536. static EasingFunction: BackEase;
  47537. /**
  47538. * The easing mode used by animations
  47539. */
  47540. static EasingMode: number;
  47541. /**
  47542. * The duration of the animation, in milliseconds
  47543. */
  47544. transitionDuration: number;
  47545. /**
  47546. * Length of the distance animated by the transition when lower radius is reached
  47547. */
  47548. lowerRadiusTransitionRange: number;
  47549. /**
  47550. * Length of the distance animated by the transition when upper radius is reached
  47551. */
  47552. upperRadiusTransitionRange: number;
  47553. private _autoTransitionRange;
  47554. /**
  47555. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  47556. */
  47557. get autoTransitionRange(): boolean;
  47558. /**
  47559. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  47560. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  47561. */
  47562. set autoTransitionRange(value: boolean);
  47563. private _attachedCamera;
  47564. private _onAfterCheckInputsObserver;
  47565. private _onMeshTargetChangedObserver;
  47566. /**
  47567. * Initializes the behavior.
  47568. */
  47569. init(): void;
  47570. /**
  47571. * Attaches the behavior to its arc rotate camera.
  47572. * @param camera Defines the camera to attach the behavior to
  47573. */
  47574. attach(camera: ArcRotateCamera): void;
  47575. /**
  47576. * Detaches the behavior from its current arc rotate camera.
  47577. */
  47578. detach(): void;
  47579. private _radiusIsAnimating;
  47580. private _radiusBounceTransition;
  47581. private _animatables;
  47582. private _cachedWheelPrecision;
  47583. /**
  47584. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  47585. * @param radiusLimit The limit to check against.
  47586. * @return Bool to indicate if at limit.
  47587. */
  47588. private _isRadiusAtLimit;
  47589. /**
  47590. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  47591. * @param radiusDelta The delta by which to animate to. Can be negative.
  47592. */
  47593. private _applyBoundRadiusAnimation;
  47594. /**
  47595. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  47596. */
  47597. protected _clearAnimationLocks(): void;
  47598. /**
  47599. * Stops and removes all animations that have been applied to the camera
  47600. */
  47601. stopAllAnimations(): void;
  47602. }
  47603. }
  47604. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  47605. import { Behavior } from "babylonjs/Behaviors/behavior";
  47606. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47607. import { ExponentialEase } from "babylonjs/Animations/easing";
  47608. import { Nullable } from "babylonjs/types";
  47609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47610. import { Vector3 } from "babylonjs/Maths/math.vector";
  47611. /**
  47612. * 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.
  47613. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47614. */
  47615. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  47616. /**
  47617. * Gets the name of the behavior.
  47618. */
  47619. get name(): string;
  47620. private _mode;
  47621. private _radiusScale;
  47622. private _positionScale;
  47623. private _defaultElevation;
  47624. private _elevationReturnTime;
  47625. private _elevationReturnWaitTime;
  47626. private _zoomStopsAnimation;
  47627. private _framingTime;
  47628. /**
  47629. * The easing function used by animations
  47630. */
  47631. static EasingFunction: ExponentialEase;
  47632. /**
  47633. * The easing mode used by animations
  47634. */
  47635. static EasingMode: number;
  47636. /**
  47637. * Sets the current mode used by the behavior
  47638. */
  47639. set mode(mode: number);
  47640. /**
  47641. * Gets current mode used by the behavior.
  47642. */
  47643. get mode(): number;
  47644. /**
  47645. * Sets the scale applied to the radius (1 by default)
  47646. */
  47647. set radiusScale(radius: number);
  47648. /**
  47649. * Gets the scale applied to the radius
  47650. */
  47651. get radiusScale(): number;
  47652. /**
  47653. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47654. */
  47655. set positionScale(scale: number);
  47656. /**
  47657. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47658. */
  47659. get positionScale(): number;
  47660. /**
  47661. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47662. * behaviour is triggered, in radians.
  47663. */
  47664. set defaultElevation(elevation: number);
  47665. /**
  47666. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47667. * behaviour is triggered, in radians.
  47668. */
  47669. get defaultElevation(): number;
  47670. /**
  47671. * Sets the time (in milliseconds) taken to return to the default beta position.
  47672. * Negative value indicates camera should not return to default.
  47673. */
  47674. set elevationReturnTime(speed: number);
  47675. /**
  47676. * Gets the time (in milliseconds) taken to return to the default beta position.
  47677. * Negative value indicates camera should not return to default.
  47678. */
  47679. get elevationReturnTime(): number;
  47680. /**
  47681. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47682. */
  47683. set elevationReturnWaitTime(time: number);
  47684. /**
  47685. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47686. */
  47687. get elevationReturnWaitTime(): number;
  47688. /**
  47689. * Sets the flag that indicates if user zooming should stop animation.
  47690. */
  47691. set zoomStopsAnimation(flag: boolean);
  47692. /**
  47693. * Gets the flag that indicates if user zooming should stop animation.
  47694. */
  47695. get zoomStopsAnimation(): boolean;
  47696. /**
  47697. * Sets the transition time when framing the mesh, in milliseconds
  47698. */
  47699. set framingTime(time: number);
  47700. /**
  47701. * Gets the transition time when framing the mesh, in milliseconds
  47702. */
  47703. get framingTime(): number;
  47704. /**
  47705. * Define if the behavior should automatically change the configured
  47706. * camera limits and sensibilities.
  47707. */
  47708. autoCorrectCameraLimitsAndSensibility: boolean;
  47709. private _onPrePointerObservableObserver;
  47710. private _onAfterCheckInputsObserver;
  47711. private _onMeshTargetChangedObserver;
  47712. private _attachedCamera;
  47713. private _isPointerDown;
  47714. private _lastInteractionTime;
  47715. /**
  47716. * Initializes the behavior.
  47717. */
  47718. init(): void;
  47719. /**
  47720. * Attaches the behavior to its arc rotate camera.
  47721. * @param camera Defines the camera to attach the behavior to
  47722. */
  47723. attach(camera: ArcRotateCamera): void;
  47724. /**
  47725. * Detaches the behavior from its current arc rotate camera.
  47726. */
  47727. detach(): void;
  47728. private _animatables;
  47729. private _betaIsAnimating;
  47730. private _betaTransition;
  47731. private _radiusTransition;
  47732. private _vectorTransition;
  47733. /**
  47734. * Targets the given mesh and updates zoom level accordingly.
  47735. * @param mesh The mesh to target.
  47736. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47737. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47738. */
  47739. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47740. /**
  47741. * Targets the given mesh with its children and updates zoom level accordingly.
  47742. * @param mesh The mesh to target.
  47743. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47744. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47745. */
  47746. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47747. /**
  47748. * Targets the given meshes with their children and updates zoom level accordingly.
  47749. * @param meshes The mesh to target.
  47750. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47751. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47752. */
  47753. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47754. /**
  47755. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  47756. * @param minimumWorld Determines the smaller position of the bounding box extend
  47757. * @param maximumWorld Determines the bigger position of the bounding box extend
  47758. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47759. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47760. */
  47761. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47762. /**
  47763. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  47764. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  47765. * frustum width.
  47766. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  47767. * to fully enclose the mesh in the viewing frustum.
  47768. */
  47769. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  47770. /**
  47771. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  47772. * is automatically returned to its default position (expected to be above ground plane).
  47773. */
  47774. private _maintainCameraAboveGround;
  47775. /**
  47776. * Returns the frustum slope based on the canvas ratio and camera FOV
  47777. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  47778. */
  47779. private _getFrustumSlope;
  47780. /**
  47781. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  47782. */
  47783. private _clearAnimationLocks;
  47784. /**
  47785. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47786. */
  47787. private _applyUserInteraction;
  47788. /**
  47789. * Stops and removes all animations that have been applied to the camera
  47790. */
  47791. stopAllAnimations(): void;
  47792. /**
  47793. * Gets a value indicating if the user is moving the camera
  47794. */
  47795. get isUserIsMoving(): boolean;
  47796. /**
  47797. * The camera can move all the way towards the mesh.
  47798. */
  47799. static IgnoreBoundsSizeMode: number;
  47800. /**
  47801. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  47802. */
  47803. static FitFrustumSidesMode: number;
  47804. }
  47805. }
  47806. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  47807. import { Nullable } from "babylonjs/types";
  47808. import { Camera } from "babylonjs/Cameras/camera";
  47809. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47810. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47811. /**
  47812. * Base class for Camera Pointer Inputs.
  47813. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  47814. * for example usage.
  47815. */
  47816. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  47817. /**
  47818. * Defines the camera the input is attached to.
  47819. */
  47820. abstract camera: Camera;
  47821. /**
  47822. * Whether keyboard modifier keys are pressed at time of last mouse event.
  47823. */
  47824. protected _altKey: boolean;
  47825. protected _ctrlKey: boolean;
  47826. protected _metaKey: boolean;
  47827. protected _shiftKey: boolean;
  47828. /**
  47829. * Which mouse buttons were pressed at time of last mouse event.
  47830. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  47831. */
  47832. protected _buttonsPressed: number;
  47833. /**
  47834. * Defines the buttons associated with the input to handle camera move.
  47835. */
  47836. buttons: number[];
  47837. /**
  47838. * Attach the input controls to a specific dom element to get the input from.
  47839. * @param element Defines the element the controls should be listened from
  47840. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47841. */
  47842. attachControl(noPreventDefault?: boolean): void;
  47843. /**
  47844. * Detach the current controls from the specified dom element.
  47845. */
  47846. detachControl(): void;
  47847. /**
  47848. * Gets the class name of the current input.
  47849. * @returns the class name
  47850. */
  47851. getClassName(): string;
  47852. /**
  47853. * Get the friendly name associated with the input class.
  47854. * @returns the input friendly name
  47855. */
  47856. getSimpleName(): string;
  47857. /**
  47858. * Called on pointer POINTERDOUBLETAP event.
  47859. * Override this method to provide functionality on POINTERDOUBLETAP event.
  47860. */
  47861. protected onDoubleTap(type: string): void;
  47862. /**
  47863. * Called on pointer POINTERMOVE event if only a single touch is active.
  47864. * Override this method to provide functionality.
  47865. */
  47866. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47867. /**
  47868. * Called on pointer POINTERMOVE event if multiple touches are active.
  47869. * Override this method to provide functionality.
  47870. */
  47871. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47872. /**
  47873. * Called on JS contextmenu event.
  47874. * Override this method to provide functionality.
  47875. */
  47876. protected onContextMenu(evt: PointerEvent): void;
  47877. /**
  47878. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47879. * press.
  47880. * Override this method to provide functionality.
  47881. */
  47882. protected onButtonDown(evt: PointerEvent): void;
  47883. /**
  47884. * Called each time a new POINTERUP event occurs. Ie, for each button
  47885. * release.
  47886. * Override this method to provide functionality.
  47887. */
  47888. protected onButtonUp(evt: PointerEvent): void;
  47889. /**
  47890. * Called when window becomes inactive.
  47891. * Override this method to provide functionality.
  47892. */
  47893. protected onLostFocus(): void;
  47894. private _pointerInput;
  47895. private _observer;
  47896. private _onLostFocus;
  47897. private pointA;
  47898. private pointB;
  47899. }
  47900. }
  47901. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  47902. import { Nullable } from "babylonjs/types";
  47903. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47904. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  47905. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47906. /**
  47907. * Manage the pointers inputs to control an arc rotate camera.
  47908. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47909. */
  47910. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  47911. /**
  47912. * Defines the camera the input is attached to.
  47913. */
  47914. camera: ArcRotateCamera;
  47915. /**
  47916. * Gets the class name of the current input.
  47917. * @returns the class name
  47918. */
  47919. getClassName(): string;
  47920. /**
  47921. * Defines the buttons associated with the input to handle camera move.
  47922. */
  47923. buttons: number[];
  47924. /**
  47925. * Defines the pointer angular sensibility along the X axis or how fast is
  47926. * the camera rotating.
  47927. */
  47928. angularSensibilityX: number;
  47929. /**
  47930. * Defines the pointer angular sensibility along the Y axis or how fast is
  47931. * the camera rotating.
  47932. */
  47933. angularSensibilityY: number;
  47934. /**
  47935. * Defines the pointer pinch precision or how fast is the camera zooming.
  47936. */
  47937. pinchPrecision: number;
  47938. /**
  47939. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47940. * from 0.
  47941. * It defines the percentage of current camera.radius to use as delta when
  47942. * pinch zoom is used.
  47943. */
  47944. pinchDeltaPercentage: number;
  47945. /**
  47946. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47947. * that any object in the plane at the camera's target point will scale
  47948. * perfectly with finger motion.
  47949. * Overrides pinchDeltaPercentage and pinchPrecision.
  47950. */
  47951. useNaturalPinchZoom: boolean;
  47952. /**
  47953. * Defines the pointer panning sensibility or how fast is the camera moving.
  47954. */
  47955. panningSensibility: number;
  47956. /**
  47957. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  47958. */
  47959. multiTouchPanning: boolean;
  47960. /**
  47961. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  47962. * zoom (pinch) through multitouch.
  47963. */
  47964. multiTouchPanAndZoom: boolean;
  47965. /**
  47966. * Revers pinch action direction.
  47967. */
  47968. pinchInwards: boolean;
  47969. private _isPanClick;
  47970. private _twoFingerActivityCount;
  47971. private _isPinching;
  47972. /**
  47973. * Called on pointer POINTERMOVE event if only a single touch is active.
  47974. */
  47975. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47976. /**
  47977. * Called on pointer POINTERDOUBLETAP event.
  47978. */
  47979. protected onDoubleTap(type: string): void;
  47980. /**
  47981. * Called on pointer POINTERMOVE event if multiple touches are active.
  47982. */
  47983. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47984. /**
  47985. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47986. * press.
  47987. */
  47988. protected onButtonDown(evt: PointerEvent): void;
  47989. /**
  47990. * Called each time a new POINTERUP event occurs. Ie, for each button
  47991. * release.
  47992. */
  47993. protected onButtonUp(evt: PointerEvent): void;
  47994. /**
  47995. * Called when window becomes inactive.
  47996. */
  47997. protected onLostFocus(): void;
  47998. }
  47999. }
  48000. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  48001. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48002. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48003. /**
  48004. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  48005. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48006. */
  48007. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  48008. /**
  48009. * Defines the camera the input is attached to.
  48010. */
  48011. camera: ArcRotateCamera;
  48012. /**
  48013. * Defines the list of key codes associated with the up action (increase alpha)
  48014. */
  48015. keysUp: number[];
  48016. /**
  48017. * Defines the list of key codes associated with the down action (decrease alpha)
  48018. */
  48019. keysDown: number[];
  48020. /**
  48021. * Defines the list of key codes associated with the left action (increase beta)
  48022. */
  48023. keysLeft: number[];
  48024. /**
  48025. * Defines the list of key codes associated with the right action (decrease beta)
  48026. */
  48027. keysRight: number[];
  48028. /**
  48029. * Defines the list of key codes associated with the reset action.
  48030. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  48031. */
  48032. keysReset: number[];
  48033. /**
  48034. * Defines the panning sensibility of the inputs.
  48035. * (How fast is the camera panning)
  48036. */
  48037. panningSensibility: number;
  48038. /**
  48039. * Defines the zooming sensibility of the inputs.
  48040. * (How fast is the camera zooming)
  48041. */
  48042. zoomingSensibility: number;
  48043. /**
  48044. * Defines whether maintaining the alt key down switch the movement mode from
  48045. * orientation to zoom.
  48046. */
  48047. useAltToZoom: boolean;
  48048. /**
  48049. * Rotation speed of the camera
  48050. */
  48051. angularSpeed: number;
  48052. private _keys;
  48053. private _ctrlPressed;
  48054. private _altPressed;
  48055. private _onCanvasBlurObserver;
  48056. private _onKeyboardObserver;
  48057. private _engine;
  48058. private _scene;
  48059. /**
  48060. * Attach the input controls to a specific dom element to get the input from.
  48061. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48062. */
  48063. attachControl(noPreventDefault?: boolean): void;
  48064. /**
  48065. * Detach the current controls from the specified dom element.
  48066. */
  48067. detachControl(): void;
  48068. /**
  48069. * Update the current camera state depending on the inputs that have been used this frame.
  48070. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48071. */
  48072. checkInputs(): void;
  48073. /**
  48074. * Gets the class name of the current intput.
  48075. * @returns the class name
  48076. */
  48077. getClassName(): string;
  48078. /**
  48079. * Get the friendly name associated with the input class.
  48080. * @returns the input friendly name
  48081. */
  48082. getSimpleName(): string;
  48083. }
  48084. }
  48085. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  48086. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48087. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48088. /**
  48089. * Manage the mouse wheel inputs to control an arc rotate camera.
  48090. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48091. */
  48092. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  48093. /**
  48094. * Defines the camera the input is attached to.
  48095. */
  48096. camera: ArcRotateCamera;
  48097. /**
  48098. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  48099. */
  48100. wheelPrecision: number;
  48101. /**
  48102. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  48103. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  48104. */
  48105. wheelDeltaPercentage: number;
  48106. private _wheel;
  48107. private _observer;
  48108. private computeDeltaFromMouseWheelLegacyEvent;
  48109. /**
  48110. * Attach the input controls to a specific dom element to get the input from.
  48111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48112. */
  48113. attachControl(noPreventDefault?: boolean): void;
  48114. /**
  48115. * Detach the current controls from the specified dom element.
  48116. */
  48117. detachControl(): void;
  48118. /**
  48119. * Gets the class name of the current intput.
  48120. * @returns the class name
  48121. */
  48122. getClassName(): string;
  48123. /**
  48124. * Get the friendly name associated with the input class.
  48125. * @returns the input friendly name
  48126. */
  48127. getSimpleName(): string;
  48128. }
  48129. }
  48130. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  48131. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48132. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  48133. /**
  48134. * Default Inputs manager for the ArcRotateCamera.
  48135. * It groups all the default supported inputs for ease of use.
  48136. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48137. */
  48138. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  48139. /**
  48140. * Instantiates a new ArcRotateCameraInputsManager.
  48141. * @param camera Defines the camera the inputs belong to
  48142. */
  48143. constructor(camera: ArcRotateCamera);
  48144. /**
  48145. * Add mouse wheel input support to the input manager.
  48146. * @returns the current input manager
  48147. */
  48148. addMouseWheel(): ArcRotateCameraInputsManager;
  48149. /**
  48150. * Add pointers input support to the input manager.
  48151. * @returns the current input manager
  48152. */
  48153. addPointers(): ArcRotateCameraInputsManager;
  48154. /**
  48155. * Add keyboard input support to the input manager.
  48156. * @returns the current input manager
  48157. */
  48158. addKeyboard(): ArcRotateCameraInputsManager;
  48159. }
  48160. }
  48161. declare module "babylonjs/Cameras/arcRotateCamera" {
  48162. import { Observable } from "babylonjs/Misc/observable";
  48163. import { Nullable } from "babylonjs/types";
  48164. import { Scene } from "babylonjs/scene";
  48165. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  48166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48167. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  48168. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  48169. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  48170. import { Camera } from "babylonjs/Cameras/camera";
  48171. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  48172. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  48173. import { Collider } from "babylonjs/Collisions/collider";
  48174. /**
  48175. * This represents an orbital type of camera.
  48176. *
  48177. * 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.
  48178. * 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.
  48179. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  48180. */
  48181. export class ArcRotateCamera extends TargetCamera {
  48182. /**
  48183. * Defines the rotation angle of the camera along the longitudinal axis.
  48184. */
  48185. alpha: number;
  48186. /**
  48187. * Defines the rotation angle of the camera along the latitudinal axis.
  48188. */
  48189. beta: number;
  48190. /**
  48191. * Defines the radius of the camera from it s target point.
  48192. */
  48193. radius: number;
  48194. protected _target: Vector3;
  48195. protected _targetHost: Nullable<AbstractMesh>;
  48196. /**
  48197. * Defines the target point of the camera.
  48198. * The camera looks towards it form the radius distance.
  48199. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  48200. */
  48201. get target(): Vector3;
  48202. set target(value: Vector3);
  48203. /**
  48204. * Define the current local position of the camera in the scene
  48205. */
  48206. get position(): Vector3;
  48207. set position(newPosition: Vector3);
  48208. protected _upToYMatrix: Matrix;
  48209. protected _YToUpMatrix: Matrix;
  48210. /**
  48211. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  48212. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  48213. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  48214. */
  48215. set upVector(vec: Vector3);
  48216. get upVector(): Vector3;
  48217. /**
  48218. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  48219. */
  48220. setMatUp(): void;
  48221. /**
  48222. * Current inertia value on the longitudinal axis.
  48223. * The bigger this number the longer it will take for the camera to stop.
  48224. */
  48225. inertialAlphaOffset: number;
  48226. /**
  48227. * Current inertia value on the latitudinal axis.
  48228. * The bigger this number the longer it will take for the camera to stop.
  48229. */
  48230. inertialBetaOffset: number;
  48231. /**
  48232. * Current inertia value on the radius axis.
  48233. * The bigger this number the longer it will take for the camera to stop.
  48234. */
  48235. inertialRadiusOffset: number;
  48236. /**
  48237. * Minimum allowed angle on the longitudinal axis.
  48238. * This can help limiting how the Camera is able to move in the scene.
  48239. */
  48240. lowerAlphaLimit: Nullable<number>;
  48241. /**
  48242. * Maximum allowed angle on the longitudinal axis.
  48243. * This can help limiting how the Camera is able to move in the scene.
  48244. */
  48245. upperAlphaLimit: Nullable<number>;
  48246. /**
  48247. * Minimum allowed angle on the latitudinal axis.
  48248. * This can help limiting how the Camera is able to move in the scene.
  48249. */
  48250. lowerBetaLimit: number;
  48251. /**
  48252. * Maximum allowed angle on the latitudinal axis.
  48253. * This can help limiting how the Camera is able to move in the scene.
  48254. */
  48255. upperBetaLimit: number;
  48256. /**
  48257. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  48258. * This can help limiting how the Camera is able to move in the scene.
  48259. */
  48260. lowerRadiusLimit: Nullable<number>;
  48261. /**
  48262. * Maximum allowed distance of the camera to the target (The camera can not get further).
  48263. * This can help limiting how the Camera is able to move in the scene.
  48264. */
  48265. upperRadiusLimit: Nullable<number>;
  48266. /**
  48267. * Defines the current inertia value used during panning of the camera along the X axis.
  48268. */
  48269. inertialPanningX: number;
  48270. /**
  48271. * Defines the current inertia value used during panning of the camera along the Y axis.
  48272. */
  48273. inertialPanningY: number;
  48274. /**
  48275. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  48276. * Basically if your fingers moves away from more than this distance you will be considered
  48277. * in pinch mode.
  48278. */
  48279. pinchToPanMaxDistance: number;
  48280. /**
  48281. * Defines the maximum distance the camera can pan.
  48282. * This could help keeping the cammera always in your scene.
  48283. */
  48284. panningDistanceLimit: Nullable<number>;
  48285. /**
  48286. * Defines the target of the camera before paning.
  48287. */
  48288. panningOriginTarget: Vector3;
  48289. /**
  48290. * Defines the value of the inertia used during panning.
  48291. * 0 would mean stop inertia and one would mean no decelleration at all.
  48292. */
  48293. panningInertia: number;
  48294. /**
  48295. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  48296. */
  48297. get angularSensibilityX(): number;
  48298. set angularSensibilityX(value: number);
  48299. /**
  48300. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  48301. */
  48302. get angularSensibilityY(): number;
  48303. set angularSensibilityY(value: number);
  48304. /**
  48305. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  48306. */
  48307. get pinchPrecision(): number;
  48308. set pinchPrecision(value: number);
  48309. /**
  48310. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  48311. * It will be used instead of pinchDeltaPrecision if different from 0.
  48312. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  48313. */
  48314. get pinchDeltaPercentage(): number;
  48315. set pinchDeltaPercentage(value: number);
  48316. /**
  48317. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  48318. * and pinch delta percentage.
  48319. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  48320. * that any object in the plane at the camera's target point will scale
  48321. * perfectly with finger motion.
  48322. */
  48323. get useNaturalPinchZoom(): boolean;
  48324. set useNaturalPinchZoom(value: boolean);
  48325. /**
  48326. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  48327. */
  48328. get panningSensibility(): number;
  48329. set panningSensibility(value: number);
  48330. /**
  48331. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  48332. */
  48333. get keysUp(): number[];
  48334. set keysUp(value: number[]);
  48335. /**
  48336. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  48337. */
  48338. get keysDown(): number[];
  48339. set keysDown(value: number[]);
  48340. /**
  48341. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  48342. */
  48343. get keysLeft(): number[];
  48344. set keysLeft(value: number[]);
  48345. /**
  48346. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  48347. */
  48348. get keysRight(): number[];
  48349. set keysRight(value: number[]);
  48350. /**
  48351. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  48352. */
  48353. get wheelPrecision(): number;
  48354. set wheelPrecision(value: number);
  48355. /**
  48356. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  48357. * It will be used instead of pinchDeltaPrecision if different from 0.
  48358. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  48359. */
  48360. get wheelDeltaPercentage(): number;
  48361. set wheelDeltaPercentage(value: number);
  48362. /**
  48363. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  48364. */
  48365. zoomOnFactor: number;
  48366. /**
  48367. * Defines a screen offset for the camera position.
  48368. */
  48369. targetScreenOffset: Vector2;
  48370. /**
  48371. * Allows the camera to be completely reversed.
  48372. * If false the camera can not arrive upside down.
  48373. */
  48374. allowUpsideDown: boolean;
  48375. /**
  48376. * Define if double tap/click is used to restore the previously saved state of the camera.
  48377. */
  48378. useInputToRestoreState: boolean;
  48379. /** @hidden */
  48380. _viewMatrix: Matrix;
  48381. /** @hidden */
  48382. _useCtrlForPanning: boolean;
  48383. /** @hidden */
  48384. _panningMouseButton: number;
  48385. /**
  48386. * Defines the input associated to the camera.
  48387. */
  48388. inputs: ArcRotateCameraInputsManager;
  48389. /** @hidden */
  48390. _reset: () => void;
  48391. /**
  48392. * Defines the allowed panning axis.
  48393. */
  48394. panningAxis: Vector3;
  48395. protected _localDirection: Vector3;
  48396. protected _transformedDirection: Vector3;
  48397. private _bouncingBehavior;
  48398. /**
  48399. * Gets the bouncing behavior of the camera if it has been enabled.
  48400. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48401. */
  48402. get bouncingBehavior(): Nullable<BouncingBehavior>;
  48403. /**
  48404. * Defines if the bouncing behavior of the camera is enabled on the camera.
  48405. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48406. */
  48407. get useBouncingBehavior(): boolean;
  48408. set useBouncingBehavior(value: boolean);
  48409. private _framingBehavior;
  48410. /**
  48411. * Gets the framing behavior of the camera if it has been enabled.
  48412. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48413. */
  48414. get framingBehavior(): Nullable<FramingBehavior>;
  48415. /**
  48416. * Defines if the framing behavior of the camera is enabled on the camera.
  48417. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48418. */
  48419. get useFramingBehavior(): boolean;
  48420. set useFramingBehavior(value: boolean);
  48421. private _autoRotationBehavior;
  48422. /**
  48423. * Gets the auto rotation behavior of the camera if it has been enabled.
  48424. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48425. */
  48426. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  48427. /**
  48428. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  48429. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48430. */
  48431. get useAutoRotationBehavior(): boolean;
  48432. set useAutoRotationBehavior(value: boolean);
  48433. /**
  48434. * Observable triggered when the mesh target has been changed on the camera.
  48435. */
  48436. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  48437. /**
  48438. * Event raised when the camera is colliding with a mesh.
  48439. */
  48440. onCollide: (collidedMesh: AbstractMesh) => void;
  48441. /**
  48442. * Defines whether the camera should check collision with the objects oh the scene.
  48443. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  48444. */
  48445. checkCollisions: boolean;
  48446. /**
  48447. * Defines the collision radius of the camera.
  48448. * This simulates a sphere around the camera.
  48449. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  48450. */
  48451. collisionRadius: Vector3;
  48452. protected _collider: Collider;
  48453. protected _previousPosition: Vector3;
  48454. protected _collisionVelocity: Vector3;
  48455. protected _newPosition: Vector3;
  48456. protected _previousAlpha: number;
  48457. protected _previousBeta: number;
  48458. protected _previousRadius: number;
  48459. protected _collisionTriggered: boolean;
  48460. protected _targetBoundingCenter: Nullable<Vector3>;
  48461. private _computationVector;
  48462. /**
  48463. * Instantiates a new ArcRotateCamera in a given scene
  48464. * @param name Defines the name of the camera
  48465. * @param alpha Defines the camera rotation along the logitudinal axis
  48466. * @param beta Defines the camera rotation along the latitudinal axis
  48467. * @param radius Defines the camera distance from its target
  48468. * @param target Defines the camera target
  48469. * @param scene Defines the scene the camera belongs to
  48470. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  48471. */
  48472. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  48473. /** @hidden */
  48474. _initCache(): void;
  48475. /** @hidden */
  48476. _updateCache(ignoreParentClass?: boolean): void;
  48477. protected _getTargetPosition(): Vector3;
  48478. private _storedAlpha;
  48479. private _storedBeta;
  48480. private _storedRadius;
  48481. private _storedTarget;
  48482. private _storedTargetScreenOffset;
  48483. /**
  48484. * Stores the current state of the camera (alpha, beta, radius and target)
  48485. * @returns the camera itself
  48486. */
  48487. storeState(): Camera;
  48488. /**
  48489. * @hidden
  48490. * Restored camera state. You must call storeState() first
  48491. */
  48492. _restoreStateValues(): boolean;
  48493. /** @hidden */
  48494. _isSynchronizedViewMatrix(): boolean;
  48495. /**
  48496. * Attach the input controls to a specific dom element to get the input from.
  48497. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48498. */
  48499. attachControl(noPreventDefault?: boolean): void;
  48500. /**
  48501. * Attach the input controls to a specific dom element to get the input from.
  48502. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  48503. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48504. */
  48505. attachControl(ignored: any, noPreventDefault?: boolean): void;
  48506. /**
  48507. * Attached controls to the current camera.
  48508. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48509. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48510. */
  48511. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  48512. /**
  48513. * Attached controls to the current camera.
  48514. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  48515. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48516. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48517. */
  48518. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  48519. /**
  48520. * Attached controls to the current camera.
  48521. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48522. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48523. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  48524. */
  48525. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  48526. /**
  48527. * Detach the current controls from the specified dom element.
  48528. */
  48529. detachControl(): void;
  48530. /**
  48531. * Detach the current controls from the specified dom element.
  48532. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  48533. */
  48534. detachControl(ignored: any): void;
  48535. /** @hidden */
  48536. _checkInputs(): void;
  48537. protected _checkLimits(): void;
  48538. /**
  48539. * Rebuilds angles (alpha, beta) and radius from the give position and target
  48540. */
  48541. rebuildAnglesAndRadius(): void;
  48542. /**
  48543. * Use a position to define the current camera related information like alpha, beta and radius
  48544. * @param position Defines the position to set the camera at
  48545. */
  48546. setPosition(position: Vector3): void;
  48547. /**
  48548. * Defines the target the camera should look at.
  48549. * This will automatically adapt alpha beta and radius to fit within the new target.
  48550. * @param target Defines the new target as a Vector or a mesh
  48551. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  48552. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  48553. */
  48554. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  48555. /** @hidden */
  48556. _getViewMatrix(): Matrix;
  48557. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  48558. /**
  48559. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  48560. * @param meshes Defines the mesh to zoom on
  48561. * @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)
  48562. */
  48563. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  48564. /**
  48565. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  48566. * The target will be changed but the radius
  48567. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  48568. * @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)
  48569. */
  48570. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  48571. min: Vector3;
  48572. max: Vector3;
  48573. distance: number;
  48574. }, doNotUpdateMaxZ?: boolean): void;
  48575. /**
  48576. * @override
  48577. * Override Camera.createRigCamera
  48578. */
  48579. createRigCamera(name: string, cameraIndex: number): Camera;
  48580. /**
  48581. * @hidden
  48582. * @override
  48583. * Override Camera._updateRigCameras
  48584. */
  48585. _updateRigCameras(): void;
  48586. /**
  48587. * Destroy the camera and release the current resources hold by it.
  48588. */
  48589. dispose(): void;
  48590. /**
  48591. * Gets the current object class name.
  48592. * @return the class name
  48593. */
  48594. getClassName(): string;
  48595. }
  48596. }
  48597. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  48598. import { Behavior } from "babylonjs/Behaviors/behavior";
  48599. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48600. /**
  48601. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  48602. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48603. */
  48604. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  48605. /**
  48606. * Gets the name of the behavior.
  48607. */
  48608. get name(): string;
  48609. private _zoomStopsAnimation;
  48610. private _idleRotationSpeed;
  48611. private _idleRotationWaitTime;
  48612. private _idleRotationSpinupTime;
  48613. /**
  48614. * Sets the flag that indicates if user zooming should stop animation.
  48615. */
  48616. set zoomStopsAnimation(flag: boolean);
  48617. /**
  48618. * Gets the flag that indicates if user zooming should stop animation.
  48619. */
  48620. get zoomStopsAnimation(): boolean;
  48621. /**
  48622. * Sets the default speed at which the camera rotates around the model.
  48623. */
  48624. set idleRotationSpeed(speed: number);
  48625. /**
  48626. * Gets the default speed at which the camera rotates around the model.
  48627. */
  48628. get idleRotationSpeed(): number;
  48629. /**
  48630. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  48631. */
  48632. set idleRotationWaitTime(time: number);
  48633. /**
  48634. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  48635. */
  48636. get idleRotationWaitTime(): number;
  48637. /**
  48638. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48639. */
  48640. set idleRotationSpinupTime(time: number);
  48641. /**
  48642. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48643. */
  48644. get idleRotationSpinupTime(): number;
  48645. /**
  48646. * Gets a value indicating if the camera is currently rotating because of this behavior
  48647. */
  48648. get rotationInProgress(): boolean;
  48649. private _onPrePointerObservableObserver;
  48650. private _onAfterCheckInputsObserver;
  48651. private _attachedCamera;
  48652. private _isPointerDown;
  48653. private _lastFrameTime;
  48654. private _lastInteractionTime;
  48655. private _cameraRotationSpeed;
  48656. /**
  48657. * Initializes the behavior.
  48658. */
  48659. init(): void;
  48660. /**
  48661. * Attaches the behavior to its arc rotate camera.
  48662. * @param camera Defines the camera to attach the behavior to
  48663. */
  48664. attach(camera: ArcRotateCamera): void;
  48665. /**
  48666. * Detaches the behavior from its current arc rotate camera.
  48667. */
  48668. detach(): void;
  48669. /**
  48670. * Returns true if user is scrolling.
  48671. * @return true if user is scrolling.
  48672. */
  48673. private _userIsZooming;
  48674. private _lastFrameRadius;
  48675. private _shouldAnimationStopForInteraction;
  48676. /**
  48677. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  48678. */
  48679. private _applyUserInteraction;
  48680. private _userIsMoving;
  48681. }
  48682. }
  48683. declare module "babylonjs/Behaviors/Cameras/index" {
  48684. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  48685. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  48686. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  48687. }
  48688. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  48689. import { Mesh } from "babylonjs/Meshes/mesh";
  48690. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48691. import { Behavior } from "babylonjs/Behaviors/behavior";
  48692. /**
  48693. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  48694. */
  48695. export class AttachToBoxBehavior implements Behavior<Mesh> {
  48696. private ui;
  48697. /**
  48698. * The name of the behavior
  48699. */
  48700. name: string;
  48701. /**
  48702. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  48703. */
  48704. distanceAwayFromFace: number;
  48705. /**
  48706. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  48707. */
  48708. distanceAwayFromBottomOfFace: number;
  48709. private _faceVectors;
  48710. private _target;
  48711. private _scene;
  48712. private _onRenderObserver;
  48713. private _tmpMatrix;
  48714. private _tmpVector;
  48715. /**
  48716. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  48717. * @param ui The transform node that should be attched to the mesh
  48718. */
  48719. constructor(ui: TransformNode);
  48720. /**
  48721. * Initializes the behavior
  48722. */
  48723. init(): void;
  48724. private _closestFace;
  48725. private _zeroVector;
  48726. private _lookAtTmpMatrix;
  48727. private _lookAtToRef;
  48728. /**
  48729. * Attaches the AttachToBoxBehavior to the passed in mesh
  48730. * @param target The mesh that the specified node will be attached to
  48731. */
  48732. attach(target: Mesh): void;
  48733. /**
  48734. * Detaches the behavior from the mesh
  48735. */
  48736. detach(): void;
  48737. }
  48738. }
  48739. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  48740. import { Behavior } from "babylonjs/Behaviors/behavior";
  48741. import { Mesh } from "babylonjs/Meshes/mesh";
  48742. /**
  48743. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  48744. */
  48745. export class FadeInOutBehavior implements Behavior<Mesh> {
  48746. /**
  48747. * Time in milliseconds to delay before fading in (Default: 0)
  48748. */
  48749. delay: number;
  48750. /**
  48751. * Time in milliseconds for the mesh to fade in (Default: 300)
  48752. */
  48753. fadeInTime: number;
  48754. private _millisecondsPerFrame;
  48755. private _hovered;
  48756. private _hoverValue;
  48757. private _ownerNode;
  48758. /**
  48759. * Instatiates the FadeInOutBehavior
  48760. */
  48761. constructor();
  48762. /**
  48763. * The name of the behavior
  48764. */
  48765. get name(): string;
  48766. /**
  48767. * Initializes the behavior
  48768. */
  48769. init(): void;
  48770. /**
  48771. * Attaches the fade behavior on the passed in mesh
  48772. * @param ownerNode The mesh that will be faded in/out once attached
  48773. */
  48774. attach(ownerNode: Mesh): void;
  48775. /**
  48776. * Detaches the behavior from the mesh
  48777. */
  48778. detach(): void;
  48779. /**
  48780. * Triggers the mesh to begin fading in or out
  48781. * @param value if the object should fade in or out (true to fade in)
  48782. */
  48783. fadeIn(value: boolean): void;
  48784. private _update;
  48785. private _setAllVisibility;
  48786. }
  48787. }
  48788. declare module "babylonjs/Misc/pivotTools" {
  48789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48790. /**
  48791. * Class containing a set of static utilities functions for managing Pivots
  48792. * @hidden
  48793. */
  48794. export class PivotTools {
  48795. private static _PivotCached;
  48796. private static _OldPivotPoint;
  48797. private static _PivotTranslation;
  48798. private static _PivotTmpVector;
  48799. private static _PivotPostMultiplyPivotMatrix;
  48800. /** @hidden */
  48801. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  48802. /** @hidden */
  48803. static _RestorePivotPoint(mesh: AbstractMesh): void;
  48804. }
  48805. }
  48806. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  48807. import { Scene } from "babylonjs/scene";
  48808. import { Vector4 } from "babylonjs/Maths/math.vector";
  48809. import { Mesh } from "babylonjs/Meshes/mesh";
  48810. import { Nullable } from "babylonjs/types";
  48811. import { Plane } from "babylonjs/Maths/math.plane";
  48812. /**
  48813. * Class containing static functions to help procedurally build meshes
  48814. */
  48815. export class PlaneBuilder {
  48816. /**
  48817. * Creates a plane mesh
  48818. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  48819. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  48820. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  48821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48822. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48824. * @param name defines the name of the mesh
  48825. * @param options defines the options used to create the mesh
  48826. * @param scene defines the hosting scene
  48827. * @returns the plane mesh
  48828. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  48829. */
  48830. static CreatePlane(name: string, options: {
  48831. size?: number;
  48832. width?: number;
  48833. height?: number;
  48834. sideOrientation?: number;
  48835. frontUVs?: Vector4;
  48836. backUVs?: Vector4;
  48837. updatable?: boolean;
  48838. sourcePlane?: Plane;
  48839. }, scene?: Nullable<Scene>): Mesh;
  48840. }
  48841. }
  48842. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  48843. import { Behavior } from "babylonjs/Behaviors/behavior";
  48844. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48845. import { Observable } from "babylonjs/Misc/observable";
  48846. import { Vector3 } from "babylonjs/Maths/math.vector";
  48847. import { Ray } from "babylonjs/Culling/ray";
  48848. import "babylonjs/Meshes/Builders/planeBuilder";
  48849. /**
  48850. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  48851. */
  48852. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  48853. private static _AnyMouseID;
  48854. /**
  48855. * Abstract mesh the behavior is set on
  48856. */
  48857. attachedNode: AbstractMesh;
  48858. private _dragPlane;
  48859. private _scene;
  48860. private _pointerObserver;
  48861. private _beforeRenderObserver;
  48862. private static _planeScene;
  48863. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  48864. /**
  48865. * 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)
  48866. */
  48867. maxDragAngle: number;
  48868. /**
  48869. * @hidden
  48870. */
  48871. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  48872. /**
  48873. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48874. */
  48875. currentDraggingPointerID: number;
  48876. /**
  48877. * The last position where the pointer hit the drag plane in world space
  48878. */
  48879. lastDragPosition: Vector3;
  48880. /**
  48881. * If the behavior is currently in a dragging state
  48882. */
  48883. dragging: boolean;
  48884. /**
  48885. * 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)
  48886. */
  48887. dragDeltaRatio: number;
  48888. /**
  48889. * If the drag plane orientation should be updated during the dragging (Default: true)
  48890. */
  48891. updateDragPlane: boolean;
  48892. private _debugMode;
  48893. private _moving;
  48894. /**
  48895. * Fires each time the attached mesh is dragged with the pointer
  48896. * * delta between last drag position and current drag position in world space
  48897. * * dragDistance along the drag axis
  48898. * * dragPlaneNormal normal of the current drag plane used during the drag
  48899. * * dragPlanePoint in world space where the drag intersects the drag plane
  48900. */
  48901. onDragObservable: Observable<{
  48902. delta: Vector3;
  48903. dragPlanePoint: Vector3;
  48904. dragPlaneNormal: Vector3;
  48905. dragDistance: number;
  48906. pointerId: number;
  48907. }>;
  48908. /**
  48909. * Fires each time a drag begins (eg. mouse down on mesh)
  48910. */
  48911. onDragStartObservable: Observable<{
  48912. dragPlanePoint: Vector3;
  48913. pointerId: number;
  48914. }>;
  48915. /**
  48916. * Fires each time a drag ends (eg. mouse release after drag)
  48917. */
  48918. onDragEndObservable: Observable<{
  48919. dragPlanePoint: Vector3;
  48920. pointerId: number;
  48921. }>;
  48922. /**
  48923. * If the attached mesh should be moved when dragged
  48924. */
  48925. moveAttached: boolean;
  48926. /**
  48927. * If the drag behavior will react to drag events (Default: true)
  48928. */
  48929. enabled: boolean;
  48930. /**
  48931. * If pointer events should start and release the drag (Default: true)
  48932. */
  48933. startAndReleaseDragOnPointerEvents: boolean;
  48934. /**
  48935. * If camera controls should be detached during the drag
  48936. */
  48937. detachCameraControls: boolean;
  48938. /**
  48939. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  48940. */
  48941. useObjectOrientationForDragging: boolean;
  48942. private _options;
  48943. /**
  48944. * Gets the options used by the behavior
  48945. */
  48946. get options(): {
  48947. dragAxis?: Vector3;
  48948. dragPlaneNormal?: Vector3;
  48949. };
  48950. /**
  48951. * Sets the options used by the behavior
  48952. */
  48953. set options(options: {
  48954. dragAxis?: Vector3;
  48955. dragPlaneNormal?: Vector3;
  48956. });
  48957. /**
  48958. * Creates a pointer drag behavior that can be attached to a mesh
  48959. * @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)
  48960. */
  48961. constructor(options?: {
  48962. dragAxis?: Vector3;
  48963. dragPlaneNormal?: Vector3;
  48964. });
  48965. /**
  48966. * Predicate to determine if it is valid to move the object to a new position when it is moved
  48967. */
  48968. validateDrag: (targetPosition: Vector3) => boolean;
  48969. /**
  48970. * The name of the behavior
  48971. */
  48972. get name(): string;
  48973. /**
  48974. * Initializes the behavior
  48975. */
  48976. init(): void;
  48977. private _tmpVector;
  48978. private _alternatePickedPoint;
  48979. private _worldDragAxis;
  48980. private _targetPosition;
  48981. private _attachedToElement;
  48982. /**
  48983. * Attaches the drag behavior the passed in mesh
  48984. * @param ownerNode The mesh that will be dragged around once attached
  48985. * @param predicate Predicate to use for pick filtering
  48986. */
  48987. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  48988. /**
  48989. * Force relase the drag action by code.
  48990. */
  48991. releaseDrag(): void;
  48992. private _startDragRay;
  48993. private _lastPointerRay;
  48994. /**
  48995. * Simulates the start of a pointer drag event on the behavior
  48996. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  48997. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  48998. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  48999. */
  49000. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  49001. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  49002. private _dragDelta;
  49003. protected _moveDrag(ray: Ray): void;
  49004. private _pickWithRayOnDragPlane;
  49005. private _pointA;
  49006. private _pointC;
  49007. private _localAxis;
  49008. private _lookAt;
  49009. private _updateDragPlanePosition;
  49010. /**
  49011. * Detaches the behavior from the mesh
  49012. */
  49013. detach(): void;
  49014. }
  49015. }
  49016. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  49017. import { Mesh } from "babylonjs/Meshes/mesh";
  49018. import { Behavior } from "babylonjs/Behaviors/behavior";
  49019. /**
  49020. * A behavior that when attached to a mesh will allow the mesh to be scaled
  49021. */
  49022. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  49023. private _dragBehaviorA;
  49024. private _dragBehaviorB;
  49025. private _startDistance;
  49026. private _initialScale;
  49027. private _targetScale;
  49028. private _ownerNode;
  49029. private _sceneRenderObserver;
  49030. /**
  49031. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  49032. */
  49033. constructor();
  49034. /**
  49035. * The name of the behavior
  49036. */
  49037. get name(): string;
  49038. /**
  49039. * Initializes the behavior
  49040. */
  49041. init(): void;
  49042. private _getCurrentDistance;
  49043. /**
  49044. * Attaches the scale behavior the passed in mesh
  49045. * @param ownerNode The mesh that will be scaled around once attached
  49046. */
  49047. attach(ownerNode: Mesh): void;
  49048. /**
  49049. * Detaches the behavior from the mesh
  49050. */
  49051. detach(): void;
  49052. }
  49053. }
  49054. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  49055. import { Behavior } from "babylonjs/Behaviors/behavior";
  49056. import { Mesh } from "babylonjs/Meshes/mesh";
  49057. import { Observable } from "babylonjs/Misc/observable";
  49058. /**
  49059. * 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
  49060. */
  49061. export class SixDofDragBehavior implements Behavior<Mesh> {
  49062. private static _virtualScene;
  49063. private _ownerNode;
  49064. private _sceneRenderObserver;
  49065. private _scene;
  49066. private _targetPosition;
  49067. private _virtualOriginMesh;
  49068. private _virtualDragMesh;
  49069. private _pointerObserver;
  49070. private _moving;
  49071. private _startingOrientation;
  49072. private _attachedToElement;
  49073. /**
  49074. * 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)
  49075. */
  49076. private zDragFactor;
  49077. /**
  49078. * If the object should rotate to face the drag origin
  49079. */
  49080. rotateDraggedObject: boolean;
  49081. /**
  49082. * If the behavior is currently in a dragging state
  49083. */
  49084. dragging: boolean;
  49085. /**
  49086. * 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)
  49087. */
  49088. dragDeltaRatio: number;
  49089. /**
  49090. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  49091. */
  49092. currentDraggingPointerID: number;
  49093. /**
  49094. * If camera controls should be detached during the drag
  49095. */
  49096. detachCameraControls: boolean;
  49097. /**
  49098. * Fires each time a drag starts
  49099. */
  49100. onDragStartObservable: Observable<{}>;
  49101. /**
  49102. * Fires each time a drag ends (eg. mouse release after drag)
  49103. */
  49104. onDragEndObservable: Observable<{}>;
  49105. /**
  49106. * 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
  49107. */
  49108. constructor();
  49109. /**
  49110. * The name of the behavior
  49111. */
  49112. get name(): string;
  49113. /**
  49114. * Initializes the behavior
  49115. */
  49116. init(): void;
  49117. /**
  49118. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  49119. */
  49120. private get _pointerCamera();
  49121. /**
  49122. * Attaches the scale behavior the passed in mesh
  49123. * @param ownerNode The mesh that will be scaled around once attached
  49124. */
  49125. attach(ownerNode: Mesh): void;
  49126. /**
  49127. * Detaches the behavior from the mesh
  49128. */
  49129. detach(): void;
  49130. }
  49131. }
  49132. declare module "babylonjs/Behaviors/Meshes/index" {
  49133. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  49134. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  49135. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  49136. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  49137. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  49138. }
  49139. declare module "babylonjs/Behaviors/index" {
  49140. export * from "babylonjs/Behaviors/behavior";
  49141. export * from "babylonjs/Behaviors/Cameras/index";
  49142. export * from "babylonjs/Behaviors/Meshes/index";
  49143. }
  49144. declare module "babylonjs/Bones/boneIKController" {
  49145. import { Bone } from "babylonjs/Bones/bone";
  49146. import { Vector3 } from "babylonjs/Maths/math.vector";
  49147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49148. import { Nullable } from "babylonjs/types";
  49149. /**
  49150. * Class used to apply inverse kinematics to bones
  49151. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  49152. */
  49153. export class BoneIKController {
  49154. private static _tmpVecs;
  49155. private static _tmpQuat;
  49156. private static _tmpMats;
  49157. /**
  49158. * Gets or sets the target mesh
  49159. */
  49160. targetMesh: AbstractMesh;
  49161. /** Gets or sets the mesh used as pole */
  49162. poleTargetMesh: AbstractMesh;
  49163. /**
  49164. * Gets or sets the bone used as pole
  49165. */
  49166. poleTargetBone: Nullable<Bone>;
  49167. /**
  49168. * Gets or sets the target position
  49169. */
  49170. targetPosition: Vector3;
  49171. /**
  49172. * Gets or sets the pole target position
  49173. */
  49174. poleTargetPosition: Vector3;
  49175. /**
  49176. * Gets or sets the pole target local offset
  49177. */
  49178. poleTargetLocalOffset: Vector3;
  49179. /**
  49180. * Gets or sets the pole angle
  49181. */
  49182. poleAngle: number;
  49183. /**
  49184. * Gets or sets the mesh associated with the controller
  49185. */
  49186. mesh: AbstractMesh;
  49187. /**
  49188. * 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)
  49189. */
  49190. slerpAmount: number;
  49191. private _bone1Quat;
  49192. private _bone1Mat;
  49193. private _bone2Ang;
  49194. private _bone1;
  49195. private _bone2;
  49196. private _bone1Length;
  49197. private _bone2Length;
  49198. private _maxAngle;
  49199. private _maxReach;
  49200. private _rightHandedSystem;
  49201. private _bendAxis;
  49202. private _slerping;
  49203. private _adjustRoll;
  49204. /**
  49205. * Gets or sets maximum allowed angle
  49206. */
  49207. get maxAngle(): number;
  49208. set maxAngle(value: number);
  49209. /**
  49210. * Creates a new BoneIKController
  49211. * @param mesh defines the mesh to control
  49212. * @param bone defines the bone to control
  49213. * @param options defines options to set up the controller
  49214. */
  49215. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  49216. targetMesh?: AbstractMesh;
  49217. poleTargetMesh?: AbstractMesh;
  49218. poleTargetBone?: Bone;
  49219. poleTargetLocalOffset?: Vector3;
  49220. poleAngle?: number;
  49221. bendAxis?: Vector3;
  49222. maxAngle?: number;
  49223. slerpAmount?: number;
  49224. });
  49225. private _setMaxAngle;
  49226. /**
  49227. * Force the controller to update the bones
  49228. */
  49229. update(): void;
  49230. }
  49231. }
  49232. declare module "babylonjs/Bones/boneLookController" {
  49233. import { Vector3 } from "babylonjs/Maths/math.vector";
  49234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49235. import { Bone } from "babylonjs/Bones/bone";
  49236. import { Space } from "babylonjs/Maths/math.axis";
  49237. /**
  49238. * Class used to make a bone look toward a point in space
  49239. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  49240. */
  49241. export class BoneLookController {
  49242. private static _tmpVecs;
  49243. private static _tmpQuat;
  49244. private static _tmpMats;
  49245. /**
  49246. * The target Vector3 that the bone will look at
  49247. */
  49248. target: Vector3;
  49249. /**
  49250. * The mesh that the bone is attached to
  49251. */
  49252. mesh: AbstractMesh;
  49253. /**
  49254. * The bone that will be looking to the target
  49255. */
  49256. bone: Bone;
  49257. /**
  49258. * The up axis of the coordinate system that is used when the bone is rotated
  49259. */
  49260. upAxis: Vector3;
  49261. /**
  49262. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  49263. */
  49264. upAxisSpace: Space;
  49265. /**
  49266. * Used to make an adjustment to the yaw of the bone
  49267. */
  49268. adjustYaw: number;
  49269. /**
  49270. * Used to make an adjustment to the pitch of the bone
  49271. */
  49272. adjustPitch: number;
  49273. /**
  49274. * Used to make an adjustment to the roll of the bone
  49275. */
  49276. adjustRoll: number;
  49277. /**
  49278. * 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)
  49279. */
  49280. slerpAmount: number;
  49281. private _minYaw;
  49282. private _maxYaw;
  49283. private _minPitch;
  49284. private _maxPitch;
  49285. private _minYawSin;
  49286. private _minYawCos;
  49287. private _maxYawSin;
  49288. private _maxYawCos;
  49289. private _midYawConstraint;
  49290. private _minPitchTan;
  49291. private _maxPitchTan;
  49292. private _boneQuat;
  49293. private _slerping;
  49294. private _transformYawPitch;
  49295. private _transformYawPitchInv;
  49296. private _firstFrameSkipped;
  49297. private _yawRange;
  49298. private _fowardAxis;
  49299. /**
  49300. * Gets or sets the minimum yaw angle that the bone can look to
  49301. */
  49302. get minYaw(): number;
  49303. set minYaw(value: number);
  49304. /**
  49305. * Gets or sets the maximum yaw angle that the bone can look to
  49306. */
  49307. get maxYaw(): number;
  49308. set maxYaw(value: number);
  49309. /**
  49310. * Gets or sets the minimum pitch angle that the bone can look to
  49311. */
  49312. get minPitch(): number;
  49313. set minPitch(value: number);
  49314. /**
  49315. * Gets or sets the maximum pitch angle that the bone can look to
  49316. */
  49317. get maxPitch(): number;
  49318. set maxPitch(value: number);
  49319. /**
  49320. * Create a BoneLookController
  49321. * @param mesh the mesh that the bone belongs to
  49322. * @param bone the bone that will be looking to the target
  49323. * @param target the target Vector3 to look at
  49324. * @param options optional settings:
  49325. * * maxYaw: the maximum angle the bone will yaw to
  49326. * * minYaw: the minimum angle the bone will yaw to
  49327. * * maxPitch: the maximum angle the bone will pitch to
  49328. * * minPitch: the minimum angle the bone will yaw to
  49329. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  49330. * * upAxis: the up axis of the coordinate system
  49331. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  49332. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  49333. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  49334. * * adjustYaw: used to make an adjustment to the yaw of the bone
  49335. * * adjustPitch: used to make an adjustment to the pitch of the bone
  49336. * * adjustRoll: used to make an adjustment to the roll of the bone
  49337. **/
  49338. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  49339. maxYaw?: number;
  49340. minYaw?: number;
  49341. maxPitch?: number;
  49342. minPitch?: number;
  49343. slerpAmount?: number;
  49344. upAxis?: Vector3;
  49345. upAxisSpace?: Space;
  49346. yawAxis?: Vector3;
  49347. pitchAxis?: Vector3;
  49348. adjustYaw?: number;
  49349. adjustPitch?: number;
  49350. adjustRoll?: number;
  49351. });
  49352. /**
  49353. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  49354. */
  49355. update(): void;
  49356. private _getAngleDiff;
  49357. private _getAngleBetween;
  49358. private _isAngleBetween;
  49359. }
  49360. }
  49361. declare module "babylonjs/Bones/index" {
  49362. export * from "babylonjs/Bones/bone";
  49363. export * from "babylonjs/Bones/boneIKController";
  49364. export * from "babylonjs/Bones/boneLookController";
  49365. export * from "babylonjs/Bones/skeleton";
  49366. }
  49367. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  49368. import { Nullable } from "babylonjs/types";
  49369. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  49370. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49371. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  49372. /**
  49373. * Manage the gamepad inputs to control an arc rotate camera.
  49374. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49375. */
  49376. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  49377. /**
  49378. * Defines the camera the input is attached to.
  49379. */
  49380. camera: ArcRotateCamera;
  49381. /**
  49382. * Defines the gamepad the input is gathering event from.
  49383. */
  49384. gamepad: Nullable<Gamepad>;
  49385. /**
  49386. * Defines the gamepad rotation sensiblity.
  49387. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49388. */
  49389. gamepadRotationSensibility: number;
  49390. /**
  49391. * Defines the gamepad move sensiblity.
  49392. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49393. */
  49394. gamepadMoveSensibility: number;
  49395. private _yAxisScale;
  49396. /**
  49397. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  49398. */
  49399. get invertYAxis(): boolean;
  49400. set invertYAxis(value: boolean);
  49401. private _onGamepadConnectedObserver;
  49402. private _onGamepadDisconnectedObserver;
  49403. /**
  49404. * Attach the input controls to a specific dom element to get the input from.
  49405. */
  49406. attachControl(): void;
  49407. /**
  49408. * Detach the current controls from the specified dom element.
  49409. */
  49410. detachControl(): void;
  49411. /**
  49412. * Update the current camera state depending on the inputs that have been used this frame.
  49413. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49414. */
  49415. checkInputs(): void;
  49416. /**
  49417. * Gets the class name of the current intput.
  49418. * @returns the class name
  49419. */
  49420. getClassName(): string;
  49421. /**
  49422. * Get the friendly name associated with the input class.
  49423. * @returns the input friendly name
  49424. */
  49425. getSimpleName(): string;
  49426. }
  49427. }
  49428. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  49429. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  49430. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49431. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  49432. interface ArcRotateCameraInputsManager {
  49433. /**
  49434. * Add orientation input support to the input manager.
  49435. * @returns the current input manager
  49436. */
  49437. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  49438. }
  49439. }
  49440. /**
  49441. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  49442. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49443. */
  49444. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  49445. /**
  49446. * Defines the camera the input is attached to.
  49447. */
  49448. camera: ArcRotateCamera;
  49449. /**
  49450. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  49451. */
  49452. alphaCorrection: number;
  49453. /**
  49454. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  49455. */
  49456. gammaCorrection: number;
  49457. private _alpha;
  49458. private _gamma;
  49459. private _dirty;
  49460. private _deviceOrientationHandler;
  49461. /**
  49462. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  49463. */
  49464. constructor();
  49465. /**
  49466. * Attach the input controls to a specific dom element to get the input from.
  49467. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49468. */
  49469. attachControl(noPreventDefault?: boolean): void;
  49470. /** @hidden */
  49471. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  49472. /**
  49473. * Update the current camera state depending on the inputs that have been used this frame.
  49474. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49475. */
  49476. checkInputs(): void;
  49477. /**
  49478. * Detach the current controls from the specified dom element.
  49479. */
  49480. detachControl(): void;
  49481. /**
  49482. * Gets the class name of the current intput.
  49483. * @returns the class name
  49484. */
  49485. getClassName(): string;
  49486. /**
  49487. * Get the friendly name associated with the input class.
  49488. * @returns the input friendly name
  49489. */
  49490. getSimpleName(): string;
  49491. }
  49492. }
  49493. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  49494. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49495. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49496. /**
  49497. * Listen to mouse events to control the camera.
  49498. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49499. */
  49500. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  49501. /**
  49502. * Defines the camera the input is attached to.
  49503. */
  49504. camera: FlyCamera;
  49505. /**
  49506. * Defines if touch is enabled. (Default is true.)
  49507. */
  49508. touchEnabled: boolean;
  49509. /**
  49510. * Defines the buttons associated with the input to handle camera rotation.
  49511. */
  49512. buttons: number[];
  49513. /**
  49514. * Assign buttons for Yaw control.
  49515. */
  49516. buttonsYaw: number[];
  49517. /**
  49518. * Assign buttons for Pitch control.
  49519. */
  49520. buttonsPitch: number[];
  49521. /**
  49522. * Assign buttons for Roll control.
  49523. */
  49524. buttonsRoll: number[];
  49525. /**
  49526. * Detect if any button is being pressed while mouse is moved.
  49527. * -1 = Mouse locked.
  49528. * 0 = Left button.
  49529. * 1 = Middle Button.
  49530. * 2 = Right Button.
  49531. */
  49532. activeButton: number;
  49533. /**
  49534. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  49535. * Higher values reduce its sensitivity.
  49536. */
  49537. angularSensibility: number;
  49538. private _observer;
  49539. private _rollObserver;
  49540. private previousPosition;
  49541. private noPreventDefault;
  49542. private element;
  49543. /**
  49544. * Listen to mouse events to control the camera.
  49545. * @param touchEnabled Define if touch is enabled. (Default is true.)
  49546. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49547. */
  49548. constructor(touchEnabled?: boolean);
  49549. /**
  49550. * Attach the mouse control to the HTML DOM element.
  49551. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  49552. */
  49553. attachControl(noPreventDefault?: boolean): void;
  49554. /**
  49555. * Detach the current controls from the specified dom element.
  49556. */
  49557. detachControl(): void;
  49558. /**
  49559. * Gets the class name of the current input.
  49560. * @returns the class name.
  49561. */
  49562. getClassName(): string;
  49563. /**
  49564. * Get the friendly name associated with the input class.
  49565. * @returns the input's friendly name.
  49566. */
  49567. getSimpleName(): string;
  49568. private _pointerInput;
  49569. private _onMouseMove;
  49570. /**
  49571. * Rotate camera by mouse offset.
  49572. */
  49573. private rotateCamera;
  49574. }
  49575. }
  49576. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  49577. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49578. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  49579. /**
  49580. * Default Inputs manager for the FlyCamera.
  49581. * It groups all the default supported inputs for ease of use.
  49582. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49583. */
  49584. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  49585. /**
  49586. * Instantiates a new FlyCameraInputsManager.
  49587. * @param camera Defines the camera the inputs belong to.
  49588. */
  49589. constructor(camera: FlyCamera);
  49590. /**
  49591. * Add keyboard input support to the input manager.
  49592. * @returns the new FlyCameraKeyboardMoveInput().
  49593. */
  49594. addKeyboard(): FlyCameraInputsManager;
  49595. /**
  49596. * Add mouse input support to the input manager.
  49597. * @param touchEnabled Enable touch screen support.
  49598. * @returns the new FlyCameraMouseInput().
  49599. */
  49600. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  49601. }
  49602. }
  49603. declare module "babylonjs/Cameras/flyCamera" {
  49604. import { Scene } from "babylonjs/scene";
  49605. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  49606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49607. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49608. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  49609. /**
  49610. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49611. * such as in a 3D Space Shooter or a Flight Simulator.
  49612. */
  49613. export class FlyCamera extends TargetCamera {
  49614. /**
  49615. * Define the collision ellipsoid of the camera.
  49616. * This is helpful for simulating a camera body, like a player's body.
  49617. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49618. */
  49619. ellipsoid: Vector3;
  49620. /**
  49621. * Define an offset for the position of the ellipsoid around the camera.
  49622. * This can be helpful if the camera is attached away from the player's body center,
  49623. * such as at its head.
  49624. */
  49625. ellipsoidOffset: Vector3;
  49626. /**
  49627. * Enable or disable collisions of the camera with the rest of the scene objects.
  49628. */
  49629. checkCollisions: boolean;
  49630. /**
  49631. * Enable or disable gravity on the camera.
  49632. */
  49633. applyGravity: boolean;
  49634. /**
  49635. * Define the current direction the camera is moving to.
  49636. */
  49637. cameraDirection: Vector3;
  49638. /**
  49639. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  49640. * This overrides and empties cameraRotation.
  49641. */
  49642. rotationQuaternion: Quaternion;
  49643. /**
  49644. * Track Roll to maintain the wanted Rolling when looking around.
  49645. */
  49646. _trackRoll: number;
  49647. /**
  49648. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  49649. */
  49650. rollCorrect: number;
  49651. /**
  49652. * Mimic a banked turn, Rolling the camera when Yawing.
  49653. * It's recommended to use rollCorrect = 10 for faster banking correction.
  49654. */
  49655. bankedTurn: boolean;
  49656. /**
  49657. * Limit in radians for how much Roll banking will add. (Default: 90°)
  49658. */
  49659. bankedTurnLimit: number;
  49660. /**
  49661. * Value of 0 disables the banked Roll.
  49662. * Value of 1 is equal to the Yaw angle in radians.
  49663. */
  49664. bankedTurnMultiplier: number;
  49665. /**
  49666. * The inputs manager loads all the input sources, such as keyboard and mouse.
  49667. */
  49668. inputs: FlyCameraInputsManager;
  49669. /**
  49670. * Gets the input sensibility for mouse input.
  49671. * Higher values reduce sensitivity.
  49672. */
  49673. get angularSensibility(): number;
  49674. /**
  49675. * Sets the input sensibility for a mouse input.
  49676. * Higher values reduce sensitivity.
  49677. */
  49678. set angularSensibility(value: number);
  49679. /**
  49680. * Get the keys for camera movement forward.
  49681. */
  49682. get keysForward(): number[];
  49683. /**
  49684. * Set the keys for camera movement forward.
  49685. */
  49686. set keysForward(value: number[]);
  49687. /**
  49688. * Get the keys for camera movement backward.
  49689. */
  49690. get keysBackward(): number[];
  49691. set keysBackward(value: number[]);
  49692. /**
  49693. * Get the keys for camera movement up.
  49694. */
  49695. get keysUp(): number[];
  49696. /**
  49697. * Set the keys for camera movement up.
  49698. */
  49699. set keysUp(value: number[]);
  49700. /**
  49701. * Get the keys for camera movement down.
  49702. */
  49703. get keysDown(): number[];
  49704. /**
  49705. * Set the keys for camera movement down.
  49706. */
  49707. set keysDown(value: number[]);
  49708. /**
  49709. * Get the keys for camera movement left.
  49710. */
  49711. get keysLeft(): number[];
  49712. /**
  49713. * Set the keys for camera movement left.
  49714. */
  49715. set keysLeft(value: number[]);
  49716. /**
  49717. * Set the keys for camera movement right.
  49718. */
  49719. get keysRight(): number[];
  49720. /**
  49721. * Set the keys for camera movement right.
  49722. */
  49723. set keysRight(value: number[]);
  49724. /**
  49725. * Event raised when the camera collides with a mesh in the scene.
  49726. */
  49727. onCollide: (collidedMesh: AbstractMesh) => void;
  49728. private _collider;
  49729. private _needMoveForGravity;
  49730. private _oldPosition;
  49731. private _diffPosition;
  49732. private _newPosition;
  49733. /** @hidden */
  49734. _localDirection: Vector3;
  49735. /** @hidden */
  49736. _transformedDirection: Vector3;
  49737. /**
  49738. * Instantiates a FlyCamera.
  49739. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49740. * such as in a 3D Space Shooter or a Flight Simulator.
  49741. * @param name Define the name of the camera in the scene.
  49742. * @param position Define the starting position of the camera in the scene.
  49743. * @param scene Define the scene the camera belongs to.
  49744. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  49745. */
  49746. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49747. /**
  49748. * Attach the input controls to a specific dom element to get the input from.
  49749. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49750. */
  49751. attachControl(noPreventDefault?: boolean): void;
  49752. /**
  49753. * Detach a control from the HTML DOM element.
  49754. * The camera will stop reacting to that input.
  49755. */
  49756. detachControl(): void;
  49757. private _collisionMask;
  49758. /**
  49759. * Get the mask that the camera ignores in collision events.
  49760. */
  49761. get collisionMask(): number;
  49762. /**
  49763. * Set the mask that the camera ignores in collision events.
  49764. */
  49765. set collisionMask(mask: number);
  49766. /** @hidden */
  49767. _collideWithWorld(displacement: Vector3): void;
  49768. /** @hidden */
  49769. private _onCollisionPositionChange;
  49770. /** @hidden */
  49771. _checkInputs(): void;
  49772. /** @hidden */
  49773. _decideIfNeedsToMove(): boolean;
  49774. /** @hidden */
  49775. _updatePosition(): void;
  49776. /**
  49777. * Restore the Roll to its target value at the rate specified.
  49778. * @param rate - Higher means slower restoring.
  49779. * @hidden
  49780. */
  49781. restoreRoll(rate: number): void;
  49782. /**
  49783. * Destroy the camera and release the current resources held by it.
  49784. */
  49785. dispose(): void;
  49786. /**
  49787. * Get the current object class name.
  49788. * @returns the class name.
  49789. */
  49790. getClassName(): string;
  49791. }
  49792. }
  49793. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  49794. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49795. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49796. /**
  49797. * Listen to keyboard events to control the camera.
  49798. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49799. */
  49800. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  49801. /**
  49802. * Defines the camera the input is attached to.
  49803. */
  49804. camera: FlyCamera;
  49805. /**
  49806. * The list of keyboard keys used to control the forward move of the camera.
  49807. */
  49808. keysForward: number[];
  49809. /**
  49810. * The list of keyboard keys used to control the backward move of the camera.
  49811. */
  49812. keysBackward: number[];
  49813. /**
  49814. * The list of keyboard keys used to control the forward move of the camera.
  49815. */
  49816. keysUp: number[];
  49817. /**
  49818. * The list of keyboard keys used to control the backward move of the camera.
  49819. */
  49820. keysDown: number[];
  49821. /**
  49822. * The list of keyboard keys used to control the right strafe move of the camera.
  49823. */
  49824. keysRight: number[];
  49825. /**
  49826. * The list of keyboard keys used to control the left strafe move of the camera.
  49827. */
  49828. keysLeft: number[];
  49829. private _keys;
  49830. private _onCanvasBlurObserver;
  49831. private _onKeyboardObserver;
  49832. private _engine;
  49833. private _scene;
  49834. /**
  49835. * Attach the input controls to a specific dom element to get the input from.
  49836. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49837. */
  49838. attachControl(noPreventDefault?: boolean): void;
  49839. /**
  49840. * Detach the current controls from the specified dom element.
  49841. */
  49842. detachControl(): void;
  49843. /**
  49844. * Gets the class name of the current intput.
  49845. * @returns the class name
  49846. */
  49847. getClassName(): string;
  49848. /** @hidden */
  49849. _onLostFocus(e: FocusEvent): void;
  49850. /**
  49851. * Get the friendly name associated with the input class.
  49852. * @returns the input friendly name
  49853. */
  49854. getSimpleName(): string;
  49855. /**
  49856. * Update the current camera state depending on the inputs that have been used this frame.
  49857. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49858. */
  49859. checkInputs(): void;
  49860. }
  49861. }
  49862. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  49863. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49864. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49865. /**
  49866. * Manage the mouse wheel inputs to control a follow camera.
  49867. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49868. */
  49869. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  49870. /**
  49871. * Defines the camera the input is attached to.
  49872. */
  49873. camera: FollowCamera;
  49874. /**
  49875. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  49876. */
  49877. axisControlRadius: boolean;
  49878. /**
  49879. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  49880. */
  49881. axisControlHeight: boolean;
  49882. /**
  49883. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  49884. */
  49885. axisControlRotation: boolean;
  49886. /**
  49887. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  49888. * relation to mouseWheel events.
  49889. */
  49890. wheelPrecision: number;
  49891. /**
  49892. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49893. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49894. */
  49895. wheelDeltaPercentage: number;
  49896. private _wheel;
  49897. private _observer;
  49898. /**
  49899. * Attach the input controls to a specific dom element to get the input from.
  49900. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49901. */
  49902. attachControl(noPreventDefault?: boolean): void;
  49903. /**
  49904. * Detach the current controls from the specified dom element.
  49905. */
  49906. detachControl(): void;
  49907. /**
  49908. * Gets the class name of the current intput.
  49909. * @returns the class name
  49910. */
  49911. getClassName(): string;
  49912. /**
  49913. * Get the friendly name associated with the input class.
  49914. * @returns the input friendly name
  49915. */
  49916. getSimpleName(): string;
  49917. }
  49918. }
  49919. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  49920. import { Nullable } from "babylonjs/types";
  49921. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49922. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  49923. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  49924. /**
  49925. * Manage the pointers inputs to control an follow camera.
  49926. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49927. */
  49928. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  49929. /**
  49930. * Defines the camera the input is attached to.
  49931. */
  49932. camera: FollowCamera;
  49933. /**
  49934. * Gets the class name of the current input.
  49935. * @returns the class name
  49936. */
  49937. getClassName(): string;
  49938. /**
  49939. * Defines the pointer angular sensibility along the X axis or how fast is
  49940. * the camera rotating.
  49941. * A negative number will reverse the axis direction.
  49942. */
  49943. angularSensibilityX: number;
  49944. /**
  49945. * Defines the pointer angular sensibility along the Y axis or how fast is
  49946. * the camera rotating.
  49947. * A negative number will reverse the axis direction.
  49948. */
  49949. angularSensibilityY: number;
  49950. /**
  49951. * Defines the pointer pinch precision or how fast is the camera zooming.
  49952. * A negative number will reverse the axis direction.
  49953. */
  49954. pinchPrecision: number;
  49955. /**
  49956. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49957. * from 0.
  49958. * It defines the percentage of current camera.radius to use as delta when
  49959. * pinch zoom is used.
  49960. */
  49961. pinchDeltaPercentage: number;
  49962. /**
  49963. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  49964. */
  49965. axisXControlRadius: boolean;
  49966. /**
  49967. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  49968. */
  49969. axisXControlHeight: boolean;
  49970. /**
  49971. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  49972. */
  49973. axisXControlRotation: boolean;
  49974. /**
  49975. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  49976. */
  49977. axisYControlRadius: boolean;
  49978. /**
  49979. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  49980. */
  49981. axisYControlHeight: boolean;
  49982. /**
  49983. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  49984. */
  49985. axisYControlRotation: boolean;
  49986. /**
  49987. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  49988. */
  49989. axisPinchControlRadius: boolean;
  49990. /**
  49991. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  49992. */
  49993. axisPinchControlHeight: boolean;
  49994. /**
  49995. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  49996. */
  49997. axisPinchControlRotation: boolean;
  49998. /**
  49999. * Log error messages if basic misconfiguration has occurred.
  50000. */
  50001. warningEnable: boolean;
  50002. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  50003. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  50004. private _warningCounter;
  50005. private _warning;
  50006. }
  50007. }
  50008. declare module "babylonjs/Cameras/followCameraInputsManager" {
  50009. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  50010. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  50011. /**
  50012. * Default Inputs manager for the FollowCamera.
  50013. * It groups all the default supported inputs for ease of use.
  50014. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50015. */
  50016. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  50017. /**
  50018. * Instantiates a new FollowCameraInputsManager.
  50019. * @param camera Defines the camera the inputs belong to
  50020. */
  50021. constructor(camera: FollowCamera);
  50022. /**
  50023. * Add keyboard input support to the input manager.
  50024. * @returns the current input manager
  50025. */
  50026. addKeyboard(): FollowCameraInputsManager;
  50027. /**
  50028. * Add mouse wheel input support to the input manager.
  50029. * @returns the current input manager
  50030. */
  50031. addMouseWheel(): FollowCameraInputsManager;
  50032. /**
  50033. * Add pointers input support to the input manager.
  50034. * @returns the current input manager
  50035. */
  50036. addPointers(): FollowCameraInputsManager;
  50037. /**
  50038. * Add orientation input support to the input manager.
  50039. * @returns the current input manager
  50040. */
  50041. addVRDeviceOrientation(): FollowCameraInputsManager;
  50042. }
  50043. }
  50044. declare module "babylonjs/Cameras/followCamera" {
  50045. import { Nullable } from "babylonjs/types";
  50046. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  50047. import { Scene } from "babylonjs/scene";
  50048. import { Vector3 } from "babylonjs/Maths/math.vector";
  50049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50050. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  50051. /**
  50052. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  50053. * an arc rotate version arcFollowCamera are available.
  50054. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  50055. */
  50056. export class FollowCamera extends TargetCamera {
  50057. /**
  50058. * Distance the follow camera should follow an object at
  50059. */
  50060. radius: number;
  50061. /**
  50062. * Minimum allowed distance of the camera to the axis of rotation
  50063. * (The camera can not get closer).
  50064. * This can help limiting how the Camera is able to move in the scene.
  50065. */
  50066. lowerRadiusLimit: Nullable<number>;
  50067. /**
  50068. * Maximum allowed distance of the camera to the axis of rotation
  50069. * (The camera can not get further).
  50070. * This can help limiting how the Camera is able to move in the scene.
  50071. */
  50072. upperRadiusLimit: Nullable<number>;
  50073. /**
  50074. * Define a rotation offset between the camera and the object it follows
  50075. */
  50076. rotationOffset: number;
  50077. /**
  50078. * Minimum allowed angle to camera position relative to target object.
  50079. * This can help limiting how the Camera is able to move in the scene.
  50080. */
  50081. lowerRotationOffsetLimit: Nullable<number>;
  50082. /**
  50083. * Maximum allowed angle to camera position relative to target object.
  50084. * This can help limiting how the Camera is able to move in the scene.
  50085. */
  50086. upperRotationOffsetLimit: Nullable<number>;
  50087. /**
  50088. * Define a height offset between the camera and the object it follows.
  50089. * It can help following an object from the top (like a car chaing a plane)
  50090. */
  50091. heightOffset: number;
  50092. /**
  50093. * Minimum allowed height of camera position relative to target object.
  50094. * This can help limiting how the Camera is able to move in the scene.
  50095. */
  50096. lowerHeightOffsetLimit: Nullable<number>;
  50097. /**
  50098. * Maximum allowed height of camera position relative to target object.
  50099. * This can help limiting how the Camera is able to move in the scene.
  50100. */
  50101. upperHeightOffsetLimit: Nullable<number>;
  50102. /**
  50103. * Define how fast the camera can accelerate to follow it s target.
  50104. */
  50105. cameraAcceleration: number;
  50106. /**
  50107. * Define the speed limit of the camera following an object.
  50108. */
  50109. maxCameraSpeed: number;
  50110. /**
  50111. * Define the target of the camera.
  50112. */
  50113. lockedTarget: Nullable<AbstractMesh>;
  50114. /**
  50115. * Defines the input associated with the camera.
  50116. */
  50117. inputs: FollowCameraInputsManager;
  50118. /**
  50119. * Instantiates the follow camera.
  50120. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  50121. * @param name Define the name of the camera in the scene
  50122. * @param position Define the position of the camera
  50123. * @param scene Define the scene the camera belong to
  50124. * @param lockedTarget Define the target of the camera
  50125. */
  50126. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  50127. private _follow;
  50128. /**
  50129. * Attach the input controls to a specific dom element to get the input from.
  50130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50131. */
  50132. attachControl(noPreventDefault?: boolean): void;
  50133. /**
  50134. * Detach the current controls from the specified dom element.
  50135. */
  50136. detachControl(): void;
  50137. /** @hidden */
  50138. _checkInputs(): void;
  50139. private _checkLimits;
  50140. /**
  50141. * Gets the camera class name.
  50142. * @returns the class name
  50143. */
  50144. getClassName(): string;
  50145. }
  50146. /**
  50147. * Arc Rotate version of the follow camera.
  50148. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  50149. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  50150. */
  50151. export class ArcFollowCamera extends TargetCamera {
  50152. /** The longitudinal angle of the camera */
  50153. alpha: number;
  50154. /** The latitudinal angle of the camera */
  50155. beta: number;
  50156. /** The radius of the camera from its target */
  50157. radius: number;
  50158. private _cartesianCoordinates;
  50159. /** Define the camera target (the mesh it should follow) */
  50160. private _meshTarget;
  50161. /**
  50162. * Instantiates a new ArcFollowCamera
  50163. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  50164. * @param name Define the name of the camera
  50165. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  50166. * @param beta Define the rotation angle of the camera around the elevation axis
  50167. * @param radius Define the radius of the camera from its target point
  50168. * @param target Define the target of the camera
  50169. * @param scene Define the scene the camera belongs to
  50170. */
  50171. constructor(name: string,
  50172. /** The longitudinal angle of the camera */
  50173. alpha: number,
  50174. /** The latitudinal angle of the camera */
  50175. beta: number,
  50176. /** The radius of the camera from its target */
  50177. radius: number,
  50178. /** Define the camera target (the mesh it should follow) */
  50179. target: Nullable<AbstractMesh>, scene: Scene);
  50180. private _follow;
  50181. /** @hidden */
  50182. _checkInputs(): void;
  50183. /**
  50184. * Returns the class name of the object.
  50185. * It is mostly used internally for serialization purposes.
  50186. */
  50187. getClassName(): string;
  50188. }
  50189. }
  50190. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  50191. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50192. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  50193. /**
  50194. * Manage the keyboard inputs to control the movement of a follow camera.
  50195. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50196. */
  50197. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  50198. /**
  50199. * Defines the camera the input is attached to.
  50200. */
  50201. camera: FollowCamera;
  50202. /**
  50203. * Defines the list of key codes associated with the up action (increase heightOffset)
  50204. */
  50205. keysHeightOffsetIncr: number[];
  50206. /**
  50207. * Defines the list of key codes associated with the down action (decrease heightOffset)
  50208. */
  50209. keysHeightOffsetDecr: number[];
  50210. /**
  50211. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  50212. */
  50213. keysHeightOffsetModifierAlt: boolean;
  50214. /**
  50215. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  50216. */
  50217. keysHeightOffsetModifierCtrl: boolean;
  50218. /**
  50219. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  50220. */
  50221. keysHeightOffsetModifierShift: boolean;
  50222. /**
  50223. * Defines the list of key codes associated with the left action (increase rotationOffset)
  50224. */
  50225. keysRotationOffsetIncr: number[];
  50226. /**
  50227. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  50228. */
  50229. keysRotationOffsetDecr: number[];
  50230. /**
  50231. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  50232. */
  50233. keysRotationOffsetModifierAlt: boolean;
  50234. /**
  50235. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  50236. */
  50237. keysRotationOffsetModifierCtrl: boolean;
  50238. /**
  50239. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  50240. */
  50241. keysRotationOffsetModifierShift: boolean;
  50242. /**
  50243. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  50244. */
  50245. keysRadiusIncr: number[];
  50246. /**
  50247. * Defines the list of key codes associated with the zoom-out action (increase radius)
  50248. */
  50249. keysRadiusDecr: number[];
  50250. /**
  50251. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  50252. */
  50253. keysRadiusModifierAlt: boolean;
  50254. /**
  50255. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  50256. */
  50257. keysRadiusModifierCtrl: boolean;
  50258. /**
  50259. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  50260. */
  50261. keysRadiusModifierShift: boolean;
  50262. /**
  50263. * Defines the rate of change of heightOffset.
  50264. */
  50265. heightSensibility: number;
  50266. /**
  50267. * Defines the rate of change of rotationOffset.
  50268. */
  50269. rotationSensibility: number;
  50270. /**
  50271. * Defines the rate of change of radius.
  50272. */
  50273. radiusSensibility: number;
  50274. private _keys;
  50275. private _ctrlPressed;
  50276. private _altPressed;
  50277. private _shiftPressed;
  50278. private _onCanvasBlurObserver;
  50279. private _onKeyboardObserver;
  50280. private _engine;
  50281. private _scene;
  50282. /**
  50283. * Attach the input controls to a specific dom element to get the input from.
  50284. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50285. */
  50286. attachControl(noPreventDefault?: boolean): void;
  50287. /**
  50288. * Detach the current controls from the specified dom element.
  50289. */
  50290. detachControl(): void;
  50291. /**
  50292. * Update the current camera state depending on the inputs that have been used this frame.
  50293. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50294. */
  50295. checkInputs(): void;
  50296. /**
  50297. * Gets the class name of the current input.
  50298. * @returns the class name
  50299. */
  50300. getClassName(): string;
  50301. /**
  50302. * Get the friendly name associated with the input class.
  50303. * @returns the input friendly name
  50304. */
  50305. getSimpleName(): string;
  50306. /**
  50307. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50308. * allow modification of the heightOffset value.
  50309. */
  50310. private _modifierHeightOffset;
  50311. /**
  50312. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50313. * allow modification of the rotationOffset value.
  50314. */
  50315. private _modifierRotationOffset;
  50316. /**
  50317. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50318. * allow modification of the radius value.
  50319. */
  50320. private _modifierRadius;
  50321. }
  50322. }
  50323. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  50324. import { Nullable } from "babylonjs/types";
  50325. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50326. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50327. import { Observable } from "babylonjs/Misc/observable";
  50328. module "babylonjs/Cameras/freeCameraInputsManager" {
  50329. interface FreeCameraInputsManager {
  50330. /**
  50331. * @hidden
  50332. */
  50333. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  50334. /**
  50335. * Add orientation input support to the input manager.
  50336. * @returns the current input manager
  50337. */
  50338. addDeviceOrientation(): FreeCameraInputsManager;
  50339. }
  50340. }
  50341. /**
  50342. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  50343. * Screen rotation is taken into account.
  50344. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50345. */
  50346. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  50347. private _camera;
  50348. private _screenOrientationAngle;
  50349. private _constantTranform;
  50350. private _screenQuaternion;
  50351. private _alpha;
  50352. private _beta;
  50353. private _gamma;
  50354. /**
  50355. * Can be used to detect if a device orientation sensor is available on a device
  50356. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  50357. * @returns a promise that will resolve on orientation change
  50358. */
  50359. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  50360. /**
  50361. * @hidden
  50362. */
  50363. _onDeviceOrientationChangedObservable: Observable<void>;
  50364. /**
  50365. * Instantiates a new input
  50366. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50367. */
  50368. constructor();
  50369. /**
  50370. * Define the camera controlled by the input.
  50371. */
  50372. get camera(): FreeCamera;
  50373. set camera(camera: FreeCamera);
  50374. /**
  50375. * Attach the input controls to a specific dom element to get the input from.
  50376. */
  50377. attachControl(): void;
  50378. private _orientationChanged;
  50379. private _deviceOrientation;
  50380. /**
  50381. * Detach the current controls from the specified dom element.
  50382. */
  50383. detachControl(): void;
  50384. /**
  50385. * Update the current camera state depending on the inputs that have been used this frame.
  50386. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50387. */
  50388. checkInputs(): void;
  50389. /**
  50390. * Gets the class name of the current intput.
  50391. * @returns the class name
  50392. */
  50393. getClassName(): string;
  50394. /**
  50395. * Get the friendly name associated with the input class.
  50396. * @returns the input friendly name
  50397. */
  50398. getSimpleName(): string;
  50399. }
  50400. }
  50401. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  50402. import { Nullable } from "babylonjs/types";
  50403. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50404. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50405. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50406. /**
  50407. * Manage the gamepad inputs to control a free camera.
  50408. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50409. */
  50410. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  50411. /**
  50412. * Define the camera the input is attached to.
  50413. */
  50414. camera: FreeCamera;
  50415. /**
  50416. * Define the Gamepad controlling the input
  50417. */
  50418. gamepad: Nullable<Gamepad>;
  50419. /**
  50420. * Defines the gamepad rotation sensiblity.
  50421. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50422. */
  50423. gamepadAngularSensibility: number;
  50424. /**
  50425. * Defines the gamepad move sensiblity.
  50426. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50427. */
  50428. gamepadMoveSensibility: number;
  50429. private _yAxisScale;
  50430. /**
  50431. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  50432. */
  50433. get invertYAxis(): boolean;
  50434. set invertYAxis(value: boolean);
  50435. private _onGamepadConnectedObserver;
  50436. private _onGamepadDisconnectedObserver;
  50437. private _cameraTransform;
  50438. private _deltaTransform;
  50439. private _vector3;
  50440. private _vector2;
  50441. /**
  50442. * Attach the input controls to a specific dom element to get the input from.
  50443. */
  50444. attachControl(): void;
  50445. /**
  50446. * Detach the current controls from the specified dom element.
  50447. */
  50448. detachControl(): void;
  50449. /**
  50450. * Update the current camera state depending on the inputs that have been used this frame.
  50451. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50452. */
  50453. checkInputs(): void;
  50454. /**
  50455. * Gets the class name of the current intput.
  50456. * @returns the class name
  50457. */
  50458. getClassName(): string;
  50459. /**
  50460. * Get the friendly name associated with the input class.
  50461. * @returns the input friendly name
  50462. */
  50463. getSimpleName(): string;
  50464. }
  50465. }
  50466. declare module "babylonjs/Misc/virtualJoystick" {
  50467. import { Nullable } from "babylonjs/types";
  50468. import { Vector3 } from "babylonjs/Maths/math.vector";
  50469. /**
  50470. * Defines the potential axis of a Joystick
  50471. */
  50472. export enum JoystickAxis {
  50473. /** X axis */
  50474. X = 0,
  50475. /** Y axis */
  50476. Y = 1,
  50477. /** Z axis */
  50478. Z = 2
  50479. }
  50480. /**
  50481. * Represents the different customization options available
  50482. * for VirtualJoystick
  50483. */
  50484. interface VirtualJoystickCustomizations {
  50485. /**
  50486. * Size of the joystick's puck
  50487. */
  50488. puckSize: number;
  50489. /**
  50490. * Size of the joystick's container
  50491. */
  50492. containerSize: number;
  50493. /**
  50494. * Color of the joystick && puck
  50495. */
  50496. color: string;
  50497. /**
  50498. * Image URL for the joystick's puck
  50499. */
  50500. puckImage?: string;
  50501. /**
  50502. * Image URL for the joystick's container
  50503. */
  50504. containerImage?: string;
  50505. /**
  50506. * Defines the unmoving position of the joystick container
  50507. */
  50508. position?: {
  50509. x: number;
  50510. y: number;
  50511. };
  50512. /**
  50513. * Defines whether or not the joystick container is always visible
  50514. */
  50515. alwaysVisible: boolean;
  50516. /**
  50517. * Defines whether or not to limit the movement of the puck to the joystick's container
  50518. */
  50519. limitToContainer: boolean;
  50520. }
  50521. /**
  50522. * Class used to define virtual joystick (used in touch mode)
  50523. */
  50524. export class VirtualJoystick {
  50525. /**
  50526. * Gets or sets a boolean indicating that left and right values must be inverted
  50527. */
  50528. reverseLeftRight: boolean;
  50529. /**
  50530. * Gets or sets a boolean indicating that up and down values must be inverted
  50531. */
  50532. reverseUpDown: boolean;
  50533. /**
  50534. * Gets the offset value for the position (ie. the change of the position value)
  50535. */
  50536. deltaPosition: Vector3;
  50537. /**
  50538. * Gets a boolean indicating if the virtual joystick was pressed
  50539. */
  50540. pressed: boolean;
  50541. /**
  50542. * Canvas the virtual joystick will render onto, default z-index of this is 5
  50543. */
  50544. static Canvas: Nullable<HTMLCanvasElement>;
  50545. /**
  50546. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  50547. */
  50548. limitToContainer: boolean;
  50549. private static _globalJoystickIndex;
  50550. private static _alwaysVisibleSticks;
  50551. private static vjCanvasContext;
  50552. private static vjCanvasWidth;
  50553. private static vjCanvasHeight;
  50554. private static halfWidth;
  50555. private static _GetDefaultOptions;
  50556. private _action;
  50557. private _axisTargetedByLeftAndRight;
  50558. private _axisTargetedByUpAndDown;
  50559. private _joystickSensibility;
  50560. private _inversedSensibility;
  50561. private _joystickPointerID;
  50562. private _joystickColor;
  50563. private _joystickPointerPos;
  50564. private _joystickPreviousPointerPos;
  50565. private _joystickPointerStartPos;
  50566. private _deltaJoystickVector;
  50567. private _leftJoystick;
  50568. private _touches;
  50569. private _joystickPosition;
  50570. private _alwaysVisible;
  50571. private _puckImage;
  50572. private _containerImage;
  50573. private _joystickPuckSize;
  50574. private _joystickContainerSize;
  50575. private _clearPuckSize;
  50576. private _clearContainerSize;
  50577. private _clearPuckSizeOffset;
  50578. private _clearContainerSizeOffset;
  50579. private _onPointerDownHandlerRef;
  50580. private _onPointerMoveHandlerRef;
  50581. private _onPointerUpHandlerRef;
  50582. private _onResize;
  50583. /**
  50584. * Creates a new virtual joystick
  50585. * @param leftJoystick defines that the joystick is for left hand (false by default)
  50586. * @param customizations Defines the options we want to customize the VirtualJoystick
  50587. */
  50588. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  50589. /**
  50590. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  50591. * @param newJoystickSensibility defines the new sensibility
  50592. */
  50593. setJoystickSensibility(newJoystickSensibility: number): void;
  50594. private _onPointerDown;
  50595. private _onPointerMove;
  50596. private _onPointerUp;
  50597. /**
  50598. * Change the color of the virtual joystick
  50599. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  50600. */
  50601. setJoystickColor(newColor: string): void;
  50602. /**
  50603. * Size of the joystick's container
  50604. */
  50605. set containerSize(newSize: number);
  50606. get containerSize(): number;
  50607. /**
  50608. * Size of the joystick's puck
  50609. */
  50610. set puckSize(newSize: number);
  50611. get puckSize(): number;
  50612. /**
  50613. * Clears the set position of the joystick
  50614. */
  50615. clearPosition(): void;
  50616. /**
  50617. * Defines whether or not the joystick container is always visible
  50618. */
  50619. set alwaysVisible(value: boolean);
  50620. get alwaysVisible(): boolean;
  50621. /**
  50622. * Sets the constant position of the Joystick container
  50623. * @param x X axis coordinate
  50624. * @param y Y axis coordinate
  50625. */
  50626. setPosition(x: number, y: number): void;
  50627. /**
  50628. * Defines a callback to call when the joystick is touched
  50629. * @param action defines the callback
  50630. */
  50631. setActionOnTouch(action: () => any): void;
  50632. /**
  50633. * Defines which axis you'd like to control for left & right
  50634. * @param axis defines the axis to use
  50635. */
  50636. setAxisForLeftRight(axis: JoystickAxis): void;
  50637. /**
  50638. * Defines which axis you'd like to control for up & down
  50639. * @param axis defines the axis to use
  50640. */
  50641. setAxisForUpDown(axis: JoystickAxis): void;
  50642. /**
  50643. * Clears the canvas from the previous puck / container draw
  50644. */
  50645. private _clearPreviousDraw;
  50646. /**
  50647. * Loads `urlPath` to be used for the container's image
  50648. * @param urlPath defines the urlPath of an image to use
  50649. */
  50650. setContainerImage(urlPath: string): void;
  50651. /**
  50652. * Loads `urlPath` to be used for the puck's image
  50653. * @param urlPath defines the urlPath of an image to use
  50654. */
  50655. setPuckImage(urlPath: string): void;
  50656. /**
  50657. * Draws the Virtual Joystick's container
  50658. */
  50659. private _drawContainer;
  50660. /**
  50661. * Draws the Virtual Joystick's puck
  50662. */
  50663. private _drawPuck;
  50664. private _drawVirtualJoystick;
  50665. /**
  50666. * Release internal HTML canvas
  50667. */
  50668. releaseCanvas(): void;
  50669. }
  50670. }
  50671. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  50672. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  50673. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50674. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50675. module "babylonjs/Cameras/freeCameraInputsManager" {
  50676. interface FreeCameraInputsManager {
  50677. /**
  50678. * Add virtual joystick input support to the input manager.
  50679. * @returns the current input manager
  50680. */
  50681. addVirtualJoystick(): FreeCameraInputsManager;
  50682. }
  50683. }
  50684. /**
  50685. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  50686. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50687. */
  50688. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  50689. /**
  50690. * Defines the camera the input is attached to.
  50691. */
  50692. camera: FreeCamera;
  50693. private _leftjoystick;
  50694. private _rightjoystick;
  50695. /**
  50696. * Gets the left stick of the virtual joystick.
  50697. * @returns The virtual Joystick
  50698. */
  50699. getLeftJoystick(): VirtualJoystick;
  50700. /**
  50701. * Gets the right stick of the virtual joystick.
  50702. * @returns The virtual Joystick
  50703. */
  50704. getRightJoystick(): VirtualJoystick;
  50705. /**
  50706. * Update the current camera state depending on the inputs that have been used this frame.
  50707. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50708. */
  50709. checkInputs(): void;
  50710. /**
  50711. * Attach the input controls to a specific dom element to get the input from.
  50712. */
  50713. attachControl(): void;
  50714. /**
  50715. * Detach the current controls from the specified dom element.
  50716. */
  50717. detachControl(): void;
  50718. /**
  50719. * Gets the class name of the current intput.
  50720. * @returns the class name
  50721. */
  50722. getClassName(): string;
  50723. /**
  50724. * Get the friendly name associated with the input class.
  50725. * @returns the input friendly name
  50726. */
  50727. getSimpleName(): string;
  50728. }
  50729. }
  50730. declare module "babylonjs/Cameras/Inputs/index" {
  50731. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  50732. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  50733. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  50734. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  50735. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  50736. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  50737. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  50738. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  50739. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  50740. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  50741. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50742. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  50743. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  50744. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  50745. export * from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  50746. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  50747. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  50748. }
  50749. declare module "babylonjs/Cameras/touchCamera" {
  50750. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50751. import { Scene } from "babylonjs/scene";
  50752. import { Vector3 } from "babylonjs/Maths/math.vector";
  50753. /**
  50754. * This represents a FPS type of camera controlled by touch.
  50755. * This is like a universal camera minus the Gamepad controls.
  50756. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50757. */
  50758. export class TouchCamera extends FreeCamera {
  50759. /**
  50760. * Defines the touch sensibility for rotation.
  50761. * The higher the faster.
  50762. */
  50763. get touchAngularSensibility(): number;
  50764. set touchAngularSensibility(value: number);
  50765. /**
  50766. * Defines the touch sensibility for move.
  50767. * The higher the faster.
  50768. */
  50769. get touchMoveSensibility(): number;
  50770. set touchMoveSensibility(value: number);
  50771. /**
  50772. * Instantiates a new touch camera.
  50773. * This represents a FPS type of camera controlled by touch.
  50774. * This is like a universal camera minus the Gamepad controls.
  50775. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50776. * @param name Define the name of the camera in the scene
  50777. * @param position Define the start position of the camera in the scene
  50778. * @param scene Define the scene the camera belongs to
  50779. */
  50780. constructor(name: string, position: Vector3, scene: Scene);
  50781. /**
  50782. * Gets the current object class name.
  50783. * @return the class name
  50784. */
  50785. getClassName(): string;
  50786. /** @hidden */
  50787. _setupInputs(): void;
  50788. }
  50789. }
  50790. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  50791. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50792. import { Scene } from "babylonjs/scene";
  50793. import { Vector3 } from "babylonjs/Maths/math.vector";
  50794. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50795. import { Axis } from "babylonjs/Maths/math.axis";
  50796. /**
  50797. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  50798. * being tilted forward or back and left or right.
  50799. */
  50800. export class DeviceOrientationCamera extends FreeCamera {
  50801. private _initialQuaternion;
  50802. private _quaternionCache;
  50803. private _tmpDragQuaternion;
  50804. private _disablePointerInputWhenUsingDeviceOrientation;
  50805. /**
  50806. * Creates a new device orientation camera
  50807. * @param name The name of the camera
  50808. * @param position The start position camera
  50809. * @param scene The scene the camera belongs to
  50810. */
  50811. constructor(name: string, position: Vector3, scene: Scene);
  50812. /**
  50813. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  50814. */
  50815. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  50816. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  50817. private _dragFactor;
  50818. /**
  50819. * Enabled turning on the y axis when the orientation sensor is active
  50820. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  50821. */
  50822. enableHorizontalDragging(dragFactor?: number): void;
  50823. /**
  50824. * Gets the current instance class name ("DeviceOrientationCamera").
  50825. * This helps avoiding instanceof at run time.
  50826. * @returns the class name
  50827. */
  50828. getClassName(): string;
  50829. /**
  50830. * @hidden
  50831. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  50832. */
  50833. _checkInputs(): void;
  50834. /**
  50835. * Reset the camera to its default orientation on the specified axis only.
  50836. * @param axis The axis to reset
  50837. */
  50838. resetToCurrentRotation(axis?: Axis): void;
  50839. }
  50840. }
  50841. declare module "babylonjs/Gamepads/xboxGamepad" {
  50842. import { Observable } from "babylonjs/Misc/observable";
  50843. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50844. /**
  50845. * Defines supported buttons for XBox360 compatible gamepads
  50846. */
  50847. export enum Xbox360Button {
  50848. /** A */
  50849. A = 0,
  50850. /** B */
  50851. B = 1,
  50852. /** X */
  50853. X = 2,
  50854. /** Y */
  50855. Y = 3,
  50856. /** Left button */
  50857. LB = 4,
  50858. /** Right button */
  50859. RB = 5,
  50860. /** Back */
  50861. Back = 8,
  50862. /** Start */
  50863. Start = 9,
  50864. /** Left stick */
  50865. LeftStick = 10,
  50866. /** Right stick */
  50867. RightStick = 11
  50868. }
  50869. /** Defines values for XBox360 DPad */
  50870. export enum Xbox360Dpad {
  50871. /** Up */
  50872. Up = 12,
  50873. /** Down */
  50874. Down = 13,
  50875. /** Left */
  50876. Left = 14,
  50877. /** Right */
  50878. Right = 15
  50879. }
  50880. /**
  50881. * Defines a XBox360 gamepad
  50882. */
  50883. export class Xbox360Pad extends Gamepad {
  50884. private _leftTrigger;
  50885. private _rightTrigger;
  50886. private _onlefttriggerchanged;
  50887. private _onrighttriggerchanged;
  50888. private _onbuttondown;
  50889. private _onbuttonup;
  50890. private _ondpaddown;
  50891. private _ondpadup;
  50892. /** Observable raised when a button is pressed */
  50893. onButtonDownObservable: Observable<Xbox360Button>;
  50894. /** Observable raised when a button is released */
  50895. onButtonUpObservable: Observable<Xbox360Button>;
  50896. /** Observable raised when a pad is pressed */
  50897. onPadDownObservable: Observable<Xbox360Dpad>;
  50898. /** Observable raised when a pad is released */
  50899. onPadUpObservable: Observable<Xbox360Dpad>;
  50900. private _buttonA;
  50901. private _buttonB;
  50902. private _buttonX;
  50903. private _buttonY;
  50904. private _buttonBack;
  50905. private _buttonStart;
  50906. private _buttonLB;
  50907. private _buttonRB;
  50908. private _buttonLeftStick;
  50909. private _buttonRightStick;
  50910. private _dPadUp;
  50911. private _dPadDown;
  50912. private _dPadLeft;
  50913. private _dPadRight;
  50914. private _isXboxOnePad;
  50915. /**
  50916. * Creates a new XBox360 gamepad object
  50917. * @param id defines the id of this gamepad
  50918. * @param index defines its index
  50919. * @param gamepad defines the internal HTML gamepad object
  50920. * @param xboxOne defines if it is a XBox One gamepad
  50921. */
  50922. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  50923. /**
  50924. * Defines the callback to call when left trigger is pressed
  50925. * @param callback defines the callback to use
  50926. */
  50927. onlefttriggerchanged(callback: (value: number) => void): void;
  50928. /**
  50929. * Defines the callback to call when right trigger is pressed
  50930. * @param callback defines the callback to use
  50931. */
  50932. onrighttriggerchanged(callback: (value: number) => void): void;
  50933. /**
  50934. * Gets the left trigger value
  50935. */
  50936. get leftTrigger(): number;
  50937. /**
  50938. * Sets the left trigger value
  50939. */
  50940. set leftTrigger(newValue: number);
  50941. /**
  50942. * Gets the right trigger value
  50943. */
  50944. get rightTrigger(): number;
  50945. /**
  50946. * Sets the right trigger value
  50947. */
  50948. set rightTrigger(newValue: number);
  50949. /**
  50950. * Defines the callback to call when a button is pressed
  50951. * @param callback defines the callback to use
  50952. */
  50953. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  50954. /**
  50955. * Defines the callback to call when a button is released
  50956. * @param callback defines the callback to use
  50957. */
  50958. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  50959. /**
  50960. * Defines the callback to call when a pad is pressed
  50961. * @param callback defines the callback to use
  50962. */
  50963. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  50964. /**
  50965. * Defines the callback to call when a pad is released
  50966. * @param callback defines the callback to use
  50967. */
  50968. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  50969. private _setButtonValue;
  50970. private _setDPadValue;
  50971. /**
  50972. * Gets the value of the `A` button
  50973. */
  50974. get buttonA(): number;
  50975. /**
  50976. * Sets the value of the `A` button
  50977. */
  50978. set buttonA(value: number);
  50979. /**
  50980. * Gets the value of the `B` button
  50981. */
  50982. get buttonB(): number;
  50983. /**
  50984. * Sets the value of the `B` button
  50985. */
  50986. set buttonB(value: number);
  50987. /**
  50988. * Gets the value of the `X` button
  50989. */
  50990. get buttonX(): number;
  50991. /**
  50992. * Sets the value of the `X` button
  50993. */
  50994. set buttonX(value: number);
  50995. /**
  50996. * Gets the value of the `Y` button
  50997. */
  50998. get buttonY(): number;
  50999. /**
  51000. * Sets the value of the `Y` button
  51001. */
  51002. set buttonY(value: number);
  51003. /**
  51004. * Gets the value of the `Start` button
  51005. */
  51006. get buttonStart(): number;
  51007. /**
  51008. * Sets the value of the `Start` button
  51009. */
  51010. set buttonStart(value: number);
  51011. /**
  51012. * Gets the value of the `Back` button
  51013. */
  51014. get buttonBack(): number;
  51015. /**
  51016. * Sets the value of the `Back` button
  51017. */
  51018. set buttonBack(value: number);
  51019. /**
  51020. * Gets the value of the `Left` button
  51021. */
  51022. get buttonLB(): number;
  51023. /**
  51024. * Sets the value of the `Left` button
  51025. */
  51026. set buttonLB(value: number);
  51027. /**
  51028. * Gets the value of the `Right` button
  51029. */
  51030. get buttonRB(): number;
  51031. /**
  51032. * Sets the value of the `Right` button
  51033. */
  51034. set buttonRB(value: number);
  51035. /**
  51036. * Gets the value of the Left joystick
  51037. */
  51038. get buttonLeftStick(): number;
  51039. /**
  51040. * Sets the value of the Left joystick
  51041. */
  51042. set buttonLeftStick(value: number);
  51043. /**
  51044. * Gets the value of the Right joystick
  51045. */
  51046. get buttonRightStick(): number;
  51047. /**
  51048. * Sets the value of the Right joystick
  51049. */
  51050. set buttonRightStick(value: number);
  51051. /**
  51052. * Gets the value of D-pad up
  51053. */
  51054. get dPadUp(): number;
  51055. /**
  51056. * Sets the value of D-pad up
  51057. */
  51058. set dPadUp(value: number);
  51059. /**
  51060. * Gets the value of D-pad down
  51061. */
  51062. get dPadDown(): number;
  51063. /**
  51064. * Sets the value of D-pad down
  51065. */
  51066. set dPadDown(value: number);
  51067. /**
  51068. * Gets the value of D-pad left
  51069. */
  51070. get dPadLeft(): number;
  51071. /**
  51072. * Sets the value of D-pad left
  51073. */
  51074. set dPadLeft(value: number);
  51075. /**
  51076. * Gets the value of D-pad right
  51077. */
  51078. get dPadRight(): number;
  51079. /**
  51080. * Sets the value of D-pad right
  51081. */
  51082. set dPadRight(value: number);
  51083. /**
  51084. * Force the gamepad to synchronize with device values
  51085. */
  51086. update(): void;
  51087. /**
  51088. * Disposes the gamepad
  51089. */
  51090. dispose(): void;
  51091. }
  51092. }
  51093. declare module "babylonjs/Gamepads/dualShockGamepad" {
  51094. import { Observable } from "babylonjs/Misc/observable";
  51095. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  51096. /**
  51097. * Defines supported buttons for DualShock compatible gamepads
  51098. */
  51099. export enum DualShockButton {
  51100. /** Cross */
  51101. Cross = 0,
  51102. /** Circle */
  51103. Circle = 1,
  51104. /** Square */
  51105. Square = 2,
  51106. /** Triangle */
  51107. Triangle = 3,
  51108. /** L1 */
  51109. L1 = 4,
  51110. /** R1 */
  51111. R1 = 5,
  51112. /** Share */
  51113. Share = 8,
  51114. /** Options */
  51115. Options = 9,
  51116. /** Left stick */
  51117. LeftStick = 10,
  51118. /** Right stick */
  51119. RightStick = 11
  51120. }
  51121. /** Defines values for DualShock DPad */
  51122. export enum DualShockDpad {
  51123. /** Up */
  51124. Up = 12,
  51125. /** Down */
  51126. Down = 13,
  51127. /** Left */
  51128. Left = 14,
  51129. /** Right */
  51130. Right = 15
  51131. }
  51132. /**
  51133. * Defines a DualShock gamepad
  51134. */
  51135. export class DualShockPad extends Gamepad {
  51136. private _leftTrigger;
  51137. private _rightTrigger;
  51138. private _onlefttriggerchanged;
  51139. private _onrighttriggerchanged;
  51140. private _onbuttondown;
  51141. private _onbuttonup;
  51142. private _ondpaddown;
  51143. private _ondpadup;
  51144. /** Observable raised when a button is pressed */
  51145. onButtonDownObservable: Observable<DualShockButton>;
  51146. /** Observable raised when a button is released */
  51147. onButtonUpObservable: Observable<DualShockButton>;
  51148. /** Observable raised when a pad is pressed */
  51149. onPadDownObservable: Observable<DualShockDpad>;
  51150. /** Observable raised when a pad is released */
  51151. onPadUpObservable: Observable<DualShockDpad>;
  51152. private _buttonCross;
  51153. private _buttonCircle;
  51154. private _buttonSquare;
  51155. private _buttonTriangle;
  51156. private _buttonShare;
  51157. private _buttonOptions;
  51158. private _buttonL1;
  51159. private _buttonR1;
  51160. private _buttonLeftStick;
  51161. private _buttonRightStick;
  51162. private _dPadUp;
  51163. private _dPadDown;
  51164. private _dPadLeft;
  51165. private _dPadRight;
  51166. /**
  51167. * Creates a new DualShock gamepad object
  51168. * @param id defines the id of this gamepad
  51169. * @param index defines its index
  51170. * @param gamepad defines the internal HTML gamepad object
  51171. */
  51172. constructor(id: string, index: number, gamepad: any);
  51173. /**
  51174. * Defines the callback to call when left trigger is pressed
  51175. * @param callback defines the callback to use
  51176. */
  51177. onlefttriggerchanged(callback: (value: number) => void): void;
  51178. /**
  51179. * Defines the callback to call when right trigger is pressed
  51180. * @param callback defines the callback to use
  51181. */
  51182. onrighttriggerchanged(callback: (value: number) => void): void;
  51183. /**
  51184. * Gets the left trigger value
  51185. */
  51186. get leftTrigger(): number;
  51187. /**
  51188. * Sets the left trigger value
  51189. */
  51190. set leftTrigger(newValue: number);
  51191. /**
  51192. * Gets the right trigger value
  51193. */
  51194. get rightTrigger(): number;
  51195. /**
  51196. * Sets the right trigger value
  51197. */
  51198. set rightTrigger(newValue: number);
  51199. /**
  51200. * Defines the callback to call when a button is pressed
  51201. * @param callback defines the callback to use
  51202. */
  51203. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  51204. /**
  51205. * Defines the callback to call when a button is released
  51206. * @param callback defines the callback to use
  51207. */
  51208. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  51209. /**
  51210. * Defines the callback to call when a pad is pressed
  51211. * @param callback defines the callback to use
  51212. */
  51213. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  51214. /**
  51215. * Defines the callback to call when a pad is released
  51216. * @param callback defines the callback to use
  51217. */
  51218. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  51219. private _setButtonValue;
  51220. private _setDPadValue;
  51221. /**
  51222. * Gets the value of the `Cross` button
  51223. */
  51224. get buttonCross(): number;
  51225. /**
  51226. * Sets the value of the `Cross` button
  51227. */
  51228. set buttonCross(value: number);
  51229. /**
  51230. * Gets the value of the `Circle` button
  51231. */
  51232. get buttonCircle(): number;
  51233. /**
  51234. * Sets the value of the `Circle` button
  51235. */
  51236. set buttonCircle(value: number);
  51237. /**
  51238. * Gets the value of the `Square` button
  51239. */
  51240. get buttonSquare(): number;
  51241. /**
  51242. * Sets the value of the `Square` button
  51243. */
  51244. set buttonSquare(value: number);
  51245. /**
  51246. * Gets the value of the `Triangle` button
  51247. */
  51248. get buttonTriangle(): number;
  51249. /**
  51250. * Sets the value of the `Triangle` button
  51251. */
  51252. set buttonTriangle(value: number);
  51253. /**
  51254. * Gets the value of the `Options` button
  51255. */
  51256. get buttonOptions(): number;
  51257. /**
  51258. * Sets the value of the `Options` button
  51259. */
  51260. set buttonOptions(value: number);
  51261. /**
  51262. * Gets the value of the `Share` button
  51263. */
  51264. get buttonShare(): number;
  51265. /**
  51266. * Sets the value of the `Share` button
  51267. */
  51268. set buttonShare(value: number);
  51269. /**
  51270. * Gets the value of the `L1` button
  51271. */
  51272. get buttonL1(): number;
  51273. /**
  51274. * Sets the value of the `L1` button
  51275. */
  51276. set buttonL1(value: number);
  51277. /**
  51278. * Gets the value of the `R1` button
  51279. */
  51280. get buttonR1(): number;
  51281. /**
  51282. * Sets the value of the `R1` button
  51283. */
  51284. set buttonR1(value: number);
  51285. /**
  51286. * Gets the value of the Left joystick
  51287. */
  51288. get buttonLeftStick(): number;
  51289. /**
  51290. * Sets the value of the Left joystick
  51291. */
  51292. set buttonLeftStick(value: number);
  51293. /**
  51294. * Gets the value of the Right joystick
  51295. */
  51296. get buttonRightStick(): number;
  51297. /**
  51298. * Sets the value of the Right joystick
  51299. */
  51300. set buttonRightStick(value: number);
  51301. /**
  51302. * Gets the value of D-pad up
  51303. */
  51304. get dPadUp(): number;
  51305. /**
  51306. * Sets the value of D-pad up
  51307. */
  51308. set dPadUp(value: number);
  51309. /**
  51310. * Gets the value of D-pad down
  51311. */
  51312. get dPadDown(): number;
  51313. /**
  51314. * Sets the value of D-pad down
  51315. */
  51316. set dPadDown(value: number);
  51317. /**
  51318. * Gets the value of D-pad left
  51319. */
  51320. get dPadLeft(): number;
  51321. /**
  51322. * Sets the value of D-pad left
  51323. */
  51324. set dPadLeft(value: number);
  51325. /**
  51326. * Gets the value of D-pad right
  51327. */
  51328. get dPadRight(): number;
  51329. /**
  51330. * Sets the value of D-pad right
  51331. */
  51332. set dPadRight(value: number);
  51333. /**
  51334. * Force the gamepad to synchronize with device values
  51335. */
  51336. update(): void;
  51337. /**
  51338. * Disposes the gamepad
  51339. */
  51340. dispose(): void;
  51341. }
  51342. }
  51343. declare module "babylonjs/Gamepads/gamepadManager" {
  51344. import { Observable } from "babylonjs/Misc/observable";
  51345. import { Nullable } from "babylonjs/types";
  51346. import { Scene } from "babylonjs/scene";
  51347. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  51348. /**
  51349. * Manager for handling gamepads
  51350. */
  51351. export class GamepadManager {
  51352. private _scene?;
  51353. private _babylonGamepads;
  51354. private _oneGamepadConnected;
  51355. /** @hidden */
  51356. _isMonitoring: boolean;
  51357. private _gamepadEventSupported;
  51358. private _gamepadSupport?;
  51359. /**
  51360. * observable to be triggered when the gamepad controller has been connected
  51361. */
  51362. onGamepadConnectedObservable: Observable<Gamepad>;
  51363. /**
  51364. * observable to be triggered when the gamepad controller has been disconnected
  51365. */
  51366. onGamepadDisconnectedObservable: Observable<Gamepad>;
  51367. private _onGamepadConnectedEvent;
  51368. private _onGamepadDisconnectedEvent;
  51369. /**
  51370. * Initializes the gamepad manager
  51371. * @param _scene BabylonJS scene
  51372. */
  51373. constructor(_scene?: Scene | undefined);
  51374. /**
  51375. * The gamepads in the game pad manager
  51376. */
  51377. get gamepads(): Gamepad[];
  51378. /**
  51379. * Get the gamepad controllers based on type
  51380. * @param type The type of gamepad controller
  51381. * @returns Nullable gamepad
  51382. */
  51383. getGamepadByType(type?: number): Nullable<Gamepad>;
  51384. /**
  51385. * Disposes the gamepad manager
  51386. */
  51387. dispose(): void;
  51388. private _addNewGamepad;
  51389. private _startMonitoringGamepads;
  51390. private _stopMonitoringGamepads;
  51391. /** @hidden */
  51392. _checkGamepadsStatus(): void;
  51393. private _updateGamepadObjects;
  51394. }
  51395. }
  51396. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  51397. import { Nullable } from "babylonjs/types";
  51398. import { Scene } from "babylonjs/scene";
  51399. import { ISceneComponent } from "babylonjs/sceneComponent";
  51400. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  51401. module "babylonjs/scene" {
  51402. interface Scene {
  51403. /** @hidden */
  51404. _gamepadManager: Nullable<GamepadManager>;
  51405. /**
  51406. * Gets the gamepad manager associated with the scene
  51407. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  51408. */
  51409. gamepadManager: GamepadManager;
  51410. }
  51411. }
  51412. module "babylonjs/Cameras/freeCameraInputsManager" {
  51413. /**
  51414. * Interface representing a free camera inputs manager
  51415. */
  51416. interface FreeCameraInputsManager {
  51417. /**
  51418. * Adds gamepad input support to the FreeCameraInputsManager.
  51419. * @returns the FreeCameraInputsManager
  51420. */
  51421. addGamepad(): FreeCameraInputsManager;
  51422. }
  51423. }
  51424. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  51425. /**
  51426. * Interface representing an arc rotate camera inputs manager
  51427. */
  51428. interface ArcRotateCameraInputsManager {
  51429. /**
  51430. * Adds gamepad input support to the ArcRotateCamera InputManager.
  51431. * @returns the camera inputs manager
  51432. */
  51433. addGamepad(): ArcRotateCameraInputsManager;
  51434. }
  51435. }
  51436. /**
  51437. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  51438. */
  51439. export class GamepadSystemSceneComponent implements ISceneComponent {
  51440. /**
  51441. * The component name helpfull to identify the component in the list of scene components.
  51442. */
  51443. readonly name: string;
  51444. /**
  51445. * The scene the component belongs to.
  51446. */
  51447. scene: Scene;
  51448. /**
  51449. * Creates a new instance of the component for the given scene
  51450. * @param scene Defines the scene to register the component in
  51451. */
  51452. constructor(scene: Scene);
  51453. /**
  51454. * Registers the component in a given scene
  51455. */
  51456. register(): void;
  51457. /**
  51458. * Rebuilds the elements related to this component in case of
  51459. * context lost for instance.
  51460. */
  51461. rebuild(): void;
  51462. /**
  51463. * Disposes the component and the associated ressources
  51464. */
  51465. dispose(): void;
  51466. private _beforeCameraUpdate;
  51467. }
  51468. }
  51469. declare module "babylonjs/Cameras/universalCamera" {
  51470. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  51471. import { Scene } from "babylonjs/scene";
  51472. import { Vector3 } from "babylonjs/Maths/math.vector";
  51473. import "babylonjs/Gamepads/gamepadSceneComponent";
  51474. /**
  51475. * 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,
  51476. * which still works and will still be found in many Playgrounds.
  51477. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51478. */
  51479. export class UniversalCamera extends TouchCamera {
  51480. /**
  51481. * Defines the gamepad rotation sensiblity.
  51482. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51483. */
  51484. get gamepadAngularSensibility(): number;
  51485. set gamepadAngularSensibility(value: number);
  51486. /**
  51487. * Defines the gamepad move sensiblity.
  51488. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51489. */
  51490. get gamepadMoveSensibility(): number;
  51491. set gamepadMoveSensibility(value: number);
  51492. /**
  51493. * 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,
  51494. * which still works and will still be found in many Playgrounds.
  51495. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51496. * @param name Define the name of the camera in the scene
  51497. * @param position Define the start position of the camera in the scene
  51498. * @param scene Define the scene the camera belongs to
  51499. */
  51500. constructor(name: string, position: Vector3, scene: Scene);
  51501. /**
  51502. * Gets the current object class name.
  51503. * @return the class name
  51504. */
  51505. getClassName(): string;
  51506. }
  51507. }
  51508. declare module "babylonjs/Cameras/gamepadCamera" {
  51509. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51510. import { Scene } from "babylonjs/scene";
  51511. import { Vector3 } from "babylonjs/Maths/math.vector";
  51512. /**
  51513. * This represents a FPS type of camera. This is only here for back compat purpose.
  51514. * Please use the UniversalCamera instead as both are identical.
  51515. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51516. */
  51517. export class GamepadCamera extends UniversalCamera {
  51518. /**
  51519. * Instantiates a new Gamepad Camera
  51520. * This represents a FPS type of camera. This is only here for back compat purpose.
  51521. * Please use the UniversalCamera instead as both are identical.
  51522. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51523. * @param name Define the name of the camera in the scene
  51524. * @param position Define the start position of the camera in the scene
  51525. * @param scene Define the scene the camera belongs to
  51526. */
  51527. constructor(name: string, position: Vector3, scene: Scene);
  51528. /**
  51529. * Gets the current object class name.
  51530. * @return the class name
  51531. */
  51532. getClassName(): string;
  51533. }
  51534. }
  51535. declare module "babylonjs/Shaders/pass.fragment" {
  51536. /** @hidden */
  51537. export var passPixelShader: {
  51538. name: string;
  51539. shader: string;
  51540. };
  51541. }
  51542. declare module "babylonjs/Shaders/passCube.fragment" {
  51543. /** @hidden */
  51544. export var passCubePixelShader: {
  51545. name: string;
  51546. shader: string;
  51547. };
  51548. }
  51549. declare module "babylonjs/PostProcesses/passPostProcess" {
  51550. import { Nullable } from "babylonjs/types";
  51551. import { Camera } from "babylonjs/Cameras/camera";
  51552. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51553. import { Engine } from "babylonjs/Engines/engine";
  51554. import "babylonjs/Shaders/pass.fragment";
  51555. import "babylonjs/Shaders/passCube.fragment";
  51556. import { Scene } from "babylonjs/scene";
  51557. /**
  51558. * PassPostProcess which produces an output the same as it's input
  51559. */
  51560. export class PassPostProcess extends PostProcess {
  51561. /**
  51562. * Gets a string identifying the name of the class
  51563. * @returns "PassPostProcess" string
  51564. */
  51565. getClassName(): string;
  51566. /**
  51567. * Creates the PassPostProcess
  51568. * @param name The name of the effect.
  51569. * @param options The required width/height ratio to downsize to before computing the render pass.
  51570. * @param camera The camera to apply the render pass to.
  51571. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51572. * @param engine The engine which the post process will be applied. (default: current engine)
  51573. * @param reusable If the post process can be reused on the same frame. (default: false)
  51574. * @param textureType The type of texture to be used when performing the post processing.
  51575. * @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)
  51576. */
  51577. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51578. /** @hidden */
  51579. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  51580. }
  51581. /**
  51582. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  51583. */
  51584. export class PassCubePostProcess extends PostProcess {
  51585. private _face;
  51586. /**
  51587. * Gets or sets the cube face to display.
  51588. * * 0 is +X
  51589. * * 1 is -X
  51590. * * 2 is +Y
  51591. * * 3 is -Y
  51592. * * 4 is +Z
  51593. * * 5 is -Z
  51594. */
  51595. get face(): number;
  51596. set face(value: number);
  51597. /**
  51598. * Gets a string identifying the name of the class
  51599. * @returns "PassCubePostProcess" string
  51600. */
  51601. getClassName(): string;
  51602. /**
  51603. * Creates the PassCubePostProcess
  51604. * @param name The name of the effect.
  51605. * @param options The required width/height ratio to downsize to before computing the render pass.
  51606. * @param camera The camera to apply the render pass to.
  51607. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51608. * @param engine The engine which the post process will be applied. (default: current engine)
  51609. * @param reusable If the post process can be reused on the same frame. (default: false)
  51610. * @param textureType The type of texture to be used when performing the post processing.
  51611. * @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)
  51612. */
  51613. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51614. /** @hidden */
  51615. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  51616. }
  51617. }
  51618. declare module "babylonjs/Shaders/anaglyph.fragment" {
  51619. /** @hidden */
  51620. export var anaglyphPixelShader: {
  51621. name: string;
  51622. shader: string;
  51623. };
  51624. }
  51625. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  51626. import { Engine } from "babylonjs/Engines/engine";
  51627. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51628. import { Camera } from "babylonjs/Cameras/camera";
  51629. import "babylonjs/Shaders/anaglyph.fragment";
  51630. /**
  51631. * Postprocess used to generate anaglyphic rendering
  51632. */
  51633. export class AnaglyphPostProcess extends PostProcess {
  51634. private _passedProcess;
  51635. /**
  51636. * Gets a string identifying the name of the class
  51637. * @returns "AnaglyphPostProcess" string
  51638. */
  51639. getClassName(): string;
  51640. /**
  51641. * Creates a new AnaglyphPostProcess
  51642. * @param name defines postprocess name
  51643. * @param options defines creation options or target ratio scale
  51644. * @param rigCameras defines cameras using this postprocess
  51645. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  51646. * @param engine defines hosting engine
  51647. * @param reusable defines if the postprocess will be reused multiple times per frame
  51648. */
  51649. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  51650. }
  51651. }
  51652. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  51653. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  51654. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51655. import { Scene } from "babylonjs/scene";
  51656. import { Vector3 } from "babylonjs/Maths/math.vector";
  51657. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51658. /**
  51659. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  51660. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51661. */
  51662. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  51663. /**
  51664. * Creates a new AnaglyphArcRotateCamera
  51665. * @param name defines camera name
  51666. * @param alpha defines alpha angle (in radians)
  51667. * @param beta defines beta angle (in radians)
  51668. * @param radius defines radius
  51669. * @param target defines camera target
  51670. * @param interaxialDistance defines distance between each color axis
  51671. * @param scene defines the hosting scene
  51672. */
  51673. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  51674. /**
  51675. * Gets camera class name
  51676. * @returns AnaglyphArcRotateCamera
  51677. */
  51678. getClassName(): string;
  51679. }
  51680. }
  51681. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  51682. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51683. import { Scene } from "babylonjs/scene";
  51684. import { Vector3 } from "babylonjs/Maths/math.vector";
  51685. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51686. /**
  51687. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  51688. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51689. */
  51690. export class AnaglyphFreeCamera extends FreeCamera {
  51691. /**
  51692. * Creates a new AnaglyphFreeCamera
  51693. * @param name defines camera name
  51694. * @param position defines initial position
  51695. * @param interaxialDistance defines distance between each color axis
  51696. * @param scene defines the hosting scene
  51697. */
  51698. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51699. /**
  51700. * Gets camera class name
  51701. * @returns AnaglyphFreeCamera
  51702. */
  51703. getClassName(): string;
  51704. }
  51705. }
  51706. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  51707. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51708. import { Scene } from "babylonjs/scene";
  51709. import { Vector3 } from "babylonjs/Maths/math.vector";
  51710. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51711. /**
  51712. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  51713. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51714. */
  51715. export class AnaglyphGamepadCamera extends GamepadCamera {
  51716. /**
  51717. * Creates a new AnaglyphGamepadCamera
  51718. * @param name defines camera name
  51719. * @param position defines initial position
  51720. * @param interaxialDistance defines distance between each color axis
  51721. * @param scene defines the hosting scene
  51722. */
  51723. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51724. /**
  51725. * Gets camera class name
  51726. * @returns AnaglyphGamepadCamera
  51727. */
  51728. getClassName(): string;
  51729. }
  51730. }
  51731. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  51732. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51733. import { Scene } from "babylonjs/scene";
  51734. import { Vector3 } from "babylonjs/Maths/math.vector";
  51735. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51736. /**
  51737. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  51738. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51739. */
  51740. export class AnaglyphUniversalCamera extends UniversalCamera {
  51741. /**
  51742. * Creates a new AnaglyphUniversalCamera
  51743. * @param name defines camera name
  51744. * @param position defines initial position
  51745. * @param interaxialDistance defines distance between each color axis
  51746. * @param scene defines the hosting scene
  51747. */
  51748. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51749. /**
  51750. * Gets camera class name
  51751. * @returns AnaglyphUniversalCamera
  51752. */
  51753. getClassName(): string;
  51754. }
  51755. }
  51756. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  51757. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  51758. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51759. import { Scene } from "babylonjs/scene";
  51760. import { Vector3 } from "babylonjs/Maths/math.vector";
  51761. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51762. /**
  51763. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  51764. * @see https://doc.babylonjs.com/features/cameras
  51765. */
  51766. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  51767. /**
  51768. * Creates a new StereoscopicArcRotateCamera
  51769. * @param name defines camera name
  51770. * @param alpha defines alpha angle (in radians)
  51771. * @param beta defines beta angle (in radians)
  51772. * @param radius defines radius
  51773. * @param target defines camera target
  51774. * @param interaxialDistance defines distance between each color axis
  51775. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51776. * @param scene defines the hosting scene
  51777. */
  51778. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51779. /**
  51780. * Gets camera class name
  51781. * @returns StereoscopicArcRotateCamera
  51782. */
  51783. getClassName(): string;
  51784. }
  51785. }
  51786. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  51787. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51788. import { Scene } from "babylonjs/scene";
  51789. import { Vector3 } from "babylonjs/Maths/math.vector";
  51790. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51791. /**
  51792. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  51793. * @see https://doc.babylonjs.com/features/cameras
  51794. */
  51795. export class StereoscopicFreeCamera extends FreeCamera {
  51796. /**
  51797. * Creates a new StereoscopicFreeCamera
  51798. * @param name defines camera name
  51799. * @param position defines initial position
  51800. * @param interaxialDistance defines distance between each color axis
  51801. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51802. * @param scene defines the hosting scene
  51803. */
  51804. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51805. /**
  51806. * Gets camera class name
  51807. * @returns StereoscopicFreeCamera
  51808. */
  51809. getClassName(): string;
  51810. }
  51811. }
  51812. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  51813. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51814. import { Scene } from "babylonjs/scene";
  51815. import { Vector3 } from "babylonjs/Maths/math.vector";
  51816. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51817. /**
  51818. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  51819. * @see https://doc.babylonjs.com/features/cameras
  51820. */
  51821. export class StereoscopicGamepadCamera extends GamepadCamera {
  51822. /**
  51823. * Creates a new StereoscopicGamepadCamera
  51824. * @param name defines camera name
  51825. * @param position defines initial position
  51826. * @param interaxialDistance defines distance between each color axis
  51827. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51828. * @param scene defines the hosting scene
  51829. */
  51830. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51831. /**
  51832. * Gets camera class name
  51833. * @returns StereoscopicGamepadCamera
  51834. */
  51835. getClassName(): string;
  51836. }
  51837. }
  51838. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  51839. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51840. import { Scene } from "babylonjs/scene";
  51841. import { Vector3 } from "babylonjs/Maths/math.vector";
  51842. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51843. /**
  51844. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  51845. * @see https://doc.babylonjs.com/features/cameras
  51846. */
  51847. export class StereoscopicUniversalCamera extends UniversalCamera {
  51848. /**
  51849. * Creates a new StereoscopicUniversalCamera
  51850. * @param name defines camera name
  51851. * @param position defines initial position
  51852. * @param interaxialDistance defines distance between each color axis
  51853. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51854. * @param scene defines the hosting scene
  51855. */
  51856. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51857. /**
  51858. * Gets camera class name
  51859. * @returns StereoscopicUniversalCamera
  51860. */
  51861. getClassName(): string;
  51862. }
  51863. }
  51864. declare module "babylonjs/Cameras/Stereoscopic/index" {
  51865. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  51866. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  51867. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  51868. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  51869. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  51870. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  51871. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  51872. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  51873. }
  51874. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  51875. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51876. import { Scene } from "babylonjs/scene";
  51877. import { Vector3 } from "babylonjs/Maths/math.vector";
  51878. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  51879. /**
  51880. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  51881. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51882. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51883. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51884. */
  51885. export class VirtualJoysticksCamera extends FreeCamera {
  51886. /**
  51887. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  51888. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51889. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51890. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51891. * @param name Define the name of the camera in the scene
  51892. * @param position Define the start position of the camera in the scene
  51893. * @param scene Define the scene the camera belongs to
  51894. */
  51895. constructor(name: string, position: Vector3, scene: Scene);
  51896. /**
  51897. * Gets the current object class name.
  51898. * @return the class name
  51899. */
  51900. getClassName(): string;
  51901. }
  51902. }
  51903. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  51904. import { Matrix } from "babylonjs/Maths/math.vector";
  51905. /**
  51906. * This represents all the required metrics to create a VR camera.
  51907. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  51908. */
  51909. export class VRCameraMetrics {
  51910. /**
  51911. * Define the horizontal resolution off the screen.
  51912. */
  51913. hResolution: number;
  51914. /**
  51915. * Define the vertical resolution off the screen.
  51916. */
  51917. vResolution: number;
  51918. /**
  51919. * Define the horizontal screen size.
  51920. */
  51921. hScreenSize: number;
  51922. /**
  51923. * Define the vertical screen size.
  51924. */
  51925. vScreenSize: number;
  51926. /**
  51927. * Define the vertical screen center position.
  51928. */
  51929. vScreenCenter: number;
  51930. /**
  51931. * Define the distance of the eyes to the screen.
  51932. */
  51933. eyeToScreenDistance: number;
  51934. /**
  51935. * Define the distance between both lenses
  51936. */
  51937. lensSeparationDistance: number;
  51938. /**
  51939. * Define the distance between both viewer's eyes.
  51940. */
  51941. interpupillaryDistance: number;
  51942. /**
  51943. * Define the distortion factor of the VR postprocess.
  51944. * Please, touch with care.
  51945. */
  51946. distortionK: number[];
  51947. /**
  51948. * Define the chromatic aberration correction factors for the VR post process.
  51949. */
  51950. chromaAbCorrection: number[];
  51951. /**
  51952. * Define the scale factor of the post process.
  51953. * The smaller the better but the slower.
  51954. */
  51955. postProcessScaleFactor: number;
  51956. /**
  51957. * Define an offset for the lens center.
  51958. */
  51959. lensCenterOffset: number;
  51960. /**
  51961. * Define if the current vr camera should compensate the distortion of the lense or not.
  51962. */
  51963. compensateDistortion: boolean;
  51964. /**
  51965. * Defines if multiview should be enabled when rendering (Default: false)
  51966. */
  51967. multiviewEnabled: boolean;
  51968. /**
  51969. * Gets the rendering aspect ratio based on the provided resolutions.
  51970. */
  51971. get aspectRatio(): number;
  51972. /**
  51973. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  51974. */
  51975. get aspectRatioFov(): number;
  51976. /**
  51977. * @hidden
  51978. */
  51979. get leftHMatrix(): Matrix;
  51980. /**
  51981. * @hidden
  51982. */
  51983. get rightHMatrix(): Matrix;
  51984. /**
  51985. * @hidden
  51986. */
  51987. get leftPreViewMatrix(): Matrix;
  51988. /**
  51989. * @hidden
  51990. */
  51991. get rightPreViewMatrix(): Matrix;
  51992. /**
  51993. * Get the default VRMetrics based on the most generic setup.
  51994. * @returns the default vr metrics
  51995. */
  51996. static GetDefault(): VRCameraMetrics;
  51997. }
  51998. }
  51999. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  52000. /** @hidden */
  52001. export var vrDistortionCorrectionPixelShader: {
  52002. name: string;
  52003. shader: string;
  52004. };
  52005. }
  52006. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  52007. import { Camera } from "babylonjs/Cameras/camera";
  52008. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  52009. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52010. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  52011. /**
  52012. * VRDistortionCorrectionPostProcess used for mobile VR
  52013. */
  52014. export class VRDistortionCorrectionPostProcess extends PostProcess {
  52015. private _isRightEye;
  52016. private _distortionFactors;
  52017. private _postProcessScaleFactor;
  52018. private _lensCenterOffset;
  52019. private _scaleIn;
  52020. private _scaleFactor;
  52021. private _lensCenter;
  52022. /**
  52023. * Gets a string identifying the name of the class
  52024. * @returns "VRDistortionCorrectionPostProcess" string
  52025. */
  52026. getClassName(): string;
  52027. /**
  52028. * Initializes the VRDistortionCorrectionPostProcess
  52029. * @param name The name of the effect.
  52030. * @param camera The camera to apply the render pass to.
  52031. * @param isRightEye If this is for the right eye distortion
  52032. * @param vrMetrics All the required metrics for the VR camera
  52033. */
  52034. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  52035. }
  52036. }
  52037. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  52038. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  52039. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  52040. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  52041. import { Scene } from "babylonjs/scene";
  52042. import { Vector3 } from "babylonjs/Maths/math.vector";
  52043. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  52044. import "babylonjs/Cameras/RigModes/vrRigMode";
  52045. /**
  52046. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  52047. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52048. */
  52049. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  52050. /**
  52051. * Creates a new VRDeviceOrientationArcRotateCamera
  52052. * @param name defines camera name
  52053. * @param alpha defines the camera rotation along the logitudinal axis
  52054. * @param beta defines the camera rotation along the latitudinal axis
  52055. * @param radius defines the camera distance from its target
  52056. * @param target defines the camera target
  52057. * @param scene defines the scene the camera belongs to
  52058. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52059. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52060. */
  52061. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52062. /**
  52063. * Gets camera class name
  52064. * @returns VRDeviceOrientationArcRotateCamera
  52065. */
  52066. getClassName(): string;
  52067. }
  52068. }
  52069. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  52070. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  52071. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  52072. import { Scene } from "babylonjs/scene";
  52073. import { Vector3 } from "babylonjs/Maths/math.vector";
  52074. import "babylonjs/Cameras/RigModes/vrRigMode";
  52075. /**
  52076. * Camera used to simulate VR rendering (based on FreeCamera)
  52077. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52078. */
  52079. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  52080. /**
  52081. * Creates a new VRDeviceOrientationFreeCamera
  52082. * @param name defines camera name
  52083. * @param position defines the start position of the camera
  52084. * @param scene defines the scene the camera belongs to
  52085. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52086. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52087. */
  52088. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52089. /**
  52090. * Gets camera class name
  52091. * @returns VRDeviceOrientationFreeCamera
  52092. */
  52093. getClassName(): string;
  52094. }
  52095. }
  52096. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  52097. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  52098. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  52099. import { Scene } from "babylonjs/scene";
  52100. import { Vector3 } from "babylonjs/Maths/math.vector";
  52101. import "babylonjs/Gamepads/gamepadSceneComponent";
  52102. /**
  52103. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  52104. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52105. */
  52106. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  52107. /**
  52108. * Creates a new VRDeviceOrientationGamepadCamera
  52109. * @param name defines camera name
  52110. * @param position defines the start position of the camera
  52111. * @param scene defines the scene the camera belongs to
  52112. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52113. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52114. */
  52115. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52116. /**
  52117. * Gets camera class name
  52118. * @returns VRDeviceOrientationGamepadCamera
  52119. */
  52120. getClassName(): string;
  52121. }
  52122. }
  52123. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  52124. import { Scene } from "babylonjs/scene";
  52125. import { Texture } from "babylonjs/Materials/Textures/texture";
  52126. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  52127. /**
  52128. * A class extending Texture allowing drawing on a texture
  52129. * @see https://doc.babylonjs.com/how_to/dynamictexture
  52130. */
  52131. export class DynamicTexture extends Texture {
  52132. private _generateMipMaps;
  52133. private _canvas;
  52134. private _context;
  52135. /**
  52136. * Creates a DynamicTexture
  52137. * @param name defines the name of the texture
  52138. * @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
  52139. * @param scene defines the scene where you want the texture
  52140. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  52141. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52142. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  52143. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  52144. */
  52145. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  52146. /**
  52147. * Get the current class name of the texture useful for serialization or dynamic coding.
  52148. * @returns "DynamicTexture"
  52149. */
  52150. getClassName(): string;
  52151. /**
  52152. * Gets the current state of canRescale
  52153. */
  52154. get canRescale(): boolean;
  52155. private _recreate;
  52156. /**
  52157. * Scales the texture
  52158. * @param ratio the scale factor to apply to both width and height
  52159. */
  52160. scale(ratio: number): void;
  52161. /**
  52162. * Resizes the texture
  52163. * @param width the new width
  52164. * @param height the new height
  52165. */
  52166. scaleTo(width: number, height: number): void;
  52167. /**
  52168. * Gets the context of the canvas used by the texture
  52169. * @returns the canvas context of the dynamic texture
  52170. */
  52171. getContext(): CanvasRenderingContext2D;
  52172. /**
  52173. * Clears the texture
  52174. */
  52175. clear(): void;
  52176. /**
  52177. * Updates the texture
  52178. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  52179. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  52180. */
  52181. update(invertY?: boolean, premulAlpha?: boolean): void;
  52182. /**
  52183. * Draws text onto the texture
  52184. * @param text defines the text to be drawn
  52185. * @param x defines the placement of the text from the left
  52186. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  52187. * @param font defines the font to be used with font-style, font-size, font-name
  52188. * @param color defines the color used for the text
  52189. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  52190. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  52191. * @param update defines whether texture is immediately update (default is true)
  52192. */
  52193. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  52194. /**
  52195. * Clones the texture
  52196. * @returns the clone of the texture.
  52197. */
  52198. clone(): DynamicTexture;
  52199. /**
  52200. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  52201. * @returns a serialized dynamic texture object
  52202. */
  52203. serialize(): any;
  52204. private _IsCanvasElement;
  52205. /** @hidden */
  52206. _rebuild(): void;
  52207. }
  52208. }
  52209. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  52210. import { Scene } from "babylonjs/scene";
  52211. import { Color3 } from "babylonjs/Maths/math.color";
  52212. import { Mesh } from "babylonjs/Meshes/mesh";
  52213. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52214. import { Nullable } from "babylonjs/types";
  52215. /**
  52216. * Class containing static functions to help procedurally build meshes
  52217. */
  52218. export class GroundBuilder {
  52219. /**
  52220. * Creates a ground mesh
  52221. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52222. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52224. * @param name defines the name of the mesh
  52225. * @param options defines the options used to create the mesh
  52226. * @param scene defines the hosting scene
  52227. * @returns the ground mesh
  52228. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52229. */
  52230. static CreateGround(name: string, options: {
  52231. width?: number;
  52232. height?: number;
  52233. subdivisions?: number;
  52234. subdivisionsX?: number;
  52235. subdivisionsY?: number;
  52236. updatable?: boolean;
  52237. }, scene: any): Mesh;
  52238. /**
  52239. * Creates a tiled ground mesh
  52240. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52241. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52242. * * 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
  52243. * * 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
  52244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52245. * @param name defines the name of the mesh
  52246. * @param options defines the options used to create the mesh
  52247. * @param scene defines the hosting scene
  52248. * @returns the tiled ground mesh
  52249. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52250. */
  52251. static CreateTiledGround(name: string, options: {
  52252. xmin: number;
  52253. zmin: number;
  52254. xmax: number;
  52255. zmax: number;
  52256. subdivisions?: {
  52257. w: number;
  52258. h: number;
  52259. };
  52260. precision?: {
  52261. w: number;
  52262. h: number;
  52263. };
  52264. updatable?: boolean;
  52265. }, scene?: Nullable<Scene>): Mesh;
  52266. /**
  52267. * Creates a ground mesh from a height map
  52268. * * The parameter `url` sets the URL of the height map image resource.
  52269. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52270. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52271. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52272. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52273. * * 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.
  52274. * * 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).
  52275. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52277. * @param name defines the name of the mesh
  52278. * @param url defines the url to the height map
  52279. * @param options defines the options used to create the mesh
  52280. * @param scene defines the hosting scene
  52281. * @returns the ground mesh
  52282. * @see https://doc.babylonjs.com/babylon101/height_map
  52283. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52284. */
  52285. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52286. width?: number;
  52287. height?: number;
  52288. subdivisions?: number;
  52289. minHeight?: number;
  52290. maxHeight?: number;
  52291. colorFilter?: Color3;
  52292. alphaFilter?: number;
  52293. updatable?: boolean;
  52294. onReady?: (mesh: GroundMesh) => void;
  52295. }, scene?: Nullable<Scene>): GroundMesh;
  52296. }
  52297. }
  52298. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  52299. import { Vector4 } from "babylonjs/Maths/math.vector";
  52300. import { Mesh } from "babylonjs/Meshes/mesh";
  52301. /**
  52302. * Class containing static functions to help procedurally build meshes
  52303. */
  52304. export class TorusBuilder {
  52305. /**
  52306. * Creates a torus mesh
  52307. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52308. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52309. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52310. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52311. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52313. * @param name defines the name of the mesh
  52314. * @param options defines the options used to create the mesh
  52315. * @param scene defines the hosting scene
  52316. * @returns the torus mesh
  52317. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52318. */
  52319. static CreateTorus(name: string, options: {
  52320. diameter?: number;
  52321. thickness?: number;
  52322. tessellation?: number;
  52323. updatable?: boolean;
  52324. sideOrientation?: number;
  52325. frontUVs?: Vector4;
  52326. backUVs?: Vector4;
  52327. }, scene: any): Mesh;
  52328. }
  52329. }
  52330. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  52331. import { Vector4 } from "babylonjs/Maths/math.vector";
  52332. import { Color4 } from "babylonjs/Maths/math.color";
  52333. import { Mesh } from "babylonjs/Meshes/mesh";
  52334. /**
  52335. * Class containing static functions to help procedurally build meshes
  52336. */
  52337. export class CylinderBuilder {
  52338. /**
  52339. * Creates a cylinder or a cone mesh
  52340. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52341. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52342. * * 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.
  52343. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52344. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52345. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52346. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52347. * * 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).
  52348. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52349. * * 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).
  52350. * * 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
  52351. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52352. * * 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
  52353. * * 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.
  52354. * * If `enclose` is false, a ring surface is one element.
  52355. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52356. * * 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
  52357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52358. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52360. * @param name defines the name of the mesh
  52361. * @param options defines the options used to create the mesh
  52362. * @param scene defines the hosting scene
  52363. * @returns the cylinder mesh
  52364. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52365. */
  52366. static CreateCylinder(name: string, options: {
  52367. height?: number;
  52368. diameterTop?: number;
  52369. diameterBottom?: number;
  52370. diameter?: number;
  52371. tessellation?: number;
  52372. subdivisions?: number;
  52373. arc?: number;
  52374. faceColors?: Color4[];
  52375. faceUV?: Vector4[];
  52376. updatable?: boolean;
  52377. hasRings?: boolean;
  52378. enclose?: boolean;
  52379. cap?: number;
  52380. sideOrientation?: number;
  52381. frontUVs?: Vector4;
  52382. backUVs?: Vector4;
  52383. }, scene: any): Mesh;
  52384. }
  52385. }
  52386. declare module "babylonjs/XR/webXRTypes" {
  52387. import { Nullable } from "babylonjs/types";
  52388. import { IDisposable } from "babylonjs/scene";
  52389. /**
  52390. * States of the webXR experience
  52391. */
  52392. export enum WebXRState {
  52393. /**
  52394. * Transitioning to being in XR mode
  52395. */
  52396. ENTERING_XR = 0,
  52397. /**
  52398. * Transitioning to non XR mode
  52399. */
  52400. EXITING_XR = 1,
  52401. /**
  52402. * In XR mode and presenting
  52403. */
  52404. IN_XR = 2,
  52405. /**
  52406. * Not entered XR mode
  52407. */
  52408. NOT_IN_XR = 3
  52409. }
  52410. /**
  52411. * The state of the XR camera's tracking
  52412. */
  52413. export enum WebXRTrackingState {
  52414. /**
  52415. * No transformation received, device is not being tracked
  52416. */
  52417. NOT_TRACKING = 0,
  52418. /**
  52419. * Tracking lost - using emulated position
  52420. */
  52421. TRACKING_LOST = 1,
  52422. /**
  52423. * Transformation tracking works normally
  52424. */
  52425. TRACKING = 2
  52426. }
  52427. /**
  52428. * Abstraction of the XR render target
  52429. */
  52430. export interface WebXRRenderTarget extends IDisposable {
  52431. /**
  52432. * xrpresent context of the canvas which can be used to display/mirror xr content
  52433. */
  52434. canvasContext: WebGLRenderingContext;
  52435. /**
  52436. * xr layer for the canvas
  52437. */
  52438. xrLayer: Nullable<XRWebGLLayer>;
  52439. /**
  52440. * Initializes the xr layer for the session
  52441. * @param xrSession xr session
  52442. * @returns a promise that will resolve once the XR Layer has been created
  52443. */
  52444. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  52445. }
  52446. }
  52447. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  52448. import { Nullable } from "babylonjs/types";
  52449. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  52450. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52451. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52452. import { Observable } from "babylonjs/Misc/observable";
  52453. /**
  52454. * COnfiguration object for WebXR output canvas
  52455. */
  52456. export class WebXRManagedOutputCanvasOptions {
  52457. /**
  52458. * An optional canvas in case you wish to create it yourself and provide it here.
  52459. * If not provided, a new canvas will be created
  52460. */
  52461. canvasElement?: HTMLCanvasElement;
  52462. /**
  52463. * Options for this XR Layer output
  52464. */
  52465. canvasOptions?: XRWebGLLayerInit;
  52466. /**
  52467. * CSS styling for a newly created canvas (if not provided)
  52468. */
  52469. newCanvasCssStyle?: string;
  52470. /**
  52471. * Get the default values of the configuration object
  52472. * @param engine defines the engine to use (can be null)
  52473. * @returns default values of this configuration object
  52474. */
  52475. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  52476. }
  52477. /**
  52478. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  52479. */
  52480. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  52481. private _options;
  52482. private _canvas;
  52483. private _engine;
  52484. private _originalCanvasSize;
  52485. /**
  52486. * Rendering context of the canvas which can be used to display/mirror xr content
  52487. */
  52488. canvasContext: WebGLRenderingContext;
  52489. /**
  52490. * xr layer for the canvas
  52491. */
  52492. xrLayer: Nullable<XRWebGLLayer>;
  52493. /**
  52494. * Obseervers registered here will be triggered when the xr layer was initialized
  52495. */
  52496. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  52497. /**
  52498. * Initializes the canvas to be added/removed upon entering/exiting xr
  52499. * @param _xrSessionManager The XR Session manager
  52500. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  52501. */
  52502. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  52503. /**
  52504. * Disposes of the object
  52505. */
  52506. dispose(): void;
  52507. /**
  52508. * Initializes the xr layer for the session
  52509. * @param xrSession xr session
  52510. * @returns a promise that will resolve once the XR Layer has been created
  52511. */
  52512. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  52513. private _addCanvas;
  52514. private _removeCanvas;
  52515. private _setCanvasSize;
  52516. private _setManagedOutputCanvas;
  52517. }
  52518. }
  52519. declare module "babylonjs/XR/webXRSessionManager" {
  52520. import { Observable } from "babylonjs/Misc/observable";
  52521. import { Nullable } from "babylonjs/types";
  52522. import { IDisposable, Scene } from "babylonjs/scene";
  52523. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52524. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52525. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  52526. /**
  52527. * Manages an XRSession to work with Babylon's engine
  52528. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  52529. */
  52530. export class WebXRSessionManager implements IDisposable {
  52531. /** The scene which the session should be created for */
  52532. scene: Scene;
  52533. private _referenceSpace;
  52534. private _rttProvider;
  52535. private _sessionEnded;
  52536. private _xrNavigator;
  52537. private baseLayer;
  52538. /**
  52539. * The base reference space from which the session started. good if you want to reset your
  52540. * reference space
  52541. */
  52542. baseReferenceSpace: XRReferenceSpace;
  52543. /**
  52544. * Current XR frame
  52545. */
  52546. currentFrame: Nullable<XRFrame>;
  52547. /** WebXR timestamp updated every frame */
  52548. currentTimestamp: number;
  52549. /**
  52550. * Used just in case of a failure to initialize an immersive session.
  52551. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  52552. */
  52553. defaultHeightCompensation: number;
  52554. /**
  52555. * Fires every time a new xrFrame arrives which can be used to update the camera
  52556. */
  52557. onXRFrameObservable: Observable<XRFrame>;
  52558. /**
  52559. * Fires when the reference space changed
  52560. */
  52561. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  52562. /**
  52563. * Fires when the xr session is ended either by the device or manually done
  52564. */
  52565. onXRSessionEnded: Observable<any>;
  52566. /**
  52567. * Fires when the xr session is ended either by the device or manually done
  52568. */
  52569. onXRSessionInit: Observable<XRSession>;
  52570. /**
  52571. * Underlying xr session
  52572. */
  52573. session: XRSession;
  52574. /**
  52575. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  52576. * or get the offset the player is currently at.
  52577. */
  52578. viewerReferenceSpace: XRReferenceSpace;
  52579. /**
  52580. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  52581. * @param scene The scene which the session should be created for
  52582. */
  52583. constructor(
  52584. /** The scene which the session should be created for */
  52585. scene: Scene);
  52586. /**
  52587. * The current reference space used in this session. This reference space can constantly change!
  52588. * It is mainly used to offset the camera's position.
  52589. */
  52590. get referenceSpace(): XRReferenceSpace;
  52591. /**
  52592. * Set a new reference space and triggers the observable
  52593. */
  52594. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  52595. /**
  52596. * Disposes of the session manager
  52597. */
  52598. dispose(): void;
  52599. /**
  52600. * Stops the xrSession and restores the render loop
  52601. * @returns Promise which resolves after it exits XR
  52602. */
  52603. exitXRAsync(): Promise<void>;
  52604. /**
  52605. * Gets the correct render target texture to be rendered this frame for this eye
  52606. * @param eye the eye for which to get the render target
  52607. * @returns the render target for the specified eye
  52608. */
  52609. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  52610. /**
  52611. * Creates a WebXRRenderTarget object for the XR session
  52612. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  52613. * @param options optional options to provide when creating a new render target
  52614. * @returns a WebXR render target to which the session can render
  52615. */
  52616. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  52617. /**
  52618. * Initializes the manager
  52619. * After initialization enterXR can be called to start an XR session
  52620. * @returns Promise which resolves after it is initialized
  52621. */
  52622. initializeAsync(): Promise<void>;
  52623. /**
  52624. * Initializes an xr session
  52625. * @param xrSessionMode mode to initialize
  52626. * @param xrSessionInit defines optional and required values to pass to the session builder
  52627. * @returns a promise which will resolve once the session has been initialized
  52628. */
  52629. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  52630. /**
  52631. * Checks if a session would be supported for the creation options specified
  52632. * @param sessionMode session mode to check if supported eg. immersive-vr
  52633. * @returns A Promise that resolves to true if supported and false if not
  52634. */
  52635. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52636. /**
  52637. * Resets the reference space to the one started the session
  52638. */
  52639. resetReferenceSpace(): void;
  52640. /**
  52641. * Starts rendering to the xr layer
  52642. */
  52643. runXRRenderLoop(): void;
  52644. /**
  52645. * Sets the reference space on the xr session
  52646. * @param referenceSpaceType space to set
  52647. * @returns a promise that will resolve once the reference space has been set
  52648. */
  52649. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  52650. /**
  52651. * Updates the render state of the session
  52652. * @param state state to set
  52653. * @returns a promise that resolves once the render state has been updated
  52654. */
  52655. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  52656. /**
  52657. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  52658. * @param sessionMode defines the session to test
  52659. * @returns a promise with boolean as final value
  52660. */
  52661. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52662. private _createRenderTargetTexture;
  52663. }
  52664. }
  52665. declare module "babylonjs/XR/webXRCamera" {
  52666. import { Vector3 } from "babylonjs/Maths/math.vector";
  52667. import { Scene } from "babylonjs/scene";
  52668. import { Camera } from "babylonjs/Cameras/camera";
  52669. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  52670. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52671. import { Observable } from "babylonjs/Misc/observable";
  52672. import { WebXRTrackingState } from "babylonjs/XR/webXRTypes";
  52673. /**
  52674. * WebXR Camera which holds the views for the xrSession
  52675. * @see https://doc.babylonjs.com/how_to/webxr_camera
  52676. */
  52677. export class WebXRCamera extends FreeCamera {
  52678. private _xrSessionManager;
  52679. private _firstFrame;
  52680. private _referenceQuaternion;
  52681. private _referencedPosition;
  52682. private _xrInvPositionCache;
  52683. private _xrInvQuaternionCache;
  52684. private _trackingState;
  52685. /**
  52686. * Observable raised before camera teleportation
  52687. */
  52688. onBeforeCameraTeleport: Observable<Vector3>;
  52689. /**
  52690. * Observable raised after camera teleportation
  52691. */
  52692. onAfterCameraTeleport: Observable<Vector3>;
  52693. /**
  52694. * Notifies when the camera's tracking state has changed.
  52695. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  52696. */
  52697. onTrackingStateChanged: Observable<WebXRTrackingState>;
  52698. /**
  52699. * Should position compensation execute on first frame.
  52700. * This is used when copying the position from a native (non XR) camera
  52701. */
  52702. compensateOnFirstFrame: boolean;
  52703. /**
  52704. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  52705. * @param name the name of the camera
  52706. * @param scene the scene to add the camera to
  52707. * @param _xrSessionManager a constructed xr session manager
  52708. */
  52709. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  52710. /**
  52711. * Get the current XR tracking state of the camera
  52712. */
  52713. get trackingState(): WebXRTrackingState;
  52714. private _setTrackingState;
  52715. /**
  52716. * Return the user's height, unrelated to the current ground.
  52717. * This will be the y position of this camera, when ground level is 0.
  52718. */
  52719. get realWorldHeight(): number;
  52720. /** @hidden */
  52721. _updateForDualEyeDebugging(): void;
  52722. /**
  52723. * Sets this camera's transformation based on a non-vr camera
  52724. * @param otherCamera the non-vr camera to copy the transformation from
  52725. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  52726. */
  52727. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  52728. /**
  52729. * Gets the current instance class name ("WebXRCamera").
  52730. * @returns the class name
  52731. */
  52732. getClassName(): string;
  52733. private _rotate180;
  52734. private _updateFromXRSession;
  52735. private _updateNumberOfRigCameras;
  52736. private _updateReferenceSpace;
  52737. private _updateReferenceSpaceOffset;
  52738. }
  52739. }
  52740. declare module "babylonjs/XR/webXRFeaturesManager" {
  52741. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52742. import { IDisposable } from "babylonjs/scene";
  52743. /**
  52744. * Defining the interface required for a (webxr) feature
  52745. */
  52746. export interface IWebXRFeature extends IDisposable {
  52747. /**
  52748. * Is this feature attached
  52749. */
  52750. attached: boolean;
  52751. /**
  52752. * Should auto-attach be disabled?
  52753. */
  52754. disableAutoAttach: boolean;
  52755. /**
  52756. * Attach the feature to the session
  52757. * Will usually be called by the features manager
  52758. *
  52759. * @param force should attachment be forced (even when already attached)
  52760. * @returns true if successful.
  52761. */
  52762. attach(force?: boolean): boolean;
  52763. /**
  52764. * Detach the feature from the session
  52765. * Will usually be called by the features manager
  52766. *
  52767. * @returns true if successful.
  52768. */
  52769. detach(): boolean;
  52770. /**
  52771. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52772. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52773. *
  52774. * @returns whether or not the feature is compatible in this environment
  52775. */
  52776. isCompatible(): boolean;
  52777. /**
  52778. * Was this feature disposed;
  52779. */
  52780. isDisposed: boolean;
  52781. /**
  52782. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  52783. */
  52784. xrNativeFeatureName?: string;
  52785. /**
  52786. * A list of (Babylon WebXR) features this feature depends on
  52787. */
  52788. dependsOn?: string[];
  52789. }
  52790. /**
  52791. * A list of the currently available features without referencing them
  52792. */
  52793. export class WebXRFeatureName {
  52794. /**
  52795. * The name of the anchor system feature
  52796. */
  52797. static readonly ANCHOR_SYSTEM: string;
  52798. /**
  52799. * The name of the background remover feature
  52800. */
  52801. static readonly BACKGROUND_REMOVER: string;
  52802. /**
  52803. * The name of the hit test feature
  52804. */
  52805. static readonly HIT_TEST: string;
  52806. /**
  52807. * physics impostors for xr controllers feature
  52808. */
  52809. static readonly PHYSICS_CONTROLLERS: string;
  52810. /**
  52811. * The name of the plane detection feature
  52812. */
  52813. static readonly PLANE_DETECTION: string;
  52814. /**
  52815. * The name of the pointer selection feature
  52816. */
  52817. static readonly POINTER_SELECTION: string;
  52818. /**
  52819. * The name of the teleportation feature
  52820. */
  52821. static readonly TELEPORTATION: string;
  52822. /**
  52823. * The name of the feature points feature.
  52824. */
  52825. static readonly FEATURE_POINTS: string;
  52826. /**
  52827. * The name of the hand tracking feature.
  52828. */
  52829. static readonly HAND_TRACKING: string;
  52830. }
  52831. /**
  52832. * Defining the constructor of a feature. Used to register the modules.
  52833. */
  52834. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  52835. /**
  52836. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  52837. * It is mainly used in AR sessions.
  52838. *
  52839. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  52840. */
  52841. export class WebXRFeaturesManager implements IDisposable {
  52842. private _xrSessionManager;
  52843. private static readonly _AvailableFeatures;
  52844. private _features;
  52845. /**
  52846. * constructs a new features manages.
  52847. *
  52848. * @param _xrSessionManager an instance of WebXRSessionManager
  52849. */
  52850. constructor(_xrSessionManager: WebXRSessionManager);
  52851. /**
  52852. * Used to register a module. After calling this function a developer can use this feature in the scene.
  52853. * Mainly used internally.
  52854. *
  52855. * @param featureName the name of the feature to register
  52856. * @param constructorFunction the function used to construct the module
  52857. * @param version the (babylon) version of the module
  52858. * @param stable is that a stable version of this module
  52859. */
  52860. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  52861. /**
  52862. * Returns a constructor of a specific feature.
  52863. *
  52864. * @param featureName the name of the feature to construct
  52865. * @param version the version of the feature to load
  52866. * @param xrSessionManager the xrSessionManager. Used to construct the module
  52867. * @param options optional options provided to the module.
  52868. * @returns a function that, when called, will return a new instance of this feature
  52869. */
  52870. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  52871. /**
  52872. * Can be used to return the list of features currently registered
  52873. *
  52874. * @returns an Array of available features
  52875. */
  52876. static GetAvailableFeatures(): string[];
  52877. /**
  52878. * Gets the versions available for a specific feature
  52879. * @param featureName the name of the feature
  52880. * @returns an array with the available versions
  52881. */
  52882. static GetAvailableVersions(featureName: string): string[];
  52883. /**
  52884. * Return the latest unstable version of this feature
  52885. * @param featureName the name of the feature to search
  52886. * @returns the version number. if not found will return -1
  52887. */
  52888. static GetLatestVersionOfFeature(featureName: string): number;
  52889. /**
  52890. * Return the latest stable version of this feature
  52891. * @param featureName the name of the feature to search
  52892. * @returns the version number. if not found will return -1
  52893. */
  52894. static GetStableVersionOfFeature(featureName: string): number;
  52895. /**
  52896. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  52897. * Can be used during a session to start a feature
  52898. * @param featureName the name of feature to attach
  52899. */
  52900. attachFeature(featureName: string): void;
  52901. /**
  52902. * Can be used inside a session or when the session ends to detach a specific feature
  52903. * @param featureName the name of the feature to detach
  52904. */
  52905. detachFeature(featureName: string): void;
  52906. /**
  52907. * Used to disable an already-enabled feature
  52908. * The feature will be disposed and will be recreated once enabled.
  52909. * @param featureName the feature to disable
  52910. * @returns true if disable was successful
  52911. */
  52912. disableFeature(featureName: string | {
  52913. Name: string;
  52914. }): boolean;
  52915. /**
  52916. * dispose this features manager
  52917. */
  52918. dispose(): void;
  52919. /**
  52920. * 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.
  52921. * 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.
  52922. *
  52923. * @param featureName the name of the feature to load or the class of the feature
  52924. * @param version optional version to load. if not provided the latest version will be enabled
  52925. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  52926. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  52927. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  52928. * @returns a new constructed feature or throws an error if feature not found.
  52929. */
  52930. enableFeature(featureName: string | {
  52931. Name: string;
  52932. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  52933. /**
  52934. * get the implementation of an enabled feature.
  52935. * @param featureName the name of the feature to load
  52936. * @returns the feature class, if found
  52937. */
  52938. getEnabledFeature(featureName: string): IWebXRFeature;
  52939. /**
  52940. * Get the list of enabled features
  52941. * @returns an array of enabled features
  52942. */
  52943. getEnabledFeatures(): string[];
  52944. /**
  52945. * This function will exten the session creation configuration object with enabled features.
  52946. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  52947. * according to the defined "required" variable, provided during enableFeature call
  52948. * @param xrSessionInit the xr Session init object to extend
  52949. *
  52950. * @returns an extended XRSessionInit object
  52951. */
  52952. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  52953. }
  52954. }
  52955. declare module "babylonjs/XR/webXRExperienceHelper" {
  52956. import { Observable } from "babylonjs/Misc/observable";
  52957. import { IDisposable, Scene } from "babylonjs/scene";
  52958. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52959. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  52960. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52961. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  52962. /**
  52963. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  52964. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  52965. */
  52966. export class WebXRExperienceHelper implements IDisposable {
  52967. private scene;
  52968. private _nonVRCamera;
  52969. private _originalSceneAutoClear;
  52970. private _supported;
  52971. /**
  52972. * Camera used to render xr content
  52973. */
  52974. camera: WebXRCamera;
  52975. /** A features manager for this xr session */
  52976. featuresManager: WebXRFeaturesManager;
  52977. /**
  52978. * Observers registered here will be triggered after the camera's initial transformation is set
  52979. * This can be used to set a different ground level or an extra rotation.
  52980. *
  52981. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  52982. * to the position set after this observable is done executing.
  52983. */
  52984. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  52985. /**
  52986. * Fires when the state of the experience helper has changed
  52987. */
  52988. onStateChangedObservable: Observable<WebXRState>;
  52989. /** Session manager used to keep track of xr session */
  52990. sessionManager: WebXRSessionManager;
  52991. /**
  52992. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  52993. */
  52994. state: WebXRState;
  52995. /**
  52996. * Creates a WebXRExperienceHelper
  52997. * @param scene The scene the helper should be created in
  52998. */
  52999. private constructor();
  53000. /**
  53001. * Creates the experience helper
  53002. * @param scene the scene to attach the experience helper to
  53003. * @returns a promise for the experience helper
  53004. */
  53005. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  53006. /**
  53007. * Disposes of the experience helper
  53008. */
  53009. dispose(): void;
  53010. /**
  53011. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  53012. * @param sessionMode options for the XR session
  53013. * @param referenceSpaceType frame of reference of the XR session
  53014. * @param renderTarget the output canvas that will be used to enter XR mode
  53015. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  53016. * @returns promise that resolves after xr mode has entered
  53017. */
  53018. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  53019. /**
  53020. * Exits XR mode and returns the scene to its original state
  53021. * @returns promise that resolves after xr mode has exited
  53022. */
  53023. exitXRAsync(): Promise<void>;
  53024. private _nonXRToXRCamera;
  53025. private _setState;
  53026. }
  53027. }
  53028. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  53029. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53030. import { Observable } from "babylonjs/Misc/observable";
  53031. import { IDisposable } from "babylonjs/scene";
  53032. /**
  53033. * X-Y values for axes in WebXR
  53034. */
  53035. export interface IWebXRMotionControllerAxesValue {
  53036. /**
  53037. * The value of the x axis
  53038. */
  53039. x: number;
  53040. /**
  53041. * The value of the y-axis
  53042. */
  53043. y: number;
  53044. }
  53045. /**
  53046. * changed / previous values for the values of this component
  53047. */
  53048. export interface IWebXRMotionControllerComponentChangesValues<T> {
  53049. /**
  53050. * current (this frame) value
  53051. */
  53052. current: T;
  53053. /**
  53054. * previous (last change) value
  53055. */
  53056. previous: T;
  53057. }
  53058. /**
  53059. * Represents changes in the component between current frame and last values recorded
  53060. */
  53061. export interface IWebXRMotionControllerComponentChanges {
  53062. /**
  53063. * will be populated with previous and current values if axes changed
  53064. */
  53065. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  53066. /**
  53067. * will be populated with previous and current values if pressed changed
  53068. */
  53069. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  53070. /**
  53071. * will be populated with previous and current values if touched changed
  53072. */
  53073. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  53074. /**
  53075. * will be populated with previous and current values if value changed
  53076. */
  53077. value?: IWebXRMotionControllerComponentChangesValues<number>;
  53078. }
  53079. /**
  53080. * This class represents a single component (for example button or thumbstick) of a motion controller
  53081. */
  53082. export class WebXRControllerComponent implements IDisposable {
  53083. /**
  53084. * the id of this component
  53085. */
  53086. id: string;
  53087. /**
  53088. * the type of the component
  53089. */
  53090. type: MotionControllerComponentType;
  53091. private _buttonIndex;
  53092. private _axesIndices;
  53093. private _axes;
  53094. private _changes;
  53095. private _currentValue;
  53096. private _hasChanges;
  53097. private _pressed;
  53098. private _touched;
  53099. /**
  53100. * button component type
  53101. */
  53102. static BUTTON_TYPE: MotionControllerComponentType;
  53103. /**
  53104. * squeeze component type
  53105. */
  53106. static SQUEEZE_TYPE: MotionControllerComponentType;
  53107. /**
  53108. * Thumbstick component type
  53109. */
  53110. static THUMBSTICK_TYPE: MotionControllerComponentType;
  53111. /**
  53112. * Touchpad component type
  53113. */
  53114. static TOUCHPAD_TYPE: MotionControllerComponentType;
  53115. /**
  53116. * trigger component type
  53117. */
  53118. static TRIGGER_TYPE: MotionControllerComponentType;
  53119. /**
  53120. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  53121. * the axes data changes
  53122. */
  53123. onAxisValueChangedObservable: Observable<{
  53124. x: number;
  53125. y: number;
  53126. }>;
  53127. /**
  53128. * Observers registered here will be triggered when the state of a button changes
  53129. * State change is either pressed / touched / value
  53130. */
  53131. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  53132. /**
  53133. * Creates a new component for a motion controller.
  53134. * It is created by the motion controller itself
  53135. *
  53136. * @param id the id of this component
  53137. * @param type the type of the component
  53138. * @param _buttonIndex index in the buttons array of the gamepad
  53139. * @param _axesIndices indices of the values in the axes array of the gamepad
  53140. */
  53141. constructor(
  53142. /**
  53143. * the id of this component
  53144. */
  53145. id: string,
  53146. /**
  53147. * the type of the component
  53148. */
  53149. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  53150. /**
  53151. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  53152. */
  53153. get axes(): IWebXRMotionControllerAxesValue;
  53154. /**
  53155. * Get the changes. Elements will be populated only if they changed with their previous and current value
  53156. */
  53157. get changes(): IWebXRMotionControllerComponentChanges;
  53158. /**
  53159. * Return whether or not the component changed the last frame
  53160. */
  53161. get hasChanges(): boolean;
  53162. /**
  53163. * is the button currently pressed
  53164. */
  53165. get pressed(): boolean;
  53166. /**
  53167. * is the button currently touched
  53168. */
  53169. get touched(): boolean;
  53170. /**
  53171. * Get the current value of this component
  53172. */
  53173. get value(): number;
  53174. /**
  53175. * Dispose this component
  53176. */
  53177. dispose(): void;
  53178. /**
  53179. * Are there axes correlating to this component
  53180. * @return true is axes data is available
  53181. */
  53182. isAxes(): boolean;
  53183. /**
  53184. * Is this component a button (hence - pressable)
  53185. * @returns true if can be pressed
  53186. */
  53187. isButton(): boolean;
  53188. /**
  53189. * update this component using the gamepad object it is in. Called on every frame
  53190. * @param nativeController the native gamepad controller object
  53191. */
  53192. update(nativeController: IMinimalMotionControllerObject): void;
  53193. }
  53194. }
  53195. declare module "babylonjs/Loading/sceneLoader" {
  53196. import { Observable } from "babylonjs/Misc/observable";
  53197. import { Nullable } from "babylonjs/types";
  53198. import { Scene } from "babylonjs/scene";
  53199. import { Engine } from "babylonjs/Engines/engine";
  53200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53201. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  53202. import { AssetContainer } from "babylonjs/assetContainer";
  53203. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53204. import { Skeleton } from "babylonjs/Bones/skeleton";
  53205. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  53206. import { WebRequest } from "babylonjs/Misc/webRequest";
  53207. /**
  53208. * Interface used to represent data loading progression
  53209. */
  53210. export interface ISceneLoaderProgressEvent {
  53211. /**
  53212. * Defines if data length to load can be evaluated
  53213. */
  53214. readonly lengthComputable: boolean;
  53215. /**
  53216. * Defines the loaded data length
  53217. */
  53218. readonly loaded: number;
  53219. /**
  53220. * Defines the data length to load
  53221. */
  53222. readonly total: number;
  53223. }
  53224. /**
  53225. * Interface used by SceneLoader plugins to define supported file extensions
  53226. */
  53227. export interface ISceneLoaderPluginExtensions {
  53228. /**
  53229. * Defines the list of supported extensions
  53230. */
  53231. [extension: string]: {
  53232. isBinary: boolean;
  53233. };
  53234. }
  53235. /**
  53236. * Interface used by SceneLoader plugin factory
  53237. */
  53238. export interface ISceneLoaderPluginFactory {
  53239. /**
  53240. * Defines the name of the factory
  53241. */
  53242. name: string;
  53243. /**
  53244. * Function called to create a new plugin
  53245. * @return the new plugin
  53246. */
  53247. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  53248. /**
  53249. * The callback that returns true if the data can be directly loaded.
  53250. * @param data string containing the file data
  53251. * @returns if the data can be loaded directly
  53252. */
  53253. canDirectLoad?(data: string): boolean;
  53254. }
  53255. /**
  53256. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  53257. */
  53258. export interface ISceneLoaderPluginBase {
  53259. /**
  53260. * The friendly name of this plugin.
  53261. */
  53262. name: string;
  53263. /**
  53264. * The file extensions supported by this plugin.
  53265. */
  53266. extensions: string | ISceneLoaderPluginExtensions;
  53267. /**
  53268. * The callback called when loading from a url.
  53269. * @param scene scene loading this url
  53270. * @param url url to load
  53271. * @param onSuccess callback called when the file successfully loads
  53272. * @param onProgress callback called while file is loading (if the server supports this mode)
  53273. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  53274. * @param onError callback called when the file fails to load
  53275. * @returns a file request object
  53276. */
  53277. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  53278. /**
  53279. * The callback called when loading from a file object.
  53280. * @param scene scene loading this file
  53281. * @param file defines the file to load
  53282. * @param onSuccess defines the callback to call when data is loaded
  53283. * @param onProgress defines the callback to call during loading process
  53284. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  53285. * @param onError defines the callback to call when an error occurs
  53286. * @returns a file request object
  53287. */
  53288. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  53289. /**
  53290. * The callback that returns true if the data can be directly loaded.
  53291. * @param data string containing the file data
  53292. * @returns if the data can be loaded directly
  53293. */
  53294. canDirectLoad?(data: string): boolean;
  53295. /**
  53296. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  53297. * @param scene scene loading this data
  53298. * @param data string containing the data
  53299. * @returns data to pass to the plugin
  53300. */
  53301. directLoad?(scene: Scene, data: string): any;
  53302. /**
  53303. * The callback that allows custom handling of the root url based on the response url.
  53304. * @param rootUrl the original root url
  53305. * @param responseURL the response url if available
  53306. * @returns the new root url
  53307. */
  53308. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  53309. }
  53310. /**
  53311. * Interface used to define a SceneLoader plugin
  53312. */
  53313. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  53314. /**
  53315. * Import meshes into a scene.
  53316. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53317. * @param scene The scene to import into
  53318. * @param data The data to import
  53319. * @param rootUrl The root url for scene and resources
  53320. * @param meshes The meshes array to import into
  53321. * @param particleSystems The particle systems array to import into
  53322. * @param skeletons The skeletons array to import into
  53323. * @param onError The callback when import fails
  53324. * @returns True if successful or false otherwise
  53325. */
  53326. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  53327. /**
  53328. * Load into a scene.
  53329. * @param scene The scene to load into
  53330. * @param data The data to import
  53331. * @param rootUrl The root url for scene and resources
  53332. * @param onError The callback when import fails
  53333. * @returns True if successful or false otherwise
  53334. */
  53335. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  53336. /**
  53337. * Load into an asset container.
  53338. * @param scene The scene to load into
  53339. * @param data The data to import
  53340. * @param rootUrl The root url for scene and resources
  53341. * @param onError The callback when import fails
  53342. * @returns The loaded asset container
  53343. */
  53344. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  53345. }
  53346. /**
  53347. * Interface used to define an async SceneLoader plugin
  53348. */
  53349. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  53350. /**
  53351. * Import meshes into a scene.
  53352. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53353. * @param scene The scene to import into
  53354. * @param data The data to import
  53355. * @param rootUrl The root url for scene and resources
  53356. * @param onProgress The callback when the load progresses
  53357. * @param fileName Defines the name of the file to load
  53358. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  53359. */
  53360. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  53361. meshes: AbstractMesh[];
  53362. particleSystems: IParticleSystem[];
  53363. skeletons: Skeleton[];
  53364. animationGroups: AnimationGroup[];
  53365. }>;
  53366. /**
  53367. * Load into a scene.
  53368. * @param scene The scene to load into
  53369. * @param data The data to import
  53370. * @param rootUrl The root url for scene and resources
  53371. * @param onProgress The callback when the load progresses
  53372. * @param fileName Defines the name of the file to load
  53373. * @returns Nothing
  53374. */
  53375. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  53376. /**
  53377. * Load into an asset container.
  53378. * @param scene The scene to load into
  53379. * @param data The data to import
  53380. * @param rootUrl The root url for scene and resources
  53381. * @param onProgress The callback when the load progresses
  53382. * @param fileName Defines the name of the file to load
  53383. * @returns The loaded asset container
  53384. */
  53385. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  53386. }
  53387. /**
  53388. * Mode that determines how to handle old animation groups before loading new ones.
  53389. */
  53390. export enum SceneLoaderAnimationGroupLoadingMode {
  53391. /**
  53392. * Reset all old animations to initial state then dispose them.
  53393. */
  53394. Clean = 0,
  53395. /**
  53396. * Stop all old animations.
  53397. */
  53398. Stop = 1,
  53399. /**
  53400. * Restart old animations from first frame.
  53401. */
  53402. Sync = 2,
  53403. /**
  53404. * Old animations remains untouched.
  53405. */
  53406. NoSync = 3
  53407. }
  53408. /**
  53409. * Defines a plugin registered by the SceneLoader
  53410. */
  53411. interface IRegisteredPlugin {
  53412. /**
  53413. * Defines the plugin to use
  53414. */
  53415. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  53416. /**
  53417. * Defines if the plugin supports binary data
  53418. */
  53419. isBinary: boolean;
  53420. }
  53421. /**
  53422. * Class used to load scene from various file formats using registered plugins
  53423. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  53424. */
  53425. export class SceneLoader {
  53426. /**
  53427. * No logging while loading
  53428. */
  53429. static readonly NO_LOGGING: number;
  53430. /**
  53431. * Minimal logging while loading
  53432. */
  53433. static readonly MINIMAL_LOGGING: number;
  53434. /**
  53435. * Summary logging while loading
  53436. */
  53437. static readonly SUMMARY_LOGGING: number;
  53438. /**
  53439. * Detailled logging while loading
  53440. */
  53441. static readonly DETAILED_LOGGING: number;
  53442. /**
  53443. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  53444. */
  53445. static get ForceFullSceneLoadingForIncremental(): boolean;
  53446. static set ForceFullSceneLoadingForIncremental(value: boolean);
  53447. /**
  53448. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  53449. */
  53450. static get ShowLoadingScreen(): boolean;
  53451. static set ShowLoadingScreen(value: boolean);
  53452. /**
  53453. * Defines the current logging level (while loading the scene)
  53454. * @ignorenaming
  53455. */
  53456. static get loggingLevel(): number;
  53457. static set loggingLevel(value: number);
  53458. /**
  53459. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  53460. */
  53461. static get CleanBoneMatrixWeights(): boolean;
  53462. static set CleanBoneMatrixWeights(value: boolean);
  53463. /**
  53464. * Event raised when a plugin is used to load a scene
  53465. */
  53466. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  53467. private static _registeredPlugins;
  53468. private static _showingLoadingScreen;
  53469. /**
  53470. * Gets the default plugin (used to load Babylon files)
  53471. * @returns the .babylon plugin
  53472. */
  53473. static GetDefaultPlugin(): IRegisteredPlugin;
  53474. private static _GetPluginForExtension;
  53475. private static _GetPluginForDirectLoad;
  53476. private static _GetPluginForFilename;
  53477. private static _GetDirectLoad;
  53478. private static _LoadData;
  53479. private static _GetFileInfo;
  53480. /**
  53481. * Gets a plugin that can load the given extension
  53482. * @param extension defines the extension to load
  53483. * @returns a plugin or null if none works
  53484. */
  53485. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  53486. /**
  53487. * Gets a boolean indicating that the given extension can be loaded
  53488. * @param extension defines the extension to load
  53489. * @returns true if the extension is supported
  53490. */
  53491. static IsPluginForExtensionAvailable(extension: string): boolean;
  53492. /**
  53493. * Adds a new plugin to the list of registered plugins
  53494. * @param plugin defines the plugin to add
  53495. */
  53496. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  53497. /**
  53498. * Import meshes into a scene
  53499. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53500. * @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)
  53501. * @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)
  53502. * @param scene the instance of BABYLON.Scene to append to
  53503. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  53504. * @param onProgress a callback with a progress event for each file being loaded
  53505. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53506. * @param pluginExtension the extension used to determine the plugin
  53507. * @returns The loaded plugin
  53508. */
  53509. 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>;
  53510. /**
  53511. * Import meshes into a scene
  53512. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53513. * @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)
  53514. * @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)
  53515. * @param scene the instance of BABYLON.Scene to append to
  53516. * @param onProgress a callback with a progress event for each file being loaded
  53517. * @param pluginExtension the extension used to determine the plugin
  53518. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  53519. */
  53520. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  53521. meshes: AbstractMesh[];
  53522. particleSystems: IParticleSystem[];
  53523. skeletons: Skeleton[];
  53524. animationGroups: AnimationGroup[];
  53525. }>;
  53526. /**
  53527. * Load a scene
  53528. * @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)
  53529. * @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)
  53530. * @param engine is the instance of BABYLON.Engine to use to create the scene
  53531. * @param onSuccess a callback with the scene when import succeeds
  53532. * @param onProgress a callback with a progress event for each file being loaded
  53533. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53534. * @param pluginExtension the extension used to determine the plugin
  53535. * @returns The loaded plugin
  53536. */
  53537. 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>;
  53538. /**
  53539. * Load a scene
  53540. * @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)
  53541. * @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)
  53542. * @param engine is the instance of BABYLON.Engine to use to create the scene
  53543. * @param onProgress a callback with a progress event for each file being loaded
  53544. * @param pluginExtension the extension used to determine the plugin
  53545. * @returns The loaded scene
  53546. */
  53547. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  53548. /**
  53549. * Append a scene
  53550. * @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)
  53551. * @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)
  53552. * @param scene is the instance of BABYLON.Scene to append to
  53553. * @param onSuccess a callback with the scene when import succeeds
  53554. * @param onProgress a callback with a progress event for each file being loaded
  53555. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53556. * @param pluginExtension the extension used to determine the plugin
  53557. * @returns The loaded plugin
  53558. */
  53559. 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>;
  53560. /**
  53561. * Append a scene
  53562. * @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)
  53563. * @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)
  53564. * @param scene is the instance of BABYLON.Scene to append to
  53565. * @param onProgress a callback with a progress event for each file being loaded
  53566. * @param pluginExtension the extension used to determine the plugin
  53567. * @returns The given scene
  53568. */
  53569. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  53570. /**
  53571. * Load a scene into an asset container
  53572. * @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)
  53573. * @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)
  53574. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53575. * @param onSuccess a callback with the scene when import succeeds
  53576. * @param onProgress a callback with a progress event for each file being loaded
  53577. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53578. * @param pluginExtension the extension used to determine the plugin
  53579. * @returns The loaded plugin
  53580. */
  53581. 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>;
  53582. /**
  53583. * Load a scene into an asset container
  53584. * @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)
  53585. * @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)
  53586. * @param scene is the instance of Scene to append to
  53587. * @param onProgress a callback with a progress event for each file being loaded
  53588. * @param pluginExtension the extension used to determine the plugin
  53589. * @returns The loaded asset container
  53590. */
  53591. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  53592. /**
  53593. * Import animations from a file into a scene
  53594. * @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)
  53595. * @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)
  53596. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53597. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53598. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53599. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53600. * @param onSuccess a callback with the scene when import succeeds
  53601. * @param onProgress a callback with a progress event for each file being loaded
  53602. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53603. * @param pluginExtension the extension used to determine the plugin
  53604. */
  53605. 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;
  53606. /**
  53607. * Import animations from a file into a scene
  53608. * @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)
  53609. * @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)
  53610. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53611. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53612. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53613. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53614. * @param onSuccess a callback with the scene when import succeeds
  53615. * @param onProgress a callback with a progress event for each file being loaded
  53616. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53617. * @param pluginExtension the extension used to determine the plugin
  53618. * @returns the updated scene with imported animations
  53619. */
  53620. 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>;
  53621. }
  53622. }
  53623. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  53624. import { IDisposable, Scene } from "babylonjs/scene";
  53625. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  53626. import { Observable } from "babylonjs/Misc/observable";
  53627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53628. import { Nullable } from "babylonjs/types";
  53629. /**
  53630. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  53631. */
  53632. export type MotionControllerHandedness = "none" | "left" | "right";
  53633. /**
  53634. * The type of components available in motion controllers.
  53635. * This is not the name of the component.
  53636. */
  53637. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  53638. /**
  53639. * The state of a controller component
  53640. */
  53641. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  53642. /**
  53643. * The schema of motion controller layout.
  53644. * No object will be initialized using this interface
  53645. * This is used just to define the profile.
  53646. */
  53647. export interface IMotionControllerLayout {
  53648. /**
  53649. * Path to load the assets. Usually relative to the base path
  53650. */
  53651. assetPath: string;
  53652. /**
  53653. * Available components (unsorted)
  53654. */
  53655. components: {
  53656. /**
  53657. * A map of component Ids
  53658. */
  53659. [componentId: string]: {
  53660. /**
  53661. * The type of input the component outputs
  53662. */
  53663. type: MotionControllerComponentType;
  53664. /**
  53665. * The indices of this component in the gamepad object
  53666. */
  53667. gamepadIndices: {
  53668. /**
  53669. * Index of button
  53670. */
  53671. button?: number;
  53672. /**
  53673. * If available, index of x-axis
  53674. */
  53675. xAxis?: number;
  53676. /**
  53677. * If available, index of y-axis
  53678. */
  53679. yAxis?: number;
  53680. };
  53681. /**
  53682. * The mesh's root node name
  53683. */
  53684. rootNodeName: string;
  53685. /**
  53686. * Animation definitions for this model
  53687. */
  53688. visualResponses: {
  53689. [stateKey: string]: {
  53690. /**
  53691. * What property will be animated
  53692. */
  53693. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  53694. /**
  53695. * What states influence this visual response
  53696. */
  53697. states: MotionControllerComponentStateType[];
  53698. /**
  53699. * Type of animation - movement or visibility
  53700. */
  53701. valueNodeProperty: "transform" | "visibility";
  53702. /**
  53703. * Base node name to move. Its position will be calculated according to the min and max nodes
  53704. */
  53705. valueNodeName?: string;
  53706. /**
  53707. * Minimum movement node
  53708. */
  53709. minNodeName?: string;
  53710. /**
  53711. * Max movement node
  53712. */
  53713. maxNodeName?: string;
  53714. };
  53715. };
  53716. /**
  53717. * If touch enabled, what is the name of node to display user feedback
  53718. */
  53719. touchPointNodeName?: string;
  53720. };
  53721. };
  53722. /**
  53723. * Is it xr standard mapping or not
  53724. */
  53725. gamepadMapping: "" | "xr-standard";
  53726. /**
  53727. * Base root node of this entire model
  53728. */
  53729. rootNodeName: string;
  53730. /**
  53731. * Defines the main button component id
  53732. */
  53733. selectComponentId: string;
  53734. }
  53735. /**
  53736. * A definition for the layout map in the input profile
  53737. */
  53738. export interface IMotionControllerLayoutMap {
  53739. /**
  53740. * Layouts with handedness type as a key
  53741. */
  53742. [handedness: string]: IMotionControllerLayout;
  53743. }
  53744. /**
  53745. * The XR Input profile schema
  53746. * Profiles can be found here:
  53747. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  53748. */
  53749. export interface IMotionControllerProfile {
  53750. /**
  53751. * fallback profiles for this profileId
  53752. */
  53753. fallbackProfileIds: string[];
  53754. /**
  53755. * The layout map, with handedness as key
  53756. */
  53757. layouts: IMotionControllerLayoutMap;
  53758. /**
  53759. * The id of this profile
  53760. * correlates to the profile(s) in the xrInput.profiles array
  53761. */
  53762. profileId: string;
  53763. }
  53764. /**
  53765. * A helper-interface for the 3 meshes needed for controller button animation
  53766. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  53767. */
  53768. export interface IMotionControllerButtonMeshMap {
  53769. /**
  53770. * the mesh that defines the pressed value mesh position.
  53771. * This is used to find the max-position of this button
  53772. */
  53773. pressedMesh: AbstractMesh;
  53774. /**
  53775. * the mesh that defines the unpressed value mesh position.
  53776. * This is used to find the min (or initial) position of this button
  53777. */
  53778. unpressedMesh: AbstractMesh;
  53779. /**
  53780. * The mesh that will be changed when value changes
  53781. */
  53782. valueMesh: AbstractMesh;
  53783. }
  53784. /**
  53785. * A helper-interface for the 3 meshes needed for controller axis animation.
  53786. * This will be expanded when touchpad animations are fully supported
  53787. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  53788. */
  53789. export interface IMotionControllerMeshMap {
  53790. /**
  53791. * the mesh that defines the maximum value mesh position.
  53792. */
  53793. maxMesh?: AbstractMesh;
  53794. /**
  53795. * the mesh that defines the minimum value mesh position.
  53796. */
  53797. minMesh?: AbstractMesh;
  53798. /**
  53799. * The mesh that will be changed when axis value changes
  53800. */
  53801. valueMesh?: AbstractMesh;
  53802. }
  53803. /**
  53804. * The elements needed for change-detection of the gamepad objects in motion controllers
  53805. */
  53806. export interface IMinimalMotionControllerObject {
  53807. /**
  53808. * Available axes of this controller
  53809. */
  53810. axes: number[];
  53811. /**
  53812. * An array of available buttons
  53813. */
  53814. buttons: Array<{
  53815. /**
  53816. * Value of the button/trigger
  53817. */
  53818. value: number;
  53819. /**
  53820. * If the button/trigger is currently touched
  53821. */
  53822. touched: boolean;
  53823. /**
  53824. * If the button/trigger is currently pressed
  53825. */
  53826. pressed: boolean;
  53827. }>;
  53828. /**
  53829. * EXPERIMENTAL haptic support.
  53830. */
  53831. hapticActuators?: Array<{
  53832. pulse: (value: number, duration: number) => Promise<boolean>;
  53833. }>;
  53834. }
  53835. /**
  53836. * An Abstract Motion controller
  53837. * This class receives an xrInput and a profile layout and uses those to initialize the components
  53838. * Each component has an observable to check for changes in value and state
  53839. */
  53840. export abstract class WebXRAbstractMotionController implements IDisposable {
  53841. protected scene: Scene;
  53842. protected layout: IMotionControllerLayout;
  53843. /**
  53844. * The gamepad object correlating to this controller
  53845. */
  53846. gamepadObject: IMinimalMotionControllerObject;
  53847. /**
  53848. * handedness (left/right/none) of this controller
  53849. */
  53850. handedness: MotionControllerHandedness;
  53851. private _initComponent;
  53852. private _modelReady;
  53853. /**
  53854. * A map of components (WebXRControllerComponent) in this motion controller
  53855. * Components have a ComponentType and can also have both button and axis definitions
  53856. */
  53857. readonly components: {
  53858. [id: string]: WebXRControllerComponent;
  53859. };
  53860. /**
  53861. * Disable the model's animation. Can be set at any time.
  53862. */
  53863. disableAnimation: boolean;
  53864. /**
  53865. * Observers registered here will be triggered when the model of this controller is done loading
  53866. */
  53867. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  53868. /**
  53869. * The profile id of this motion controller
  53870. */
  53871. abstract profileId: string;
  53872. /**
  53873. * The root mesh of the model. It is null if the model was not yet initialized
  53874. */
  53875. rootMesh: Nullable<AbstractMesh>;
  53876. /**
  53877. * constructs a new abstract motion controller
  53878. * @param scene the scene to which the model of the controller will be added
  53879. * @param layout The profile layout to load
  53880. * @param gamepadObject The gamepad object correlating to this controller
  53881. * @param handedness handedness (left/right/none) of this controller
  53882. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  53883. */
  53884. constructor(scene: Scene, layout: IMotionControllerLayout,
  53885. /**
  53886. * The gamepad object correlating to this controller
  53887. */
  53888. gamepadObject: IMinimalMotionControllerObject,
  53889. /**
  53890. * handedness (left/right/none) of this controller
  53891. */
  53892. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  53893. /**
  53894. * Dispose this controller, the model mesh and all its components
  53895. */
  53896. dispose(): void;
  53897. /**
  53898. * Returns all components of specific type
  53899. * @param type the type to search for
  53900. * @return an array of components with this type
  53901. */
  53902. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  53903. /**
  53904. * get a component based an its component id as defined in layout.components
  53905. * @param id the id of the component
  53906. * @returns the component correlates to the id or undefined if not found
  53907. */
  53908. getComponent(id: string): WebXRControllerComponent;
  53909. /**
  53910. * Get the list of components available in this motion controller
  53911. * @returns an array of strings correlating to available components
  53912. */
  53913. getComponentIds(): string[];
  53914. /**
  53915. * Get the first component of specific type
  53916. * @param type type of component to find
  53917. * @return a controller component or null if not found
  53918. */
  53919. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  53920. /**
  53921. * Get the main (Select) component of this controller as defined in the layout
  53922. * @returns the main component of this controller
  53923. */
  53924. getMainComponent(): WebXRControllerComponent;
  53925. /**
  53926. * Loads the model correlating to this controller
  53927. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  53928. * @returns A promise fulfilled with the result of the model loading
  53929. */
  53930. loadModel(): Promise<boolean>;
  53931. /**
  53932. * Update this model using the current XRFrame
  53933. * @param xrFrame the current xr frame to use and update the model
  53934. */
  53935. updateFromXRFrame(xrFrame: XRFrame): void;
  53936. /**
  53937. * Backwards compatibility due to a deeply-integrated typo
  53938. */
  53939. get handness(): XREye;
  53940. /**
  53941. * Pulse (vibrate) this controller
  53942. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  53943. * Consecutive calls to this function will cancel the last pulse call
  53944. *
  53945. * @param value the strength of the pulse in 0.0...1.0 range
  53946. * @param duration Duration of the pulse in milliseconds
  53947. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  53948. * @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
  53949. */
  53950. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  53951. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53952. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53953. /**
  53954. * Moves the axis on the controller mesh based on its current state
  53955. * @param axis the index of the axis
  53956. * @param axisValue the value of the axis which determines the meshes new position
  53957. * @hidden
  53958. */
  53959. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  53960. /**
  53961. * Update the model itself with the current frame data
  53962. * @param xrFrame the frame to use for updating the model mesh
  53963. */
  53964. protected updateModel(xrFrame: XRFrame): void;
  53965. /**
  53966. * Get the filename and path for this controller's model
  53967. * @returns a map of filename and path
  53968. */
  53969. protected abstract _getFilenameAndPath(): {
  53970. filename: string;
  53971. path: string;
  53972. };
  53973. /**
  53974. * This function is called before the mesh is loaded. It checks for loading constraints.
  53975. * For example, this function can check if the GLB loader is available
  53976. * If this function returns false, the generic controller will be loaded instead
  53977. * @returns Is the client ready to load the mesh
  53978. */
  53979. protected abstract _getModelLoadingConstraints(): boolean;
  53980. /**
  53981. * This function will be called after the model was successfully loaded and can be used
  53982. * for mesh transformations before it is available for the user
  53983. * @param meshes the loaded meshes
  53984. */
  53985. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  53986. /**
  53987. * Set the root mesh for this controller. Important for the WebXR controller class
  53988. * @param meshes the loaded meshes
  53989. */
  53990. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  53991. /**
  53992. * A function executed each frame that updates the mesh (if needed)
  53993. * @param xrFrame the current xrFrame
  53994. */
  53995. protected abstract _updateModel(xrFrame: XRFrame): void;
  53996. private _getGenericFilenameAndPath;
  53997. private _getGenericParentMesh;
  53998. }
  53999. }
  54000. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  54001. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  54002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54003. import { Scene } from "babylonjs/scene";
  54004. /**
  54005. * A generic trigger-only motion controller for WebXR
  54006. */
  54007. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  54008. /**
  54009. * Static version of the profile id of this controller
  54010. */
  54011. static ProfileId: string;
  54012. profileId: string;
  54013. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  54014. protected _getFilenameAndPath(): {
  54015. filename: string;
  54016. path: string;
  54017. };
  54018. protected _getModelLoadingConstraints(): boolean;
  54019. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  54020. protected _setRootMesh(meshes: AbstractMesh[]): void;
  54021. protected _updateModel(): void;
  54022. }
  54023. }
  54024. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  54025. import { Vector4 } from "babylonjs/Maths/math.vector";
  54026. import { Mesh } from "babylonjs/Meshes/mesh";
  54027. import { Scene } from "babylonjs/scene";
  54028. import { Nullable } from "babylonjs/types";
  54029. /**
  54030. * Class containing static functions to help procedurally build meshes
  54031. */
  54032. export class SphereBuilder {
  54033. /**
  54034. * Creates a sphere mesh
  54035. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54036. * * 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`)
  54037. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54038. * * 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
  54039. * * 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)
  54040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54041. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54043. * @param name defines the name of the mesh
  54044. * @param options defines the options used to create the mesh
  54045. * @param scene defines the hosting scene
  54046. * @returns the sphere mesh
  54047. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54048. */
  54049. static CreateSphere(name: string, options: {
  54050. segments?: number;
  54051. diameter?: number;
  54052. diameterX?: number;
  54053. diameterY?: number;
  54054. diameterZ?: number;
  54055. arc?: number;
  54056. slice?: number;
  54057. sideOrientation?: number;
  54058. frontUVs?: Vector4;
  54059. backUVs?: Vector4;
  54060. updatable?: boolean;
  54061. }, scene?: Nullable<Scene>): Mesh;
  54062. }
  54063. }
  54064. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  54065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54066. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  54067. import { Scene } from "babylonjs/scene";
  54068. /**
  54069. * A profiled motion controller has its profile loaded from an online repository.
  54070. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  54071. */
  54072. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  54073. private _repositoryUrl;
  54074. private _buttonMeshMapping;
  54075. private _touchDots;
  54076. /**
  54077. * The profile ID of this controller. Will be populated when the controller initializes.
  54078. */
  54079. profileId: string;
  54080. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  54081. dispose(): void;
  54082. protected _getFilenameAndPath(): {
  54083. filename: string;
  54084. path: string;
  54085. };
  54086. protected _getModelLoadingConstraints(): boolean;
  54087. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  54088. protected _setRootMesh(meshes: AbstractMesh[]): void;
  54089. protected _updateModel(_xrFrame: XRFrame): void;
  54090. }
  54091. }
  54092. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  54093. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  54094. import { Scene } from "babylonjs/scene";
  54095. /**
  54096. * A construction function type to create a new controller based on an xrInput object
  54097. */
  54098. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  54099. /**
  54100. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  54101. *
  54102. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  54103. * it should be replaced with auto-loaded controllers.
  54104. *
  54105. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  54106. */
  54107. export class WebXRMotionControllerManager {
  54108. private static _AvailableControllers;
  54109. private static _Fallbacks;
  54110. private static _ProfileLoadingPromises;
  54111. private static _ProfilesList;
  54112. /**
  54113. * The base URL of the online controller repository. Can be changed at any time.
  54114. */
  54115. static BaseRepositoryUrl: string;
  54116. /**
  54117. * Which repository gets priority - local or online
  54118. */
  54119. static PrioritizeOnlineRepository: boolean;
  54120. /**
  54121. * Use the online repository, or use only locally-defined controllers
  54122. */
  54123. static UseOnlineRepository: boolean;
  54124. /**
  54125. * Clear the cache used for profile loading and reload when requested again
  54126. */
  54127. static ClearProfilesCache(): void;
  54128. /**
  54129. * Register the default fallbacks.
  54130. * This function is called automatically when this file is imported.
  54131. */
  54132. static DefaultFallbacks(): void;
  54133. /**
  54134. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  54135. * @param profileId the profile to which a fallback needs to be found
  54136. * @return an array with corresponding fallback profiles
  54137. */
  54138. static FindFallbackWithProfileId(profileId: string): string[];
  54139. /**
  54140. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  54141. * The order of search:
  54142. *
  54143. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  54144. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  54145. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  54146. * 4) return the generic trigger controller if none were found
  54147. *
  54148. * @param xrInput the xrInput to which a new controller is initialized
  54149. * @param scene the scene to which the model will be added
  54150. * @param forceProfile force a certain profile for this controller
  54151. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  54152. */
  54153. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  54154. /**
  54155. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  54156. *
  54157. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  54158. *
  54159. * @param type the profile type to register
  54160. * @param constructFunction the function to be called when loading this profile
  54161. */
  54162. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  54163. /**
  54164. * Register a fallback to a specific profile.
  54165. * @param profileId the profileId that will receive the fallbacks
  54166. * @param fallbacks A list of fallback profiles
  54167. */
  54168. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  54169. /**
  54170. * Will update the list of profiles available in the repository
  54171. * @return a promise that resolves to a map of profiles available online
  54172. */
  54173. static UpdateProfilesList(): Promise<{
  54174. [profile: string]: string;
  54175. }>;
  54176. private static _LoadProfileFromRepository;
  54177. private static _LoadProfilesFromAvailableControllers;
  54178. }
  54179. }
  54180. declare module "babylonjs/XR/webXRInputSource" {
  54181. import { Observable } from "babylonjs/Misc/observable";
  54182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54183. import { Ray } from "babylonjs/Culling/ray";
  54184. import { Scene } from "babylonjs/scene";
  54185. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  54186. /**
  54187. * Configuration options for the WebXR controller creation
  54188. */
  54189. export interface IWebXRControllerOptions {
  54190. /**
  54191. * Should the controller mesh be animated when a user interacts with it
  54192. * The pressed buttons / thumbstick and touchpad animations will be disabled
  54193. */
  54194. disableMotionControllerAnimation?: boolean;
  54195. /**
  54196. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  54197. */
  54198. doNotLoadControllerMesh?: boolean;
  54199. /**
  54200. * Force a specific controller type for this controller.
  54201. * This can be used when creating your own profile or when testing different controllers
  54202. */
  54203. forceControllerProfile?: string;
  54204. /**
  54205. * Defines a rendering group ID for meshes that will be loaded.
  54206. * This is for the default controllers only.
  54207. */
  54208. renderingGroupId?: number;
  54209. }
  54210. /**
  54211. * Represents an XR controller
  54212. */
  54213. export class WebXRInputSource {
  54214. private _scene;
  54215. /** The underlying input source for the controller */
  54216. inputSource: XRInputSource;
  54217. private _options;
  54218. private _tmpVector;
  54219. private _uniqueId;
  54220. private _disposed;
  54221. /**
  54222. * 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
  54223. */
  54224. grip?: AbstractMesh;
  54225. /**
  54226. * If available, this is the gamepad object related to this controller.
  54227. * Using this object it is possible to get click events and trackpad changes of the
  54228. * webxr controller that is currently being used.
  54229. */
  54230. motionController?: WebXRAbstractMotionController;
  54231. /**
  54232. * Event that fires when the controller is removed/disposed.
  54233. * The object provided as event data is this controller, after associated assets were disposed.
  54234. * uniqueId is still available.
  54235. */
  54236. onDisposeObservable: Observable<WebXRInputSource>;
  54237. /**
  54238. * Will be triggered when the mesh associated with the motion controller is done loading.
  54239. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  54240. * A shortened version of controller -> motion controller -> on mesh loaded.
  54241. */
  54242. onMeshLoadedObservable: Observable<AbstractMesh>;
  54243. /**
  54244. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  54245. */
  54246. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  54247. /**
  54248. * Pointer which can be used to select objects or attach a visible laser to
  54249. */
  54250. pointer: AbstractMesh;
  54251. /**
  54252. * Creates the input source object
  54253. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  54254. * @param _scene the scene which the controller should be associated to
  54255. * @param inputSource the underlying input source for the controller
  54256. * @param _options options for this controller creation
  54257. */
  54258. constructor(_scene: Scene,
  54259. /** The underlying input source for the controller */
  54260. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  54261. /**
  54262. * Get this controllers unique id
  54263. */
  54264. get uniqueId(): string;
  54265. /**
  54266. * Disposes of the object
  54267. */
  54268. dispose(): void;
  54269. /**
  54270. * Gets a world space ray coming from the pointer or grip
  54271. * @param result the resulting ray
  54272. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  54273. */
  54274. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  54275. /**
  54276. * Updates the controller pose based on the given XRFrame
  54277. * @param xrFrame xr frame to update the pose with
  54278. * @param referenceSpace reference space to use
  54279. */
  54280. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  54281. }
  54282. }
  54283. declare module "babylonjs/XR/webXRInput" {
  54284. import { Observable } from "babylonjs/Misc/observable";
  54285. import { IDisposable } from "babylonjs/scene";
  54286. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  54287. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54288. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  54289. /**
  54290. * The schema for initialization options of the XR Input class
  54291. */
  54292. export interface IWebXRInputOptions {
  54293. /**
  54294. * If set to true no model will be automatically loaded
  54295. */
  54296. doNotLoadControllerMeshes?: boolean;
  54297. /**
  54298. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  54299. * If not found, the xr input profile data will be used.
  54300. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  54301. */
  54302. forceInputProfile?: string;
  54303. /**
  54304. * Do not send a request to the controller repository to load the profile.
  54305. *
  54306. * Instead, use the controllers available in babylon itself.
  54307. */
  54308. disableOnlineControllerRepository?: boolean;
  54309. /**
  54310. * A custom URL for the controllers repository
  54311. */
  54312. customControllersRepositoryURL?: string;
  54313. /**
  54314. * Should the controller model's components not move according to the user input
  54315. */
  54316. disableControllerAnimation?: boolean;
  54317. /**
  54318. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  54319. */
  54320. controllerOptions?: IWebXRControllerOptions;
  54321. }
  54322. /**
  54323. * XR input used to track XR inputs such as controllers/rays
  54324. */
  54325. export class WebXRInput implements IDisposable {
  54326. /**
  54327. * the xr session manager for this session
  54328. */
  54329. xrSessionManager: WebXRSessionManager;
  54330. /**
  54331. * the WebXR camera for this session. Mainly used for teleportation
  54332. */
  54333. xrCamera: WebXRCamera;
  54334. private readonly options;
  54335. /**
  54336. * XR controllers being tracked
  54337. */
  54338. controllers: Array<WebXRInputSource>;
  54339. private _frameObserver;
  54340. private _sessionEndedObserver;
  54341. private _sessionInitObserver;
  54342. /**
  54343. * Event when a controller has been connected/added
  54344. */
  54345. onControllerAddedObservable: Observable<WebXRInputSource>;
  54346. /**
  54347. * Event when a controller has been removed/disconnected
  54348. */
  54349. onControllerRemovedObservable: Observable<WebXRInputSource>;
  54350. /**
  54351. * Initializes the WebXRInput
  54352. * @param xrSessionManager the xr session manager for this session
  54353. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  54354. * @param options = initialization options for this xr input
  54355. */
  54356. constructor(
  54357. /**
  54358. * the xr session manager for this session
  54359. */
  54360. xrSessionManager: WebXRSessionManager,
  54361. /**
  54362. * the WebXR camera for this session. Mainly used for teleportation
  54363. */
  54364. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  54365. private _onInputSourcesChange;
  54366. private _addAndRemoveControllers;
  54367. /**
  54368. * Disposes of the object
  54369. */
  54370. dispose(): void;
  54371. }
  54372. }
  54373. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  54374. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  54375. import { Observable, EventState } from "babylonjs/Misc/observable";
  54376. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54377. /**
  54378. * This is the base class for all WebXR features.
  54379. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  54380. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  54381. */
  54382. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  54383. protected _xrSessionManager: WebXRSessionManager;
  54384. private _attached;
  54385. private _removeOnDetach;
  54386. /**
  54387. * Is this feature disposed?
  54388. */
  54389. isDisposed: boolean;
  54390. /**
  54391. * Should auto-attach be disabled?
  54392. */
  54393. disableAutoAttach: boolean;
  54394. /**
  54395. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  54396. */
  54397. xrNativeFeatureName: string;
  54398. /**
  54399. * Construct a new (abstract) WebXR feature
  54400. * @param _xrSessionManager the xr session manager for this feature
  54401. */
  54402. constructor(_xrSessionManager: WebXRSessionManager);
  54403. /**
  54404. * Is this feature attached
  54405. */
  54406. get attached(): boolean;
  54407. /**
  54408. * attach this feature
  54409. *
  54410. * @param force should attachment be forced (even when already attached)
  54411. * @returns true if successful, false is failed or already attached
  54412. */
  54413. attach(force?: boolean): boolean;
  54414. /**
  54415. * detach this feature.
  54416. *
  54417. * @returns true if successful, false if failed or already detached
  54418. */
  54419. detach(): boolean;
  54420. /**
  54421. * Dispose this feature and all of the resources attached
  54422. */
  54423. dispose(): void;
  54424. /**
  54425. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  54426. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  54427. *
  54428. * @returns whether or not the feature is compatible in this environment
  54429. */
  54430. isCompatible(): boolean;
  54431. /**
  54432. * This is used to register callbacks that will automatically be removed when detach is called.
  54433. * @param observable the observable to which the observer will be attached
  54434. * @param callback the callback to register
  54435. */
  54436. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  54437. /**
  54438. * Code in this function will be executed on each xrFrame received from the browser.
  54439. * This function will not execute after the feature is detached.
  54440. * @param _xrFrame the current frame
  54441. */
  54442. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  54443. }
  54444. }
  54445. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  54446. import { IDisposable, Scene } from "babylonjs/scene";
  54447. import { Nullable } from "babylonjs/types";
  54448. import { Observable } from "babylonjs/Misc/observable";
  54449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54450. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  54451. import { Camera } from "babylonjs/Cameras/camera";
  54452. /**
  54453. * Renders a layer on top of an existing scene
  54454. */
  54455. export class UtilityLayerRenderer implements IDisposable {
  54456. /** the original scene that will be rendered on top of */
  54457. originalScene: Scene;
  54458. private _pointerCaptures;
  54459. private _lastPointerEvents;
  54460. private static _DefaultUtilityLayer;
  54461. private static _DefaultKeepDepthUtilityLayer;
  54462. private _sharedGizmoLight;
  54463. private _renderCamera;
  54464. /**
  54465. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  54466. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  54467. * @returns the camera that is used when rendering the utility layer
  54468. */
  54469. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  54470. /**
  54471. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  54472. * @param cam the camera that should be used when rendering the utility layer
  54473. */
  54474. setRenderCamera(cam: Nullable<Camera>): void;
  54475. /**
  54476. * @hidden
  54477. * Light which used by gizmos to get light shading
  54478. */
  54479. _getSharedGizmoLight(): HemisphericLight;
  54480. /**
  54481. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  54482. */
  54483. pickUtilitySceneFirst: boolean;
  54484. /**
  54485. * 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)
  54486. */
  54487. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  54488. /**
  54489. * 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)
  54490. */
  54491. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  54492. /**
  54493. * The scene that is rendered on top of the original scene
  54494. */
  54495. utilityLayerScene: Scene;
  54496. /**
  54497. * If the utility layer should automatically be rendered on top of existing scene
  54498. */
  54499. shouldRender: boolean;
  54500. /**
  54501. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  54502. */
  54503. onlyCheckPointerDownEvents: boolean;
  54504. /**
  54505. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  54506. */
  54507. processAllEvents: boolean;
  54508. /**
  54509. * Observable raised when the pointer move from the utility layer scene to the main scene
  54510. */
  54511. onPointerOutObservable: Observable<number>;
  54512. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  54513. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  54514. private _afterRenderObserver;
  54515. private _sceneDisposeObserver;
  54516. private _originalPointerObserver;
  54517. /**
  54518. * Instantiates a UtilityLayerRenderer
  54519. * @param originalScene the original scene that will be rendered on top of
  54520. * @param handleEvents boolean indicating if the utility layer should handle events
  54521. */
  54522. constructor(
  54523. /** the original scene that will be rendered on top of */
  54524. originalScene: Scene, handleEvents?: boolean);
  54525. private _notifyObservers;
  54526. /**
  54527. * Renders the utility layers scene on top of the original scene
  54528. */
  54529. render(): void;
  54530. /**
  54531. * Disposes of the renderer
  54532. */
  54533. dispose(): void;
  54534. private _updateCamera;
  54535. }
  54536. }
  54537. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  54538. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54540. import { WebXRInput } from "babylonjs/XR/webXRInput";
  54541. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  54542. import { Scene } from "babylonjs/scene";
  54543. import { Nullable } from "babylonjs/types";
  54544. import { Color3 } from "babylonjs/Maths/math.color";
  54545. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  54546. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  54547. /**
  54548. * Options interface for the pointer selection module
  54549. */
  54550. export interface IWebXRControllerPointerSelectionOptions {
  54551. /**
  54552. * if provided, this scene will be used to render meshes.
  54553. */
  54554. customUtilityLayerScene?: Scene;
  54555. /**
  54556. * 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)
  54557. * If not disabled, the last picked point will be used to execute a pointer up event
  54558. * If disabled, pointer up event will be triggered right after the pointer down event.
  54559. * Used in screen and gaze target ray mode only
  54560. */
  54561. disablePointerUpOnTouchOut: boolean;
  54562. /**
  54563. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  54564. */
  54565. forceGazeMode: boolean;
  54566. /**
  54567. * 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
  54568. * to start a new countdown to the pointer down event.
  54569. * Defaults to 1.
  54570. */
  54571. gazeModePointerMovedFactor?: number;
  54572. /**
  54573. * Different button type to use instead of the main component
  54574. */
  54575. overrideButtonId?: string;
  54576. /**
  54577. * use this rendering group id for the meshes (optional)
  54578. */
  54579. renderingGroupId?: number;
  54580. /**
  54581. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  54582. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  54583. * 3000 means 3 seconds between pointing at something and selecting it
  54584. */
  54585. timeToSelect?: number;
  54586. /**
  54587. * Should meshes created here be added to a utility layer or the main scene
  54588. */
  54589. useUtilityLayer?: boolean;
  54590. /**
  54591. * Optional WebXR camera to be used for gaze selection
  54592. */
  54593. gazeCamera?: WebXRCamera;
  54594. /**
  54595. * the xr input to use with this pointer selection
  54596. */
  54597. xrInput: WebXRInput;
  54598. /**
  54599. * Should the scene pointerX and pointerY update be disabled
  54600. * This is required for fullscreen AR GUI, but might slow down other experiences.
  54601. * Disable in VR, if not needed.
  54602. * The first rig camera (left eye) will be used to calculate the projection
  54603. */
  54604. disableScenePointerVectorUpdate: boolean;
  54605. /**
  54606. * Enable pointer selection on all controllers instead of switching between them
  54607. */
  54608. enablePointerSelectionOnAllControllers?: boolean;
  54609. /**
  54610. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  54611. * If switch is enabled, it will still allow the user to switch between the different controllers
  54612. */
  54613. preferredHandedness?: XRHandedness;
  54614. /**
  54615. * Disable switching the pointer selection from one controller to the other.
  54616. * If the preferred hand is set it will be fixed on this hand, and if not it will be fixed on the first controller added to the scene
  54617. */
  54618. disableSwitchOnClick?: boolean;
  54619. /**
  54620. * The maximum distance of the pointer selection feature. Defaults to 100.
  54621. */
  54622. maxPointerDistance?: number;
  54623. }
  54624. /**
  54625. * A module that will enable pointer selection for motion controllers of XR Input Sources
  54626. */
  54627. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  54628. private readonly _options;
  54629. private static _idCounter;
  54630. private _attachController;
  54631. private _controllers;
  54632. private _scene;
  54633. private _tmpVectorForPickCompare;
  54634. private _attachedController;
  54635. /**
  54636. * The module's name
  54637. */
  54638. static readonly Name: string;
  54639. /**
  54640. * The (Babylon) version of this module.
  54641. * This is an integer representing the implementation version.
  54642. * This number does not correspond to the WebXR specs version
  54643. */
  54644. static readonly Version: number;
  54645. /**
  54646. * Disable lighting on the laser pointer (so it will always be visible)
  54647. */
  54648. disablePointerLighting: boolean;
  54649. /**
  54650. * Disable lighting on the selection mesh (so it will always be visible)
  54651. */
  54652. disableSelectionMeshLighting: boolean;
  54653. /**
  54654. * Should the laser pointer be displayed
  54655. */
  54656. displayLaserPointer: boolean;
  54657. /**
  54658. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  54659. */
  54660. displaySelectionMesh: boolean;
  54661. /**
  54662. * This color will be set to the laser pointer when selection is triggered
  54663. */
  54664. laserPointerPickedColor: Color3;
  54665. /**
  54666. * Default color of the laser pointer
  54667. */
  54668. laserPointerDefaultColor: Color3;
  54669. /**
  54670. * default color of the selection ring
  54671. */
  54672. selectionMeshDefaultColor: Color3;
  54673. /**
  54674. * This color will be applied to the selection ring when selection is triggered
  54675. */
  54676. selectionMeshPickedColor: Color3;
  54677. /**
  54678. * Optional filter to be used for ray selection. This predicate shares behavior with
  54679. * scene.pointerMovePredicate which takes priority if it is also assigned.
  54680. */
  54681. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  54682. /**
  54683. * constructs a new background remover module
  54684. * @param _xrSessionManager the session manager for this module
  54685. * @param _options read-only options to be used in this module
  54686. */
  54687. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  54688. /**
  54689. * attach this feature
  54690. * Will usually be called by the features manager
  54691. *
  54692. * @returns true if successful.
  54693. */
  54694. attach(): boolean;
  54695. /**
  54696. * detach this feature.
  54697. * Will usually be called by the features manager
  54698. *
  54699. * @returns true if successful.
  54700. */
  54701. detach(): boolean;
  54702. /**
  54703. * Will get the mesh under a specific pointer.
  54704. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  54705. * @param controllerId the controllerId to check
  54706. * @returns The mesh under pointer or null if no mesh is under the pointer
  54707. */
  54708. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  54709. /**
  54710. * Get the xr controller that correlates to the pointer id in the pointer event
  54711. *
  54712. * @param id the pointer id to search for
  54713. * @returns the controller that correlates to this id or null if not found
  54714. */
  54715. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  54716. private _identityMatrix;
  54717. private _screenCoordinatesRef;
  54718. private _viewportRef;
  54719. protected _onXRFrame(_xrFrame: XRFrame): void;
  54720. private _attachGazeMode;
  54721. private _attachScreenRayMode;
  54722. private _attachTrackedPointerRayMode;
  54723. private _convertNormalToDirectionOfRay;
  54724. private _detachController;
  54725. private _generateNewMeshPair;
  54726. private _pickingMoved;
  54727. private _updatePointerDistance;
  54728. /** @hidden */
  54729. get lasterPointerDefaultColor(): Color3;
  54730. }
  54731. }
  54732. declare module "babylonjs/XR/webXREnterExitUI" {
  54733. import { Nullable } from "babylonjs/types";
  54734. import { Observable } from "babylonjs/Misc/observable";
  54735. import { IDisposable, Scene } from "babylonjs/scene";
  54736. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54737. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54738. /**
  54739. * Button which can be used to enter a different mode of XR
  54740. */
  54741. export class WebXREnterExitUIButton {
  54742. /** button element */
  54743. element: HTMLElement;
  54744. /** XR initialization options for the button */
  54745. sessionMode: XRSessionMode;
  54746. /** Reference space type */
  54747. referenceSpaceType: XRReferenceSpaceType;
  54748. /**
  54749. * Creates a WebXREnterExitUIButton
  54750. * @param element button element
  54751. * @param sessionMode XR initialization session mode
  54752. * @param referenceSpaceType the type of reference space to be used
  54753. */
  54754. constructor(
  54755. /** button element */
  54756. element: HTMLElement,
  54757. /** XR initialization options for the button */
  54758. sessionMode: XRSessionMode,
  54759. /** Reference space type */
  54760. referenceSpaceType: XRReferenceSpaceType);
  54761. /**
  54762. * Extendable function which can be used to update the button's visuals when the state changes
  54763. * @param activeButton the current active button in the UI
  54764. */
  54765. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  54766. }
  54767. /**
  54768. * Options to create the webXR UI
  54769. */
  54770. export class WebXREnterExitUIOptions {
  54771. /**
  54772. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  54773. */
  54774. customButtons?: Array<WebXREnterExitUIButton>;
  54775. /**
  54776. * A reference space type to use when creating the default button.
  54777. * Default is local-floor
  54778. */
  54779. referenceSpaceType?: XRReferenceSpaceType;
  54780. /**
  54781. * Context to enter xr with
  54782. */
  54783. renderTarget?: Nullable<WebXRRenderTarget>;
  54784. /**
  54785. * A session mode to use when creating the default button.
  54786. * Default is immersive-vr
  54787. */
  54788. sessionMode?: XRSessionMode;
  54789. /**
  54790. * A list of optional features to init the session with
  54791. */
  54792. optionalFeatures?: string[];
  54793. /**
  54794. * A list of optional features to init the session with
  54795. */
  54796. requiredFeatures?: string[];
  54797. /**
  54798. * If defined, this function will be executed if the UI encounters an error when entering XR
  54799. */
  54800. onError?: (error: any) => void;
  54801. }
  54802. /**
  54803. * UI to allow the user to enter/exit XR mode
  54804. */
  54805. export class WebXREnterExitUI implements IDisposable {
  54806. private scene;
  54807. /** version of the options passed to this UI */
  54808. options: WebXREnterExitUIOptions;
  54809. private _activeButton;
  54810. private _buttons;
  54811. /**
  54812. * The HTML Div Element to which buttons are added.
  54813. */
  54814. readonly overlay: HTMLDivElement;
  54815. /**
  54816. * Fired every time the active button is changed.
  54817. *
  54818. * When xr is entered via a button that launches xr that button will be the callback parameter
  54819. *
  54820. * When exiting xr the callback parameter will be null)
  54821. */
  54822. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  54823. /**
  54824. *
  54825. * @param scene babylon scene object to use
  54826. * @param options (read-only) version of the options passed to this UI
  54827. */
  54828. private constructor();
  54829. /**
  54830. * Creates UI to allow the user to enter/exit XR mode
  54831. * @param scene the scene to add the ui to
  54832. * @param helper the xr experience helper to enter/exit xr with
  54833. * @param options options to configure the UI
  54834. * @returns the created ui
  54835. */
  54836. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  54837. /**
  54838. * Disposes of the XR UI component
  54839. */
  54840. dispose(): void;
  54841. private _updateButtons;
  54842. }
  54843. }
  54844. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  54845. import { Vector3 } from "babylonjs/Maths/math.vector";
  54846. import { Color4 } from "babylonjs/Maths/math.color";
  54847. import { Nullable } from "babylonjs/types";
  54848. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  54849. import { Scene } from "babylonjs/scene";
  54850. /**
  54851. * Class containing static functions to help procedurally build meshes
  54852. */
  54853. export class LinesBuilder {
  54854. /**
  54855. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54856. * * 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
  54857. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54858. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54859. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54860. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54861. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54862. * * 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
  54863. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54865. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54866. * @param name defines the name of the new line system
  54867. * @param options defines the options used to create the line system
  54868. * @param scene defines the hosting scene
  54869. * @returns a new line system mesh
  54870. */
  54871. static CreateLineSystem(name: string, options: {
  54872. lines: Vector3[][];
  54873. updatable?: boolean;
  54874. instance?: Nullable<LinesMesh>;
  54875. colors?: Nullable<Color4[][]>;
  54876. useVertexAlpha?: boolean;
  54877. }, scene: Nullable<Scene>): LinesMesh;
  54878. /**
  54879. * Creates a line mesh
  54880. * 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
  54881. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54882. * * The parameter `points` is an array successive Vector3
  54883. * * 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
  54884. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54885. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54886. * * When updating an instance, remember that only point positions can change, not the number of points
  54887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54888. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54889. * @param name defines the name of the new line system
  54890. * @param options defines the options used to create the line system
  54891. * @param scene defines the hosting scene
  54892. * @returns a new line mesh
  54893. */
  54894. static CreateLines(name: string, options: {
  54895. points: Vector3[];
  54896. updatable?: boolean;
  54897. instance?: Nullable<LinesMesh>;
  54898. colors?: Color4[];
  54899. useVertexAlpha?: boolean;
  54900. }, scene?: Nullable<Scene>): LinesMesh;
  54901. /**
  54902. * Creates a dashed line mesh
  54903. * * 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
  54904. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54905. * * The parameter `points` is an array successive Vector3
  54906. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54907. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54908. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54909. * * 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
  54910. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54911. * * When updating an instance, remember that only point positions can change, not the number of points
  54912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54913. * @param name defines the name of the mesh
  54914. * @param options defines the options used to create the mesh
  54915. * @param scene defines the hosting scene
  54916. * @returns the dashed line mesh
  54917. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54918. */
  54919. static CreateDashedLines(name: string, options: {
  54920. points: Vector3[];
  54921. dashSize?: number;
  54922. gapSize?: number;
  54923. dashNb?: number;
  54924. updatable?: boolean;
  54925. instance?: LinesMesh;
  54926. useVertexAlpha?: boolean;
  54927. }, scene?: Nullable<Scene>): LinesMesh;
  54928. }
  54929. }
  54930. declare module "babylonjs/Misc/timer" {
  54931. import { Observable, Observer } from "babylonjs/Misc/observable";
  54932. import { Nullable } from "babylonjs/types";
  54933. import { IDisposable } from "babylonjs/scene";
  54934. /**
  54935. * Construction options for a timer
  54936. */
  54937. export interface ITimerOptions<T> {
  54938. /**
  54939. * Time-to-end
  54940. */
  54941. timeout: number;
  54942. /**
  54943. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  54944. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  54945. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  54946. */
  54947. contextObservable: Observable<T>;
  54948. /**
  54949. * Optional parameters when adding an observer to the observable
  54950. */
  54951. observableParameters?: {
  54952. mask?: number;
  54953. insertFirst?: boolean;
  54954. scope?: any;
  54955. };
  54956. /**
  54957. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  54958. */
  54959. breakCondition?: (data?: ITimerData<T>) => boolean;
  54960. /**
  54961. * Will be triggered when the time condition has met
  54962. */
  54963. onEnded?: (data: ITimerData<any>) => void;
  54964. /**
  54965. * Will be triggered when the break condition has met (prematurely ended)
  54966. */
  54967. onAborted?: (data: ITimerData<any>) => void;
  54968. /**
  54969. * Optional function to execute on each tick (or count)
  54970. */
  54971. onTick?: (data: ITimerData<any>) => void;
  54972. }
  54973. /**
  54974. * An interface defining the data sent by the timer
  54975. */
  54976. export interface ITimerData<T> {
  54977. /**
  54978. * When did it start
  54979. */
  54980. startTime: number;
  54981. /**
  54982. * Time now
  54983. */
  54984. currentTime: number;
  54985. /**
  54986. * Time passed since started
  54987. */
  54988. deltaTime: number;
  54989. /**
  54990. * How much is completed, in [0.0...1.0].
  54991. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  54992. */
  54993. completeRate: number;
  54994. /**
  54995. * What the registered observable sent in the last count
  54996. */
  54997. payload: T;
  54998. }
  54999. /**
  55000. * The current state of the timer
  55001. */
  55002. export enum TimerState {
  55003. /**
  55004. * Timer initialized, not yet started
  55005. */
  55006. INIT = 0,
  55007. /**
  55008. * Timer started and counting
  55009. */
  55010. STARTED = 1,
  55011. /**
  55012. * Timer ended (whether aborted or time reached)
  55013. */
  55014. ENDED = 2
  55015. }
  55016. /**
  55017. * A simple version of the timer. Will take options and start the timer immediately after calling it
  55018. *
  55019. * @param options options with which to initialize this timer
  55020. */
  55021. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  55022. /**
  55023. * An advanced implementation of a timer class
  55024. */
  55025. export class AdvancedTimer<T = any> implements IDisposable {
  55026. /**
  55027. * Will notify each time the timer calculates the remaining time
  55028. */
  55029. onEachCountObservable: Observable<ITimerData<T>>;
  55030. /**
  55031. * Will trigger when the timer was aborted due to the break condition
  55032. */
  55033. onTimerAbortedObservable: Observable<ITimerData<T>>;
  55034. /**
  55035. * Will trigger when the timer ended successfully
  55036. */
  55037. onTimerEndedObservable: Observable<ITimerData<T>>;
  55038. /**
  55039. * Will trigger when the timer state has changed
  55040. */
  55041. onStateChangedObservable: Observable<TimerState>;
  55042. private _observer;
  55043. private _contextObservable;
  55044. private _observableParameters;
  55045. private _startTime;
  55046. private _timer;
  55047. private _state;
  55048. private _breakCondition;
  55049. private _timeToEnd;
  55050. private _breakOnNextTick;
  55051. /**
  55052. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  55053. * @param options construction options for this advanced timer
  55054. */
  55055. constructor(options: ITimerOptions<T>);
  55056. /**
  55057. * set a breaking condition for this timer. Default is to never break during count
  55058. * @param predicate the new break condition. Returns true to break, false otherwise
  55059. */
  55060. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  55061. /**
  55062. * Reset ALL associated observables in this advanced timer
  55063. */
  55064. clearObservables(): void;
  55065. /**
  55066. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  55067. *
  55068. * @param timeToEnd how much time to measure until timer ended
  55069. */
  55070. start(timeToEnd?: number): void;
  55071. /**
  55072. * Will force a stop on the next tick.
  55073. */
  55074. stop(): void;
  55075. /**
  55076. * Dispose this timer, clearing all resources
  55077. */
  55078. dispose(): void;
  55079. private _setState;
  55080. private _tick;
  55081. private _stop;
  55082. }
  55083. }
  55084. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  55085. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  55086. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  55087. import { Nullable } from "babylonjs/types";
  55088. import { WebXRInput } from "babylonjs/XR/webXRInput";
  55089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55090. import { Vector3 } from "babylonjs/Maths/math.vector";
  55091. import { Material } from "babylonjs/Materials/material";
  55092. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  55093. import { Scene } from "babylonjs/scene";
  55094. /**
  55095. * The options container for the teleportation module
  55096. */
  55097. export interface IWebXRTeleportationOptions {
  55098. /**
  55099. * if provided, this scene will be used to render meshes.
  55100. */
  55101. customUtilityLayerScene?: Scene;
  55102. /**
  55103. * Values to configure the default target mesh
  55104. */
  55105. defaultTargetMeshOptions?: {
  55106. /**
  55107. * Fill color of the teleportation area
  55108. */
  55109. teleportationFillColor?: string;
  55110. /**
  55111. * Border color for the teleportation area
  55112. */
  55113. teleportationBorderColor?: string;
  55114. /**
  55115. * Disable the mesh's animation sequence
  55116. */
  55117. disableAnimation?: boolean;
  55118. /**
  55119. * Disable lighting on the material or the ring and arrow
  55120. */
  55121. disableLighting?: boolean;
  55122. /**
  55123. * Override the default material of the torus and arrow
  55124. */
  55125. torusArrowMaterial?: Material;
  55126. };
  55127. /**
  55128. * A list of meshes to use as floor meshes.
  55129. * Meshes can be added and removed after initializing the feature using the
  55130. * addFloorMesh and removeFloorMesh functions
  55131. * If empty, rotation will still work
  55132. */
  55133. floorMeshes?: AbstractMesh[];
  55134. /**
  55135. * use this rendering group id for the meshes (optional)
  55136. */
  55137. renderingGroupId?: number;
  55138. /**
  55139. * Should teleportation move only to snap points
  55140. */
  55141. snapPointsOnly?: boolean;
  55142. /**
  55143. * An array of points to which the teleportation will snap to.
  55144. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  55145. */
  55146. snapPositions?: Vector3[];
  55147. /**
  55148. * How close should the teleportation ray be in order to snap to position.
  55149. * Default to 0.8 units (meters)
  55150. */
  55151. snapToPositionRadius?: number;
  55152. /**
  55153. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  55154. * If you want to support rotation, make sure your mesh has a direction indicator.
  55155. *
  55156. * When left untouched, the default mesh will be initialized.
  55157. */
  55158. teleportationTargetMesh?: AbstractMesh;
  55159. /**
  55160. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  55161. */
  55162. timeToTeleport?: number;
  55163. /**
  55164. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  55165. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  55166. */
  55167. useMainComponentOnly?: boolean;
  55168. /**
  55169. * Should meshes created here be added to a utility layer or the main scene
  55170. */
  55171. useUtilityLayer?: boolean;
  55172. /**
  55173. * Babylon XR Input class for controller
  55174. */
  55175. xrInput: WebXRInput;
  55176. /**
  55177. * Meshes that the teleportation ray cannot go through
  55178. */
  55179. pickBlockerMeshes?: AbstractMesh[];
  55180. }
  55181. /**
  55182. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  55183. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  55184. * the input of the attached controllers.
  55185. */
  55186. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  55187. private _options;
  55188. private _controllers;
  55189. private _currentTeleportationControllerId;
  55190. private _floorMeshes;
  55191. private _quadraticBezierCurve;
  55192. private _selectionFeature;
  55193. private _snapToPositions;
  55194. private _snappedToPoint;
  55195. private _teleportationRingMaterial?;
  55196. private _tmpRay;
  55197. private _tmpVector;
  55198. private _tmpQuaternion;
  55199. /**
  55200. * The module's name
  55201. */
  55202. static readonly Name: string;
  55203. /**
  55204. * The (Babylon) version of this module.
  55205. * This is an integer representing the implementation version.
  55206. * This number does not correspond to the webxr specs version
  55207. */
  55208. static readonly Version: number;
  55209. /**
  55210. * Is movement backwards enabled
  55211. */
  55212. backwardsMovementEnabled: boolean;
  55213. /**
  55214. * Distance to travel when moving backwards
  55215. */
  55216. backwardsTeleportationDistance: number;
  55217. /**
  55218. * The distance from the user to the inspection point in the direction of the controller
  55219. * A higher number will allow the user to move further
  55220. * defaults to 5 (meters, in xr units)
  55221. */
  55222. parabolicCheckRadius: number;
  55223. /**
  55224. * Should the module support parabolic ray on top of direct ray
  55225. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  55226. * Very helpful when moving between floors / different heights
  55227. */
  55228. parabolicRayEnabled: boolean;
  55229. /**
  55230. * How much rotation should be applied when rotating right and left
  55231. */
  55232. rotationAngle: number;
  55233. /**
  55234. * Is rotation enabled when moving forward?
  55235. * Disabling this feature will prevent the user from deciding the direction when teleporting
  55236. */
  55237. rotationEnabled: boolean;
  55238. /**
  55239. * constructs a new anchor system
  55240. * @param _xrSessionManager an instance of WebXRSessionManager
  55241. * @param _options configuration object for this feature
  55242. */
  55243. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  55244. /**
  55245. * Get the snapPointsOnly flag
  55246. */
  55247. get snapPointsOnly(): boolean;
  55248. /**
  55249. * Sets the snapPointsOnly flag
  55250. * @param snapToPoints should teleportation be exclusively to snap points
  55251. */
  55252. set snapPointsOnly(snapToPoints: boolean);
  55253. /**
  55254. * Add a new mesh to the floor meshes array
  55255. * @param mesh the mesh to use as floor mesh
  55256. */
  55257. addFloorMesh(mesh: AbstractMesh): void;
  55258. /**
  55259. * Add a new snap-to point to fix teleportation to this position
  55260. * @param newSnapPoint The new Snap-To point
  55261. */
  55262. addSnapPoint(newSnapPoint: Vector3): void;
  55263. attach(): boolean;
  55264. detach(): boolean;
  55265. dispose(): void;
  55266. /**
  55267. * Remove a mesh from the floor meshes array
  55268. * @param mesh the mesh to remove
  55269. */
  55270. removeFloorMesh(mesh: AbstractMesh): void;
  55271. /**
  55272. * Remove a mesh from the floor meshes array using its name
  55273. * @param name the mesh name to remove
  55274. */
  55275. removeFloorMeshByName(name: string): void;
  55276. /**
  55277. * 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
  55278. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  55279. * @returns was the point found and removed or not
  55280. */
  55281. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  55282. /**
  55283. * This function sets a selection feature that will be disabled when
  55284. * the forward ray is shown and will be reattached when hidden.
  55285. * This is used to remove the selection rays when moving.
  55286. * @param selectionFeature the feature to disable when forward movement is enabled
  55287. */
  55288. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  55289. protected _onXRFrame(_xrFrame: XRFrame): void;
  55290. private _attachController;
  55291. private _createDefaultTargetMesh;
  55292. private _detachController;
  55293. private _findClosestSnapPointWithRadius;
  55294. private _setTargetMeshPosition;
  55295. private _setTargetMeshVisibility;
  55296. private _showParabolicPath;
  55297. private _teleportForward;
  55298. }
  55299. }
  55300. declare module "babylonjs/XR/webXRDefaultExperience" {
  55301. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  55302. import { Scene } from "babylonjs/scene";
  55303. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  55304. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  55305. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  55306. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  55307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55308. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  55309. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  55310. /**
  55311. * Options for the default xr helper
  55312. */
  55313. export class WebXRDefaultExperienceOptions {
  55314. /**
  55315. * Enable or disable default UI to enter XR
  55316. */
  55317. disableDefaultUI?: boolean;
  55318. /**
  55319. * Should teleportation not initialize. defaults to false.
  55320. */
  55321. disableTeleportation?: boolean;
  55322. /**
  55323. * Floor meshes that will be used for teleport
  55324. */
  55325. floorMeshes?: Array<AbstractMesh>;
  55326. /**
  55327. * If set to true, the first frame will not be used to reset position
  55328. * The first frame is mainly used when copying transformation from the old camera
  55329. * Mainly used in AR
  55330. */
  55331. ignoreNativeCameraTransformation?: boolean;
  55332. /**
  55333. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  55334. */
  55335. inputOptions?: IWebXRInputOptions;
  55336. /**
  55337. * optional configuration for the output canvas
  55338. */
  55339. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  55340. /**
  55341. * optional UI options. This can be used among other to change session mode and reference space type
  55342. */
  55343. uiOptions?: WebXREnterExitUIOptions;
  55344. /**
  55345. * When loading teleportation and pointer select, use stable versions instead of latest.
  55346. */
  55347. useStablePlugins?: boolean;
  55348. /**
  55349. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  55350. */
  55351. renderingGroupId?: number;
  55352. /**
  55353. * A list of optional features to init the session with
  55354. * If set to true, all features we support will be added
  55355. */
  55356. optionalFeatures?: boolean | string[];
  55357. }
  55358. /**
  55359. * Default experience which provides a similar setup to the previous webVRExperience
  55360. */
  55361. export class WebXRDefaultExperience {
  55362. /**
  55363. * Base experience
  55364. */
  55365. baseExperience: WebXRExperienceHelper;
  55366. /**
  55367. * Enables ui for entering/exiting xr
  55368. */
  55369. enterExitUI: WebXREnterExitUI;
  55370. /**
  55371. * Input experience extension
  55372. */
  55373. input: WebXRInput;
  55374. /**
  55375. * Enables laser pointer and selection
  55376. */
  55377. pointerSelection: WebXRControllerPointerSelection;
  55378. /**
  55379. * Default target xr should render to
  55380. */
  55381. renderTarget: WebXRRenderTarget;
  55382. /**
  55383. * Enables teleportation
  55384. */
  55385. teleportation: WebXRMotionControllerTeleportation;
  55386. private constructor();
  55387. /**
  55388. * Creates the default xr experience
  55389. * @param scene scene
  55390. * @param options options for basic configuration
  55391. * @returns resulting WebXRDefaultExperience
  55392. */
  55393. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55394. /**
  55395. * DIsposes of the experience helper
  55396. */
  55397. dispose(): void;
  55398. }
  55399. }
  55400. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  55401. import { Observable } from "babylonjs/Misc/observable";
  55402. import { Nullable } from "babylonjs/types";
  55403. import { Camera } from "babylonjs/Cameras/camera";
  55404. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  55405. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55406. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  55407. import { Scene } from "babylonjs/scene";
  55408. import { Vector3 } from "babylonjs/Maths/math.vector";
  55409. import { Color3 } from "babylonjs/Maths/math.color";
  55410. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55412. import { Mesh } from "babylonjs/Meshes/mesh";
  55413. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  55414. import { EasingFunction } from "babylonjs/Animations/easing";
  55415. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  55416. import "babylonjs/Meshes/Builders/groundBuilder";
  55417. import "babylonjs/Meshes/Builders/torusBuilder";
  55418. import "babylonjs/Meshes/Builders/cylinderBuilder";
  55419. import "babylonjs/Gamepads/gamepadSceneComponent";
  55420. import "babylonjs/Animations/animatable";
  55421. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  55422. /**
  55423. * Options to modify the vr teleportation behavior.
  55424. */
  55425. export interface VRTeleportationOptions {
  55426. /**
  55427. * The name of the mesh which should be used as the teleportation floor. (default: null)
  55428. */
  55429. floorMeshName?: string;
  55430. /**
  55431. * A list of meshes to be used as the teleportation floor. (default: empty)
  55432. */
  55433. floorMeshes?: Mesh[];
  55434. /**
  55435. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  55436. */
  55437. teleportationMode?: number;
  55438. /**
  55439. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  55440. */
  55441. teleportationTime?: number;
  55442. /**
  55443. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  55444. */
  55445. teleportationSpeed?: number;
  55446. /**
  55447. * The easing function used in the animation or null for Linear. (default CircleEase)
  55448. */
  55449. easingFunction?: EasingFunction;
  55450. }
  55451. /**
  55452. * Options to modify the vr experience helper's behavior.
  55453. */
  55454. export interface VRExperienceHelperOptions extends WebVROptions {
  55455. /**
  55456. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  55457. */
  55458. createDeviceOrientationCamera?: boolean;
  55459. /**
  55460. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  55461. */
  55462. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  55463. /**
  55464. * Uses the main button on the controller to toggle the laser casted. (default: true)
  55465. */
  55466. laserToggle?: boolean;
  55467. /**
  55468. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  55469. */
  55470. floorMeshes?: Mesh[];
  55471. /**
  55472. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  55473. */
  55474. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  55475. /**
  55476. * Defines if WebXR should be used instead of WebVR (if available)
  55477. */
  55478. useXR?: boolean;
  55479. }
  55480. /**
  55481. * Event containing information after VR has been entered
  55482. */
  55483. export class OnAfterEnteringVRObservableEvent {
  55484. /**
  55485. * If entering vr was successful
  55486. */
  55487. success: boolean;
  55488. }
  55489. /**
  55490. * Helps to quickly add VR support to an existing scene.
  55491. * See https://doc.babylonjs.com/how_to/webvr_helper
  55492. */
  55493. export class VRExperienceHelper {
  55494. /** Options to modify the vr experience helper's behavior. */
  55495. webVROptions: VRExperienceHelperOptions;
  55496. private _scene;
  55497. private _position;
  55498. private _btnVR;
  55499. private _btnVRDisplayed;
  55500. private _webVRsupported;
  55501. private _webVRready;
  55502. private _webVRrequesting;
  55503. private _webVRpresenting;
  55504. private _hasEnteredVR;
  55505. private _fullscreenVRpresenting;
  55506. private _inputElement;
  55507. private _webVRCamera;
  55508. private _vrDeviceOrientationCamera;
  55509. private _deviceOrientationCamera;
  55510. private _existingCamera;
  55511. private _onKeyDown;
  55512. private _onVrDisplayPresentChange;
  55513. private _onVRDisplayChanged;
  55514. private _onVRRequestPresentStart;
  55515. private _onVRRequestPresentComplete;
  55516. /**
  55517. * 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)
  55518. */
  55519. enableGazeEvenWhenNoPointerLock: boolean;
  55520. /**
  55521. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  55522. */
  55523. exitVROnDoubleTap: boolean;
  55524. /**
  55525. * Observable raised right before entering VR.
  55526. */
  55527. onEnteringVRObservable: Observable<VRExperienceHelper>;
  55528. /**
  55529. * Observable raised when entering VR has completed.
  55530. */
  55531. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  55532. /**
  55533. * Observable raised when exiting VR.
  55534. */
  55535. onExitingVRObservable: Observable<VRExperienceHelper>;
  55536. /**
  55537. * Observable raised when controller mesh is loaded.
  55538. */
  55539. onControllerMeshLoadedObservable: Observable<WebVRController>;
  55540. /** Return this.onEnteringVRObservable
  55541. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  55542. */
  55543. get onEnteringVR(): Observable<VRExperienceHelper>;
  55544. /** Return this.onExitingVRObservable
  55545. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  55546. */
  55547. get onExitingVR(): Observable<VRExperienceHelper>;
  55548. /** Return this.onControllerMeshLoadedObservable
  55549. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  55550. */
  55551. get onControllerMeshLoaded(): Observable<WebVRController>;
  55552. private _rayLength;
  55553. private _useCustomVRButton;
  55554. private _teleportationRequested;
  55555. private _teleportActive;
  55556. private _floorMeshName;
  55557. private _floorMeshesCollection;
  55558. private _teleportationMode;
  55559. private _teleportationTime;
  55560. private _teleportationSpeed;
  55561. private _teleportationEasing;
  55562. private _rotationAllowed;
  55563. private _teleportBackwardsVector;
  55564. private _teleportationTarget;
  55565. private _isDefaultTeleportationTarget;
  55566. private _postProcessMove;
  55567. private _teleportationFillColor;
  55568. private _teleportationBorderColor;
  55569. private _rotationAngle;
  55570. private _haloCenter;
  55571. private _cameraGazer;
  55572. private _padSensibilityUp;
  55573. private _padSensibilityDown;
  55574. private _leftController;
  55575. private _rightController;
  55576. private _gazeColor;
  55577. private _laserColor;
  55578. private _pickedLaserColor;
  55579. private _pickedGazeColor;
  55580. /**
  55581. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  55582. */
  55583. onNewMeshSelected: Observable<AbstractMesh>;
  55584. /**
  55585. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  55586. * This observable will provide the mesh and the controller used to select the mesh
  55587. */
  55588. onMeshSelectedWithController: Observable<{
  55589. mesh: AbstractMesh;
  55590. controller: WebVRController;
  55591. }>;
  55592. /**
  55593. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  55594. */
  55595. onNewMeshPicked: Observable<PickingInfo>;
  55596. private _circleEase;
  55597. /**
  55598. * Observable raised before camera teleportation
  55599. */
  55600. onBeforeCameraTeleport: Observable<Vector3>;
  55601. /**
  55602. * Observable raised after camera teleportation
  55603. */
  55604. onAfterCameraTeleport: Observable<Vector3>;
  55605. /**
  55606. * Observable raised when current selected mesh gets unselected
  55607. */
  55608. onSelectedMeshUnselected: Observable<AbstractMesh>;
  55609. private _raySelectionPredicate;
  55610. /**
  55611. * To be optionaly changed by user to define custom ray selection
  55612. */
  55613. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55614. /**
  55615. * To be optionaly changed by user to define custom selection logic (after ray selection)
  55616. */
  55617. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  55618. /**
  55619. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  55620. */
  55621. teleportationEnabled: boolean;
  55622. private _defaultHeight;
  55623. private _teleportationInitialized;
  55624. private _interactionsEnabled;
  55625. private _interactionsRequested;
  55626. private _displayGaze;
  55627. private _displayLaserPointer;
  55628. /**
  55629. * The mesh used to display where the user is going to teleport.
  55630. */
  55631. get teleportationTarget(): Mesh;
  55632. /**
  55633. * Sets the mesh to be used to display where the user is going to teleport.
  55634. */
  55635. set teleportationTarget(value: Mesh);
  55636. /**
  55637. * 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
  55638. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  55639. * See https://doc.babylonjs.com/resources/baking_transformations
  55640. */
  55641. get gazeTrackerMesh(): Mesh;
  55642. set gazeTrackerMesh(value: Mesh);
  55643. /**
  55644. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  55645. */
  55646. updateGazeTrackerScale: boolean;
  55647. /**
  55648. * If the gaze trackers color should be updated when selecting meshes
  55649. */
  55650. updateGazeTrackerColor: boolean;
  55651. /**
  55652. * If the controller laser color should be updated when selecting meshes
  55653. */
  55654. updateControllerLaserColor: boolean;
  55655. /**
  55656. * The gaze tracking mesh corresponding to the left controller
  55657. */
  55658. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  55659. /**
  55660. * The gaze tracking mesh corresponding to the right controller
  55661. */
  55662. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  55663. /**
  55664. * If the ray of the gaze should be displayed.
  55665. */
  55666. get displayGaze(): boolean;
  55667. /**
  55668. * Sets if the ray of the gaze should be displayed.
  55669. */
  55670. set displayGaze(value: boolean);
  55671. /**
  55672. * If the ray of the LaserPointer should be displayed.
  55673. */
  55674. get displayLaserPointer(): boolean;
  55675. /**
  55676. * Sets if the ray of the LaserPointer should be displayed.
  55677. */
  55678. set displayLaserPointer(value: boolean);
  55679. /**
  55680. * The deviceOrientationCamera used as the camera when not in VR.
  55681. */
  55682. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  55683. /**
  55684. * Based on the current WebVR support, returns the current VR camera used.
  55685. */
  55686. get currentVRCamera(): Nullable<Camera>;
  55687. /**
  55688. * The webVRCamera which is used when in VR.
  55689. */
  55690. get webVRCamera(): WebVRFreeCamera;
  55691. /**
  55692. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  55693. */
  55694. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  55695. /**
  55696. * The html button that is used to trigger entering into VR.
  55697. */
  55698. get vrButton(): Nullable<HTMLButtonElement>;
  55699. private get _teleportationRequestInitiated();
  55700. /**
  55701. * Defines whether or not Pointer lock should be requested when switching to
  55702. * full screen.
  55703. */
  55704. requestPointerLockOnFullScreen: boolean;
  55705. /**
  55706. * If asking to force XR, this will be populated with the default xr experience
  55707. */
  55708. xr: WebXRDefaultExperience;
  55709. /**
  55710. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  55711. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  55712. */
  55713. xrTestDone: boolean;
  55714. /**
  55715. * Instantiates a VRExperienceHelper.
  55716. * Helps to quickly add VR support to an existing scene.
  55717. * @param scene The scene the VRExperienceHelper belongs to.
  55718. * @param webVROptions Options to modify the vr experience helper's behavior.
  55719. */
  55720. constructor(scene: Scene,
  55721. /** Options to modify the vr experience helper's behavior. */
  55722. webVROptions?: VRExperienceHelperOptions);
  55723. private completeVRInit;
  55724. private _onDefaultMeshLoaded;
  55725. private _onResize;
  55726. private _onFullscreenChange;
  55727. /**
  55728. * Gets a value indicating if we are currently in VR mode.
  55729. */
  55730. get isInVRMode(): boolean;
  55731. private onVrDisplayPresentChange;
  55732. private onVRDisplayChanged;
  55733. private moveButtonToBottomRight;
  55734. private displayVRButton;
  55735. private updateButtonVisibility;
  55736. private _cachedAngularSensibility;
  55737. /**
  55738. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  55739. * Otherwise, will use the fullscreen API.
  55740. */
  55741. enterVR(): void;
  55742. /**
  55743. * Attempt to exit VR, or fullscreen.
  55744. */
  55745. exitVR(): void;
  55746. /**
  55747. * The position of the vr experience helper.
  55748. */
  55749. get position(): Vector3;
  55750. /**
  55751. * Sets the position of the vr experience helper.
  55752. */
  55753. set position(value: Vector3);
  55754. /**
  55755. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  55756. */
  55757. enableInteractions(): void;
  55758. private get _noControllerIsActive();
  55759. private beforeRender;
  55760. private _isTeleportationFloor;
  55761. /**
  55762. * Adds a floor mesh to be used for teleportation.
  55763. * @param floorMesh the mesh to be used for teleportation.
  55764. */
  55765. addFloorMesh(floorMesh: Mesh): void;
  55766. /**
  55767. * Removes a floor mesh from being used for teleportation.
  55768. * @param floorMesh the mesh to be removed.
  55769. */
  55770. removeFloorMesh(floorMesh: Mesh): void;
  55771. /**
  55772. * Enables interactions and teleportation using the VR controllers and gaze.
  55773. * @param vrTeleportationOptions options to modify teleportation behavior.
  55774. */
  55775. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  55776. private _onNewGamepadConnected;
  55777. private _tryEnableInteractionOnController;
  55778. private _onNewGamepadDisconnected;
  55779. private _enableInteractionOnController;
  55780. private _checkTeleportWithRay;
  55781. private _checkRotate;
  55782. private _checkTeleportBackwards;
  55783. private _enableTeleportationOnController;
  55784. private _createTeleportationCircles;
  55785. private _displayTeleportationTarget;
  55786. private _hideTeleportationTarget;
  55787. private _rotateCamera;
  55788. private _moveTeleportationSelectorTo;
  55789. private _workingVector;
  55790. private _workingQuaternion;
  55791. private _workingMatrix;
  55792. /**
  55793. * Time Constant Teleportation Mode
  55794. */
  55795. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  55796. /**
  55797. * Speed Constant Teleportation Mode
  55798. */
  55799. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  55800. /**
  55801. * Teleports the users feet to the desired location
  55802. * @param location The location where the user's feet should be placed
  55803. */
  55804. teleportCamera(location: Vector3): void;
  55805. private _convertNormalToDirectionOfRay;
  55806. private _castRayAndSelectObject;
  55807. private _notifySelectedMeshUnselected;
  55808. /**
  55809. * Permanently set new colors for the laser pointer
  55810. * @param color the new laser color
  55811. * @param pickedColor the new laser color when picked mesh detected
  55812. */
  55813. setLaserColor(color: Color3, pickedColor?: Color3): void;
  55814. /**
  55815. * Set lighting enabled / disabled on the laser pointer of both controllers
  55816. * @param enabled should the lighting be enabled on the laser pointer
  55817. */
  55818. setLaserLightingState(enabled?: boolean): void;
  55819. /**
  55820. * Permanently set new colors for the gaze pointer
  55821. * @param color the new gaze color
  55822. * @param pickedColor the new gaze color when picked mesh detected
  55823. */
  55824. setGazeColor(color: Color3, pickedColor?: Color3): void;
  55825. /**
  55826. * Sets the color of the laser ray from the vr controllers.
  55827. * @param color new color for the ray.
  55828. */
  55829. changeLaserColor(color: Color3): void;
  55830. /**
  55831. * Sets the color of the ray from the vr headsets gaze.
  55832. * @param color new color for the ray.
  55833. */
  55834. changeGazeColor(color: Color3): void;
  55835. /**
  55836. * Exits VR and disposes of the vr experience helper
  55837. */
  55838. dispose(): void;
  55839. /**
  55840. * Gets the name of the VRExperienceHelper class
  55841. * @returns "VRExperienceHelper"
  55842. */
  55843. getClassName(): string;
  55844. }
  55845. }
  55846. declare module "babylonjs/Cameras/VR/index" {
  55847. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  55848. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  55849. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55850. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  55851. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  55852. export * from "babylonjs/Cameras/VR/webVRCamera";
  55853. }
  55854. declare module "babylonjs/Cameras/RigModes/index" {
  55855. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  55856. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  55857. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  55858. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  55859. }
  55860. declare module "babylonjs/Cameras/index" {
  55861. export * from "babylonjs/Cameras/Inputs/index";
  55862. export * from "babylonjs/Cameras/cameraInputsManager";
  55863. export * from "babylonjs/Cameras/camera";
  55864. export * from "babylonjs/Cameras/targetCamera";
  55865. export * from "babylonjs/Cameras/freeCamera";
  55866. export * from "babylonjs/Cameras/freeCameraInputsManager";
  55867. export * from "babylonjs/Cameras/touchCamera";
  55868. export * from "babylonjs/Cameras/arcRotateCamera";
  55869. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  55870. export * from "babylonjs/Cameras/deviceOrientationCamera";
  55871. export * from "babylonjs/Cameras/flyCamera";
  55872. export * from "babylonjs/Cameras/flyCameraInputsManager";
  55873. export * from "babylonjs/Cameras/followCamera";
  55874. export * from "babylonjs/Cameras/followCameraInputsManager";
  55875. export * from "babylonjs/Cameras/gamepadCamera";
  55876. export * from "babylonjs/Cameras/Stereoscopic/index";
  55877. export * from "babylonjs/Cameras/universalCamera";
  55878. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  55879. export * from "babylonjs/Cameras/VR/index";
  55880. export * from "babylonjs/Cameras/RigModes/index";
  55881. }
  55882. declare module "babylonjs/Collisions/index" {
  55883. export * from "babylonjs/Collisions/collider";
  55884. export * from "babylonjs/Collisions/collisionCoordinator";
  55885. export * from "babylonjs/Collisions/pickingInfo";
  55886. export * from "babylonjs/Collisions/intersectionInfo";
  55887. export * from "babylonjs/Collisions/meshCollisionData";
  55888. }
  55889. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  55890. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  55891. import { Vector3 } from "babylonjs/Maths/math.vector";
  55892. import { Ray } from "babylonjs/Culling/ray";
  55893. import { Plane } from "babylonjs/Maths/math.plane";
  55894. /**
  55895. * Contains an array of blocks representing the octree
  55896. */
  55897. export interface IOctreeContainer<T> {
  55898. /**
  55899. * Blocks within the octree
  55900. */
  55901. blocks: Array<OctreeBlock<T>>;
  55902. }
  55903. /**
  55904. * Class used to store a cell in an octree
  55905. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55906. */
  55907. export class OctreeBlock<T> {
  55908. /**
  55909. * Gets the content of the current block
  55910. */
  55911. entries: T[];
  55912. /**
  55913. * Gets the list of block children
  55914. */
  55915. blocks: Array<OctreeBlock<T>>;
  55916. private _depth;
  55917. private _maxDepth;
  55918. private _capacity;
  55919. private _minPoint;
  55920. private _maxPoint;
  55921. private _boundingVectors;
  55922. private _creationFunc;
  55923. /**
  55924. * Creates a new block
  55925. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  55926. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  55927. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55928. * @param depth defines the current depth of this block in the octree
  55929. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  55930. * @param creationFunc defines a callback to call when an element is added to the block
  55931. */
  55932. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  55933. /**
  55934. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55935. */
  55936. get capacity(): number;
  55937. /**
  55938. * Gets the minimum vector (in world space) of the block's bounding box
  55939. */
  55940. get minPoint(): Vector3;
  55941. /**
  55942. * Gets the maximum vector (in world space) of the block's bounding box
  55943. */
  55944. get maxPoint(): Vector3;
  55945. /**
  55946. * Add a new element to this block
  55947. * @param entry defines the element to add
  55948. */
  55949. addEntry(entry: T): void;
  55950. /**
  55951. * Remove an element from this block
  55952. * @param entry defines the element to remove
  55953. */
  55954. removeEntry(entry: T): void;
  55955. /**
  55956. * Add an array of elements to this block
  55957. * @param entries defines the array of elements to add
  55958. */
  55959. addEntries(entries: T[]): void;
  55960. /**
  55961. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  55962. * @param frustumPlanes defines the frustum planes to test
  55963. * @param selection defines the array to store current content if selection is positive
  55964. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55965. */
  55966. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55967. /**
  55968. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  55969. * @param sphereCenter defines the bounding sphere center
  55970. * @param sphereRadius defines the bounding sphere radius
  55971. * @param selection defines the array to store current content if selection is positive
  55972. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55973. */
  55974. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55975. /**
  55976. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  55977. * @param ray defines the ray to test with
  55978. * @param selection defines the array to store current content if selection is positive
  55979. */
  55980. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  55981. /**
  55982. * Subdivide the content into child blocks (this block will then be empty)
  55983. */
  55984. createInnerBlocks(): void;
  55985. /**
  55986. * @hidden
  55987. */
  55988. 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;
  55989. }
  55990. }
  55991. declare module "babylonjs/Culling/Octrees/octree" {
  55992. import { SmartArray } from "babylonjs/Misc/smartArray";
  55993. import { Vector3 } from "babylonjs/Maths/math.vector";
  55994. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55996. import { Ray } from "babylonjs/Culling/ray";
  55997. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  55998. import { Plane } from "babylonjs/Maths/math.plane";
  55999. /**
  56000. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  56001. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56002. */
  56003. export class Octree<T> {
  56004. /** 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.) */
  56005. maxDepth: number;
  56006. /**
  56007. * Blocks within the octree containing objects
  56008. */
  56009. blocks: Array<OctreeBlock<T>>;
  56010. /**
  56011. * Content stored in the octree
  56012. */
  56013. dynamicContent: T[];
  56014. private _maxBlockCapacity;
  56015. private _selectionContent;
  56016. private _creationFunc;
  56017. /**
  56018. * Creates a octree
  56019. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56020. * @param creationFunc function to be used to instatiate the octree
  56021. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  56022. * @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.)
  56023. */
  56024. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  56025. /** 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.) */
  56026. maxDepth?: number);
  56027. /**
  56028. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  56029. * @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);
  56030. * @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);
  56031. * @param entries meshes to be added to the octree blocks
  56032. */
  56033. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  56034. /**
  56035. * Adds a mesh to the octree
  56036. * @param entry Mesh to add to the octree
  56037. */
  56038. addMesh(entry: T): void;
  56039. /**
  56040. * Remove an element from the octree
  56041. * @param entry defines the element to remove
  56042. */
  56043. removeMesh(entry: T): void;
  56044. /**
  56045. * Selects an array of meshes within the frustum
  56046. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  56047. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  56048. * @returns array of meshes within the frustum
  56049. */
  56050. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  56051. /**
  56052. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  56053. * @param sphereCenter defines the bounding sphere center
  56054. * @param sphereRadius defines the bounding sphere radius
  56055. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56056. * @returns an array of objects that intersect the sphere
  56057. */
  56058. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  56059. /**
  56060. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  56061. * @param ray defines the ray to test with
  56062. * @returns array of intersected objects
  56063. */
  56064. intersectsRay(ray: Ray): SmartArray<T>;
  56065. /**
  56066. * Adds a mesh into the octree block if it intersects the block
  56067. */
  56068. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  56069. /**
  56070. * Adds a submesh into the octree block if it intersects the block
  56071. */
  56072. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  56073. }
  56074. }
  56075. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  56076. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  56077. import { Scene } from "babylonjs/scene";
  56078. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56080. import { Ray } from "babylonjs/Culling/ray";
  56081. import { Octree } from "babylonjs/Culling/Octrees/octree";
  56082. import { Collider } from "babylonjs/Collisions/collider";
  56083. module "babylonjs/scene" {
  56084. interface Scene {
  56085. /**
  56086. * @hidden
  56087. * Backing Filed
  56088. */
  56089. _selectionOctree: Octree<AbstractMesh>;
  56090. /**
  56091. * Gets the octree used to boost mesh selection (picking)
  56092. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56093. */
  56094. selectionOctree: Octree<AbstractMesh>;
  56095. /**
  56096. * Creates or updates the octree used to boost selection (picking)
  56097. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56098. * @param maxCapacity defines the maximum capacity per leaf
  56099. * @param maxDepth defines the maximum depth of the octree
  56100. * @returns an octree of AbstractMesh
  56101. */
  56102. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  56103. }
  56104. }
  56105. module "babylonjs/Meshes/abstractMesh" {
  56106. interface AbstractMesh {
  56107. /**
  56108. * @hidden
  56109. * Backing Field
  56110. */
  56111. _submeshesOctree: Octree<SubMesh>;
  56112. /**
  56113. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  56114. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  56115. * @param maxCapacity defines the maximum size of each block (64 by default)
  56116. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  56117. * @returns the new octree
  56118. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  56119. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56120. */
  56121. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  56122. }
  56123. }
  56124. /**
  56125. * Defines the octree scene component responsible to manage any octrees
  56126. * in a given scene.
  56127. */
  56128. export class OctreeSceneComponent {
  56129. /**
  56130. * The component name help to identify the component in the list of scene components.
  56131. */
  56132. readonly name: string;
  56133. /**
  56134. * The scene the component belongs to.
  56135. */
  56136. scene: Scene;
  56137. /**
  56138. * Indicates if the meshes have been checked to make sure they are isEnabled()
  56139. */
  56140. readonly checksIsEnabled: boolean;
  56141. /**
  56142. * Creates a new instance of the component for the given scene
  56143. * @param scene Defines the scene to register the component in
  56144. */
  56145. constructor(scene: Scene);
  56146. /**
  56147. * Registers the component in a given scene
  56148. */
  56149. register(): void;
  56150. /**
  56151. * Return the list of active meshes
  56152. * @returns the list of active meshes
  56153. */
  56154. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  56155. /**
  56156. * Return the list of active sub meshes
  56157. * @param mesh The mesh to get the candidates sub meshes from
  56158. * @returns the list of active sub meshes
  56159. */
  56160. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  56161. private _tempRay;
  56162. /**
  56163. * Return the list of sub meshes intersecting with a given local ray
  56164. * @param mesh defines the mesh to find the submesh for
  56165. * @param localRay defines the ray in local space
  56166. * @returns the list of intersecting sub meshes
  56167. */
  56168. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  56169. /**
  56170. * Return the list of sub meshes colliding with a collider
  56171. * @param mesh defines the mesh to find the submesh for
  56172. * @param collider defines the collider to evaluate the collision against
  56173. * @returns the list of colliding sub meshes
  56174. */
  56175. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  56176. /**
  56177. * Rebuilds the elements related to this component in case of
  56178. * context lost for instance.
  56179. */
  56180. rebuild(): void;
  56181. /**
  56182. * Disposes the component and the associated ressources.
  56183. */
  56184. dispose(): void;
  56185. }
  56186. }
  56187. declare module "babylonjs/Culling/Octrees/index" {
  56188. export * from "babylonjs/Culling/Octrees/octree";
  56189. export * from "babylonjs/Culling/Octrees/octreeBlock";
  56190. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  56191. }
  56192. declare module "babylonjs/Culling/index" {
  56193. export * from "babylonjs/Culling/boundingBox";
  56194. export * from "babylonjs/Culling/boundingInfo";
  56195. export * from "babylonjs/Culling/boundingSphere";
  56196. export * from "babylonjs/Culling/Octrees/index";
  56197. export * from "babylonjs/Culling/ray";
  56198. }
  56199. declare module "babylonjs/Gizmos/gizmo" {
  56200. import { Observer } from "babylonjs/Misc/observable";
  56201. import { Nullable } from "babylonjs/types";
  56202. import { IDisposable } from "babylonjs/scene";
  56203. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56204. import { Mesh } from "babylonjs/Meshes/mesh";
  56205. import { Node } from "babylonjs/node";
  56206. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56207. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56208. import { PointerInfo } from "babylonjs/Events/pointerEvents";
  56209. /**
  56210. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  56211. */
  56212. export interface GizmoAxisCache {
  56213. /** Mesh used to runder the Gizmo */
  56214. gizmoMeshes: Mesh[];
  56215. /** Mesh used to detect user interaction with Gizmo */
  56216. colliderMeshes: Mesh[];
  56217. /** Material used to inicate color of gizmo mesh */
  56218. material: StandardMaterial;
  56219. /** Material used to inicate hover state of the Gizmo */
  56220. hoverMaterial: StandardMaterial;
  56221. /** Material used to inicate disabled state of the Gizmo */
  56222. disableMaterial: StandardMaterial;
  56223. /** Used to indicate Active state of the Gizmo */
  56224. active: boolean;
  56225. }
  56226. /**
  56227. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  56228. */
  56229. export class Gizmo implements IDisposable {
  56230. /** The utility layer the gizmo will be added to */
  56231. gizmoLayer: UtilityLayerRenderer;
  56232. /**
  56233. * The root mesh of the gizmo
  56234. */
  56235. _rootMesh: Mesh;
  56236. private _attachedMesh;
  56237. private _attachedNode;
  56238. /**
  56239. * Ratio for the scale of the gizmo (Default: 1)
  56240. */
  56241. protected _scaleRatio: number;
  56242. /**
  56243. * boolean updated by pointermove when a gizmo mesh is hovered
  56244. */
  56245. protected _isHovered: boolean;
  56246. /**
  56247. * Ratio for the scale of the gizmo (Default: 1)
  56248. */
  56249. set scaleRatio(value: number);
  56250. get scaleRatio(): number;
  56251. /**
  56252. * True when the mouse pointer is hovered a gizmo mesh
  56253. */
  56254. get isHovered(): boolean;
  56255. /**
  56256. * If a custom mesh has been set (Default: false)
  56257. */
  56258. protected _customMeshSet: boolean;
  56259. /**
  56260. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  56261. * * When set, interactions will be enabled
  56262. */
  56263. get attachedMesh(): Nullable<AbstractMesh>;
  56264. set attachedMesh(value: Nullable<AbstractMesh>);
  56265. /**
  56266. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  56267. * * When set, interactions will be enabled
  56268. */
  56269. get attachedNode(): Nullable<Node>;
  56270. set attachedNode(value: Nullable<Node>);
  56271. /**
  56272. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56273. * @param mesh The mesh to replace the default mesh of the gizmo
  56274. */
  56275. setCustomMesh(mesh: Mesh): void;
  56276. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  56277. /**
  56278. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  56279. */
  56280. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56281. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56282. /**
  56283. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  56284. */
  56285. updateGizmoPositionToMatchAttachedMesh: boolean;
  56286. /**
  56287. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  56288. */
  56289. updateScale: boolean;
  56290. protected _interactionsEnabled: boolean;
  56291. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56292. private _beforeRenderObserver;
  56293. private _tempQuaternion;
  56294. private _tempVector;
  56295. private _tempVector2;
  56296. private _tempMatrix1;
  56297. private _tempMatrix2;
  56298. private _rightHandtoLeftHandMatrix;
  56299. /**
  56300. * Creates a gizmo
  56301. * @param gizmoLayer The utility layer the gizmo will be added to
  56302. */
  56303. constructor(
  56304. /** The utility layer the gizmo will be added to */
  56305. gizmoLayer?: UtilityLayerRenderer);
  56306. /**
  56307. * Updates the gizmo to match the attached mesh's position/rotation
  56308. */
  56309. protected _update(): void;
  56310. /**
  56311. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  56312. * @param value Node, TransformNode or mesh
  56313. */
  56314. protected _matrixChanged(): void;
  56315. /**
  56316. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  56317. * @param gizmoLayer The utility layer the gizmo will be added to
  56318. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  56319. * @returns {Observer<PointerInfo>} pointerObserver
  56320. */
  56321. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  56322. /**
  56323. * Disposes of the gizmo
  56324. */
  56325. dispose(): void;
  56326. }
  56327. }
  56328. declare module "babylonjs/Gizmos/planeDragGizmo" {
  56329. import { Observable } from "babylonjs/Misc/observable";
  56330. import { Nullable } from "babylonjs/types";
  56331. import { Vector3 } from "babylonjs/Maths/math.vector";
  56332. import { Color3 } from "babylonjs/Maths/math.color";
  56333. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56334. import { Node } from "babylonjs/node";
  56335. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56336. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56337. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56338. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56339. import { Scene } from "babylonjs/scene";
  56340. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56341. /**
  56342. * Single plane drag gizmo
  56343. */
  56344. export class PlaneDragGizmo extends Gizmo {
  56345. /**
  56346. * Drag behavior responsible for the gizmos dragging interactions
  56347. */
  56348. dragBehavior: PointerDragBehavior;
  56349. private _pointerObserver;
  56350. /**
  56351. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56352. */
  56353. snapDistance: number;
  56354. /**
  56355. * Event that fires each time the gizmo snaps to a new location.
  56356. * * snapDistance is the the change in distance
  56357. */
  56358. onSnapObservable: Observable<{
  56359. snapDistance: number;
  56360. }>;
  56361. private _gizmoMesh;
  56362. private _coloredMaterial;
  56363. private _hoverMaterial;
  56364. private _disableMaterial;
  56365. private _isEnabled;
  56366. private _parent;
  56367. private _dragging;
  56368. /** @hidden */
  56369. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  56370. /**
  56371. * Creates a PlaneDragGizmo
  56372. * @param gizmoLayer The utility layer the gizmo will be added to
  56373. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  56374. * @param color The color of the gizmo
  56375. */
  56376. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  56377. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56378. /**
  56379. * If the gizmo is enabled
  56380. */
  56381. set isEnabled(value: boolean);
  56382. get isEnabled(): boolean;
  56383. /**
  56384. * Disposes of the gizmo
  56385. */
  56386. dispose(): void;
  56387. }
  56388. }
  56389. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  56390. import { Observable } from "babylonjs/Misc/observable";
  56391. import { Nullable } from "babylonjs/types";
  56392. import { Vector3 } from "babylonjs/Maths/math.vector";
  56393. import { Color3 } from "babylonjs/Maths/math.color";
  56394. import "babylonjs/Meshes/Builders/linesBuilder";
  56395. import { Node } from "babylonjs/node";
  56396. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56397. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56398. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56399. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56400. /**
  56401. * Single plane rotation gizmo
  56402. */
  56403. export class PlaneRotationGizmo extends Gizmo {
  56404. /**
  56405. * Drag behavior responsible for the gizmos dragging interactions
  56406. */
  56407. dragBehavior: PointerDragBehavior;
  56408. private _pointerObserver;
  56409. /**
  56410. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56411. */
  56412. snapDistance: number;
  56413. /**
  56414. * Event that fires each time the gizmo snaps to a new location.
  56415. * * snapDistance is the the change in distance
  56416. */
  56417. onSnapObservable: Observable<{
  56418. snapDistance: number;
  56419. }>;
  56420. private _isEnabled;
  56421. private _parent;
  56422. private _coloredMaterial;
  56423. private _hoverMaterial;
  56424. private _disableMaterial;
  56425. private _gizmoMesh;
  56426. private _rotationCircle;
  56427. private _dragging;
  56428. private static _CircleConstants;
  56429. /**
  56430. * Creates a PlaneRotationGizmo
  56431. * @param gizmoLayer The utility layer the gizmo will be added to
  56432. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56433. * @param color The color of the gizmo
  56434. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56435. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56436. * @param thickness display gizmo axis thickness
  56437. */
  56438. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56439. /** Create Geometry for Gizmo */
  56440. private _createGizmoMesh;
  56441. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56442. private setupRotationCircle;
  56443. private updateRotationPath;
  56444. private updateRotationCircle;
  56445. /**
  56446. * If the gizmo is enabled
  56447. */
  56448. set isEnabled(value: boolean);
  56449. get isEnabled(): boolean;
  56450. /**
  56451. * Disposes of the gizmo
  56452. */
  56453. dispose(): void;
  56454. }
  56455. }
  56456. declare module "babylonjs/Gizmos/rotationGizmo" {
  56457. import { Observable } from "babylonjs/Misc/observable";
  56458. import { Nullable } from "babylonjs/types";
  56459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56460. import { Mesh } from "babylonjs/Meshes/mesh";
  56461. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  56462. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  56463. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56464. import { Node } from "babylonjs/node";
  56465. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  56466. /**
  56467. * Gizmo that enables rotating a mesh along 3 axis
  56468. */
  56469. export class RotationGizmo extends Gizmo {
  56470. /**
  56471. * Internal gizmo used for interactions on the x axis
  56472. */
  56473. xGizmo: PlaneRotationGizmo;
  56474. /**
  56475. * Internal gizmo used for interactions on the y axis
  56476. */
  56477. yGizmo: PlaneRotationGizmo;
  56478. /**
  56479. * Internal gizmo used for interactions on the z axis
  56480. */
  56481. zGizmo: PlaneRotationGizmo;
  56482. /** Fires an event when any of it's sub gizmos are dragged */
  56483. onDragStartObservable: Observable<unknown>;
  56484. /** Fires an event when any of it's sub gizmos are released from dragging */
  56485. onDragEndObservable: Observable<unknown>;
  56486. private _meshAttached;
  56487. private _nodeAttached;
  56488. private _observables;
  56489. /** Node Caching for quick lookup */
  56490. private _gizmoAxisCache;
  56491. get attachedMesh(): Nullable<AbstractMesh>;
  56492. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56493. get attachedNode(): Nullable<Node>;
  56494. set attachedNode(node: Nullable<Node>);
  56495. protected _checkBillboardTransform(): void;
  56496. /**
  56497. * True when the mouse pointer is hovering a gizmo mesh
  56498. */
  56499. get isHovered(): boolean;
  56500. /**
  56501. * Creates a RotationGizmo
  56502. * @param gizmoLayer The utility layer the gizmo will be added to
  56503. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56504. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56505. * @param thickness display gizmo axis thickness
  56506. */
  56507. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  56508. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56509. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56510. /**
  56511. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56512. */
  56513. set snapDistance(value: number);
  56514. get snapDistance(): number;
  56515. /**
  56516. * Ratio for the scale of the gizmo (Default: 1)
  56517. */
  56518. set scaleRatio(value: number);
  56519. get scaleRatio(): number;
  56520. /**
  56521. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  56522. * @param mesh Axis gizmo mesh
  56523. * @param cache Gizmo axis definition used for reactive gizmo UI
  56524. */
  56525. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  56526. /**
  56527. * Disposes of the gizmo
  56528. */
  56529. dispose(): void;
  56530. /**
  56531. * CustomMeshes are not supported by this gizmo
  56532. * @param mesh The mesh to replace the default mesh of the gizmo
  56533. */
  56534. setCustomMesh(mesh: Mesh): void;
  56535. }
  56536. }
  56537. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  56538. import { Scene } from "babylonjs/scene";
  56539. import { Vector4 } from "babylonjs/Maths/math.vector";
  56540. import { Color4 } from "babylonjs/Maths/math.color";
  56541. import { Mesh } from "babylonjs/Meshes/mesh";
  56542. import { Nullable } from "babylonjs/types";
  56543. /**
  56544. * Class containing static functions to help procedurally build meshes
  56545. */
  56546. export class PolyhedronBuilder {
  56547. /**
  56548. * Creates a polyhedron mesh
  56549. * * 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
  56550. * * The parameter `size` (positive float, default 1) sets the polygon size
  56551. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56552. * * 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`
  56553. * * 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
  56554. * * 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)`)
  56555. * * 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
  56556. * * 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
  56557. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56558. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56560. * @param name defines the name of the mesh
  56561. * @param options defines the options used to create the mesh
  56562. * @param scene defines the hosting scene
  56563. * @returns the polyhedron mesh
  56564. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56565. */
  56566. static CreatePolyhedron(name: string, options: {
  56567. type?: number;
  56568. size?: number;
  56569. sizeX?: number;
  56570. sizeY?: number;
  56571. sizeZ?: number;
  56572. custom?: any;
  56573. faceUV?: Vector4[];
  56574. faceColors?: Color4[];
  56575. flat?: boolean;
  56576. updatable?: boolean;
  56577. sideOrientation?: number;
  56578. frontUVs?: Vector4;
  56579. backUVs?: Vector4;
  56580. }, scene?: Nullable<Scene>): Mesh;
  56581. }
  56582. }
  56583. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  56584. import { Nullable } from "babylonjs/types";
  56585. import { Scene } from "babylonjs/scene";
  56586. import { Vector4 } from "babylonjs/Maths/math.vector";
  56587. import { Color4 } from "babylonjs/Maths/math.color";
  56588. import { Mesh } from "babylonjs/Meshes/mesh";
  56589. /**
  56590. * Class containing static functions to help procedurally build meshes
  56591. */
  56592. export class BoxBuilder {
  56593. /**
  56594. * Creates a box mesh
  56595. * * The parameter `size` sets the size (float) of each box side (default 1)
  56596. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56597. * * 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)
  56598. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56600. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56602. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56603. * @param name defines the name of the mesh
  56604. * @param options defines the options used to create the mesh
  56605. * @param scene defines the hosting scene
  56606. * @returns the box mesh
  56607. */
  56608. static CreateBox(name: string, options: {
  56609. size?: number;
  56610. width?: number;
  56611. height?: number;
  56612. depth?: number;
  56613. faceUV?: Vector4[];
  56614. faceColors?: Color4[];
  56615. sideOrientation?: number;
  56616. frontUVs?: Vector4;
  56617. backUVs?: Vector4;
  56618. wrap?: boolean;
  56619. topBaseAt?: number;
  56620. bottomBaseAt?: number;
  56621. updatable?: boolean;
  56622. }, scene?: Nullable<Scene>): Mesh;
  56623. }
  56624. }
  56625. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  56626. import { Observable } from "babylonjs/Misc/observable";
  56627. import { Nullable } from "babylonjs/types";
  56628. import { Vector3 } from "babylonjs/Maths/math.vector";
  56629. import { Node } from "babylonjs/node";
  56630. import { Mesh } from "babylonjs/Meshes/mesh";
  56631. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56632. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56633. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56634. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56635. import { Color3 } from "babylonjs/Maths/math.color";
  56636. /**
  56637. * Single axis scale gizmo
  56638. */
  56639. export class AxisScaleGizmo extends Gizmo {
  56640. /**
  56641. * Drag behavior responsible for the gizmos dragging interactions
  56642. */
  56643. dragBehavior: PointerDragBehavior;
  56644. private _pointerObserver;
  56645. /**
  56646. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56647. */
  56648. snapDistance: number;
  56649. /**
  56650. * Event that fires each time the gizmo snaps to a new location.
  56651. * * snapDistance is the the change in distance
  56652. */
  56653. onSnapObservable: Observable<{
  56654. snapDistance: number;
  56655. }>;
  56656. /**
  56657. * If the scaling operation should be done on all axis (default: false)
  56658. */
  56659. uniformScaling: boolean;
  56660. /**
  56661. * Custom sensitivity value for the drag strength
  56662. */
  56663. sensitivity: number;
  56664. private _isEnabled;
  56665. private _parent;
  56666. private _gizmoMesh;
  56667. private _coloredMaterial;
  56668. private _hoverMaterial;
  56669. private _disableMaterial;
  56670. private _dragging;
  56671. /**
  56672. * Creates an AxisScaleGizmo
  56673. * @param gizmoLayer The utility layer the gizmo will be added to
  56674. * @param dragAxis The axis which the gizmo will be able to scale on
  56675. * @param color The color of the gizmo
  56676. * @param thickness display gizmo axis thickness
  56677. */
  56678. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56679. /** Create Geometry for Gizmo */
  56680. private _createGizmoMesh;
  56681. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56682. /**
  56683. * If the gizmo is enabled
  56684. */
  56685. set isEnabled(value: boolean);
  56686. get isEnabled(): boolean;
  56687. /**
  56688. * Disposes of the gizmo
  56689. */
  56690. dispose(): void;
  56691. /**
  56692. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56693. * @param mesh The mesh to replace the default mesh of the gizmo
  56694. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56695. */
  56696. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56697. }
  56698. }
  56699. declare module "babylonjs/Gizmos/scaleGizmo" {
  56700. import { Observable } from "babylonjs/Misc/observable";
  56701. import { Nullable } from "babylonjs/types";
  56702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56703. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  56704. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  56705. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56706. import { Mesh } from "babylonjs/Meshes/mesh";
  56707. import { Node } from "babylonjs/node";
  56708. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  56709. /**
  56710. * Gizmo that enables scaling a mesh along 3 axis
  56711. */
  56712. export class ScaleGizmo extends Gizmo {
  56713. /**
  56714. * Internal gizmo used for interactions on the x axis
  56715. */
  56716. xGizmo: AxisScaleGizmo;
  56717. /**
  56718. * Internal gizmo used for interactions on the y axis
  56719. */
  56720. yGizmo: AxisScaleGizmo;
  56721. /**
  56722. * Internal gizmo used for interactions on the z axis
  56723. */
  56724. zGizmo: AxisScaleGizmo;
  56725. /**
  56726. * Internal gizmo used to scale all axis equally
  56727. */
  56728. uniformScaleGizmo: AxisScaleGizmo;
  56729. private _meshAttached;
  56730. private _nodeAttached;
  56731. private _snapDistance;
  56732. private _uniformScalingMesh;
  56733. private _octahedron;
  56734. private _sensitivity;
  56735. private _coloredMaterial;
  56736. private _hoverMaterial;
  56737. private _disableMaterial;
  56738. private _observables;
  56739. /** Node Caching for quick lookup */
  56740. private _gizmoAxisCache;
  56741. /** Fires an event when any of it's sub gizmos are dragged */
  56742. onDragStartObservable: Observable<unknown>;
  56743. /** Fires an event when any of it's sub gizmos are released from dragging */
  56744. onDragEndObservable: Observable<unknown>;
  56745. get attachedMesh(): Nullable<AbstractMesh>;
  56746. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56747. get attachedNode(): Nullable<Node>;
  56748. set attachedNode(node: Nullable<Node>);
  56749. /**
  56750. * True when the mouse pointer is hovering a gizmo mesh
  56751. */
  56752. get isHovered(): boolean;
  56753. /**
  56754. * Creates a ScaleGizmo
  56755. * @param gizmoLayer The utility layer the gizmo will be added to
  56756. * @param thickness display gizmo axis thickness
  56757. */
  56758. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  56759. /** Create Geometry for Gizmo */
  56760. private _createUniformScaleMesh;
  56761. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56762. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56763. /**
  56764. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56765. */
  56766. set snapDistance(value: number);
  56767. get snapDistance(): number;
  56768. /**
  56769. * Ratio for the scale of the gizmo (Default: 1)
  56770. */
  56771. set scaleRatio(value: number);
  56772. get scaleRatio(): number;
  56773. /**
  56774. * Sensitivity factor for dragging (Default: 1)
  56775. */
  56776. set sensitivity(value: number);
  56777. get sensitivity(): number;
  56778. /**
  56779. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  56780. * @param mesh Axis gizmo mesh
  56781. * @param cache Gizmo axis definition used for reactive gizmo UI
  56782. */
  56783. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  56784. /**
  56785. * Disposes of the gizmo
  56786. */
  56787. dispose(): void;
  56788. }
  56789. }
  56790. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  56791. import { Observable } from "babylonjs/Misc/observable";
  56792. import { Nullable } from "babylonjs/types";
  56793. import { Vector3 } from "babylonjs/Maths/math.vector";
  56794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56795. import { Mesh } from "babylonjs/Meshes/mesh";
  56796. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56797. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56798. import { Color3 } from "babylonjs/Maths/math.color";
  56799. import "babylonjs/Meshes/Builders/boxBuilder";
  56800. /**
  56801. * Bounding box gizmo
  56802. */
  56803. export class BoundingBoxGizmo extends Gizmo {
  56804. private _lineBoundingBox;
  56805. private _rotateSpheresParent;
  56806. private _scaleBoxesParent;
  56807. private _boundingDimensions;
  56808. private _renderObserver;
  56809. private _pointerObserver;
  56810. private _scaleDragSpeed;
  56811. private _tmpQuaternion;
  56812. private _tmpVector;
  56813. private _tmpRotationMatrix;
  56814. /**
  56815. * 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)
  56816. */
  56817. ignoreChildren: boolean;
  56818. /**
  56819. * 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)
  56820. */
  56821. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56822. /**
  56823. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56824. */
  56825. rotationSphereSize: number;
  56826. /**
  56827. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56828. */
  56829. scaleBoxSize: number;
  56830. /**
  56831. * 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)
  56832. */
  56833. fixedDragMeshScreenSize: boolean;
  56834. /**
  56835. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56836. */
  56837. fixedDragMeshScreenSizeDistanceFactor: number;
  56838. /**
  56839. * Fired when a rotation sphere or scale box is dragged
  56840. */
  56841. onDragStartObservable: Observable<{}>;
  56842. /**
  56843. * Fired when a scale box is dragged
  56844. */
  56845. onScaleBoxDragObservable: Observable<{}>;
  56846. /**
  56847. * Fired when a scale box drag is ended
  56848. */
  56849. onScaleBoxDragEndObservable: Observable<{}>;
  56850. /**
  56851. * Fired when a rotation sphere is dragged
  56852. */
  56853. onRotationSphereDragObservable: Observable<{}>;
  56854. /**
  56855. * Fired when a rotation sphere drag is ended
  56856. */
  56857. onRotationSphereDragEndObservable: Observable<{}>;
  56858. /**
  56859. * 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)
  56860. */
  56861. scalePivot: Nullable<Vector3>;
  56862. /**
  56863. * Mesh used as a pivot to rotate the attached node
  56864. */
  56865. private _anchorMesh;
  56866. private _existingMeshScale;
  56867. private _dragMesh;
  56868. private pointerDragBehavior;
  56869. private coloredMaterial;
  56870. private hoverColoredMaterial;
  56871. /**
  56872. * Sets the color of the bounding box gizmo
  56873. * @param color the color to set
  56874. */
  56875. setColor(color: Color3): void;
  56876. /**
  56877. * Creates an BoundingBoxGizmo
  56878. * @param gizmoLayer The utility layer the gizmo will be added to
  56879. * @param color The color of the gizmo
  56880. */
  56881. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56882. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  56883. private _selectNode;
  56884. /**
  56885. * Updates the bounding box information for the Gizmo
  56886. */
  56887. updateBoundingBox(): void;
  56888. private _updateRotationSpheres;
  56889. private _updateScaleBoxes;
  56890. /**
  56891. * Enables rotation on the specified axis and disables rotation on the others
  56892. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  56893. */
  56894. setEnabledRotationAxis(axis: string): void;
  56895. /**
  56896. * Enables/disables scaling
  56897. * @param enable if scaling should be enabled
  56898. * @param homogeneousScaling defines if scaling should only be homogeneous
  56899. */
  56900. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  56901. private _updateDummy;
  56902. /**
  56903. * Enables a pointer drag behavior on the bounding box of the gizmo
  56904. */
  56905. enableDragBehavior(): void;
  56906. /**
  56907. * Disposes of the gizmo
  56908. */
  56909. dispose(): void;
  56910. /**
  56911. * 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)
  56912. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  56913. * @returns the bounding box mesh with the passed in mesh as a child
  56914. */
  56915. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  56916. /**
  56917. * CustomMeshes are not supported by this gizmo
  56918. * @param mesh The mesh to replace the default mesh of the gizmo
  56919. */
  56920. setCustomMesh(mesh: Mesh): void;
  56921. }
  56922. }
  56923. declare module "babylonjs/Gizmos/gizmoManager" {
  56924. import { Observable } from "babylonjs/Misc/observable";
  56925. import { Nullable } from "babylonjs/types";
  56926. import { Scene, IDisposable } from "babylonjs/scene";
  56927. import { Node } from "babylonjs/node";
  56928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56929. import { Mesh } from "babylonjs/Meshes/mesh";
  56930. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56931. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  56932. import { GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  56933. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56934. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56935. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56936. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  56937. /**
  56938. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56939. */
  56940. export class GizmoManager implements IDisposable {
  56941. private scene;
  56942. /**
  56943. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56944. */
  56945. gizmos: {
  56946. positionGizmo: Nullable<PositionGizmo>;
  56947. rotationGizmo: Nullable<RotationGizmo>;
  56948. scaleGizmo: Nullable<ScaleGizmo>;
  56949. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56950. };
  56951. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56952. clearGizmoOnEmptyPointerEvent: boolean;
  56953. /** Fires an event when the manager is attached to a mesh */
  56954. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56955. /** Fires an event when the manager is attached to a node */
  56956. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56957. private _gizmosEnabled;
  56958. private _pointerObservers;
  56959. private _attachedMesh;
  56960. private _attachedNode;
  56961. private _boundingBoxColor;
  56962. private _defaultUtilityLayer;
  56963. private _defaultKeepDepthUtilityLayer;
  56964. private _thickness;
  56965. /** Node Caching for quick lookup */
  56966. private _gizmoAxisCache;
  56967. /**
  56968. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56969. */
  56970. boundingBoxDragBehavior: SixDofDragBehavior;
  56971. /**
  56972. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56973. */
  56974. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56975. /**
  56976. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56977. */
  56978. attachableNodes: Nullable<Array<Node>>;
  56979. /**
  56980. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56981. */
  56982. usePointerToAttachGizmos: boolean;
  56983. /**
  56984. * Utility layer that the bounding box gizmo belongs to
  56985. */
  56986. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56987. /**
  56988. * Utility layer that all gizmos besides bounding box belong to
  56989. */
  56990. get utilityLayer(): UtilityLayerRenderer;
  56991. /**
  56992. * True when the mouse pointer is hovering a gizmo mesh
  56993. */
  56994. get isHovered(): boolean;
  56995. /**
  56996. * Instatiates a gizmo manager
  56997. * @param scene the scene to overlay the gizmos on top of
  56998. * @param thickness display gizmo axis thickness
  56999. * @param utilityLayer the layer where gizmos are rendered
  57000. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  57001. */
  57002. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  57003. /**
  57004. * Subscribes to pointer down events, for attaching and detaching mesh
  57005. * @param scene The sceme layer the observer will be added to
  57006. */
  57007. private _attachToMeshPointerObserver;
  57008. /**
  57009. * Attaches a set of gizmos to the specified mesh
  57010. * @param mesh The mesh the gizmo's should be attached to
  57011. */
  57012. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57013. /**
  57014. * Attaches a set of gizmos to the specified node
  57015. * @param node The node the gizmo's should be attached to
  57016. */
  57017. attachToNode(node: Nullable<Node>): void;
  57018. /**
  57019. * If the position gizmo is enabled
  57020. */
  57021. set positionGizmoEnabled(value: boolean);
  57022. get positionGizmoEnabled(): boolean;
  57023. /**
  57024. * If the rotation gizmo is enabled
  57025. */
  57026. set rotationGizmoEnabled(value: boolean);
  57027. get rotationGizmoEnabled(): boolean;
  57028. /**
  57029. * If the scale gizmo is enabled
  57030. */
  57031. set scaleGizmoEnabled(value: boolean);
  57032. get scaleGizmoEnabled(): boolean;
  57033. /**
  57034. * If the boundingBox gizmo is enabled
  57035. */
  57036. set boundingBoxGizmoEnabled(value: boolean);
  57037. get boundingBoxGizmoEnabled(): boolean;
  57038. /**
  57039. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57040. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57041. */
  57042. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  57043. /**
  57044. * Disposes of the gizmo manager
  57045. */
  57046. dispose(): void;
  57047. }
  57048. }
  57049. declare module "babylonjs/Gizmos/positionGizmo" {
  57050. import { Observable } from "babylonjs/Misc/observable";
  57051. import { Nullable } from "babylonjs/types";
  57052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57053. import { Node } from "babylonjs/node";
  57054. import { Mesh } from "babylonjs/Meshes/mesh";
  57055. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  57056. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  57057. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  57058. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  57059. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  57060. /**
  57061. * Gizmo that enables dragging a mesh along 3 axis
  57062. */
  57063. export class PositionGizmo extends Gizmo {
  57064. /**
  57065. * Internal gizmo used for interactions on the x axis
  57066. */
  57067. xGizmo: AxisDragGizmo;
  57068. /**
  57069. * Internal gizmo used for interactions on the y axis
  57070. */
  57071. yGizmo: AxisDragGizmo;
  57072. /**
  57073. * Internal gizmo used for interactions on the z axis
  57074. */
  57075. zGizmo: AxisDragGizmo;
  57076. /**
  57077. * Internal gizmo used for interactions on the yz plane
  57078. */
  57079. xPlaneGizmo: PlaneDragGizmo;
  57080. /**
  57081. * Internal gizmo used for interactions on the xz plane
  57082. */
  57083. yPlaneGizmo: PlaneDragGizmo;
  57084. /**
  57085. * Internal gizmo used for interactions on the xy plane
  57086. */
  57087. zPlaneGizmo: PlaneDragGizmo;
  57088. /**
  57089. * private variables
  57090. */
  57091. private _meshAttached;
  57092. private _nodeAttached;
  57093. private _snapDistance;
  57094. private _observables;
  57095. /** Node Caching for quick lookup */
  57096. private _gizmoAxisCache;
  57097. /** Fires an event when any of it's sub gizmos are dragged */
  57098. onDragStartObservable: Observable<unknown>;
  57099. /** Fires an event when any of it's sub gizmos are released from dragging */
  57100. onDragEndObservable: Observable<unknown>;
  57101. /**
  57102. * If set to true, planar drag is enabled
  57103. */
  57104. private _planarGizmoEnabled;
  57105. get attachedMesh(): Nullable<AbstractMesh>;
  57106. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57107. get attachedNode(): Nullable<Node>;
  57108. set attachedNode(node: Nullable<Node>);
  57109. /**
  57110. * True when the mouse pointer is hovering a gizmo mesh
  57111. */
  57112. get isHovered(): boolean;
  57113. /**
  57114. * Creates a PositionGizmo
  57115. * @param gizmoLayer The utility layer the gizmo will be added to
  57116. @param thickness display gizmo axis thickness
  57117. */
  57118. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57119. /**
  57120. * If the planar drag gizmo is enabled
  57121. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  57122. */
  57123. set planarGizmoEnabled(value: boolean);
  57124. get planarGizmoEnabled(): boolean;
  57125. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57126. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57127. /**
  57128. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57129. */
  57130. set snapDistance(value: number);
  57131. get snapDistance(): number;
  57132. /**
  57133. * Ratio for the scale of the gizmo (Default: 1)
  57134. */
  57135. set scaleRatio(value: number);
  57136. get scaleRatio(): number;
  57137. /**
  57138. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57139. * @param mesh Axis gizmo mesh
  57140. * @param cache Gizmo axis definition used for reactive gizmo UI
  57141. */
  57142. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57143. /**
  57144. * Disposes of the gizmo
  57145. */
  57146. dispose(): void;
  57147. /**
  57148. * CustomMeshes are not supported by this gizmo
  57149. * @param mesh The mesh to replace the default mesh of the gizmo
  57150. */
  57151. setCustomMesh(mesh: Mesh): void;
  57152. }
  57153. }
  57154. declare module "babylonjs/Gizmos/axisDragGizmo" {
  57155. import { Observable } from "babylonjs/Misc/observable";
  57156. import { Nullable } from "babylonjs/types";
  57157. import { Vector3 } from "babylonjs/Maths/math.vector";
  57158. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57159. import { Node } from "babylonjs/node";
  57160. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  57161. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  57162. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  57163. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  57164. import { Scene } from "babylonjs/scene";
  57165. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  57166. import { Color3 } from "babylonjs/Maths/math.color";
  57167. /**
  57168. * Single axis drag gizmo
  57169. */
  57170. export class AxisDragGizmo extends Gizmo {
  57171. /**
  57172. * Drag behavior responsible for the gizmos dragging interactions
  57173. */
  57174. dragBehavior: PointerDragBehavior;
  57175. private _pointerObserver;
  57176. /**
  57177. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57178. */
  57179. snapDistance: number;
  57180. /**
  57181. * Event that fires each time the gizmo snaps to a new location.
  57182. * * snapDistance is the the change in distance
  57183. */
  57184. onSnapObservable: Observable<{
  57185. snapDistance: number;
  57186. }>;
  57187. private _isEnabled;
  57188. private _parent;
  57189. private _gizmoMesh;
  57190. private _coloredMaterial;
  57191. private _hoverMaterial;
  57192. private _disableMaterial;
  57193. private _dragging;
  57194. /** @hidden */
  57195. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  57196. /** @hidden */
  57197. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  57198. /**
  57199. * Creates an AxisDragGizmo
  57200. * @param gizmoLayer The utility layer the gizmo will be added to
  57201. * @param dragAxis The axis which the gizmo will be able to drag on
  57202. * @param color The color of the gizmo
  57203. * @param thickness display gizmo axis thickness
  57204. */
  57205. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  57206. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57207. /**
  57208. * If the gizmo is enabled
  57209. */
  57210. set isEnabled(value: boolean);
  57211. get isEnabled(): boolean;
  57212. /**
  57213. * Disposes of the gizmo
  57214. */
  57215. dispose(): void;
  57216. }
  57217. }
  57218. declare module "babylonjs/Debug/axesViewer" {
  57219. import { Vector3 } from "babylonjs/Maths/math.vector";
  57220. import { Nullable } from "babylonjs/types";
  57221. import { Scene } from "babylonjs/scene";
  57222. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57223. /**
  57224. * The Axes viewer will show 3 axes in a specific point in space
  57225. */
  57226. export class AxesViewer {
  57227. private _xAxis;
  57228. private _yAxis;
  57229. private _zAxis;
  57230. private _scaleLinesFactor;
  57231. private _instanced;
  57232. /**
  57233. * Gets the hosting scene
  57234. */
  57235. scene: Nullable<Scene>;
  57236. /**
  57237. * Gets or sets a number used to scale line length
  57238. */
  57239. scaleLines: number;
  57240. /** Gets the node hierarchy used to render x-axis */
  57241. get xAxis(): TransformNode;
  57242. /** Gets the node hierarchy used to render y-axis */
  57243. get yAxis(): TransformNode;
  57244. /** Gets the node hierarchy used to render z-axis */
  57245. get zAxis(): TransformNode;
  57246. /**
  57247. * Creates a new AxesViewer
  57248. * @param scene defines the hosting scene
  57249. * @param scaleLines defines a number used to scale line length (1 by default)
  57250. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  57251. * @param xAxis defines the node hierarchy used to render the x-axis
  57252. * @param yAxis defines the node hierarchy used to render the y-axis
  57253. * @param zAxis defines the node hierarchy used to render the z-axis
  57254. */
  57255. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  57256. /**
  57257. * Force the viewer to update
  57258. * @param position defines the position of the viewer
  57259. * @param xaxis defines the x axis of the viewer
  57260. * @param yaxis defines the y axis of the viewer
  57261. * @param zaxis defines the z axis of the viewer
  57262. */
  57263. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  57264. /**
  57265. * Creates an instance of this axes viewer.
  57266. * @returns a new axes viewer with instanced meshes
  57267. */
  57268. createInstance(): AxesViewer;
  57269. /** Releases resources */
  57270. dispose(): void;
  57271. private static _SetRenderingGroupId;
  57272. }
  57273. }
  57274. declare module "babylonjs/Debug/boneAxesViewer" {
  57275. import { Nullable } from "babylonjs/types";
  57276. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  57277. import { Vector3 } from "babylonjs/Maths/math.vector";
  57278. import { Mesh } from "babylonjs/Meshes/mesh";
  57279. import { Bone } from "babylonjs/Bones/bone";
  57280. import { Scene } from "babylonjs/scene";
  57281. /**
  57282. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  57283. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  57284. */
  57285. export class BoneAxesViewer extends AxesViewer {
  57286. /**
  57287. * Gets or sets the target mesh where to display the axes viewer
  57288. */
  57289. mesh: Nullable<Mesh>;
  57290. /**
  57291. * Gets or sets the target bone where to display the axes viewer
  57292. */
  57293. bone: Nullable<Bone>;
  57294. /** Gets current position */
  57295. pos: Vector3;
  57296. /** Gets direction of X axis */
  57297. xaxis: Vector3;
  57298. /** Gets direction of Y axis */
  57299. yaxis: Vector3;
  57300. /** Gets direction of Z axis */
  57301. zaxis: Vector3;
  57302. /**
  57303. * Creates a new BoneAxesViewer
  57304. * @param scene defines the hosting scene
  57305. * @param bone defines the target bone
  57306. * @param mesh defines the target mesh
  57307. * @param scaleLines defines a scaling factor for line length (1 by default)
  57308. */
  57309. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  57310. /**
  57311. * Force the viewer to update
  57312. */
  57313. update(): void;
  57314. /** Releases resources */
  57315. dispose(): void;
  57316. }
  57317. }
  57318. declare module "babylonjs/Debug/debugLayer" {
  57319. import { Scene } from "babylonjs/scene";
  57320. /**
  57321. * Interface used to define scene explorer extensibility option
  57322. */
  57323. export interface IExplorerExtensibilityOption {
  57324. /**
  57325. * Define the option label
  57326. */
  57327. label: string;
  57328. /**
  57329. * Defines the action to execute on click
  57330. */
  57331. action: (entity: any) => void;
  57332. }
  57333. /**
  57334. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  57335. */
  57336. export interface IExplorerExtensibilityGroup {
  57337. /**
  57338. * Defines a predicate to test if a given type mut be extended
  57339. */
  57340. predicate: (entity: any) => boolean;
  57341. /**
  57342. * Gets the list of options added to a type
  57343. */
  57344. entries: IExplorerExtensibilityOption[];
  57345. }
  57346. /**
  57347. * Interface used to define the options to use to create the Inspector
  57348. */
  57349. export interface IInspectorOptions {
  57350. /**
  57351. * Display in overlay mode (default: false)
  57352. */
  57353. overlay?: boolean;
  57354. /**
  57355. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  57356. */
  57357. globalRoot?: HTMLElement;
  57358. /**
  57359. * Display the Scene explorer
  57360. */
  57361. showExplorer?: boolean;
  57362. /**
  57363. * Display the property inspector
  57364. */
  57365. showInspector?: boolean;
  57366. /**
  57367. * Display in embed mode (both panes on the right)
  57368. */
  57369. embedMode?: boolean;
  57370. /**
  57371. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  57372. */
  57373. handleResize?: boolean;
  57374. /**
  57375. * Allow the panes to popup (default: true)
  57376. */
  57377. enablePopup?: boolean;
  57378. /**
  57379. * Allow the panes to be closed by users (default: true)
  57380. */
  57381. enableClose?: boolean;
  57382. /**
  57383. * Optional list of extensibility entries
  57384. */
  57385. explorerExtensibility?: IExplorerExtensibilityGroup[];
  57386. /**
  57387. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  57388. */
  57389. inspectorURL?: string;
  57390. /**
  57391. * Optional initial tab (default to DebugLayerTab.Properties)
  57392. */
  57393. initialTab?: DebugLayerTab;
  57394. }
  57395. module "babylonjs/scene" {
  57396. interface Scene {
  57397. /**
  57398. * @hidden
  57399. * Backing field
  57400. */
  57401. _debugLayer: DebugLayer;
  57402. /**
  57403. * Gets the debug layer (aka Inspector) associated with the scene
  57404. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57405. */
  57406. debugLayer: DebugLayer;
  57407. }
  57408. }
  57409. /**
  57410. * Enum of inspector action tab
  57411. */
  57412. export enum DebugLayerTab {
  57413. /**
  57414. * Properties tag (default)
  57415. */
  57416. Properties = 0,
  57417. /**
  57418. * Debug tab
  57419. */
  57420. Debug = 1,
  57421. /**
  57422. * Statistics tab
  57423. */
  57424. Statistics = 2,
  57425. /**
  57426. * Tools tab
  57427. */
  57428. Tools = 3,
  57429. /**
  57430. * Settings tab
  57431. */
  57432. Settings = 4
  57433. }
  57434. /**
  57435. * The debug layer (aka Inspector) is the go to tool in order to better understand
  57436. * what is happening in your scene
  57437. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57438. */
  57439. export class DebugLayer {
  57440. /**
  57441. * Define the url to get the inspector script from.
  57442. * By default it uses the babylonjs CDN.
  57443. * @ignoreNaming
  57444. */
  57445. static InspectorURL: string;
  57446. private _scene;
  57447. private BJSINSPECTOR;
  57448. private _onPropertyChangedObservable?;
  57449. /**
  57450. * Observable triggered when a property is changed through the inspector.
  57451. */
  57452. get onPropertyChangedObservable(): any;
  57453. /**
  57454. * Instantiates a new debug layer.
  57455. * The debug layer (aka Inspector) is the go to tool in order to better understand
  57456. * what is happening in your scene
  57457. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57458. * @param scene Defines the scene to inspect
  57459. */
  57460. constructor(scene: Scene);
  57461. /** Creates the inspector window. */
  57462. private _createInspector;
  57463. /**
  57464. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  57465. * @param entity defines the entity to select
  57466. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  57467. */
  57468. select(entity: any, lineContainerTitles?: string | string[]): void;
  57469. /** Get the inspector from bundle or global */
  57470. private _getGlobalInspector;
  57471. /**
  57472. * Get if the inspector is visible or not.
  57473. * @returns true if visible otherwise, false
  57474. */
  57475. isVisible(): boolean;
  57476. /**
  57477. * Hide the inspector and close its window.
  57478. */
  57479. hide(): void;
  57480. /**
  57481. * Update the scene in the inspector
  57482. */
  57483. setAsActiveScene(): void;
  57484. /**
  57485. * Launch the debugLayer.
  57486. * @param config Define the configuration of the inspector
  57487. * @return a promise fulfilled when the debug layer is visible
  57488. */
  57489. show(config?: IInspectorOptions): Promise<DebugLayer>;
  57490. }
  57491. }
  57492. declare module "babylonjs/Debug/physicsViewer" {
  57493. import { Nullable } from "babylonjs/types";
  57494. import { Scene } from "babylonjs/scene";
  57495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57496. import { Mesh } from "babylonjs/Meshes/mesh";
  57497. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57498. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57499. /**
  57500. * Used to show the physics impostor around the specific mesh
  57501. */
  57502. export class PhysicsViewer {
  57503. /** @hidden */
  57504. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  57505. /** @hidden */
  57506. protected _meshes: Array<Nullable<AbstractMesh>>;
  57507. /** @hidden */
  57508. protected _scene: Nullable<Scene>;
  57509. /** @hidden */
  57510. protected _numMeshes: number;
  57511. /** @hidden */
  57512. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  57513. private _renderFunction;
  57514. private _utilityLayer;
  57515. private _debugBoxMesh;
  57516. private _debugSphereMesh;
  57517. private _debugCylinderMesh;
  57518. private _debugMaterial;
  57519. private _debugMeshMeshes;
  57520. /**
  57521. * Creates a new PhysicsViewer
  57522. * @param scene defines the hosting scene
  57523. */
  57524. constructor(scene: Scene);
  57525. /** @hidden */
  57526. protected _updateDebugMeshes(): void;
  57527. /**
  57528. * Renders a specified physic impostor
  57529. * @param impostor defines the impostor to render
  57530. * @param targetMesh defines the mesh represented by the impostor
  57531. * @returns the new debug mesh used to render the impostor
  57532. */
  57533. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  57534. /**
  57535. * Hides a specified physic impostor
  57536. * @param impostor defines the impostor to hide
  57537. */
  57538. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  57539. private _getDebugMaterial;
  57540. private _getDebugBoxMesh;
  57541. private _getDebugSphereMesh;
  57542. private _getDebugCylinderMesh;
  57543. private _getDebugMeshMesh;
  57544. private _getDebugMesh;
  57545. /** Releases all resources */
  57546. dispose(): void;
  57547. }
  57548. }
  57549. declare module "babylonjs/Debug/rayHelper" {
  57550. import { Nullable } from "babylonjs/types";
  57551. import { Ray } from "babylonjs/Culling/ray";
  57552. import { Vector3 } from "babylonjs/Maths/math.vector";
  57553. import { Color3 } from "babylonjs/Maths/math.color";
  57554. import { Scene } from "babylonjs/scene";
  57555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57556. import "babylonjs/Meshes/Builders/linesBuilder";
  57557. /**
  57558. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  57559. * in order to better appreciate the issue one might have.
  57560. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  57561. */
  57562. export class RayHelper {
  57563. /**
  57564. * Defines the ray we are currently tryin to visualize.
  57565. */
  57566. ray: Nullable<Ray>;
  57567. private _renderPoints;
  57568. private _renderLine;
  57569. private _renderFunction;
  57570. private _scene;
  57571. private _onAfterRenderObserver;
  57572. private _onAfterStepObserver;
  57573. private _attachedToMesh;
  57574. private _meshSpaceDirection;
  57575. private _meshSpaceOrigin;
  57576. /**
  57577. * Helper function to create a colored helper in a scene in one line.
  57578. * @param ray Defines the ray we are currently tryin to visualize
  57579. * @param scene Defines the scene the ray is used in
  57580. * @param color Defines the color we want to see the ray in
  57581. * @returns The newly created ray helper.
  57582. */
  57583. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  57584. /**
  57585. * Instantiate a new ray helper.
  57586. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  57587. * in order to better appreciate the issue one might have.
  57588. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  57589. * @param ray Defines the ray we are currently tryin to visualize
  57590. */
  57591. constructor(ray: Ray);
  57592. /**
  57593. * Shows the ray we are willing to debug.
  57594. * @param scene Defines the scene the ray needs to be rendered in
  57595. * @param color Defines the color the ray needs to be rendered in
  57596. */
  57597. show(scene: Scene, color?: Color3): void;
  57598. /**
  57599. * Hides the ray we are debugging.
  57600. */
  57601. hide(): void;
  57602. private _render;
  57603. /**
  57604. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  57605. * @param mesh Defines the mesh we want the helper attached to
  57606. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  57607. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  57608. * @param length Defines the length of the ray
  57609. */
  57610. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  57611. /**
  57612. * Detach the ray helper from the mesh it has previously been attached to.
  57613. */
  57614. detachFromMesh(): void;
  57615. private _updateToMesh;
  57616. /**
  57617. * Dispose the helper and release its associated resources.
  57618. */
  57619. dispose(): void;
  57620. }
  57621. }
  57622. declare module "babylonjs/Debug/ISkeletonViewer" {
  57623. import { Skeleton } from "babylonjs/Bones/skeleton";
  57624. import { Color3 } from "babylonjs/Maths/math.color";
  57625. /**
  57626. * Defines the options associated with the creation of a SkeletonViewer.
  57627. */
  57628. export interface ISkeletonViewerOptions {
  57629. /** Should the system pause animations before building the Viewer? */
  57630. pauseAnimations: boolean;
  57631. /** Should the system return the skeleton to rest before building? */
  57632. returnToRest: boolean;
  57633. /** public Display Mode of the Viewer */
  57634. displayMode: number;
  57635. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  57636. displayOptions: ISkeletonViewerDisplayOptions;
  57637. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  57638. computeBonesUsingShaders: boolean;
  57639. /** Flag ignore non weighted bones */
  57640. useAllBones: boolean;
  57641. }
  57642. /**
  57643. * Defines how to display the various bone meshes for the viewer.
  57644. */
  57645. export interface ISkeletonViewerDisplayOptions {
  57646. /** How far down to start tapering the bone spurs */
  57647. midStep?: number;
  57648. /** How big is the midStep? */
  57649. midStepFactor?: number;
  57650. /** Base for the Sphere Size */
  57651. sphereBaseSize?: number;
  57652. /** The ratio of the sphere to the longest bone in units */
  57653. sphereScaleUnit?: number;
  57654. /** Ratio for the Sphere Size */
  57655. sphereFactor?: number;
  57656. /** Whether a spur should attach its far end to the child bone position */
  57657. spurFollowsChild?: boolean;
  57658. /** Whether to show local axes or not */
  57659. showLocalAxes?: boolean;
  57660. /** Length of each local axis */
  57661. localAxesSize?: number;
  57662. }
  57663. /**
  57664. * Defines the constructor options for the BoneWeight Shader.
  57665. */
  57666. export interface IBoneWeightShaderOptions {
  57667. /** Skeleton to Map */
  57668. skeleton: Skeleton;
  57669. /** Colors for Uninfluenced bones */
  57670. colorBase?: Color3;
  57671. /** Colors for 0.0-0.25 Weight bones */
  57672. colorZero?: Color3;
  57673. /** Color for 0.25-0.5 Weight Influence */
  57674. colorQuarter?: Color3;
  57675. /** Color for 0.5-0.75 Weight Influence */
  57676. colorHalf?: Color3;
  57677. /** Color for 0.75-1 Weight Influence */
  57678. colorFull?: Color3;
  57679. /** Color for Zero Weight Influence */
  57680. targetBoneIndex?: number;
  57681. }
  57682. /**
  57683. * Simple structure of the gradient steps for the Color Map.
  57684. */
  57685. export interface ISkeletonMapShaderColorMapKnot {
  57686. /** Color of the Knot */
  57687. color: Color3;
  57688. /** Location of the Knot */
  57689. location: number;
  57690. }
  57691. /**
  57692. * Defines the constructor options for the SkeletonMap Shader.
  57693. */
  57694. export interface ISkeletonMapShaderOptions {
  57695. /** Skeleton to Map */
  57696. skeleton: Skeleton;
  57697. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  57698. colorMap?: ISkeletonMapShaderColorMapKnot[];
  57699. }
  57700. }
  57701. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57702. import { Nullable } from "babylonjs/types";
  57703. import { Scene } from "babylonjs/scene";
  57704. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57705. import { Color4 } from "babylonjs/Maths/math.color";
  57706. import { Mesh } from "babylonjs/Meshes/mesh";
  57707. /**
  57708. * Class containing static functions to help procedurally build meshes
  57709. */
  57710. export class RibbonBuilder {
  57711. /**
  57712. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57713. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57714. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57715. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57716. * * 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
  57717. * * 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
  57718. * * 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
  57719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57720. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57721. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57722. * * 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
  57723. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57724. * * 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
  57725. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57727. * @param name defines the name of the mesh
  57728. * @param options defines the options used to create the mesh
  57729. * @param scene defines the hosting scene
  57730. * @returns the ribbon mesh
  57731. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57732. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57733. */
  57734. static CreateRibbon(name: string, options: {
  57735. pathArray: Vector3[][];
  57736. closeArray?: boolean;
  57737. closePath?: boolean;
  57738. offset?: number;
  57739. updatable?: boolean;
  57740. sideOrientation?: number;
  57741. frontUVs?: Vector4;
  57742. backUVs?: Vector4;
  57743. instance?: Mesh;
  57744. invertUV?: boolean;
  57745. uvs?: Vector2[];
  57746. colors?: Color4[];
  57747. }, scene?: Nullable<Scene>): Mesh;
  57748. }
  57749. }
  57750. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57751. import { Nullable } from "babylonjs/types";
  57752. import { Scene } from "babylonjs/scene";
  57753. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57754. import { Mesh } from "babylonjs/Meshes/mesh";
  57755. /**
  57756. * Class containing static functions to help procedurally build meshes
  57757. */
  57758. export class ShapeBuilder {
  57759. /**
  57760. * 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.
  57761. * * 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.
  57762. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57763. * * 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.
  57764. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57765. * * 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
  57766. * * 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
  57767. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57768. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57769. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57770. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57772. * @param name defines the name of the mesh
  57773. * @param options defines the options used to create the mesh
  57774. * @param scene defines the hosting scene
  57775. * @returns the extruded shape mesh
  57776. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57777. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57778. */
  57779. static ExtrudeShape(name: string, options: {
  57780. shape: Vector3[];
  57781. path: Vector3[];
  57782. scale?: number;
  57783. rotation?: number;
  57784. cap?: number;
  57785. updatable?: boolean;
  57786. sideOrientation?: number;
  57787. frontUVs?: Vector4;
  57788. backUVs?: Vector4;
  57789. instance?: Mesh;
  57790. invertUV?: boolean;
  57791. }, scene?: Nullable<Scene>): Mesh;
  57792. /**
  57793. * Creates an custom extruded shape mesh.
  57794. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57795. * * 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.
  57796. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57797. * * 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
  57798. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57799. * * 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
  57800. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57801. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57802. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57803. * * 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
  57804. * * 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
  57805. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57806. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57807. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57808. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57810. * @param name defines the name of the mesh
  57811. * @param options defines the options used to create the mesh
  57812. * @param scene defines the hosting scene
  57813. * @returns the custom extruded shape mesh
  57814. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57815. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57816. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57817. */
  57818. static ExtrudeShapeCustom(name: string, options: {
  57819. shape: Vector3[];
  57820. path: Vector3[];
  57821. scaleFunction?: any;
  57822. rotationFunction?: any;
  57823. ribbonCloseArray?: boolean;
  57824. ribbonClosePath?: boolean;
  57825. cap?: number;
  57826. updatable?: boolean;
  57827. sideOrientation?: number;
  57828. frontUVs?: Vector4;
  57829. backUVs?: Vector4;
  57830. instance?: Mesh;
  57831. invertUV?: boolean;
  57832. }, scene?: Nullable<Scene>): Mesh;
  57833. private static _ExtrudeShapeGeneric;
  57834. }
  57835. }
  57836. declare module "babylonjs/Debug/skeletonViewer" {
  57837. import { Color3 } from "babylonjs/Maths/math.color";
  57838. import { Scene } from "babylonjs/scene";
  57839. import { Nullable } from "babylonjs/types";
  57840. import { Skeleton } from "babylonjs/Bones/skeleton";
  57841. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57842. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  57843. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  57844. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  57845. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  57846. /**
  57847. * Class used to render a debug view of a given skeleton
  57848. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  57849. */
  57850. export class SkeletonViewer {
  57851. /** defines the skeleton to render */
  57852. skeleton: Skeleton;
  57853. /** defines the mesh attached to the skeleton */
  57854. mesh: AbstractMesh;
  57855. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  57856. autoUpdateBonesMatrices: boolean;
  57857. /** defines the rendering group id to use with the viewer */
  57858. renderingGroupId: number;
  57859. /** is the options for the viewer */
  57860. options: Partial<ISkeletonViewerOptions>;
  57861. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  57862. static readonly DISPLAY_LINES: number;
  57863. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  57864. static readonly DISPLAY_SPHERES: number;
  57865. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  57866. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  57867. /** public static method to create a BoneWeight Shader
  57868. * @param options The constructor options
  57869. * @param scene The scene that the shader is scoped to
  57870. * @returns The created ShaderMaterial
  57871. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  57872. */
  57873. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  57874. /** public static method to create a BoneWeight Shader
  57875. * @param options The constructor options
  57876. * @param scene The scene that the shader is scoped to
  57877. * @returns The created ShaderMaterial
  57878. */
  57879. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  57880. /** private static method to create a BoneWeight Shader
  57881. * @param size The size of the buffer to create (usually the bone count)
  57882. * @param colorMap The gradient data to generate
  57883. * @param scene The scene that the shader is scoped to
  57884. * @returns an Array of floats from the color gradient values
  57885. */
  57886. private static _CreateBoneMapColorBuffer;
  57887. /** If SkeletonViewer scene scope. */
  57888. private _scene;
  57889. /** Gets or sets the color used to render the skeleton */
  57890. color: Color3;
  57891. /** Array of the points of the skeleton fo the line view. */
  57892. private _debugLines;
  57893. /** The SkeletonViewers Mesh. */
  57894. private _debugMesh;
  57895. /** The local axes Meshes. */
  57896. private _localAxes;
  57897. /** If SkeletonViewer is enabled. */
  57898. private _isEnabled;
  57899. /** If SkeletonViewer is ready. */
  57900. private _ready;
  57901. /** SkeletonViewer render observable. */
  57902. private _obs;
  57903. /** The Utility Layer to render the gizmos in. */
  57904. private _utilityLayer;
  57905. private _boneIndices;
  57906. /** Gets the Scene. */
  57907. get scene(): Scene;
  57908. /** Gets the utilityLayer. */
  57909. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  57910. /** Checks Ready Status. */
  57911. get isReady(): Boolean;
  57912. /** Sets Ready Status. */
  57913. set ready(value: boolean);
  57914. /** Gets the debugMesh */
  57915. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  57916. /** Sets the debugMesh */
  57917. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  57918. /** Gets the displayMode */
  57919. get displayMode(): number;
  57920. /** Sets the displayMode */
  57921. set displayMode(value: number);
  57922. /**
  57923. * Creates a new SkeletonViewer
  57924. * @param skeleton defines the skeleton to render
  57925. * @param mesh defines the mesh attached to the skeleton
  57926. * @param scene defines the hosting scene
  57927. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  57928. * @param renderingGroupId defines the rendering group id to use with the viewer
  57929. * @param options All of the extra constructor options for the SkeletonViewer
  57930. */
  57931. constructor(
  57932. /** defines the skeleton to render */
  57933. skeleton: Skeleton,
  57934. /** defines the mesh attached to the skeleton */
  57935. mesh: AbstractMesh,
  57936. /** The Scene scope*/
  57937. scene: Scene,
  57938. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  57939. autoUpdateBonesMatrices?: boolean,
  57940. /** defines the rendering group id to use with the viewer */
  57941. renderingGroupId?: number,
  57942. /** is the options for the viewer */
  57943. options?: Partial<ISkeletonViewerOptions>);
  57944. /** The Dynamic bindings for the update functions */
  57945. private _bindObs;
  57946. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  57947. update(): void;
  57948. /** Gets or sets a boolean indicating if the viewer is enabled */
  57949. set isEnabled(value: boolean);
  57950. get isEnabled(): boolean;
  57951. private _getBonePosition;
  57952. private _getLinesForBonesWithLength;
  57953. private _getLinesForBonesNoLength;
  57954. /** function to revert the mesh and scene back to the initial state. */
  57955. private _revert;
  57956. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  57957. private _getAbsoluteBindPoseToRef;
  57958. /** function to build and bind sphere joint points and spur bone representations. */
  57959. private _buildSpheresAndSpurs;
  57960. private _buildLocalAxes;
  57961. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  57962. private _displayLinesUpdate;
  57963. /** Changes the displayMode of the skeleton viewer
  57964. * @param mode The displayMode numerical value
  57965. */
  57966. changeDisplayMode(mode: number): void;
  57967. /** Sets a display option of the skeleton viewer
  57968. *
  57969. * | Option | Type | Default | Description |
  57970. * | ---------------- | ------- | ------- | ----------- |
  57971. * | 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`. |
  57972. * | 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`. |
  57973. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  57974. * | 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`. |
  57975. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  57976. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  57977. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  57978. *
  57979. * @param option String of the option name
  57980. * @param value The numerical option value
  57981. */
  57982. changeDisplayOptions(option: string, value: number): void;
  57983. /** Release associated resources */
  57984. dispose(): void;
  57985. }
  57986. }
  57987. declare module "babylonjs/Debug/index" {
  57988. export * from "babylonjs/Debug/axesViewer";
  57989. export * from "babylonjs/Debug/boneAxesViewer";
  57990. export * from "babylonjs/Debug/debugLayer";
  57991. export * from "babylonjs/Debug/physicsViewer";
  57992. export * from "babylonjs/Debug/rayHelper";
  57993. export * from "babylonjs/Debug/skeletonViewer";
  57994. export * from "babylonjs/Debug/ISkeletonViewer";
  57995. }
  57996. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  57997. /**
  57998. * Enum for Device Types
  57999. */
  58000. export enum DeviceType {
  58001. /** Generic */
  58002. Generic = 0,
  58003. /** Keyboard */
  58004. Keyboard = 1,
  58005. /** Mouse */
  58006. Mouse = 2,
  58007. /** Touch Pointers */
  58008. Touch = 3,
  58009. /** PS4 Dual Shock */
  58010. DualShock = 4,
  58011. /** Xbox */
  58012. Xbox = 5,
  58013. /** Switch Controller */
  58014. Switch = 6
  58015. }
  58016. /**
  58017. * Enum for All Pointers (Touch/Mouse)
  58018. */
  58019. export enum PointerInput {
  58020. /** Horizontal Axis */
  58021. Horizontal = 0,
  58022. /** Vertical Axis */
  58023. Vertical = 1,
  58024. /** Left Click or Touch */
  58025. LeftClick = 2,
  58026. /** Middle Click */
  58027. MiddleClick = 3,
  58028. /** Right Click */
  58029. RightClick = 4,
  58030. /** Browser Back */
  58031. BrowserBack = 5,
  58032. /** Browser Forward */
  58033. BrowserForward = 6
  58034. }
  58035. /**
  58036. * Enum for Dual Shock Gamepad
  58037. */
  58038. export enum DualShockInput {
  58039. /** Cross */
  58040. Cross = 0,
  58041. /** Circle */
  58042. Circle = 1,
  58043. /** Square */
  58044. Square = 2,
  58045. /** Triangle */
  58046. Triangle = 3,
  58047. /** L1 */
  58048. L1 = 4,
  58049. /** R1 */
  58050. R1 = 5,
  58051. /** L2 */
  58052. L2 = 6,
  58053. /** R2 */
  58054. R2 = 7,
  58055. /** Share */
  58056. Share = 8,
  58057. /** Options */
  58058. Options = 9,
  58059. /** L3 */
  58060. L3 = 10,
  58061. /** R3 */
  58062. R3 = 11,
  58063. /** DPadUp */
  58064. DPadUp = 12,
  58065. /** DPadDown */
  58066. DPadDown = 13,
  58067. /** DPadLeft */
  58068. DPadLeft = 14,
  58069. /** DRight */
  58070. DPadRight = 15,
  58071. /** Home */
  58072. Home = 16,
  58073. /** TouchPad */
  58074. TouchPad = 17,
  58075. /** LStickXAxis */
  58076. LStickXAxis = 18,
  58077. /** LStickYAxis */
  58078. LStickYAxis = 19,
  58079. /** RStickXAxis */
  58080. RStickXAxis = 20,
  58081. /** RStickYAxis */
  58082. RStickYAxis = 21
  58083. }
  58084. /**
  58085. * Enum for Xbox Gamepad
  58086. */
  58087. export enum XboxInput {
  58088. /** A */
  58089. A = 0,
  58090. /** B */
  58091. B = 1,
  58092. /** X */
  58093. X = 2,
  58094. /** Y */
  58095. Y = 3,
  58096. /** LB */
  58097. LB = 4,
  58098. /** RB */
  58099. RB = 5,
  58100. /** LT */
  58101. LT = 6,
  58102. /** RT */
  58103. RT = 7,
  58104. /** Back */
  58105. Back = 8,
  58106. /** Start */
  58107. Start = 9,
  58108. /** LS */
  58109. LS = 10,
  58110. /** RS */
  58111. RS = 11,
  58112. /** DPadUp */
  58113. DPadUp = 12,
  58114. /** DPadDown */
  58115. DPadDown = 13,
  58116. /** DPadLeft */
  58117. DPadLeft = 14,
  58118. /** DRight */
  58119. DPadRight = 15,
  58120. /** Home */
  58121. Home = 16,
  58122. /** LStickXAxis */
  58123. LStickXAxis = 17,
  58124. /** LStickYAxis */
  58125. LStickYAxis = 18,
  58126. /** RStickXAxis */
  58127. RStickXAxis = 19,
  58128. /** RStickYAxis */
  58129. RStickYAxis = 20
  58130. }
  58131. /**
  58132. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  58133. */
  58134. export enum SwitchInput {
  58135. /** B */
  58136. B = 0,
  58137. /** A */
  58138. A = 1,
  58139. /** Y */
  58140. Y = 2,
  58141. /** X */
  58142. X = 3,
  58143. /** L */
  58144. L = 4,
  58145. /** R */
  58146. R = 5,
  58147. /** ZL */
  58148. ZL = 6,
  58149. /** ZR */
  58150. ZR = 7,
  58151. /** Minus */
  58152. Minus = 8,
  58153. /** Plus */
  58154. Plus = 9,
  58155. /** LS */
  58156. LS = 10,
  58157. /** RS */
  58158. RS = 11,
  58159. /** DPadUp */
  58160. DPadUp = 12,
  58161. /** DPadDown */
  58162. DPadDown = 13,
  58163. /** DPadLeft */
  58164. DPadLeft = 14,
  58165. /** DRight */
  58166. DPadRight = 15,
  58167. /** Home */
  58168. Home = 16,
  58169. /** Capture */
  58170. Capture = 17,
  58171. /** LStickXAxis */
  58172. LStickXAxis = 18,
  58173. /** LStickYAxis */
  58174. LStickYAxis = 19,
  58175. /** RStickXAxis */
  58176. RStickXAxis = 20,
  58177. /** RStickYAxis */
  58178. RStickYAxis = 21
  58179. }
  58180. }
  58181. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  58182. import { Engine } from "babylonjs/Engines/engine";
  58183. import { IDisposable } from "babylonjs/scene";
  58184. import { Nullable } from "babylonjs/types";
  58185. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  58186. /**
  58187. * This class will take all inputs from Keyboard, Pointer, and
  58188. * any Gamepads and provide a polling system that all devices
  58189. * will use. This class assumes that there will only be one
  58190. * pointer device and one keyboard.
  58191. */
  58192. export class DeviceInputSystem implements IDisposable {
  58193. /**
  58194. * Returns onDeviceConnected callback property
  58195. * @returns Callback with function to execute when a device is connected
  58196. */
  58197. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  58198. /**
  58199. * Sets callback function when a device is connected and executes against all connected devices
  58200. * @param callback Function to execute when a device is connected
  58201. */
  58202. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  58203. /**
  58204. * Callback to be triggered when a device is disconnected
  58205. */
  58206. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  58207. /**
  58208. * Callback to be triggered when event driven input is updated
  58209. */
  58210. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  58211. private _inputs;
  58212. private _gamepads;
  58213. private _keyboardActive;
  58214. private _pointerActive;
  58215. private _elementToAttachTo;
  58216. private _keyboardDownEvent;
  58217. private _keyboardUpEvent;
  58218. private _pointerMoveEvent;
  58219. private _pointerDownEvent;
  58220. private _pointerUpEvent;
  58221. private _gamepadConnectedEvent;
  58222. private _gamepadDisconnectedEvent;
  58223. private _onDeviceConnected;
  58224. private static _MAX_KEYCODES;
  58225. private static _MAX_POINTER_INPUTS;
  58226. private constructor();
  58227. /**
  58228. * Creates a new DeviceInputSystem instance
  58229. * @param engine Engine to pull input element from
  58230. * @returns The new instance
  58231. */
  58232. static Create(engine: Engine): DeviceInputSystem;
  58233. /**
  58234. * Checks for current device input value, given an id and input index
  58235. * @param deviceName Id of connected device
  58236. * @param inputIndex Index of device input
  58237. * @returns Current value of input
  58238. */
  58239. /**
  58240. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  58241. * @param deviceType Enum specifiying device type
  58242. * @param deviceSlot "Slot" or index that device is referenced in
  58243. * @param inputIndex Id of input to be checked
  58244. * @returns Current value of input
  58245. */
  58246. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  58247. /**
  58248. * Dispose of all the eventlisteners
  58249. */
  58250. dispose(): void;
  58251. /**
  58252. * Checks for existing connections to devices and register them, if necessary
  58253. * Currently handles gamepads and mouse
  58254. */
  58255. private _checkForConnectedDevices;
  58256. /**
  58257. * Add a gamepad to the DeviceInputSystem
  58258. * @param gamepad A single DOM Gamepad object
  58259. */
  58260. private _addGamePad;
  58261. /**
  58262. * Add pointer device to DeviceInputSystem
  58263. * @param deviceType Type of Pointer to add
  58264. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  58265. * @param currentX Current X at point of adding
  58266. * @param currentY Current Y at point of adding
  58267. */
  58268. private _addPointerDevice;
  58269. /**
  58270. * Add device and inputs to device array
  58271. * @param deviceType Enum specifiying device type
  58272. * @param deviceSlot "Slot" or index that device is referenced in
  58273. * @param numberOfInputs Number of input entries to create for given device
  58274. */
  58275. private _registerDevice;
  58276. /**
  58277. * Given a specific device name, remove that device from the device map
  58278. * @param deviceType Enum specifiying device type
  58279. * @param deviceSlot "Slot" or index that device is referenced in
  58280. */
  58281. private _unregisterDevice;
  58282. /**
  58283. * Handle all actions that come from keyboard interaction
  58284. */
  58285. private _handleKeyActions;
  58286. /**
  58287. * Handle all actions that come from pointer interaction
  58288. */
  58289. private _handlePointerActions;
  58290. /**
  58291. * Handle all actions that come from gamepad interaction
  58292. */
  58293. private _handleGamepadActions;
  58294. /**
  58295. * Update all non-event based devices with each frame
  58296. * @param deviceType Enum specifiying device type
  58297. * @param deviceSlot "Slot" or index that device is referenced in
  58298. * @param inputIndex Id of input to be checked
  58299. */
  58300. private _updateDevice;
  58301. /**
  58302. * Gets DeviceType from the device name
  58303. * @param deviceName Name of Device from DeviceInputSystem
  58304. * @returns DeviceType enum value
  58305. */
  58306. private _getGamepadDeviceType;
  58307. }
  58308. }
  58309. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  58310. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  58311. /**
  58312. * Type to handle enforcement of inputs
  58313. */
  58314. 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;
  58315. }
  58316. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  58317. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  58318. import { Engine } from "babylonjs/Engines/engine";
  58319. import { IDisposable } from "babylonjs/scene";
  58320. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  58321. import { Nullable } from "babylonjs/types";
  58322. import { Observable } from "babylonjs/Misc/observable";
  58323. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  58324. /**
  58325. * Class that handles all input for a specific device
  58326. */
  58327. export class DeviceSource<T extends DeviceType> {
  58328. /** Type of device */
  58329. readonly deviceType: DeviceType;
  58330. /** "Slot" or index that device is referenced in */
  58331. readonly deviceSlot: number;
  58332. /**
  58333. * Observable to handle device input changes per device
  58334. */
  58335. readonly onInputChangedObservable: Observable<{
  58336. inputIndex: DeviceInput<T>;
  58337. previousState: Nullable<number>;
  58338. currentState: Nullable<number>;
  58339. }>;
  58340. private readonly _deviceInputSystem;
  58341. /**
  58342. * Default Constructor
  58343. * @param deviceInputSystem Reference to DeviceInputSystem
  58344. * @param deviceType Type of device
  58345. * @param deviceSlot "Slot" or index that device is referenced in
  58346. */
  58347. constructor(deviceInputSystem: DeviceInputSystem,
  58348. /** Type of device */
  58349. deviceType: DeviceType,
  58350. /** "Slot" or index that device is referenced in */
  58351. deviceSlot?: number);
  58352. /**
  58353. * Get input for specific input
  58354. * @param inputIndex index of specific input on device
  58355. * @returns Input value from DeviceInputSystem
  58356. */
  58357. getInput(inputIndex: DeviceInput<T>): number;
  58358. }
  58359. /**
  58360. * Class to keep track of devices
  58361. */
  58362. export class DeviceSourceManager implements IDisposable {
  58363. /**
  58364. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  58365. */
  58366. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  58367. /**
  58368. * Observable to be triggered when after a device is disconnected
  58369. */
  58370. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  58371. private readonly _devices;
  58372. private readonly _firstDevice;
  58373. private readonly _deviceInputSystem;
  58374. /**
  58375. * Default Constructor
  58376. * @param engine engine to pull input element from
  58377. */
  58378. constructor(engine: Engine);
  58379. /**
  58380. * Gets a DeviceSource, given a type and slot
  58381. * @param deviceType Enum specifying device type
  58382. * @param deviceSlot "Slot" or index that device is referenced in
  58383. * @returns DeviceSource object
  58384. */
  58385. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  58386. /**
  58387. * Gets an array of DeviceSource objects for a given device type
  58388. * @param deviceType Enum specifying device type
  58389. * @returns Array of DeviceSource objects
  58390. */
  58391. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  58392. /**
  58393. * Returns a read-only list of all available devices
  58394. * @returns Read-only array with active devices
  58395. */
  58396. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  58397. /**
  58398. * Dispose of DeviceInputSystem and other parts
  58399. */
  58400. dispose(): void;
  58401. /**
  58402. * Function to add device name to device list
  58403. * @param deviceType Enum specifying device type
  58404. * @param deviceSlot "Slot" or index that device is referenced in
  58405. */
  58406. private _addDevice;
  58407. /**
  58408. * Function to remove device name to device list
  58409. * @param deviceType Enum specifying device type
  58410. * @param deviceSlot "Slot" or index that device is referenced in
  58411. */
  58412. private _removeDevice;
  58413. /**
  58414. * Updates array storing first connected device of each type
  58415. * @param type Type of Device
  58416. */
  58417. private _updateFirstDevices;
  58418. }
  58419. }
  58420. declare module "babylonjs/DeviceInput/index" {
  58421. export * from "babylonjs/DeviceInput/deviceInputSystem";
  58422. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  58423. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  58424. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  58425. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  58426. }
  58427. declare module "babylonjs/Engines/nullEngine" {
  58428. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  58429. import { Engine } from "babylonjs/Engines/engine";
  58430. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  58431. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  58432. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58433. import { Effect } from "babylonjs/Materials/effect";
  58434. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  58435. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  58436. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  58437. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  58438. /**
  58439. * Options to create the null engine
  58440. */
  58441. export class NullEngineOptions {
  58442. /**
  58443. * Render width (Default: 512)
  58444. */
  58445. renderWidth: number;
  58446. /**
  58447. * Render height (Default: 256)
  58448. */
  58449. renderHeight: number;
  58450. /**
  58451. * Texture size (Default: 512)
  58452. */
  58453. textureSize: number;
  58454. /**
  58455. * If delta time between frames should be constant
  58456. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58457. */
  58458. deterministicLockstep: boolean;
  58459. /**
  58460. * Maximum about of steps between frames (Default: 4)
  58461. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58462. */
  58463. lockstepMaxSteps: number;
  58464. /**
  58465. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  58466. */
  58467. useHighPrecisionMatrix?: boolean;
  58468. }
  58469. /**
  58470. * The null engine class provides support for headless version of babylon.js.
  58471. * This can be used in server side scenario or for testing purposes
  58472. */
  58473. export class NullEngine extends Engine {
  58474. private _options;
  58475. /**
  58476. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  58477. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58478. * @returns true if engine is in deterministic lock step mode
  58479. */
  58480. isDeterministicLockStep(): boolean;
  58481. /**
  58482. * Gets the max steps when engine is running in deterministic lock step
  58483. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58484. * @returns the max steps
  58485. */
  58486. getLockstepMaxSteps(): number;
  58487. /**
  58488. * Gets the current hardware scaling level.
  58489. * By default the hardware scaling level is computed from the window device ratio.
  58490. * 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.
  58491. * @returns a number indicating the current hardware scaling level
  58492. */
  58493. getHardwareScalingLevel(): number;
  58494. constructor(options?: NullEngineOptions);
  58495. /**
  58496. * Creates a vertex buffer
  58497. * @param vertices the data for the vertex buffer
  58498. * @returns the new WebGL static buffer
  58499. */
  58500. createVertexBuffer(vertices: FloatArray): DataBuffer;
  58501. /**
  58502. * Creates a new index buffer
  58503. * @param indices defines the content of the index buffer
  58504. * @param updatable defines if the index buffer must be updatable
  58505. * @returns a new webGL buffer
  58506. */
  58507. createIndexBuffer(indices: IndicesArray): DataBuffer;
  58508. /**
  58509. * Clear the current render buffer or the current render target (if any is set up)
  58510. * @param color defines the color to use
  58511. * @param backBuffer defines if the back buffer must be cleared
  58512. * @param depth defines if the depth buffer must be cleared
  58513. * @param stencil defines if the stencil buffer must be cleared
  58514. */
  58515. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  58516. /**
  58517. * Gets the current render width
  58518. * @param useScreen defines if screen size must be used (or the current render target if any)
  58519. * @returns a number defining the current render width
  58520. */
  58521. getRenderWidth(useScreen?: boolean): number;
  58522. /**
  58523. * Gets the current render height
  58524. * @param useScreen defines if screen size must be used (or the current render target if any)
  58525. * @returns a number defining the current render height
  58526. */
  58527. getRenderHeight(useScreen?: boolean): number;
  58528. /**
  58529. * Set the WebGL's viewport
  58530. * @param viewport defines the viewport element to be used
  58531. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  58532. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  58533. */
  58534. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  58535. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  58536. /**
  58537. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  58538. * @param pipelineContext defines the pipeline context to use
  58539. * @param uniformsNames defines the list of uniform names
  58540. * @returns an array of webGL uniform locations
  58541. */
  58542. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  58543. /**
  58544. * Gets the lsit of active attributes for a given webGL program
  58545. * @param pipelineContext defines the pipeline context to use
  58546. * @param attributesNames defines the list of attribute names to get
  58547. * @returns an array of indices indicating the offset of each attribute
  58548. */
  58549. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  58550. /**
  58551. * Binds an effect to the webGL context
  58552. * @param effect defines the effect to bind
  58553. */
  58554. bindSamplers(effect: Effect): void;
  58555. /**
  58556. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  58557. * @param effect defines the effect to activate
  58558. */
  58559. enableEffect(effect: Effect): void;
  58560. /**
  58561. * Set various states to the webGL context
  58562. * @param culling defines backface culling state
  58563. * @param zOffset defines the value to apply to zOffset (0 by default)
  58564. * @param force defines if states must be applied even if cache is up to date
  58565. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  58566. */
  58567. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  58568. /**
  58569. * Set the value of an uniform to an array of int32
  58570. * @param uniform defines the webGL uniform location where to store the value
  58571. * @param array defines the array of int32 to store
  58572. * @returns true if value was set
  58573. */
  58574. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58575. /**
  58576. * Set the value of an uniform to an array of int32 (stored as vec2)
  58577. * @param uniform defines the webGL uniform location where to store the value
  58578. * @param array defines the array of int32 to store
  58579. * @returns true if value was set
  58580. */
  58581. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58582. /**
  58583. * Set the value of an uniform to an array of int32 (stored as vec3)
  58584. * @param uniform defines the webGL uniform location where to store the value
  58585. * @param array defines the array of int32 to store
  58586. * @returns true if value was set
  58587. */
  58588. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58589. /**
  58590. * Set the value of an uniform to an array of int32 (stored as vec4)
  58591. * @param uniform defines the webGL uniform location where to store the value
  58592. * @param array defines the array of int32 to store
  58593. * @returns true if value was set
  58594. */
  58595. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58596. /**
  58597. * Set the value of an uniform to an array of float32
  58598. * @param uniform defines the webGL uniform location where to store the value
  58599. * @param array defines the array of float32 to store
  58600. * @returns true if value was set
  58601. */
  58602. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58603. /**
  58604. * Set the value of an uniform to an array of float32 (stored as vec2)
  58605. * @param uniform defines the webGL uniform location where to store the value
  58606. * @param array defines the array of float32 to store
  58607. * @returns true if value was set
  58608. */
  58609. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58610. /**
  58611. * Set the value of an uniform to an array of float32 (stored as vec3)
  58612. * @param uniform defines the webGL uniform location where to store the value
  58613. * @param array defines the array of float32 to store
  58614. * @returns true if value was set
  58615. */
  58616. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58617. /**
  58618. * Set the value of an uniform to an array of float32 (stored as vec4)
  58619. * @param uniform defines the webGL uniform location where to store the value
  58620. * @param array defines the array of float32 to store
  58621. * @returns true if value was set
  58622. */
  58623. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58624. /**
  58625. * Set the value of an uniform to an array of number
  58626. * @param uniform defines the webGL uniform location where to store the value
  58627. * @param array defines the array of number to store
  58628. * @returns true if value was set
  58629. */
  58630. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  58631. /**
  58632. * Set the value of an uniform to an array of number (stored as vec2)
  58633. * @param uniform defines the webGL uniform location where to store the value
  58634. * @param array defines the array of number to store
  58635. * @returns true if value was set
  58636. */
  58637. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  58638. /**
  58639. * Set the value of an uniform to an array of number (stored as vec3)
  58640. * @param uniform defines the webGL uniform location where to store the value
  58641. * @param array defines the array of number to store
  58642. * @returns true if value was set
  58643. */
  58644. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  58645. /**
  58646. * Set the value of an uniform to an array of number (stored as vec4)
  58647. * @param uniform defines the webGL uniform location where to store the value
  58648. * @param array defines the array of number to store
  58649. * @returns true if value was set
  58650. */
  58651. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  58652. /**
  58653. * Set the value of an uniform to an array of float32 (stored as matrices)
  58654. * @param uniform defines the webGL uniform location where to store the value
  58655. * @param matrices defines the array of float32 to store
  58656. * @returns true if value was set
  58657. */
  58658. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  58659. /**
  58660. * Set the value of an uniform to a matrix (3x3)
  58661. * @param uniform defines the webGL uniform location where to store the value
  58662. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  58663. * @returns true if value was set
  58664. */
  58665. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58666. /**
  58667. * Set the value of an uniform to a matrix (2x2)
  58668. * @param uniform defines the webGL uniform location where to store the value
  58669. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  58670. * @returns true if value was set
  58671. */
  58672. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58673. /**
  58674. * Set the value of an uniform to a number (float)
  58675. * @param uniform defines the webGL uniform location where to store the value
  58676. * @param value defines the float number to store
  58677. * @returns true if value was set
  58678. */
  58679. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  58680. /**
  58681. * Set the value of an uniform to a vec2
  58682. * @param uniform defines the webGL uniform location where to store the value
  58683. * @param x defines the 1st component of the value
  58684. * @param y defines the 2nd component of the value
  58685. * @returns true if value was set
  58686. */
  58687. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  58688. /**
  58689. * Set the value of an uniform to a vec3
  58690. * @param uniform defines the webGL uniform location where to store the value
  58691. * @param x defines the 1st component of the value
  58692. * @param y defines the 2nd component of the value
  58693. * @param z defines the 3rd component of the value
  58694. * @returns true if value was set
  58695. */
  58696. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  58697. /**
  58698. * Set the value of an uniform to a boolean
  58699. * @param uniform defines the webGL uniform location where to store the value
  58700. * @param bool defines the boolean to store
  58701. * @returns true if value was set
  58702. */
  58703. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  58704. /**
  58705. * Set the value of an uniform to a vec4
  58706. * @param uniform defines the webGL uniform location where to store the value
  58707. * @param x defines the 1st component of the value
  58708. * @param y defines the 2nd component of the value
  58709. * @param z defines the 3rd component of the value
  58710. * @param w defines the 4th component of the value
  58711. * @returns true if value was set
  58712. */
  58713. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  58714. /**
  58715. * Sets the current alpha mode
  58716. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  58717. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  58718. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58719. */
  58720. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  58721. /**
  58722. * Bind webGl buffers directly to the webGL context
  58723. * @param vertexBuffers defines the vertex buffer to bind
  58724. * @param indexBuffer defines the index buffer to bind
  58725. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  58726. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  58727. * @param effect defines the effect associated with the vertex buffer
  58728. */
  58729. bindBuffers(vertexBuffers: {
  58730. [key: string]: VertexBuffer;
  58731. }, indexBuffer: DataBuffer, effect: Effect): void;
  58732. /**
  58733. * Force the entire cache to be cleared
  58734. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  58735. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  58736. */
  58737. wipeCaches(bruteForce?: boolean): void;
  58738. /**
  58739. * Send a draw order
  58740. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  58741. * @param indexStart defines the starting index
  58742. * @param indexCount defines the number of index to draw
  58743. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58744. */
  58745. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  58746. /**
  58747. * Draw a list of indexed primitives
  58748. * @param fillMode defines the primitive to use
  58749. * @param indexStart defines the starting index
  58750. * @param indexCount defines the number of index to draw
  58751. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58752. */
  58753. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  58754. /**
  58755. * Draw a list of unindexed primitives
  58756. * @param fillMode defines the primitive to use
  58757. * @param verticesStart defines the index of first vertex to draw
  58758. * @param verticesCount defines the count of vertices to draw
  58759. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58760. */
  58761. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  58762. /** @hidden */
  58763. _createTexture(): WebGLTexture;
  58764. /** @hidden */
  58765. _releaseTexture(texture: InternalTexture): void;
  58766. /**
  58767. * Usually called from Texture.ts.
  58768. * Passed information to create a WebGLTexture
  58769. * @param urlArg defines a value which contains one of the following:
  58770. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  58771. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  58772. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  58773. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  58774. * @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)
  58775. * @param scene needed for loading to the correct scene
  58776. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  58777. * @param onLoad optional callback to be called upon successful completion
  58778. * @param onError optional callback to be called upon failure
  58779. * @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
  58780. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  58781. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  58782. * @param forcedExtension defines the extension to use to pick the right loader
  58783. * @param mimeType defines an optional mime type
  58784. * @returns a InternalTexture for assignment back into BABYLON.Texture
  58785. */
  58786. 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;
  58787. /**
  58788. * Creates a new render target texture
  58789. * @param size defines the size of the texture
  58790. * @param options defines the options used to create the texture
  58791. * @returns a new render target texture stored in an InternalTexture
  58792. */
  58793. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  58794. /**
  58795. * Update the sampling mode of a given texture
  58796. * @param samplingMode defines the required sampling mode
  58797. * @param texture defines the texture to update
  58798. */
  58799. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  58800. /**
  58801. * Binds the frame buffer to the specified texture.
  58802. * @param texture The texture to render to or null for the default canvas
  58803. * @param faceIndex The face of the texture to render to in case of cube texture
  58804. * @param requiredWidth The width of the target to render to
  58805. * @param requiredHeight The height of the target to render to
  58806. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  58807. * @param lodLevel defines le lod level to bind to the frame buffer
  58808. */
  58809. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  58810. /**
  58811. * Unbind the current render target texture from the webGL context
  58812. * @param texture defines the render target texture to unbind
  58813. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  58814. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  58815. */
  58816. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  58817. /**
  58818. * Creates a dynamic vertex buffer
  58819. * @param vertices the data for the dynamic vertex buffer
  58820. * @returns the new WebGL dynamic buffer
  58821. */
  58822. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  58823. /**
  58824. * Update the content of a dynamic texture
  58825. * @param texture defines the texture to update
  58826. * @param canvas defines the canvas containing the source
  58827. * @param invertY defines if data must be stored with Y axis inverted
  58828. * @param premulAlpha defines if alpha is stored as premultiplied
  58829. * @param format defines the format of the data
  58830. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  58831. */
  58832. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  58833. /**
  58834. * Gets a boolean indicating if all created effects are ready
  58835. * @returns true if all effects are ready
  58836. */
  58837. areAllEffectsReady(): boolean;
  58838. /**
  58839. * @hidden
  58840. * Get the current error code of the webGL context
  58841. * @returns the error code
  58842. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  58843. */
  58844. getError(): number;
  58845. /** @hidden */
  58846. _getUnpackAlignement(): number;
  58847. /** @hidden */
  58848. _unpackFlipY(value: boolean): void;
  58849. /**
  58850. * Update a dynamic index buffer
  58851. * @param indexBuffer defines the target index buffer
  58852. * @param indices defines the data to update
  58853. * @param offset defines the offset in the target index buffer where update should start
  58854. */
  58855. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  58856. /**
  58857. * Updates a dynamic vertex buffer.
  58858. * @param vertexBuffer the vertex buffer to update
  58859. * @param vertices the data used to update the vertex buffer
  58860. * @param byteOffset the byte offset of the data (optional)
  58861. * @param byteLength the byte length of the data (optional)
  58862. */
  58863. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  58864. /** @hidden */
  58865. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  58866. /** @hidden */
  58867. _bindTexture(channel: number, texture: InternalTexture): void;
  58868. protected _deleteBuffer(buffer: WebGLBuffer): void;
  58869. /**
  58870. * 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
  58871. */
  58872. releaseEffects(): void;
  58873. displayLoadingUI(): void;
  58874. hideLoadingUI(): void;
  58875. /** @hidden */
  58876. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58877. /** @hidden */
  58878. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58879. /** @hidden */
  58880. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58881. /** @hidden */
  58882. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  58883. }
  58884. }
  58885. declare module "babylonjs/Instrumentation/timeToken" {
  58886. import { Nullable } from "babylonjs/types";
  58887. /**
  58888. * @hidden
  58889. **/
  58890. export class _TimeToken {
  58891. _startTimeQuery: Nullable<WebGLQuery>;
  58892. _endTimeQuery: Nullable<WebGLQuery>;
  58893. _timeElapsedQuery: Nullable<WebGLQuery>;
  58894. _timeElapsedQueryEnded: boolean;
  58895. }
  58896. }
  58897. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  58898. import { Nullable, int } from "babylonjs/types";
  58899. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  58900. /** @hidden */
  58901. export class _OcclusionDataStorage {
  58902. /** @hidden */
  58903. occlusionInternalRetryCounter: number;
  58904. /** @hidden */
  58905. isOcclusionQueryInProgress: boolean;
  58906. /** @hidden */
  58907. isOccluded: boolean;
  58908. /** @hidden */
  58909. occlusionRetryCount: number;
  58910. /** @hidden */
  58911. occlusionType: number;
  58912. /** @hidden */
  58913. occlusionQueryAlgorithmType: number;
  58914. }
  58915. module "babylonjs/Engines/engine" {
  58916. interface Engine {
  58917. /**
  58918. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  58919. * @return the new query
  58920. */
  58921. createQuery(): WebGLQuery;
  58922. /**
  58923. * Delete and release a webGL query
  58924. * @param query defines the query to delete
  58925. * @return the current engine
  58926. */
  58927. deleteQuery(query: WebGLQuery): Engine;
  58928. /**
  58929. * Check if a given query has resolved and got its value
  58930. * @param query defines the query to check
  58931. * @returns true if the query got its value
  58932. */
  58933. isQueryResultAvailable(query: WebGLQuery): boolean;
  58934. /**
  58935. * Gets the value of a given query
  58936. * @param query defines the query to check
  58937. * @returns the value of the query
  58938. */
  58939. getQueryResult(query: WebGLQuery): number;
  58940. /**
  58941. * Initiates an occlusion query
  58942. * @param algorithmType defines the algorithm to use
  58943. * @param query defines the query to use
  58944. * @returns the current engine
  58945. * @see https://doc.babylonjs.com/features/occlusionquery
  58946. */
  58947. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  58948. /**
  58949. * Ends an occlusion query
  58950. * @see https://doc.babylonjs.com/features/occlusionquery
  58951. * @param algorithmType defines the algorithm to use
  58952. * @returns the current engine
  58953. */
  58954. endOcclusionQuery(algorithmType: number): Engine;
  58955. /**
  58956. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  58957. * Please note that only one query can be issued at a time
  58958. * @returns a time token used to track the time span
  58959. */
  58960. startTimeQuery(): Nullable<_TimeToken>;
  58961. /**
  58962. * Ends a time query
  58963. * @param token defines the token used to measure the time span
  58964. * @returns the time spent (in ns)
  58965. */
  58966. endTimeQuery(token: _TimeToken): int;
  58967. /** @hidden */
  58968. _currentNonTimestampToken: Nullable<_TimeToken>;
  58969. /** @hidden */
  58970. _createTimeQuery(): WebGLQuery;
  58971. /** @hidden */
  58972. _deleteTimeQuery(query: WebGLQuery): void;
  58973. /** @hidden */
  58974. _getGlAlgorithmType(algorithmType: number): number;
  58975. /** @hidden */
  58976. _getTimeQueryResult(query: WebGLQuery): any;
  58977. /** @hidden */
  58978. _getTimeQueryAvailability(query: WebGLQuery): any;
  58979. }
  58980. }
  58981. module "babylonjs/Meshes/abstractMesh" {
  58982. interface AbstractMesh {
  58983. /**
  58984. * Backing filed
  58985. * @hidden
  58986. */
  58987. __occlusionDataStorage: _OcclusionDataStorage;
  58988. /**
  58989. * Access property
  58990. * @hidden
  58991. */
  58992. _occlusionDataStorage: _OcclusionDataStorage;
  58993. /**
  58994. * 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.
  58995. * The default value is -1 which means don't break the query and wait till the result
  58996. * @see https://doc.babylonjs.com/features/occlusionquery
  58997. */
  58998. occlusionRetryCount: number;
  58999. /**
  59000. * 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:
  59001. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  59002. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  59003. * * 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.
  59004. * @see https://doc.babylonjs.com/features/occlusionquery
  59005. */
  59006. occlusionType: number;
  59007. /**
  59008. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  59009. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  59010. * * 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.
  59011. * @see https://doc.babylonjs.com/features/occlusionquery
  59012. */
  59013. occlusionQueryAlgorithmType: number;
  59014. /**
  59015. * 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
  59016. * @see https://doc.babylonjs.com/features/occlusionquery
  59017. */
  59018. isOccluded: boolean;
  59019. /**
  59020. * Flag to check the progress status of the query
  59021. * @see https://doc.babylonjs.com/features/occlusionquery
  59022. */
  59023. isOcclusionQueryInProgress: boolean;
  59024. }
  59025. }
  59026. }
  59027. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  59028. import { Nullable } from "babylonjs/types";
  59029. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  59030. /** @hidden */
  59031. export var _forceTransformFeedbackToBundle: boolean;
  59032. module "babylonjs/Engines/engine" {
  59033. interface Engine {
  59034. /**
  59035. * Creates a webGL transform feedback object
  59036. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  59037. * @returns the webGL transform feedback object
  59038. */
  59039. createTransformFeedback(): WebGLTransformFeedback;
  59040. /**
  59041. * Delete a webGL transform feedback object
  59042. * @param value defines the webGL transform feedback object to delete
  59043. */
  59044. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  59045. /**
  59046. * Bind a webGL transform feedback object to the webgl context
  59047. * @param value defines the webGL transform feedback object to bind
  59048. */
  59049. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  59050. /**
  59051. * Begins a transform feedback operation
  59052. * @param usePoints defines if points or triangles must be used
  59053. */
  59054. beginTransformFeedback(usePoints: boolean): void;
  59055. /**
  59056. * Ends a transform feedback operation
  59057. */
  59058. endTransformFeedback(): void;
  59059. /**
  59060. * Specify the varyings to use with transform feedback
  59061. * @param program defines the associated webGL program
  59062. * @param value defines the list of strings representing the varying names
  59063. */
  59064. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  59065. /**
  59066. * Bind a webGL buffer for a transform feedback operation
  59067. * @param value defines the webGL buffer to bind
  59068. */
  59069. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  59070. }
  59071. }
  59072. }
  59073. declare module "babylonjs/Engines/Extensions/engine.views" {
  59074. import { Camera } from "babylonjs/Cameras/camera";
  59075. import { Nullable } from "babylonjs/types";
  59076. /**
  59077. * Class used to define an additional view for the engine
  59078. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59079. */
  59080. export class EngineView {
  59081. /** Defines the canvas where to render the view */
  59082. target: HTMLCanvasElement;
  59083. /** Defines an optional camera used to render the view (will use active camera else) */
  59084. camera?: Camera;
  59085. }
  59086. module "babylonjs/Engines/engine" {
  59087. interface Engine {
  59088. /**
  59089. * Gets or sets the HTML element to use for attaching events
  59090. */
  59091. inputElement: Nullable<HTMLElement>;
  59092. /**
  59093. * Gets the current engine view
  59094. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59095. */
  59096. activeView: Nullable<EngineView>;
  59097. /** Gets or sets the list of views */
  59098. views: EngineView[];
  59099. /**
  59100. * Register a new child canvas
  59101. * @param canvas defines the canvas to register
  59102. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  59103. * @returns the associated view
  59104. */
  59105. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  59106. /**
  59107. * Remove a registered child canvas
  59108. * @param canvas defines the canvas to remove
  59109. * @returns the current engine
  59110. */
  59111. unRegisterView(canvas: HTMLCanvasElement): Engine;
  59112. }
  59113. }
  59114. }
  59115. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  59116. import { Nullable } from "babylonjs/types";
  59117. module "babylonjs/Engines/engine" {
  59118. interface Engine {
  59119. /** @hidden */
  59120. _excludedCompressedTextures: string[];
  59121. /** @hidden */
  59122. _textureFormatInUse: string;
  59123. /**
  59124. * Gets the list of texture formats supported
  59125. */
  59126. readonly texturesSupported: Array<string>;
  59127. /**
  59128. * Gets the texture format in use
  59129. */
  59130. readonly textureFormatInUse: Nullable<string>;
  59131. /**
  59132. * Set the compressed texture extensions or file names to skip.
  59133. *
  59134. * @param skippedFiles defines the list of those texture files you want to skip
  59135. * Example: [".dds", ".env", "myfile.png"]
  59136. */
  59137. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  59138. /**
  59139. * Set the compressed texture format to use, based on the formats you have, and the formats
  59140. * supported by the hardware / browser.
  59141. *
  59142. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  59143. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  59144. * to API arguments needed to compressed textures. This puts the burden on the container
  59145. * generator to house the arcane code for determining these for current & future formats.
  59146. *
  59147. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59148. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59149. *
  59150. * Note: The result of this call is not taken into account when a texture is base64.
  59151. *
  59152. * @param formatsAvailable defines the list of those format families you have created
  59153. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  59154. *
  59155. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  59156. * @returns The extension selected.
  59157. */
  59158. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  59159. }
  59160. }
  59161. }
  59162. declare module "babylonjs/Engines/Extensions/index" {
  59163. export * from "babylonjs/Engines/Extensions/engine.alpha";
  59164. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  59165. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  59166. export * from "babylonjs/Engines/Extensions/engine.multiview";
  59167. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  59168. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59169. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  59170. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  59171. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  59172. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  59173. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  59174. export * from "babylonjs/Engines/Extensions/engine.webVR";
  59175. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  59176. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  59177. export * from "babylonjs/Engines/Extensions/engine.views";
  59178. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  59179. import "babylonjs/Engines/Extensions/engine.textureSelector";
  59180. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  59181. }
  59182. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  59183. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59184. /** @hidden */
  59185. export var rgbdEncodePixelShader: {
  59186. name: string;
  59187. shader: string;
  59188. };
  59189. }
  59190. declare module "babylonjs/Misc/environmentTextureTools" {
  59191. import { Nullable } from "babylonjs/types";
  59192. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59193. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59194. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59195. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  59196. import "babylonjs/Engines/Extensions/engine.readTexture";
  59197. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  59198. import "babylonjs/Shaders/rgbdEncode.fragment";
  59199. import "babylonjs/Shaders/rgbdDecode.fragment";
  59200. /**
  59201. * Raw texture data and descriptor sufficient for WebGL texture upload
  59202. */
  59203. export interface EnvironmentTextureInfo {
  59204. /**
  59205. * Version of the environment map
  59206. */
  59207. version: number;
  59208. /**
  59209. * Width of image
  59210. */
  59211. width: number;
  59212. /**
  59213. * Irradiance information stored in the file.
  59214. */
  59215. irradiance: any;
  59216. /**
  59217. * Specular information stored in the file.
  59218. */
  59219. specular: any;
  59220. }
  59221. /**
  59222. * Defines One Image in the file. It requires only the position in the file
  59223. * as well as the length.
  59224. */
  59225. interface BufferImageData {
  59226. /**
  59227. * Length of the image data.
  59228. */
  59229. length: number;
  59230. /**
  59231. * Position of the data from the null terminator delimiting the end of the JSON.
  59232. */
  59233. position: number;
  59234. }
  59235. /**
  59236. * Defines the specular data enclosed in the file.
  59237. * This corresponds to the version 1 of the data.
  59238. */
  59239. export interface EnvironmentTextureSpecularInfoV1 {
  59240. /**
  59241. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  59242. */
  59243. specularDataPosition?: number;
  59244. /**
  59245. * This contains all the images data needed to reconstruct the cubemap.
  59246. */
  59247. mipmaps: Array<BufferImageData>;
  59248. /**
  59249. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  59250. */
  59251. lodGenerationScale: number;
  59252. }
  59253. /**
  59254. * Sets of helpers addressing the serialization and deserialization of environment texture
  59255. * stored in a BabylonJS env file.
  59256. * Those files are usually stored as .env files.
  59257. */
  59258. export class EnvironmentTextureTools {
  59259. /**
  59260. * Magic number identifying the env file.
  59261. */
  59262. private static _MagicBytes;
  59263. /**
  59264. * Gets the environment info from an env file.
  59265. * @param data The array buffer containing the .env bytes.
  59266. * @returns the environment file info (the json header) if successfully parsed.
  59267. */
  59268. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  59269. /**
  59270. * Creates an environment texture from a loaded cube texture.
  59271. * @param texture defines the cube texture to convert in env file
  59272. * @return a promise containing the environment data if succesfull.
  59273. */
  59274. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  59275. /**
  59276. * Creates a JSON representation of the spherical data.
  59277. * @param texture defines the texture containing the polynomials
  59278. * @return the JSON representation of the spherical info
  59279. */
  59280. private static _CreateEnvTextureIrradiance;
  59281. /**
  59282. * Creates the ArrayBufferViews used for initializing environment texture image data.
  59283. * @param data the image data
  59284. * @param info parameters that determine what views will be created for accessing the underlying buffer
  59285. * @return the views described by info providing access to the underlying buffer
  59286. */
  59287. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  59288. /**
  59289. * Uploads the texture info contained in the env file to the GPU.
  59290. * @param texture defines the internal texture to upload to
  59291. * @param data defines the data to load
  59292. * @param info defines the texture info retrieved through the GetEnvInfo method
  59293. * @returns a promise
  59294. */
  59295. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  59296. private static _OnImageReadyAsync;
  59297. /**
  59298. * Uploads the levels of image data to the GPU.
  59299. * @param texture defines the internal texture to upload to
  59300. * @param imageData defines the array buffer views of image data [mipmap][face]
  59301. * @returns a promise
  59302. */
  59303. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  59304. /**
  59305. * Uploads spherical polynomials information to the texture.
  59306. * @param texture defines the texture we are trying to upload the information to
  59307. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  59308. */
  59309. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  59310. /** @hidden */
  59311. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59312. }
  59313. }
  59314. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  59315. /**
  59316. * Class used to inline functions in shader code
  59317. */
  59318. export class ShaderCodeInliner {
  59319. private static readonly _RegexpFindFunctionNameAndType;
  59320. private _sourceCode;
  59321. private _functionDescr;
  59322. private _numMaxIterations;
  59323. /** Gets or sets the token used to mark the functions to inline */
  59324. inlineToken: string;
  59325. /** Gets or sets the debug mode */
  59326. debug: boolean;
  59327. /** Gets the code after the inlining process */
  59328. get code(): string;
  59329. /**
  59330. * Initializes the inliner
  59331. * @param sourceCode shader code source to inline
  59332. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  59333. */
  59334. constructor(sourceCode: string, numMaxIterations?: number);
  59335. /**
  59336. * Start the processing of the shader code
  59337. */
  59338. processCode(): void;
  59339. private _collectFunctions;
  59340. private _processInlining;
  59341. private _extractBetweenMarkers;
  59342. private _skipWhitespaces;
  59343. private _removeComments;
  59344. private _replaceFunctionCallsByCode;
  59345. private _findBackward;
  59346. private _escapeRegExp;
  59347. private _replaceNames;
  59348. }
  59349. }
  59350. declare module "babylonjs/Engines/nativeEngine" {
  59351. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  59352. import { Engine } from "babylonjs/Engines/engine";
  59353. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  59354. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59355. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59356. import { Effect } from "babylonjs/Materials/effect";
  59357. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  59358. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  59359. import { IColor4Like } from "babylonjs/Maths/math.like";
  59360. import { Scene } from "babylonjs/scene";
  59361. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  59362. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  59363. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  59364. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  59365. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  59366. /**
  59367. * Container for accessors for natively-stored mesh data buffers.
  59368. */
  59369. class NativeDataBuffer extends DataBuffer {
  59370. /**
  59371. * Accessor value used to identify/retrieve a natively-stored index buffer.
  59372. */
  59373. nativeIndexBuffer?: any;
  59374. /**
  59375. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  59376. */
  59377. nativeVertexBuffer?: any;
  59378. }
  59379. /** @hidden */
  59380. class NativeTexture extends InternalTexture {
  59381. getInternalTexture(): InternalTexture;
  59382. getViewCount(): number;
  59383. }
  59384. /** @hidden */
  59385. export class NativeEngine extends Engine {
  59386. private readonly _native;
  59387. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  59388. private readonly INVALID_HANDLE;
  59389. private _boundBuffersVertexArray;
  59390. private _currentDepthTest;
  59391. getHardwareScalingLevel(): number;
  59392. constructor();
  59393. dispose(): void;
  59394. /**
  59395. * Can be used to override the current requestAnimationFrame requester.
  59396. * @hidden
  59397. */
  59398. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  59399. /**
  59400. * Override default engine behavior.
  59401. * @param color
  59402. * @param backBuffer
  59403. * @param depth
  59404. * @param stencil
  59405. */
  59406. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  59407. /**
  59408. * Gets host document
  59409. * @returns the host document object
  59410. */
  59411. getHostDocument(): Nullable<Document>;
  59412. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59413. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  59414. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  59415. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  59416. [key: string]: VertexBuffer;
  59417. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59418. bindBuffers(vertexBuffers: {
  59419. [key: string]: VertexBuffer;
  59420. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59421. recordVertexArrayObject(vertexBuffers: {
  59422. [key: string]: VertexBuffer;
  59423. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  59424. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59425. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59426. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59427. /**
  59428. * Draw a list of indexed primitives
  59429. * @param fillMode defines the primitive to use
  59430. * @param indexStart defines the starting index
  59431. * @param indexCount defines the number of index to draw
  59432. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59433. */
  59434. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59435. /**
  59436. * Draw a list of unindexed primitives
  59437. * @param fillMode defines the primitive to use
  59438. * @param verticesStart defines the index of first vertex to draw
  59439. * @param verticesCount defines the count of vertices to draw
  59440. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59441. */
  59442. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59443. createPipelineContext(): IPipelineContext;
  59444. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  59445. /** @hidden */
  59446. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  59447. /** @hidden */
  59448. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  59449. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  59450. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  59451. protected _setProgram(program: WebGLProgram): void;
  59452. _releaseEffect(effect: Effect): void;
  59453. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  59454. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  59455. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  59456. bindSamplers(effect: Effect): void;
  59457. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  59458. getRenderWidth(useScreen?: boolean): number;
  59459. getRenderHeight(useScreen?: boolean): number;
  59460. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  59461. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  59462. /**
  59463. * Set the z offset to apply to current rendering
  59464. * @param value defines the offset to apply
  59465. */
  59466. setZOffset(value: number): void;
  59467. /**
  59468. * Gets the current value of the zOffset
  59469. * @returns the current zOffset state
  59470. */
  59471. getZOffset(): number;
  59472. /**
  59473. * Enable or disable depth buffering
  59474. * @param enable defines the state to set
  59475. */
  59476. setDepthBuffer(enable: boolean): void;
  59477. /**
  59478. * Gets a boolean indicating if depth writing is enabled
  59479. * @returns the current depth writing state
  59480. */
  59481. getDepthWrite(): boolean;
  59482. setDepthFunctionToGreater(): void;
  59483. setDepthFunctionToGreaterOrEqual(): void;
  59484. setDepthFunctionToLess(): void;
  59485. setDepthFunctionToLessOrEqual(): void;
  59486. /**
  59487. * Enable or disable depth writing
  59488. * @param enable defines the state to set
  59489. */
  59490. setDepthWrite(enable: boolean): void;
  59491. /**
  59492. * Enable or disable color writing
  59493. * @param enable defines the state to set
  59494. */
  59495. setColorWrite(enable: boolean): void;
  59496. /**
  59497. * Gets a boolean indicating if color writing is enabled
  59498. * @returns the current color writing state
  59499. */
  59500. getColorWrite(): boolean;
  59501. /**
  59502. * Sets alpha constants used by some alpha blending modes
  59503. * @param r defines the red component
  59504. * @param g defines the green component
  59505. * @param b defines the blue component
  59506. * @param a defines the alpha component
  59507. */
  59508. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  59509. /**
  59510. * Sets the current alpha mode
  59511. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  59512. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59513. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59514. */
  59515. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59516. /**
  59517. * Gets the current alpha mode
  59518. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59519. * @returns the current alpha mode
  59520. */
  59521. getAlphaMode(): number;
  59522. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  59523. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59524. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59525. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59526. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59527. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59528. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59529. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59530. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59531. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59532. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59533. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59534. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59535. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59536. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59537. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59538. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59539. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59540. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59541. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59542. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  59543. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  59544. wipeCaches(bruteForce?: boolean): void;
  59545. _createTexture(): WebGLTexture;
  59546. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  59547. /**
  59548. * Update the content of a dynamic texture
  59549. * @param texture defines the texture to update
  59550. * @param canvas defines the canvas containing the source
  59551. * @param invertY defines if data must be stored with Y axis inverted
  59552. * @param premulAlpha defines if alpha is stored as premultiplied
  59553. * @param format defines the format of the data
  59554. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  59555. */
  59556. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  59557. /**
  59558. * Usually called from Texture.ts.
  59559. * Passed information to create a WebGLTexture
  59560. * @param url defines a value which contains one of the following:
  59561. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59562. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59563. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59564. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59565. * @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)
  59566. * @param scene needed for loading to the correct scene
  59567. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59568. * @param onLoad optional callback to be called upon successful completion
  59569. * @param onError optional callback to be called upon failure
  59570. * @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
  59571. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59572. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59573. * @param forcedExtension defines the extension to use to pick the right loader
  59574. * @param mimeType defines an optional mime type
  59575. * @param loaderOptions options to be passed to the loader
  59576. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59577. */
  59578. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  59579. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  59580. _releaseFramebufferObjects(texture: InternalTexture): void;
  59581. /**
  59582. * Creates a cube texture
  59583. * @param rootUrl defines the url where the files to load is located
  59584. * @param scene defines the current scene
  59585. * @param files defines the list of files to load (1 per face)
  59586. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  59587. * @param onLoad defines an optional callback raised when the texture is loaded
  59588. * @param onError defines an optional callback raised if there is an issue to load the texture
  59589. * @param format defines the format of the data
  59590. * @param forcedExtension defines the extension to use to pick the right loader
  59591. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  59592. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59593. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59594. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  59595. * @returns the cube texture as an InternalTexture
  59596. */
  59597. 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;
  59598. createRenderTargetTexture(size: number | {
  59599. width: number;
  59600. height: number;
  59601. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  59602. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59603. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  59604. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  59605. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  59606. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  59607. /**
  59608. * Updates a dynamic vertex buffer.
  59609. * @param vertexBuffer the vertex buffer to update
  59610. * @param data the data used to update the vertex buffer
  59611. * @param byteOffset the byte offset of the data (optional)
  59612. * @param byteLength the byte length of the data (optional)
  59613. */
  59614. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  59615. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  59616. private _updateAnisotropicLevel;
  59617. private _getAddressMode;
  59618. /** @hidden */
  59619. _bindTexture(channel: number, texture: InternalTexture): void;
  59620. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  59621. releaseEffects(): void;
  59622. /** @hidden */
  59623. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59624. /** @hidden */
  59625. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59626. /** @hidden */
  59627. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59628. /** @hidden */
  59629. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  59630. private _getNativeSamplingMode;
  59631. private _getNativeTextureFormat;
  59632. private _getNativeAlphaMode;
  59633. private _getNativeAttribType;
  59634. }
  59635. }
  59636. declare module "babylonjs/Engines/index" {
  59637. export * from "babylonjs/Engines/constants";
  59638. export * from "babylonjs/Engines/engineCapabilities";
  59639. export * from "babylonjs/Engines/instancingAttributeInfo";
  59640. export * from "babylonjs/Engines/thinEngine";
  59641. export * from "babylonjs/Engines/engine";
  59642. export * from "babylonjs/Engines/engineStore";
  59643. export * from "babylonjs/Engines/nullEngine";
  59644. export * from "babylonjs/Engines/Extensions/index";
  59645. export * from "babylonjs/Engines/IPipelineContext";
  59646. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  59647. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  59648. export * from "babylonjs/Engines/nativeEngine";
  59649. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  59650. export * from "babylonjs/Engines/performanceConfigurator";
  59651. }
  59652. declare module "babylonjs/Events/clipboardEvents" {
  59653. /**
  59654. * Gather the list of clipboard event types as constants.
  59655. */
  59656. export class ClipboardEventTypes {
  59657. /**
  59658. * The clipboard event is fired when a copy command is active (pressed).
  59659. */
  59660. static readonly COPY: number;
  59661. /**
  59662. * The clipboard event is fired when a cut command is active (pressed).
  59663. */
  59664. static readonly CUT: number;
  59665. /**
  59666. * The clipboard event is fired when a paste command is active (pressed).
  59667. */
  59668. static readonly PASTE: number;
  59669. }
  59670. /**
  59671. * This class is used to store clipboard related info for the onClipboardObservable event.
  59672. */
  59673. export class ClipboardInfo {
  59674. /**
  59675. * Defines the type of event (BABYLON.ClipboardEventTypes)
  59676. */
  59677. type: number;
  59678. /**
  59679. * Defines the related dom event
  59680. */
  59681. event: ClipboardEvent;
  59682. /**
  59683. *Creates an instance of ClipboardInfo.
  59684. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  59685. * @param event Defines the related dom event
  59686. */
  59687. constructor(
  59688. /**
  59689. * Defines the type of event (BABYLON.ClipboardEventTypes)
  59690. */
  59691. type: number,
  59692. /**
  59693. * Defines the related dom event
  59694. */
  59695. event: ClipboardEvent);
  59696. /**
  59697. * Get the clipboard event's type from the keycode.
  59698. * @param keyCode Defines the keyCode for the current keyboard event.
  59699. * @return {number}
  59700. */
  59701. static GetTypeFromCharacter(keyCode: number): number;
  59702. }
  59703. }
  59704. declare module "babylonjs/Events/index" {
  59705. export * from "babylonjs/Events/keyboardEvents";
  59706. export * from "babylonjs/Events/pointerEvents";
  59707. export * from "babylonjs/Events/clipboardEvents";
  59708. }
  59709. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  59710. import { Scene } from "babylonjs/scene";
  59711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59712. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59713. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59714. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59715. /**
  59716. * Google Daydream controller
  59717. */
  59718. export class DaydreamController extends WebVRController {
  59719. /**
  59720. * Base Url for the controller model.
  59721. */
  59722. static MODEL_BASE_URL: string;
  59723. /**
  59724. * File name for the controller model.
  59725. */
  59726. static MODEL_FILENAME: string;
  59727. /**
  59728. * Gamepad Id prefix used to identify Daydream Controller.
  59729. */
  59730. static readonly GAMEPAD_ID_PREFIX: string;
  59731. /**
  59732. * Creates a new DaydreamController from a gamepad
  59733. * @param vrGamepad the gamepad that the controller should be created from
  59734. */
  59735. constructor(vrGamepad: any);
  59736. /**
  59737. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59738. * @param scene scene in which to add meshes
  59739. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59740. */
  59741. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59742. /**
  59743. * Called once for each button that changed state since the last frame
  59744. * @param buttonIdx Which button index changed
  59745. * @param state New state of the button
  59746. * @param changes Which properties on the state changed since last frame
  59747. */
  59748. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59749. }
  59750. }
  59751. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  59752. import { Scene } from "babylonjs/scene";
  59753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59754. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59755. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59756. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59757. /**
  59758. * Gear VR Controller
  59759. */
  59760. export class GearVRController extends WebVRController {
  59761. /**
  59762. * Base Url for the controller model.
  59763. */
  59764. static MODEL_BASE_URL: string;
  59765. /**
  59766. * File name for the controller model.
  59767. */
  59768. static MODEL_FILENAME: string;
  59769. /**
  59770. * Gamepad Id prefix used to identify this controller.
  59771. */
  59772. static readonly GAMEPAD_ID_PREFIX: string;
  59773. private readonly _buttonIndexToObservableNameMap;
  59774. /**
  59775. * Creates a new GearVRController from a gamepad
  59776. * @param vrGamepad the gamepad that the controller should be created from
  59777. */
  59778. constructor(vrGamepad: any);
  59779. /**
  59780. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59781. * @param scene scene in which to add meshes
  59782. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59783. */
  59784. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59785. /**
  59786. * Called once for each button that changed state since the last frame
  59787. * @param buttonIdx Which button index changed
  59788. * @param state New state of the button
  59789. * @param changes Which properties on the state changed since last frame
  59790. */
  59791. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59792. }
  59793. }
  59794. declare module "babylonjs/Gamepads/Controllers/genericController" {
  59795. import { Scene } from "babylonjs/scene";
  59796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59797. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59798. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59799. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59800. /**
  59801. * Generic Controller
  59802. */
  59803. export class GenericController extends WebVRController {
  59804. /**
  59805. * Base Url for the controller model.
  59806. */
  59807. static readonly MODEL_BASE_URL: string;
  59808. /**
  59809. * File name for the controller model.
  59810. */
  59811. static readonly MODEL_FILENAME: string;
  59812. /**
  59813. * Creates a new GenericController from a gamepad
  59814. * @param vrGamepad the gamepad that the controller should be created from
  59815. */
  59816. constructor(vrGamepad: any);
  59817. /**
  59818. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59819. * @param scene scene in which to add meshes
  59820. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59821. */
  59822. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59823. /**
  59824. * Called once for each button that changed state since the last frame
  59825. * @param buttonIdx Which button index changed
  59826. * @param state New state of the button
  59827. * @param changes Which properties on the state changed since last frame
  59828. */
  59829. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59830. }
  59831. }
  59832. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  59833. import { Observable } from "babylonjs/Misc/observable";
  59834. import { Scene } from "babylonjs/scene";
  59835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59836. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59837. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59838. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59839. /**
  59840. * Oculus Touch Controller
  59841. */
  59842. export class OculusTouchController extends WebVRController {
  59843. /**
  59844. * Base Url for the controller model.
  59845. */
  59846. static MODEL_BASE_URL: string;
  59847. /**
  59848. * File name for the left controller model.
  59849. */
  59850. static MODEL_LEFT_FILENAME: string;
  59851. /**
  59852. * File name for the right controller model.
  59853. */
  59854. static MODEL_RIGHT_FILENAME: string;
  59855. /**
  59856. * Base Url for the Quest controller model.
  59857. */
  59858. static QUEST_MODEL_BASE_URL: string;
  59859. /**
  59860. * @hidden
  59861. * If the controllers are running on a device that needs the updated Quest controller models
  59862. */
  59863. static _IsQuest: boolean;
  59864. /**
  59865. * Fired when the secondary trigger on this controller is modified
  59866. */
  59867. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  59868. /**
  59869. * Fired when the thumb rest on this controller is modified
  59870. */
  59871. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  59872. /**
  59873. * Creates a new OculusTouchController from a gamepad
  59874. * @param vrGamepad the gamepad that the controller should be created from
  59875. */
  59876. constructor(vrGamepad: any);
  59877. /**
  59878. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59879. * @param scene scene in which to add meshes
  59880. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59881. */
  59882. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59883. /**
  59884. * Fired when the A button on this controller is modified
  59885. */
  59886. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59887. /**
  59888. * Fired when the B button on this controller is modified
  59889. */
  59890. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59891. /**
  59892. * Fired when the X button on this controller is modified
  59893. */
  59894. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59895. /**
  59896. * Fired when the Y button on this controller is modified
  59897. */
  59898. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59899. /**
  59900. * Called once for each button that changed state since the last frame
  59901. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  59902. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  59903. * 2) secondary trigger (same)
  59904. * 3) A (right) X (left), touch, pressed = value
  59905. * 4) B / Y
  59906. * 5) thumb rest
  59907. * @param buttonIdx Which button index changed
  59908. * @param state New state of the button
  59909. * @param changes Which properties on the state changed since last frame
  59910. */
  59911. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59912. }
  59913. }
  59914. declare module "babylonjs/Gamepads/Controllers/viveController" {
  59915. import { Scene } from "babylonjs/scene";
  59916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59917. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59918. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59919. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59920. import { Observable } from "babylonjs/Misc/observable";
  59921. /**
  59922. * Vive Controller
  59923. */
  59924. export class ViveController extends WebVRController {
  59925. /**
  59926. * Base Url for the controller model.
  59927. */
  59928. static MODEL_BASE_URL: string;
  59929. /**
  59930. * File name for the controller model.
  59931. */
  59932. static MODEL_FILENAME: string;
  59933. /**
  59934. * Creates a new ViveController from a gamepad
  59935. * @param vrGamepad the gamepad that the controller should be created from
  59936. */
  59937. constructor(vrGamepad: any);
  59938. /**
  59939. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59940. * @param scene scene in which to add meshes
  59941. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59942. */
  59943. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59944. /**
  59945. * Fired when the left button on this controller is modified
  59946. */
  59947. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59948. /**
  59949. * Fired when the right button on this controller is modified
  59950. */
  59951. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59952. /**
  59953. * Fired when the menu button on this controller is modified
  59954. */
  59955. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59956. /**
  59957. * Called once for each button that changed state since the last frame
  59958. * Vive mapping:
  59959. * 0: touchpad
  59960. * 1: trigger
  59961. * 2: left AND right buttons
  59962. * 3: menu button
  59963. * @param buttonIdx Which button index changed
  59964. * @param state New state of the button
  59965. * @param changes Which properties on the state changed since last frame
  59966. */
  59967. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59968. }
  59969. }
  59970. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  59971. import { Observable } from "babylonjs/Misc/observable";
  59972. import { Scene } from "babylonjs/scene";
  59973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59974. import { Ray } from "babylonjs/Culling/ray";
  59975. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59976. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59977. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59978. /**
  59979. * Defines the WindowsMotionController object that the state of the windows motion controller
  59980. */
  59981. export class WindowsMotionController extends WebVRController {
  59982. /**
  59983. * The base url used to load the left and right controller models
  59984. */
  59985. static MODEL_BASE_URL: string;
  59986. /**
  59987. * The name of the left controller model file
  59988. */
  59989. static MODEL_LEFT_FILENAME: string;
  59990. /**
  59991. * The name of the right controller model file
  59992. */
  59993. static MODEL_RIGHT_FILENAME: string;
  59994. /**
  59995. * The controller name prefix for this controller type
  59996. */
  59997. static readonly GAMEPAD_ID_PREFIX: string;
  59998. /**
  59999. * The controller id pattern for this controller type
  60000. */
  60001. private static readonly GAMEPAD_ID_PATTERN;
  60002. private _loadedMeshInfo;
  60003. protected readonly _mapping: {
  60004. buttons: string[];
  60005. buttonMeshNames: {
  60006. trigger: string;
  60007. menu: string;
  60008. grip: string;
  60009. thumbstick: string;
  60010. trackpad: string;
  60011. };
  60012. buttonObservableNames: {
  60013. trigger: string;
  60014. menu: string;
  60015. grip: string;
  60016. thumbstick: string;
  60017. trackpad: string;
  60018. };
  60019. axisMeshNames: string[];
  60020. pointingPoseMeshName: string;
  60021. };
  60022. /**
  60023. * Fired when the trackpad on this controller is clicked
  60024. */
  60025. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60026. /**
  60027. * Fired when the trackpad on this controller is modified
  60028. */
  60029. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60030. /**
  60031. * The current x and y values of this controller's trackpad
  60032. */
  60033. trackpad: StickValues;
  60034. /**
  60035. * Creates a new WindowsMotionController from a gamepad
  60036. * @param vrGamepad the gamepad that the controller should be created from
  60037. */
  60038. constructor(vrGamepad: any);
  60039. /**
  60040. * Fired when the trigger on this controller is modified
  60041. */
  60042. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60043. /**
  60044. * Fired when the menu button on this controller is modified
  60045. */
  60046. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60047. /**
  60048. * Fired when the grip button on this controller is modified
  60049. */
  60050. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60051. /**
  60052. * Fired when the thumbstick button on this controller is modified
  60053. */
  60054. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60055. /**
  60056. * Fired when the touchpad button on this controller is modified
  60057. */
  60058. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60059. /**
  60060. * Fired when the touchpad values on this controller are modified
  60061. */
  60062. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  60063. protected _updateTrackpad(): void;
  60064. /**
  60065. * Called once per frame by the engine.
  60066. */
  60067. update(): void;
  60068. /**
  60069. * Called once for each button that changed state since the last frame
  60070. * @param buttonIdx Which button index changed
  60071. * @param state New state of the button
  60072. * @param changes Which properties on the state changed since last frame
  60073. */
  60074. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60075. /**
  60076. * Moves the buttons on the controller mesh based on their current state
  60077. * @param buttonName the name of the button to move
  60078. * @param buttonValue the value of the button which determines the buttons new position
  60079. */
  60080. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  60081. /**
  60082. * Moves the axis on the controller mesh based on its current state
  60083. * @param axis the index of the axis
  60084. * @param axisValue the value of the axis which determines the meshes new position
  60085. * @hidden
  60086. */
  60087. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  60088. /**
  60089. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60090. * @param scene scene in which to add meshes
  60091. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60092. */
  60093. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  60094. /**
  60095. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  60096. * can be transformed by button presses and axes values, based on this._mapping.
  60097. *
  60098. * @param scene scene in which the meshes exist
  60099. * @param meshes list of meshes that make up the controller model to process
  60100. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  60101. */
  60102. private processModel;
  60103. private createMeshInfo;
  60104. /**
  60105. * Gets the ray of the controller in the direction the controller is pointing
  60106. * @param length the length the resulting ray should be
  60107. * @returns a ray in the direction the controller is pointing
  60108. */
  60109. getForwardRay(length?: number): Ray;
  60110. /**
  60111. * Disposes of the controller
  60112. */
  60113. dispose(): void;
  60114. }
  60115. /**
  60116. * This class represents a new windows motion controller in XR.
  60117. */
  60118. export class XRWindowsMotionController extends WindowsMotionController {
  60119. /**
  60120. * Changing the original WIndowsMotionController mapping to fir the new mapping
  60121. */
  60122. protected readonly _mapping: {
  60123. buttons: string[];
  60124. buttonMeshNames: {
  60125. trigger: string;
  60126. menu: string;
  60127. grip: string;
  60128. thumbstick: string;
  60129. trackpad: string;
  60130. };
  60131. buttonObservableNames: {
  60132. trigger: string;
  60133. menu: string;
  60134. grip: string;
  60135. thumbstick: string;
  60136. trackpad: string;
  60137. };
  60138. axisMeshNames: string[];
  60139. pointingPoseMeshName: string;
  60140. };
  60141. /**
  60142. * Construct a new XR-Based windows motion controller
  60143. *
  60144. * @param gamepadInfo the gamepad object from the browser
  60145. */
  60146. constructor(gamepadInfo: any);
  60147. /**
  60148. * holds the thumbstick values (X,Y)
  60149. */
  60150. thumbstickValues: StickValues;
  60151. /**
  60152. * Fired when the thumbstick on this controller is clicked
  60153. */
  60154. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  60155. /**
  60156. * Fired when the thumbstick on this controller is modified
  60157. */
  60158. onThumbstickValuesChangedObservable: Observable<StickValues>;
  60159. /**
  60160. * Fired when the touchpad button on this controller is modified
  60161. */
  60162. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60163. /**
  60164. * Fired when the touchpad values on this controller are modified
  60165. */
  60166. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60167. /**
  60168. * Fired when the thumbstick button on this controller is modified
  60169. * here to prevent breaking changes
  60170. */
  60171. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60172. /**
  60173. * updating the thumbstick(!) and not the trackpad.
  60174. * This is named this way due to the difference between WebVR and XR and to avoid
  60175. * changing the parent class.
  60176. */
  60177. protected _updateTrackpad(): void;
  60178. /**
  60179. * Disposes the class with joy
  60180. */
  60181. dispose(): void;
  60182. }
  60183. }
  60184. declare module "babylonjs/Gamepads/Controllers/index" {
  60185. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  60186. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  60187. export * from "babylonjs/Gamepads/Controllers/genericController";
  60188. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  60189. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  60190. export * from "babylonjs/Gamepads/Controllers/viveController";
  60191. export * from "babylonjs/Gamepads/Controllers/webVRController";
  60192. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  60193. }
  60194. declare module "babylonjs/Gamepads/index" {
  60195. export * from "babylonjs/Gamepads/Controllers/index";
  60196. export * from "babylonjs/Gamepads/gamepad";
  60197. export * from "babylonjs/Gamepads/gamepadManager";
  60198. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  60199. export * from "babylonjs/Gamepads/xboxGamepad";
  60200. export * from "babylonjs/Gamepads/dualShockGamepad";
  60201. }
  60202. declare module "babylonjs/Lights/directionalLight" {
  60203. import { Camera } from "babylonjs/Cameras/camera";
  60204. import { Scene } from "babylonjs/scene";
  60205. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60207. import { Light } from "babylonjs/Lights/light";
  60208. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  60209. import { Effect } from "babylonjs/Materials/effect";
  60210. /**
  60211. * A directional light is defined by a direction (what a surprise!).
  60212. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  60213. * 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.
  60214. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60215. */
  60216. export class DirectionalLight extends ShadowLight {
  60217. private _shadowFrustumSize;
  60218. /**
  60219. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  60220. */
  60221. get shadowFrustumSize(): number;
  60222. /**
  60223. * Specifies a fix frustum size for the shadow generation.
  60224. */
  60225. set shadowFrustumSize(value: number);
  60226. private _shadowOrthoScale;
  60227. /**
  60228. * Gets the shadow projection scale against the optimal computed one.
  60229. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60230. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60231. */
  60232. get shadowOrthoScale(): number;
  60233. /**
  60234. * Sets the shadow projection scale against the optimal computed one.
  60235. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60236. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60237. */
  60238. set shadowOrthoScale(value: number);
  60239. /**
  60240. * Automatically compute the projection matrix to best fit (including all the casters)
  60241. * on each frame.
  60242. */
  60243. autoUpdateExtends: boolean;
  60244. /**
  60245. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  60246. * on each frame. autoUpdateExtends must be set to true for this to work
  60247. */
  60248. autoCalcShadowZBounds: boolean;
  60249. private _orthoLeft;
  60250. private _orthoRight;
  60251. private _orthoTop;
  60252. private _orthoBottom;
  60253. /**
  60254. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  60255. * The directional light is emitted from everywhere in the given direction.
  60256. * It can cast shadows.
  60257. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60258. * @param name The friendly name of the light
  60259. * @param direction The direction of the light
  60260. * @param scene The scene the light belongs to
  60261. */
  60262. constructor(name: string, direction: Vector3, scene: Scene);
  60263. /**
  60264. * Returns the string "DirectionalLight".
  60265. * @return The class name
  60266. */
  60267. getClassName(): string;
  60268. /**
  60269. * Returns the integer 1.
  60270. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60271. */
  60272. getTypeID(): number;
  60273. /**
  60274. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  60275. * Returns the DirectionalLight Shadow projection matrix.
  60276. */
  60277. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60278. /**
  60279. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  60280. * Returns the DirectionalLight Shadow projection matrix.
  60281. */
  60282. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  60283. /**
  60284. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  60285. * Returns the DirectionalLight Shadow projection matrix.
  60286. */
  60287. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60288. protected _buildUniformLayout(): void;
  60289. /**
  60290. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  60291. * @param effect The effect to update
  60292. * @param lightIndex The index of the light in the effect to update
  60293. * @returns The directional light
  60294. */
  60295. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  60296. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  60297. /**
  60298. * Gets the minZ used for shadow according to both the scene and the light.
  60299. *
  60300. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60301. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60302. * @param activeCamera The camera we are returning the min for
  60303. * @returns the depth min z
  60304. */
  60305. getDepthMinZ(activeCamera: Camera): number;
  60306. /**
  60307. * Gets the maxZ used for shadow according to both the scene and the light.
  60308. *
  60309. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60310. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60311. * @param activeCamera The camera we are returning the max for
  60312. * @returns the depth max z
  60313. */
  60314. getDepthMaxZ(activeCamera: Camera): number;
  60315. /**
  60316. * Prepares the list of defines specific to the light type.
  60317. * @param defines the list of defines
  60318. * @param lightIndex defines the index of the light for the effect
  60319. */
  60320. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60321. }
  60322. }
  60323. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  60324. import { Mesh } from "babylonjs/Meshes/mesh";
  60325. /**
  60326. * Class containing static functions to help procedurally build meshes
  60327. */
  60328. export class HemisphereBuilder {
  60329. /**
  60330. * Creates a hemisphere mesh
  60331. * @param name defines the name of the mesh
  60332. * @param options defines the options used to create the mesh
  60333. * @param scene defines the hosting scene
  60334. * @returns the hemisphere mesh
  60335. */
  60336. static CreateHemisphere(name: string, options: {
  60337. segments?: number;
  60338. diameter?: number;
  60339. sideOrientation?: number;
  60340. }, scene: any): Mesh;
  60341. }
  60342. }
  60343. declare module "babylonjs/Lights/spotLight" {
  60344. import { Nullable } from "babylonjs/types";
  60345. import { Scene } from "babylonjs/scene";
  60346. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60348. import { Effect } from "babylonjs/Materials/effect";
  60349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60350. import { Light } from "babylonjs/Lights/light";
  60351. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  60352. /**
  60353. * A spot light is defined by a position, a direction, an angle, and an exponent.
  60354. * These values define a cone of light starting from the position, emitting toward the direction.
  60355. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  60356. * and the exponent defines the speed of the decay of the light with distance (reach).
  60357. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60358. */
  60359. export class SpotLight extends ShadowLight {
  60360. private _angle;
  60361. private _innerAngle;
  60362. private _cosHalfAngle;
  60363. private _lightAngleScale;
  60364. private _lightAngleOffset;
  60365. /**
  60366. * Gets the cone angle of the spot light in Radians.
  60367. */
  60368. get angle(): number;
  60369. /**
  60370. * Sets the cone angle of the spot light in Radians.
  60371. */
  60372. set angle(value: number);
  60373. /**
  60374. * Only used in gltf falloff mode, this defines the angle where
  60375. * the directional falloff will start before cutting at angle which could be seen
  60376. * as outer angle.
  60377. */
  60378. get innerAngle(): number;
  60379. /**
  60380. * Only used in gltf falloff mode, this defines the angle where
  60381. * the directional falloff will start before cutting at angle which could be seen
  60382. * as outer angle.
  60383. */
  60384. set innerAngle(value: number);
  60385. private _shadowAngleScale;
  60386. /**
  60387. * Allows scaling the angle of the light for shadow generation only.
  60388. */
  60389. get shadowAngleScale(): number;
  60390. /**
  60391. * Allows scaling the angle of the light for shadow generation only.
  60392. */
  60393. set shadowAngleScale(value: number);
  60394. /**
  60395. * The light decay speed with the distance from the emission spot.
  60396. */
  60397. exponent: number;
  60398. private _projectionTextureMatrix;
  60399. /**
  60400. * Allows reading the projecton texture
  60401. */
  60402. get projectionTextureMatrix(): Matrix;
  60403. protected _projectionTextureLightNear: number;
  60404. /**
  60405. * Gets the near clip of the Spotlight for texture projection.
  60406. */
  60407. get projectionTextureLightNear(): number;
  60408. /**
  60409. * Sets the near clip of the Spotlight for texture projection.
  60410. */
  60411. set projectionTextureLightNear(value: number);
  60412. protected _projectionTextureLightFar: number;
  60413. /**
  60414. * Gets the far clip of the Spotlight for texture projection.
  60415. */
  60416. get projectionTextureLightFar(): number;
  60417. /**
  60418. * Sets the far clip of the Spotlight for texture projection.
  60419. */
  60420. set projectionTextureLightFar(value: number);
  60421. protected _projectionTextureUpDirection: Vector3;
  60422. /**
  60423. * Gets the Up vector of the Spotlight for texture projection.
  60424. */
  60425. get projectionTextureUpDirection(): Vector3;
  60426. /**
  60427. * Sets the Up vector of the Spotlight for texture projection.
  60428. */
  60429. set projectionTextureUpDirection(value: Vector3);
  60430. private _projectionTexture;
  60431. /**
  60432. * Gets the projection texture of the light.
  60433. */
  60434. get projectionTexture(): Nullable<BaseTexture>;
  60435. /**
  60436. * Sets the projection texture of the light.
  60437. */
  60438. set projectionTexture(value: Nullable<BaseTexture>);
  60439. private static _IsProceduralTexture;
  60440. private static _IsTexture;
  60441. private _projectionTextureViewLightDirty;
  60442. private _projectionTextureProjectionLightDirty;
  60443. private _projectionTextureDirty;
  60444. private _projectionTextureViewTargetVector;
  60445. private _projectionTextureViewLightMatrix;
  60446. private _projectionTextureProjectionLightMatrix;
  60447. private _projectionTextureScalingMatrix;
  60448. /**
  60449. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  60450. * It can cast shadows.
  60451. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60452. * @param name The light friendly name
  60453. * @param position The position of the spot light in the scene
  60454. * @param direction The direction of the light in the scene
  60455. * @param angle The cone angle of the light in Radians
  60456. * @param exponent The light decay speed with the distance from the emission spot
  60457. * @param scene The scene the lights belongs to
  60458. */
  60459. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  60460. /**
  60461. * Returns the string "SpotLight".
  60462. * @returns the class name
  60463. */
  60464. getClassName(): string;
  60465. /**
  60466. * Returns the integer 2.
  60467. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60468. */
  60469. getTypeID(): number;
  60470. /**
  60471. * Overrides the direction setter to recompute the projection texture view light Matrix.
  60472. */
  60473. protected _setDirection(value: Vector3): void;
  60474. /**
  60475. * Overrides the position setter to recompute the projection texture view light Matrix.
  60476. */
  60477. protected _setPosition(value: Vector3): void;
  60478. /**
  60479. * 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.
  60480. * Returns the SpotLight.
  60481. */
  60482. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60483. protected _computeProjectionTextureViewLightMatrix(): void;
  60484. protected _computeProjectionTextureProjectionLightMatrix(): void;
  60485. /**
  60486. * Main function for light texture projection matrix computing.
  60487. */
  60488. protected _computeProjectionTextureMatrix(): void;
  60489. protected _buildUniformLayout(): void;
  60490. private _computeAngleValues;
  60491. /**
  60492. * Sets the passed Effect "effect" with the Light textures.
  60493. * @param effect The effect to update
  60494. * @param lightIndex The index of the light in the effect to update
  60495. * @returns The light
  60496. */
  60497. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  60498. /**
  60499. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  60500. * @param effect The effect to update
  60501. * @param lightIndex The index of the light in the effect to update
  60502. * @returns The spot light
  60503. */
  60504. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  60505. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60506. /**
  60507. * Disposes the light and the associated resources.
  60508. */
  60509. dispose(): void;
  60510. /**
  60511. * Prepares the list of defines specific to the light type.
  60512. * @param defines the list of defines
  60513. * @param lightIndex defines the index of the light for the effect
  60514. */
  60515. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60516. }
  60517. }
  60518. declare module "babylonjs/Gizmos/lightGizmo" {
  60519. import { Nullable } from "babylonjs/types";
  60520. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60521. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60522. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60523. import { Light } from "babylonjs/Lights/light";
  60524. import { Observable } from "babylonjs/Misc/observable";
  60525. /**
  60526. * Gizmo that enables viewing a light
  60527. */
  60528. export class LightGizmo extends Gizmo {
  60529. private _lightMesh;
  60530. private _material;
  60531. private _cachedPosition;
  60532. private _cachedForward;
  60533. private _attachedMeshParent;
  60534. private _pointerObserver;
  60535. /**
  60536. * Event that fires each time the gizmo is clicked
  60537. */
  60538. onClickedObservable: Observable<Light>;
  60539. /**
  60540. * Creates a LightGizmo
  60541. * @param gizmoLayer The utility layer the gizmo will be added to
  60542. */
  60543. constructor(gizmoLayer?: UtilityLayerRenderer);
  60544. private _light;
  60545. /**
  60546. * The light that the gizmo is attached to
  60547. */
  60548. set light(light: Nullable<Light>);
  60549. get light(): Nullable<Light>;
  60550. /**
  60551. * Gets the material used to render the light gizmo
  60552. */
  60553. get material(): StandardMaterial;
  60554. /**
  60555. * @hidden
  60556. * Updates the gizmo to match the attached mesh's position/rotation
  60557. */
  60558. protected _update(): void;
  60559. private static _Scale;
  60560. /**
  60561. * Creates the lines for a light mesh
  60562. */
  60563. private static _CreateLightLines;
  60564. /**
  60565. * Disposes of the light gizmo
  60566. */
  60567. dispose(): void;
  60568. private static _CreateHemisphericLightMesh;
  60569. private static _CreatePointLightMesh;
  60570. private static _CreateSpotLightMesh;
  60571. private static _CreateDirectionalLightMesh;
  60572. }
  60573. }
  60574. declare module "babylonjs/Gizmos/cameraGizmo" {
  60575. import { Nullable } from "babylonjs/types";
  60576. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60577. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60578. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60579. import { Camera } from "babylonjs/Cameras/camera";
  60580. import { Observable } from "babylonjs/Misc/observable";
  60581. /**
  60582. * Gizmo that enables viewing a camera
  60583. */
  60584. export class CameraGizmo extends Gizmo {
  60585. private _cameraMesh;
  60586. private _cameraLinesMesh;
  60587. private _material;
  60588. private _pointerObserver;
  60589. /**
  60590. * Event that fires each time the gizmo is clicked
  60591. */
  60592. onClickedObservable: Observable<Camera>;
  60593. /**
  60594. * Creates a CameraGizmo
  60595. * @param gizmoLayer The utility layer the gizmo will be added to
  60596. */
  60597. constructor(gizmoLayer?: UtilityLayerRenderer);
  60598. private _camera;
  60599. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  60600. get displayFrustum(): boolean;
  60601. set displayFrustum(value: boolean);
  60602. /**
  60603. * The camera that the gizmo is attached to
  60604. */
  60605. set camera(camera: Nullable<Camera>);
  60606. get camera(): Nullable<Camera>;
  60607. /**
  60608. * Gets the material used to render the camera gizmo
  60609. */
  60610. get material(): StandardMaterial;
  60611. /**
  60612. * @hidden
  60613. * Updates the gizmo to match the attached mesh's position/rotation
  60614. */
  60615. protected _update(): void;
  60616. private static _Scale;
  60617. private _invProjection;
  60618. /**
  60619. * Disposes of the camera gizmo
  60620. */
  60621. dispose(): void;
  60622. private static _CreateCameraMesh;
  60623. private static _CreateCameraFrustum;
  60624. }
  60625. }
  60626. declare module "babylonjs/Gizmos/index" {
  60627. export * from "babylonjs/Gizmos/axisDragGizmo";
  60628. export * from "babylonjs/Gizmos/axisScaleGizmo";
  60629. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  60630. export * from "babylonjs/Gizmos/gizmo";
  60631. export * from "babylonjs/Gizmos/gizmoManager";
  60632. export * from "babylonjs/Gizmos/planeRotationGizmo";
  60633. export * from "babylonjs/Gizmos/positionGizmo";
  60634. export * from "babylonjs/Gizmos/rotationGizmo";
  60635. export * from "babylonjs/Gizmos/scaleGizmo";
  60636. export * from "babylonjs/Gizmos/lightGizmo";
  60637. export * from "babylonjs/Gizmos/cameraGizmo";
  60638. export * from "babylonjs/Gizmos/planeDragGizmo";
  60639. }
  60640. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  60641. /** @hidden */
  60642. export var backgroundFragmentDeclaration: {
  60643. name: string;
  60644. shader: string;
  60645. };
  60646. }
  60647. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  60648. /** @hidden */
  60649. export var backgroundUboDeclaration: {
  60650. name: string;
  60651. shader: string;
  60652. };
  60653. }
  60654. declare module "babylonjs/Shaders/background.fragment" {
  60655. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  60656. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  60657. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  60658. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60659. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60660. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60661. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60662. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  60663. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  60664. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60665. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  60666. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  60667. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60668. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  60669. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  60670. /** @hidden */
  60671. export var backgroundPixelShader: {
  60672. name: string;
  60673. shader: string;
  60674. };
  60675. }
  60676. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  60677. /** @hidden */
  60678. export var backgroundVertexDeclaration: {
  60679. name: string;
  60680. shader: string;
  60681. };
  60682. }
  60683. declare module "babylonjs/Shaders/background.vertex" {
  60684. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  60685. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  60686. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60687. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60688. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60689. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  60690. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  60691. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60692. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60693. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60694. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60695. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60696. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  60697. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  60698. /** @hidden */
  60699. export var backgroundVertexShader: {
  60700. name: string;
  60701. shader: string;
  60702. };
  60703. }
  60704. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  60705. import { Nullable, int, float } from "babylonjs/types";
  60706. import { Scene } from "babylonjs/scene";
  60707. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60708. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60710. import { Mesh } from "babylonjs/Meshes/mesh";
  60711. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  60712. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  60713. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  60714. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60715. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  60716. import { Color3 } from "babylonjs/Maths/math.color";
  60717. import "babylonjs/Shaders/background.fragment";
  60718. import "babylonjs/Shaders/background.vertex";
  60719. /**
  60720. * Background material used to create an efficient environement around your scene.
  60721. */
  60722. export class BackgroundMaterial extends PushMaterial {
  60723. /**
  60724. * Standard reflectance value at parallel view angle.
  60725. */
  60726. static StandardReflectance0: number;
  60727. /**
  60728. * Standard reflectance value at grazing angle.
  60729. */
  60730. static StandardReflectance90: number;
  60731. protected _primaryColor: Color3;
  60732. /**
  60733. * Key light Color (multiply against the environement texture)
  60734. */
  60735. primaryColor: Color3;
  60736. protected __perceptualColor: Nullable<Color3>;
  60737. /**
  60738. * Experimental Internal Use Only.
  60739. *
  60740. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  60741. * This acts as a helper to set the primary color to a more "human friendly" value.
  60742. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  60743. * output color as close as possible from the chosen value.
  60744. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  60745. * part of lighting setup.)
  60746. */
  60747. get _perceptualColor(): Nullable<Color3>;
  60748. set _perceptualColor(value: Nullable<Color3>);
  60749. protected _primaryColorShadowLevel: float;
  60750. /**
  60751. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  60752. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  60753. */
  60754. get primaryColorShadowLevel(): float;
  60755. set primaryColorShadowLevel(value: float);
  60756. protected _primaryColorHighlightLevel: float;
  60757. /**
  60758. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  60759. * The primary color is used at the level chosen to define what the white area would look.
  60760. */
  60761. get primaryColorHighlightLevel(): float;
  60762. set primaryColorHighlightLevel(value: float);
  60763. protected _reflectionTexture: Nullable<BaseTexture>;
  60764. /**
  60765. * Reflection Texture used in the material.
  60766. * Should be author in a specific way for the best result (refer to the documentation).
  60767. */
  60768. reflectionTexture: Nullable<BaseTexture>;
  60769. protected _reflectionBlur: float;
  60770. /**
  60771. * Reflection Texture level of blur.
  60772. *
  60773. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  60774. * texture twice.
  60775. */
  60776. reflectionBlur: float;
  60777. protected _diffuseTexture: Nullable<BaseTexture>;
  60778. /**
  60779. * Diffuse Texture used in the material.
  60780. * Should be author in a specific way for the best result (refer to the documentation).
  60781. */
  60782. diffuseTexture: Nullable<BaseTexture>;
  60783. protected _shadowLights: Nullable<IShadowLight[]>;
  60784. /**
  60785. * Specify the list of lights casting shadow on the material.
  60786. * All scene shadow lights will be included if null.
  60787. */
  60788. shadowLights: Nullable<IShadowLight[]>;
  60789. protected _shadowLevel: float;
  60790. /**
  60791. * Helps adjusting the shadow to a softer level if required.
  60792. * 0 means black shadows and 1 means no shadows.
  60793. */
  60794. shadowLevel: float;
  60795. protected _sceneCenter: Vector3;
  60796. /**
  60797. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  60798. * It is usually zero but might be interesting to modify according to your setup.
  60799. */
  60800. sceneCenter: Vector3;
  60801. protected _opacityFresnel: boolean;
  60802. /**
  60803. * This helps specifying that the material is falling off to the sky box at grazing angle.
  60804. * This helps ensuring a nice transition when the camera goes under the ground.
  60805. */
  60806. opacityFresnel: boolean;
  60807. protected _reflectionFresnel: boolean;
  60808. /**
  60809. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  60810. * This helps adding a mirror texture on the ground.
  60811. */
  60812. reflectionFresnel: boolean;
  60813. protected _reflectionFalloffDistance: number;
  60814. /**
  60815. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  60816. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  60817. */
  60818. reflectionFalloffDistance: number;
  60819. protected _reflectionAmount: number;
  60820. /**
  60821. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  60822. */
  60823. reflectionAmount: number;
  60824. protected _reflectionReflectance0: number;
  60825. /**
  60826. * This specifies the weight of the reflection at grazing angle.
  60827. */
  60828. reflectionReflectance0: number;
  60829. protected _reflectionReflectance90: number;
  60830. /**
  60831. * This specifies the weight of the reflection at a perpendicular point of view.
  60832. */
  60833. reflectionReflectance90: number;
  60834. /**
  60835. * Sets the reflection reflectance fresnel values according to the default standard
  60836. * empirically know to work well :-)
  60837. */
  60838. set reflectionStandardFresnelWeight(value: number);
  60839. protected _useRGBColor: boolean;
  60840. /**
  60841. * Helps to directly use the maps channels instead of their level.
  60842. */
  60843. useRGBColor: boolean;
  60844. protected _enableNoise: boolean;
  60845. /**
  60846. * This helps reducing the banding effect that could occur on the background.
  60847. */
  60848. enableNoise: boolean;
  60849. /**
  60850. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60851. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  60852. * Recommended to be keep at 1.0 except for special cases.
  60853. */
  60854. get fovMultiplier(): number;
  60855. set fovMultiplier(value: number);
  60856. private _fovMultiplier;
  60857. /**
  60858. * Enable the FOV adjustment feature controlled by fovMultiplier.
  60859. */
  60860. useEquirectangularFOV: boolean;
  60861. private _maxSimultaneousLights;
  60862. /**
  60863. * Number of Simultaneous lights allowed on the material.
  60864. */
  60865. maxSimultaneousLights: int;
  60866. private _shadowOnly;
  60867. /**
  60868. * Make the material only render shadows
  60869. */
  60870. shadowOnly: boolean;
  60871. /**
  60872. * Default configuration related to image processing available in the Background Material.
  60873. */
  60874. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60875. /**
  60876. * Keep track of the image processing observer to allow dispose and replace.
  60877. */
  60878. private _imageProcessingObserver;
  60879. /**
  60880. * Attaches a new image processing configuration to the PBR Material.
  60881. * @param configuration (if null the scene configuration will be use)
  60882. */
  60883. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60884. /**
  60885. * Gets the image processing configuration used either in this material.
  60886. */
  60887. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  60888. /**
  60889. * Sets the Default image processing configuration used either in the this material.
  60890. *
  60891. * If sets to null, the scene one is in use.
  60892. */
  60893. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  60894. /**
  60895. * Gets wether the color curves effect is enabled.
  60896. */
  60897. get cameraColorCurvesEnabled(): boolean;
  60898. /**
  60899. * Sets wether the color curves effect is enabled.
  60900. */
  60901. set cameraColorCurvesEnabled(value: boolean);
  60902. /**
  60903. * Gets wether the color grading effect is enabled.
  60904. */
  60905. get cameraColorGradingEnabled(): boolean;
  60906. /**
  60907. * Gets wether the color grading effect is enabled.
  60908. */
  60909. set cameraColorGradingEnabled(value: boolean);
  60910. /**
  60911. * Gets wether tonemapping is enabled or not.
  60912. */
  60913. get cameraToneMappingEnabled(): boolean;
  60914. /**
  60915. * Sets wether tonemapping is enabled or not
  60916. */
  60917. set cameraToneMappingEnabled(value: boolean);
  60918. /**
  60919. * The camera exposure used on this material.
  60920. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60921. * This corresponds to a photographic exposure.
  60922. */
  60923. get cameraExposure(): float;
  60924. /**
  60925. * The camera exposure used on this material.
  60926. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60927. * This corresponds to a photographic exposure.
  60928. */
  60929. set cameraExposure(value: float);
  60930. /**
  60931. * Gets The camera contrast used on this material.
  60932. */
  60933. get cameraContrast(): float;
  60934. /**
  60935. * Sets The camera contrast used on this material.
  60936. */
  60937. set cameraContrast(value: float);
  60938. /**
  60939. * Gets the Color Grading 2D Lookup Texture.
  60940. */
  60941. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60942. /**
  60943. * Sets the Color Grading 2D Lookup Texture.
  60944. */
  60945. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60946. /**
  60947. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60948. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60949. * 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;
  60950. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60951. */
  60952. get cameraColorCurves(): Nullable<ColorCurves>;
  60953. /**
  60954. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60955. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60956. * 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;
  60957. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60958. */
  60959. set cameraColorCurves(value: Nullable<ColorCurves>);
  60960. /**
  60961. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  60962. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  60963. */
  60964. switchToBGR: boolean;
  60965. private _renderTargets;
  60966. private _reflectionControls;
  60967. private _white;
  60968. private _primaryShadowColor;
  60969. private _primaryHighlightColor;
  60970. /**
  60971. * Instantiates a Background Material in the given scene
  60972. * @param name The friendly name of the material
  60973. * @param scene The scene to add the material to
  60974. */
  60975. constructor(name: string, scene: Scene);
  60976. /**
  60977. * Gets a boolean indicating that current material needs to register RTT
  60978. */
  60979. get hasRenderTargetTextures(): boolean;
  60980. /**
  60981. * The entire material has been created in order to prevent overdraw.
  60982. * @returns false
  60983. */
  60984. needAlphaTesting(): boolean;
  60985. /**
  60986. * The entire material has been created in order to prevent overdraw.
  60987. * @returns true if blending is enable
  60988. */
  60989. needAlphaBlending(): boolean;
  60990. /**
  60991. * Checks wether the material is ready to be rendered for a given mesh.
  60992. * @param mesh The mesh to render
  60993. * @param subMesh The submesh to check against
  60994. * @param useInstances Specify wether or not the material is used with instances
  60995. * @returns true if all the dependencies are ready (Textures, Effects...)
  60996. */
  60997. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60998. /**
  60999. * Compute the primary color according to the chosen perceptual color.
  61000. */
  61001. private _computePrimaryColorFromPerceptualColor;
  61002. /**
  61003. * Compute the highlights and shadow colors according to their chosen levels.
  61004. */
  61005. private _computePrimaryColors;
  61006. /**
  61007. * Build the uniform buffer used in the material.
  61008. */
  61009. buildUniformLayout(): void;
  61010. /**
  61011. * Unbind the material.
  61012. */
  61013. unbind(): void;
  61014. /**
  61015. * Bind only the world matrix to the material.
  61016. * @param world The world matrix to bind.
  61017. */
  61018. bindOnlyWorldMatrix(world: Matrix): void;
  61019. /**
  61020. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  61021. * @param world The world matrix to bind.
  61022. * @param subMesh The submesh to bind for.
  61023. */
  61024. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61025. /**
  61026. * Checks to see if a texture is used in the material.
  61027. * @param texture - Base texture to use.
  61028. * @returns - Boolean specifying if a texture is used in the material.
  61029. */
  61030. hasTexture(texture: BaseTexture): boolean;
  61031. /**
  61032. * Dispose the material.
  61033. * @param forceDisposeEffect Force disposal of the associated effect.
  61034. * @param forceDisposeTextures Force disposal of the associated textures.
  61035. */
  61036. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  61037. /**
  61038. * Clones the material.
  61039. * @param name The cloned name.
  61040. * @returns The cloned material.
  61041. */
  61042. clone(name: string): BackgroundMaterial;
  61043. /**
  61044. * Serializes the current material to its JSON representation.
  61045. * @returns The JSON representation.
  61046. */
  61047. serialize(): any;
  61048. /**
  61049. * Gets the class name of the material
  61050. * @returns "BackgroundMaterial"
  61051. */
  61052. getClassName(): string;
  61053. /**
  61054. * Parse a JSON input to create back a background material.
  61055. * @param source The JSON data to parse
  61056. * @param scene The scene to create the parsed material in
  61057. * @param rootUrl The root url of the assets the material depends upon
  61058. * @returns the instantiated BackgroundMaterial.
  61059. */
  61060. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  61061. }
  61062. }
  61063. declare module "babylonjs/Helpers/environmentHelper" {
  61064. import { Observable } from "babylonjs/Misc/observable";
  61065. import { Nullable } from "babylonjs/types";
  61066. import { Scene } from "babylonjs/scene";
  61067. import { Vector3 } from "babylonjs/Maths/math.vector";
  61068. import { Color3 } from "babylonjs/Maths/math.color";
  61069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61070. import { Mesh } from "babylonjs/Meshes/mesh";
  61071. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61072. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  61073. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  61074. import "babylonjs/Meshes/Builders/planeBuilder";
  61075. import "babylonjs/Meshes/Builders/boxBuilder";
  61076. /**
  61077. * Represents the different options available during the creation of
  61078. * a Environment helper.
  61079. *
  61080. * This can control the default ground, skybox and image processing setup of your scene.
  61081. */
  61082. export interface IEnvironmentHelperOptions {
  61083. /**
  61084. * Specifies whether or not to create a ground.
  61085. * True by default.
  61086. */
  61087. createGround: boolean;
  61088. /**
  61089. * Specifies the ground size.
  61090. * 15 by default.
  61091. */
  61092. groundSize: number;
  61093. /**
  61094. * The texture used on the ground for the main color.
  61095. * Comes from the BabylonJS CDN by default.
  61096. *
  61097. * Remarks: Can be either a texture or a url.
  61098. */
  61099. groundTexture: string | BaseTexture;
  61100. /**
  61101. * The color mixed in the ground texture by default.
  61102. * BabylonJS clearColor by default.
  61103. */
  61104. groundColor: Color3;
  61105. /**
  61106. * Specifies the ground opacity.
  61107. * 1 by default.
  61108. */
  61109. groundOpacity: number;
  61110. /**
  61111. * Enables the ground to receive shadows.
  61112. * True by default.
  61113. */
  61114. enableGroundShadow: boolean;
  61115. /**
  61116. * Helps preventing the shadow to be fully black on the ground.
  61117. * 0.5 by default.
  61118. */
  61119. groundShadowLevel: number;
  61120. /**
  61121. * Creates a mirror texture attach to the ground.
  61122. * false by default.
  61123. */
  61124. enableGroundMirror: boolean;
  61125. /**
  61126. * Specifies the ground mirror size ratio.
  61127. * 0.3 by default as the default kernel is 64.
  61128. */
  61129. groundMirrorSizeRatio: number;
  61130. /**
  61131. * Specifies the ground mirror blur kernel size.
  61132. * 64 by default.
  61133. */
  61134. groundMirrorBlurKernel: number;
  61135. /**
  61136. * Specifies the ground mirror visibility amount.
  61137. * 1 by default
  61138. */
  61139. groundMirrorAmount: number;
  61140. /**
  61141. * Specifies the ground mirror reflectance weight.
  61142. * This uses the standard weight of the background material to setup the fresnel effect
  61143. * of the mirror.
  61144. * 1 by default.
  61145. */
  61146. groundMirrorFresnelWeight: number;
  61147. /**
  61148. * Specifies the ground mirror Falloff distance.
  61149. * This can helps reducing the size of the reflection.
  61150. * 0 by Default.
  61151. */
  61152. groundMirrorFallOffDistance: number;
  61153. /**
  61154. * Specifies the ground mirror texture type.
  61155. * Unsigned Int by Default.
  61156. */
  61157. groundMirrorTextureType: number;
  61158. /**
  61159. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  61160. * the shown objects.
  61161. */
  61162. groundYBias: number;
  61163. /**
  61164. * Specifies whether or not to create a skybox.
  61165. * True by default.
  61166. */
  61167. createSkybox: boolean;
  61168. /**
  61169. * Specifies the skybox size.
  61170. * 20 by default.
  61171. */
  61172. skyboxSize: number;
  61173. /**
  61174. * The texture used on the skybox for the main color.
  61175. * Comes from the BabylonJS CDN by default.
  61176. *
  61177. * Remarks: Can be either a texture or a url.
  61178. */
  61179. skyboxTexture: string | BaseTexture;
  61180. /**
  61181. * The color mixed in the skybox texture by default.
  61182. * BabylonJS clearColor by default.
  61183. */
  61184. skyboxColor: Color3;
  61185. /**
  61186. * The background rotation around the Y axis of the scene.
  61187. * This helps aligning the key lights of your scene with the background.
  61188. * 0 by default.
  61189. */
  61190. backgroundYRotation: number;
  61191. /**
  61192. * Compute automatically the size of the elements to best fit with the scene.
  61193. */
  61194. sizeAuto: boolean;
  61195. /**
  61196. * Default position of the rootMesh if autoSize is not true.
  61197. */
  61198. rootPosition: Vector3;
  61199. /**
  61200. * Sets up the image processing in the scene.
  61201. * true by default.
  61202. */
  61203. setupImageProcessing: boolean;
  61204. /**
  61205. * The texture used as your environment texture in the scene.
  61206. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  61207. *
  61208. * Remarks: Can be either a texture or a url.
  61209. */
  61210. environmentTexture: string | BaseTexture;
  61211. /**
  61212. * The value of the exposure to apply to the scene.
  61213. * 0.6 by default if setupImageProcessing is true.
  61214. */
  61215. cameraExposure: number;
  61216. /**
  61217. * The value of the contrast to apply to the scene.
  61218. * 1.6 by default if setupImageProcessing is true.
  61219. */
  61220. cameraContrast: number;
  61221. /**
  61222. * Specifies whether or not tonemapping should be enabled in the scene.
  61223. * true by default if setupImageProcessing is true.
  61224. */
  61225. toneMappingEnabled: boolean;
  61226. }
  61227. /**
  61228. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  61229. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  61230. * It also helps with the default setup of your imageProcessing configuration.
  61231. */
  61232. export class EnvironmentHelper {
  61233. /**
  61234. * Default ground texture URL.
  61235. */
  61236. private static _groundTextureCDNUrl;
  61237. /**
  61238. * Default skybox texture URL.
  61239. */
  61240. private static _skyboxTextureCDNUrl;
  61241. /**
  61242. * Default environment texture URL.
  61243. */
  61244. private static _environmentTextureCDNUrl;
  61245. /**
  61246. * Creates the default options for the helper.
  61247. */
  61248. private static _getDefaultOptions;
  61249. private _rootMesh;
  61250. /**
  61251. * Gets the root mesh created by the helper.
  61252. */
  61253. get rootMesh(): Mesh;
  61254. private _skybox;
  61255. /**
  61256. * Gets the skybox created by the helper.
  61257. */
  61258. get skybox(): Nullable<Mesh>;
  61259. private _skyboxTexture;
  61260. /**
  61261. * Gets the skybox texture created by the helper.
  61262. */
  61263. get skyboxTexture(): Nullable<BaseTexture>;
  61264. private _skyboxMaterial;
  61265. /**
  61266. * Gets the skybox material created by the helper.
  61267. */
  61268. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  61269. private _ground;
  61270. /**
  61271. * Gets the ground mesh created by the helper.
  61272. */
  61273. get ground(): Nullable<Mesh>;
  61274. private _groundTexture;
  61275. /**
  61276. * Gets the ground texture created by the helper.
  61277. */
  61278. get groundTexture(): Nullable<BaseTexture>;
  61279. private _groundMirror;
  61280. /**
  61281. * Gets the ground mirror created by the helper.
  61282. */
  61283. get groundMirror(): Nullable<MirrorTexture>;
  61284. /**
  61285. * Gets the ground mirror render list to helps pushing the meshes
  61286. * you wish in the ground reflection.
  61287. */
  61288. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  61289. private _groundMaterial;
  61290. /**
  61291. * Gets the ground material created by the helper.
  61292. */
  61293. get groundMaterial(): Nullable<BackgroundMaterial>;
  61294. /**
  61295. * Stores the creation options.
  61296. */
  61297. private readonly _scene;
  61298. private _options;
  61299. /**
  61300. * This observable will be notified with any error during the creation of the environment,
  61301. * mainly texture creation errors.
  61302. */
  61303. onErrorObservable: Observable<{
  61304. message?: string;
  61305. exception?: any;
  61306. }>;
  61307. /**
  61308. * constructor
  61309. * @param options Defines the options we want to customize the helper
  61310. * @param scene The scene to add the material to
  61311. */
  61312. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  61313. /**
  61314. * Updates the background according to the new options
  61315. * @param options
  61316. */
  61317. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  61318. /**
  61319. * Sets the primary color of all the available elements.
  61320. * @param color the main color to affect to the ground and the background
  61321. */
  61322. setMainColor(color: Color3): void;
  61323. /**
  61324. * Setup the image processing according to the specified options.
  61325. */
  61326. private _setupImageProcessing;
  61327. /**
  61328. * Setup the environment texture according to the specified options.
  61329. */
  61330. private _setupEnvironmentTexture;
  61331. /**
  61332. * Setup the background according to the specified options.
  61333. */
  61334. private _setupBackground;
  61335. /**
  61336. * Get the scene sizes according to the setup.
  61337. */
  61338. private _getSceneSize;
  61339. /**
  61340. * Setup the ground according to the specified options.
  61341. */
  61342. private _setupGround;
  61343. /**
  61344. * Setup the ground material according to the specified options.
  61345. */
  61346. private _setupGroundMaterial;
  61347. /**
  61348. * Setup the ground diffuse texture according to the specified options.
  61349. */
  61350. private _setupGroundDiffuseTexture;
  61351. /**
  61352. * Setup the ground mirror texture according to the specified options.
  61353. */
  61354. private _setupGroundMirrorTexture;
  61355. /**
  61356. * Setup the ground to receive the mirror texture.
  61357. */
  61358. private _setupMirrorInGroundMaterial;
  61359. /**
  61360. * Setup the skybox according to the specified options.
  61361. */
  61362. private _setupSkybox;
  61363. /**
  61364. * Setup the skybox material according to the specified options.
  61365. */
  61366. private _setupSkyboxMaterial;
  61367. /**
  61368. * Setup the skybox reflection texture according to the specified options.
  61369. */
  61370. private _setupSkyboxReflectionTexture;
  61371. private _errorHandler;
  61372. /**
  61373. * Dispose all the elements created by the Helper.
  61374. */
  61375. dispose(): void;
  61376. }
  61377. }
  61378. declare module "babylonjs/Helpers/textureDome" {
  61379. import { Scene } from "babylonjs/scene";
  61380. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61381. import { Mesh } from "babylonjs/Meshes/mesh";
  61382. import { Texture } from "babylonjs/Materials/Textures/texture";
  61383. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  61384. import "babylonjs/Meshes/Builders/sphereBuilder";
  61385. import { Nullable } from "babylonjs/types";
  61386. import { Observable } from "babylonjs/Misc/observable";
  61387. /**
  61388. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  61389. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  61390. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61391. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61392. */
  61393. export abstract class TextureDome<T extends Texture> extends TransformNode {
  61394. protected onError: Nullable<(message?: string, exception?: any) => void>;
  61395. /**
  61396. * Define the source as a Monoscopic panoramic 360/180.
  61397. */
  61398. static readonly MODE_MONOSCOPIC: number;
  61399. /**
  61400. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  61401. */
  61402. static readonly MODE_TOPBOTTOM: number;
  61403. /**
  61404. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  61405. */
  61406. static readonly MODE_SIDEBYSIDE: number;
  61407. private _halfDome;
  61408. private _crossEye;
  61409. protected _useDirectMapping: boolean;
  61410. /**
  61411. * The texture being displayed on the sphere
  61412. */
  61413. protected _texture: T;
  61414. /**
  61415. * Gets the texture being displayed on the sphere
  61416. */
  61417. get texture(): T;
  61418. /**
  61419. * Sets the texture being displayed on the sphere
  61420. */
  61421. set texture(newTexture: T);
  61422. /**
  61423. * The skybox material
  61424. */
  61425. protected _material: BackgroundMaterial;
  61426. /**
  61427. * The surface used for the dome
  61428. */
  61429. protected _mesh: Mesh;
  61430. /**
  61431. * Gets the mesh used for the dome.
  61432. */
  61433. get mesh(): Mesh;
  61434. /**
  61435. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  61436. */
  61437. private _halfDomeMask;
  61438. /**
  61439. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61440. * Also see the options.resolution property.
  61441. */
  61442. get fovMultiplier(): number;
  61443. set fovMultiplier(value: number);
  61444. protected _textureMode: number;
  61445. /**
  61446. * Gets or set the current texture mode for the texture. It can be:
  61447. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61448. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61449. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61450. */
  61451. get textureMode(): number;
  61452. /**
  61453. * Sets the current texture mode for the texture. It can be:
  61454. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61455. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61456. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61457. */
  61458. set textureMode(value: number);
  61459. /**
  61460. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  61461. */
  61462. get halfDome(): boolean;
  61463. /**
  61464. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  61465. */
  61466. set halfDome(enabled: boolean);
  61467. /**
  61468. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  61469. */
  61470. set crossEye(enabled: boolean);
  61471. /**
  61472. * Is it a cross-eye texture?
  61473. */
  61474. get crossEye(): boolean;
  61475. /**
  61476. * The background material of this dome.
  61477. */
  61478. get material(): BackgroundMaterial;
  61479. /**
  61480. * Oberserver used in Stereoscopic VR Mode.
  61481. */
  61482. private _onBeforeCameraRenderObserver;
  61483. /**
  61484. * Observable raised when an error occured while loading the 360 image
  61485. */
  61486. onLoadErrorObservable: Observable<string>;
  61487. /**
  61488. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  61489. * @param name Element's name, child elements will append suffixes for their own names.
  61490. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  61491. * @param options An object containing optional or exposed sub element properties
  61492. */
  61493. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  61494. resolution?: number;
  61495. clickToPlay?: boolean;
  61496. autoPlay?: boolean;
  61497. loop?: boolean;
  61498. size?: number;
  61499. poster?: string;
  61500. faceForward?: boolean;
  61501. useDirectMapping?: boolean;
  61502. halfDomeMode?: boolean;
  61503. crossEyeMode?: boolean;
  61504. generateMipMaps?: boolean;
  61505. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  61506. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  61507. protected _changeTextureMode(value: number): void;
  61508. /**
  61509. * Releases resources associated with this node.
  61510. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  61511. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  61512. */
  61513. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  61514. }
  61515. }
  61516. declare module "babylonjs/Helpers/photoDome" {
  61517. import { Scene } from "babylonjs/scene";
  61518. import { Texture } from "babylonjs/Materials/Textures/texture";
  61519. import { TextureDome } from "babylonjs/Helpers/textureDome";
  61520. /**
  61521. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  61522. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  61523. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61524. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61525. */
  61526. export class PhotoDome extends TextureDome<Texture> {
  61527. /**
  61528. * Define the image as a Monoscopic panoramic 360 image.
  61529. */
  61530. static readonly MODE_MONOSCOPIC: number;
  61531. /**
  61532. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  61533. */
  61534. static readonly MODE_TOPBOTTOM: number;
  61535. /**
  61536. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  61537. */
  61538. static readonly MODE_SIDEBYSIDE: number;
  61539. /**
  61540. * Gets or sets the texture being displayed on the sphere
  61541. */
  61542. get photoTexture(): Texture;
  61543. /**
  61544. * sets the texture being displayed on the sphere
  61545. */
  61546. set photoTexture(value: Texture);
  61547. /**
  61548. * Gets the current video mode for the video. It can be:
  61549. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61550. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61551. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61552. */
  61553. get imageMode(): number;
  61554. /**
  61555. * Sets the current video mode for the video. It can be:
  61556. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61557. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61558. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61559. */
  61560. set imageMode(value: number);
  61561. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  61562. }
  61563. }
  61564. declare module "babylonjs/Misc/dds" {
  61565. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  61566. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61567. import { Nullable } from "babylonjs/types";
  61568. import { Scene } from "babylonjs/scene";
  61569. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  61570. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61571. /**
  61572. * Direct draw surface info
  61573. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  61574. */
  61575. export interface DDSInfo {
  61576. /**
  61577. * Width of the texture
  61578. */
  61579. width: number;
  61580. /**
  61581. * Width of the texture
  61582. */
  61583. height: number;
  61584. /**
  61585. * Number of Mipmaps for the texture
  61586. * @see https://en.wikipedia.org/wiki/Mipmap
  61587. */
  61588. mipmapCount: number;
  61589. /**
  61590. * If the textures format is a known fourCC format
  61591. * @see https://www.fourcc.org/
  61592. */
  61593. isFourCC: boolean;
  61594. /**
  61595. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  61596. */
  61597. isRGB: boolean;
  61598. /**
  61599. * If the texture is a lumincance format
  61600. */
  61601. isLuminance: boolean;
  61602. /**
  61603. * If this is a cube texture
  61604. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  61605. */
  61606. isCube: boolean;
  61607. /**
  61608. * If the texture is a compressed format eg. FOURCC_DXT1
  61609. */
  61610. isCompressed: boolean;
  61611. /**
  61612. * The dxgiFormat of the texture
  61613. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  61614. */
  61615. dxgiFormat: number;
  61616. /**
  61617. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  61618. */
  61619. textureType: number;
  61620. /**
  61621. * Sphericle polynomial created for the dds texture
  61622. */
  61623. sphericalPolynomial?: SphericalPolynomial;
  61624. }
  61625. /**
  61626. * Class used to provide DDS decompression tools
  61627. */
  61628. export class DDSTools {
  61629. /**
  61630. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  61631. */
  61632. static StoreLODInAlphaChannel: boolean;
  61633. /**
  61634. * Gets DDS information from an array buffer
  61635. * @param data defines the array buffer view to read data from
  61636. * @returns the DDS information
  61637. */
  61638. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  61639. private static _FloatView;
  61640. private static _Int32View;
  61641. private static _ToHalfFloat;
  61642. private static _FromHalfFloat;
  61643. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  61644. private static _GetHalfFloatRGBAArrayBuffer;
  61645. private static _GetFloatRGBAArrayBuffer;
  61646. private static _GetFloatAsUIntRGBAArrayBuffer;
  61647. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  61648. private static _GetRGBAArrayBuffer;
  61649. private static _ExtractLongWordOrder;
  61650. private static _GetRGBArrayBuffer;
  61651. private static _GetLuminanceArrayBuffer;
  61652. /**
  61653. * Uploads DDS Levels to a Babylon Texture
  61654. * @hidden
  61655. */
  61656. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  61657. }
  61658. module "babylonjs/Engines/thinEngine" {
  61659. interface ThinEngine {
  61660. /**
  61661. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  61662. * @param rootUrl defines the url where the file to load is located
  61663. * @param scene defines the current scene
  61664. * @param lodScale defines scale to apply to the mip map selection
  61665. * @param lodOffset defines offset to apply to the mip map selection
  61666. * @param onLoad defines an optional callback raised when the texture is loaded
  61667. * @param onError defines an optional callback raised if there is an issue to load the texture
  61668. * @param format defines the format of the data
  61669. * @param forcedExtension defines the extension to use to pick the right loader
  61670. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  61671. * @returns the cube texture as an InternalTexture
  61672. */
  61673. 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;
  61674. }
  61675. }
  61676. }
  61677. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  61678. import { Nullable } from "babylonjs/types";
  61679. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61680. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61681. /**
  61682. * Implementation of the DDS Texture Loader.
  61683. * @hidden
  61684. */
  61685. export class _DDSTextureLoader implements IInternalTextureLoader {
  61686. /**
  61687. * Defines wether the loader supports cascade loading the different faces.
  61688. */
  61689. readonly supportCascades: boolean;
  61690. /**
  61691. * This returns if the loader support the current file information.
  61692. * @param extension defines the file extension of the file being loaded
  61693. * @returns true if the loader can load the specified file
  61694. */
  61695. canLoad(extension: string): boolean;
  61696. /**
  61697. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61698. * @param data contains the texture data
  61699. * @param texture defines the BabylonJS internal texture
  61700. * @param createPolynomials will be true if polynomials have been requested
  61701. * @param onLoad defines the callback to trigger once the texture is ready
  61702. * @param onError defines the callback to trigger in case of error
  61703. */
  61704. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61705. /**
  61706. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61707. * @param data contains the texture data
  61708. * @param texture defines the BabylonJS internal texture
  61709. * @param callback defines the method to call once ready to upload
  61710. */
  61711. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61712. }
  61713. }
  61714. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  61715. import { Nullable } from "babylonjs/types";
  61716. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61717. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61718. /**
  61719. * Implementation of the ENV Texture Loader.
  61720. * @hidden
  61721. */
  61722. export class _ENVTextureLoader implements IInternalTextureLoader {
  61723. /**
  61724. * Defines wether the loader supports cascade loading the different faces.
  61725. */
  61726. readonly supportCascades: boolean;
  61727. /**
  61728. * This returns if the loader support the current file information.
  61729. * @param extension defines the file extension of the file being loaded
  61730. * @returns true if the loader can load the specified file
  61731. */
  61732. canLoad(extension: string): boolean;
  61733. /**
  61734. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61735. * @param data contains the texture data
  61736. * @param texture defines the BabylonJS internal texture
  61737. * @param createPolynomials will be true if polynomials have been requested
  61738. * @param onLoad defines the callback to trigger once the texture is ready
  61739. * @param onError defines the callback to trigger in case of error
  61740. */
  61741. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61742. /**
  61743. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61744. * @param data contains the texture data
  61745. * @param texture defines the BabylonJS internal texture
  61746. * @param callback defines the method to call once ready to upload
  61747. */
  61748. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61749. }
  61750. }
  61751. declare module "babylonjs/Misc/khronosTextureContainer" {
  61752. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61753. /**
  61754. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  61755. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  61756. */
  61757. export class KhronosTextureContainer {
  61758. /** contents of the KTX container file */
  61759. data: ArrayBufferView;
  61760. private static HEADER_LEN;
  61761. private static COMPRESSED_2D;
  61762. private static COMPRESSED_3D;
  61763. private static TEX_2D;
  61764. private static TEX_3D;
  61765. /**
  61766. * Gets the openGL type
  61767. */
  61768. glType: number;
  61769. /**
  61770. * Gets the openGL type size
  61771. */
  61772. glTypeSize: number;
  61773. /**
  61774. * Gets the openGL format
  61775. */
  61776. glFormat: number;
  61777. /**
  61778. * Gets the openGL internal format
  61779. */
  61780. glInternalFormat: number;
  61781. /**
  61782. * Gets the base internal format
  61783. */
  61784. glBaseInternalFormat: number;
  61785. /**
  61786. * Gets image width in pixel
  61787. */
  61788. pixelWidth: number;
  61789. /**
  61790. * Gets image height in pixel
  61791. */
  61792. pixelHeight: number;
  61793. /**
  61794. * Gets image depth in pixels
  61795. */
  61796. pixelDepth: number;
  61797. /**
  61798. * Gets the number of array elements
  61799. */
  61800. numberOfArrayElements: number;
  61801. /**
  61802. * Gets the number of faces
  61803. */
  61804. numberOfFaces: number;
  61805. /**
  61806. * Gets the number of mipmap levels
  61807. */
  61808. numberOfMipmapLevels: number;
  61809. /**
  61810. * Gets the bytes of key value data
  61811. */
  61812. bytesOfKeyValueData: number;
  61813. /**
  61814. * Gets the load type
  61815. */
  61816. loadType: number;
  61817. /**
  61818. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  61819. */
  61820. isInvalid: boolean;
  61821. /**
  61822. * Creates a new KhronosTextureContainer
  61823. * @param data contents of the KTX container file
  61824. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  61825. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  61826. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  61827. */
  61828. constructor(
  61829. /** contents of the KTX container file */
  61830. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  61831. /**
  61832. * Uploads KTX content to a Babylon Texture.
  61833. * It is assumed that the texture has already been created & is currently bound
  61834. * @hidden
  61835. */
  61836. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  61837. private _upload2DCompressedLevels;
  61838. /**
  61839. * Checks if the given data starts with a KTX file identifier.
  61840. * @param data the data to check
  61841. * @returns true if the data is a KTX file or false otherwise
  61842. */
  61843. static IsValid(data: ArrayBufferView): boolean;
  61844. }
  61845. }
  61846. declare module "babylonjs/Misc/workerPool" {
  61847. import { IDisposable } from "babylonjs/scene";
  61848. /**
  61849. * Helper class to push actions to a pool of workers.
  61850. */
  61851. export class WorkerPool implements IDisposable {
  61852. private _workerInfos;
  61853. private _pendingActions;
  61854. /**
  61855. * Constructor
  61856. * @param workers Array of workers to use for actions
  61857. */
  61858. constructor(workers: Array<Worker>);
  61859. /**
  61860. * Terminates all workers and clears any pending actions.
  61861. */
  61862. dispose(): void;
  61863. /**
  61864. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61865. * pended until a worker has completed its action.
  61866. * @param action The action to perform. Call onComplete when the action is complete.
  61867. */
  61868. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61869. private _execute;
  61870. }
  61871. }
  61872. declare module "babylonjs/Misc/khronosTextureContainer2" {
  61873. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61874. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61875. /**
  61876. * Class for loading KTX2 files
  61877. */
  61878. export class KhronosTextureContainer2 {
  61879. private static _WorkerPoolPromise?;
  61880. private static _Initialized;
  61881. private static _Ktx2Decoder;
  61882. /**
  61883. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  61884. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  61885. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  61886. * Urls you can change:
  61887. * URLConfig.jsDecoderModule
  61888. * URLConfig.wasmUASTCToASTC
  61889. * URLConfig.wasmUASTCToBC7
  61890. * URLConfig.wasmUASTCToRGBA_UNORM
  61891. * URLConfig.wasmUASTCToRGBA_SRGB
  61892. * URLConfig.jsMSCTranscoder
  61893. * URLConfig.wasmMSCTranscoder
  61894. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  61895. */
  61896. static URLConfig: {
  61897. jsDecoderModule: string;
  61898. wasmUASTCToASTC: null;
  61899. wasmUASTCToBC7: null;
  61900. wasmUASTCToRGBA_UNORM: null;
  61901. wasmUASTCToRGBA_SRGB: null;
  61902. jsMSCTranscoder: null;
  61903. wasmMSCTranscoder: null;
  61904. };
  61905. /**
  61906. * Default number of workers used to handle data decoding
  61907. */
  61908. static DefaultNumWorkers: number;
  61909. private static GetDefaultNumWorkers;
  61910. private _engine;
  61911. private static _CreateWorkerPool;
  61912. /**
  61913. * Constructor
  61914. * @param engine The engine to use
  61915. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61916. */
  61917. constructor(engine: ThinEngine, numWorkers?: number);
  61918. /** @hidden */
  61919. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  61920. /**
  61921. * Stop all async operations and release resources.
  61922. */
  61923. dispose(): void;
  61924. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  61925. /**
  61926. * Checks if the given data starts with a KTX2 file identifier.
  61927. * @param data the data to check
  61928. * @returns true if the data is a KTX2 file or false otherwise
  61929. */
  61930. static IsValid(data: ArrayBufferView): boolean;
  61931. }
  61932. }
  61933. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  61934. import { Nullable } from "babylonjs/types";
  61935. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61936. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61937. /**
  61938. * Implementation of the KTX Texture Loader.
  61939. * @hidden
  61940. */
  61941. export class _KTXTextureLoader implements IInternalTextureLoader {
  61942. /**
  61943. * Defines wether the loader supports cascade loading the different faces.
  61944. */
  61945. readonly supportCascades: boolean;
  61946. /**
  61947. * This returns if the loader support the current file information.
  61948. * @param extension defines the file extension of the file being loaded
  61949. * @param mimeType defines the optional mime type of the file being loaded
  61950. * @returns true if the loader can load the specified file
  61951. */
  61952. canLoad(extension: string, mimeType?: string): boolean;
  61953. /**
  61954. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61955. * @param data contains the texture data
  61956. * @param texture defines the BabylonJS internal texture
  61957. * @param createPolynomials will be true if polynomials have been requested
  61958. * @param onLoad defines the callback to trigger once the texture is ready
  61959. * @param onError defines the callback to trigger in case of error
  61960. */
  61961. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61962. /**
  61963. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61964. * @param data contains the texture data
  61965. * @param texture defines the BabylonJS internal texture
  61966. * @param callback defines the method to call once ready to upload
  61967. */
  61968. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  61969. }
  61970. }
  61971. declare module "babylonjs/Helpers/sceneHelpers" {
  61972. import { Nullable } from "babylonjs/types";
  61973. import { Mesh } from "babylonjs/Meshes/mesh";
  61974. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61975. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  61976. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  61977. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  61978. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  61979. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  61980. import "babylonjs/Meshes/Builders/boxBuilder";
  61981. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  61982. /** @hidden */
  61983. export var _forceSceneHelpersToBundle: boolean;
  61984. module "babylonjs/scene" {
  61985. interface Scene {
  61986. /**
  61987. * Creates a default light for the scene.
  61988. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  61989. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  61990. */
  61991. createDefaultLight(replace?: boolean): void;
  61992. /**
  61993. * Creates a default camera for the scene.
  61994. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  61995. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61996. * @param replace has default false, when true replaces the active camera in the scene
  61997. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  61998. */
  61999. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62000. /**
  62001. * Creates a default camera and a default light.
  62002. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  62003. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62004. * @param replace has the default false, when true replaces the active camera/light in the scene
  62005. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  62006. */
  62007. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62008. /**
  62009. * Creates a new sky box
  62010. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  62011. * @param environmentTexture defines the texture to use as environment texture
  62012. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  62013. * @param scale defines the overall scale of the skybox
  62014. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  62015. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  62016. * @returns a new mesh holding the sky box
  62017. */
  62018. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  62019. /**
  62020. * Creates a new environment
  62021. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  62022. * @param options defines the options you can use to configure the environment
  62023. * @returns the new EnvironmentHelper
  62024. */
  62025. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  62026. /**
  62027. * Creates a new VREXperienceHelper
  62028. * @see https://doc.babylonjs.com/how_to/webvr_helper
  62029. * @param webVROptions defines the options used to create the new VREXperienceHelper
  62030. * @returns a new VREXperienceHelper
  62031. */
  62032. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  62033. /**
  62034. * Creates a new WebXRDefaultExperience
  62035. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  62036. * @param options experience options
  62037. * @returns a promise for a new WebXRDefaultExperience
  62038. */
  62039. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  62040. }
  62041. }
  62042. }
  62043. declare module "babylonjs/Helpers/videoDome" {
  62044. import { Scene } from "babylonjs/scene";
  62045. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  62046. import { TextureDome } from "babylonjs/Helpers/textureDome";
  62047. /**
  62048. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  62049. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  62050. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  62051. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62052. */
  62053. export class VideoDome extends TextureDome<VideoTexture> {
  62054. /**
  62055. * Define the video source as a Monoscopic panoramic 360 video.
  62056. */
  62057. static readonly MODE_MONOSCOPIC: number;
  62058. /**
  62059. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  62060. */
  62061. static readonly MODE_TOPBOTTOM: number;
  62062. /**
  62063. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  62064. */
  62065. static readonly MODE_SIDEBYSIDE: number;
  62066. /**
  62067. * Get the video texture associated with this video dome
  62068. */
  62069. get videoTexture(): VideoTexture;
  62070. /**
  62071. * Get the video mode of this dome
  62072. */
  62073. get videoMode(): number;
  62074. /**
  62075. * Set the video mode of this dome.
  62076. * @see textureMode
  62077. */
  62078. set videoMode(value: number);
  62079. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  62080. }
  62081. }
  62082. declare module "babylonjs/Helpers/index" {
  62083. export * from "babylonjs/Helpers/environmentHelper";
  62084. export * from "babylonjs/Helpers/photoDome";
  62085. export * from "babylonjs/Helpers/sceneHelpers";
  62086. export * from "babylonjs/Helpers/videoDome";
  62087. }
  62088. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  62089. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  62090. import { IDisposable } from "babylonjs/scene";
  62091. import { Engine } from "babylonjs/Engines/engine";
  62092. /**
  62093. * This class can be used to get instrumentation data from a Babylon engine
  62094. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62095. */
  62096. export class EngineInstrumentation implements IDisposable {
  62097. /**
  62098. * Define the instrumented engine.
  62099. */
  62100. engine: Engine;
  62101. private _captureGPUFrameTime;
  62102. private _gpuFrameTimeToken;
  62103. private _gpuFrameTime;
  62104. private _captureShaderCompilationTime;
  62105. private _shaderCompilationTime;
  62106. private _onBeginFrameObserver;
  62107. private _onEndFrameObserver;
  62108. private _onBeforeShaderCompilationObserver;
  62109. private _onAfterShaderCompilationObserver;
  62110. /**
  62111. * Gets the perf counter used for GPU frame time
  62112. */
  62113. get gpuFrameTimeCounter(): PerfCounter;
  62114. /**
  62115. * Gets the GPU frame time capture status
  62116. */
  62117. get captureGPUFrameTime(): boolean;
  62118. /**
  62119. * Enable or disable the GPU frame time capture
  62120. */
  62121. set captureGPUFrameTime(value: boolean);
  62122. /**
  62123. * Gets the perf counter used for shader compilation time
  62124. */
  62125. get shaderCompilationTimeCounter(): PerfCounter;
  62126. /**
  62127. * Gets the shader compilation time capture status
  62128. */
  62129. get captureShaderCompilationTime(): boolean;
  62130. /**
  62131. * Enable or disable the shader compilation time capture
  62132. */
  62133. set captureShaderCompilationTime(value: boolean);
  62134. /**
  62135. * Instantiates a new engine instrumentation.
  62136. * This class can be used to get instrumentation data from a Babylon engine
  62137. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62138. * @param engine Defines the engine to instrument
  62139. */
  62140. constructor(
  62141. /**
  62142. * Define the instrumented engine.
  62143. */
  62144. engine: Engine);
  62145. /**
  62146. * Dispose and release associated resources.
  62147. */
  62148. dispose(): void;
  62149. }
  62150. }
  62151. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  62152. import { Scene, IDisposable } from "babylonjs/scene";
  62153. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  62154. /**
  62155. * This class can be used to get instrumentation data from a Babylon engine
  62156. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62157. */
  62158. export class SceneInstrumentation implements IDisposable {
  62159. /**
  62160. * Defines the scene to instrument
  62161. */
  62162. scene: Scene;
  62163. private _captureActiveMeshesEvaluationTime;
  62164. private _activeMeshesEvaluationTime;
  62165. private _captureRenderTargetsRenderTime;
  62166. private _renderTargetsRenderTime;
  62167. private _captureFrameTime;
  62168. private _frameTime;
  62169. private _captureRenderTime;
  62170. private _renderTime;
  62171. private _captureInterFrameTime;
  62172. private _interFrameTime;
  62173. private _captureParticlesRenderTime;
  62174. private _particlesRenderTime;
  62175. private _captureSpritesRenderTime;
  62176. private _spritesRenderTime;
  62177. private _capturePhysicsTime;
  62178. private _physicsTime;
  62179. private _captureAnimationsTime;
  62180. private _animationsTime;
  62181. private _captureCameraRenderTime;
  62182. private _cameraRenderTime;
  62183. private _onBeforeActiveMeshesEvaluationObserver;
  62184. private _onAfterActiveMeshesEvaluationObserver;
  62185. private _onBeforeRenderTargetsRenderObserver;
  62186. private _onAfterRenderTargetsRenderObserver;
  62187. private _onAfterRenderObserver;
  62188. private _onBeforeDrawPhaseObserver;
  62189. private _onAfterDrawPhaseObserver;
  62190. private _onBeforeAnimationsObserver;
  62191. private _onBeforeParticlesRenderingObserver;
  62192. private _onAfterParticlesRenderingObserver;
  62193. private _onBeforeSpritesRenderingObserver;
  62194. private _onAfterSpritesRenderingObserver;
  62195. private _onBeforePhysicsObserver;
  62196. private _onAfterPhysicsObserver;
  62197. private _onAfterAnimationsObserver;
  62198. private _onBeforeCameraRenderObserver;
  62199. private _onAfterCameraRenderObserver;
  62200. /**
  62201. * Gets the perf counter used for active meshes evaluation time
  62202. */
  62203. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  62204. /**
  62205. * Gets the active meshes evaluation time capture status
  62206. */
  62207. get captureActiveMeshesEvaluationTime(): boolean;
  62208. /**
  62209. * Enable or disable the active meshes evaluation time capture
  62210. */
  62211. set captureActiveMeshesEvaluationTime(value: boolean);
  62212. /**
  62213. * Gets the perf counter used for render targets render time
  62214. */
  62215. get renderTargetsRenderTimeCounter(): PerfCounter;
  62216. /**
  62217. * Gets the render targets render time capture status
  62218. */
  62219. get captureRenderTargetsRenderTime(): boolean;
  62220. /**
  62221. * Enable or disable the render targets render time capture
  62222. */
  62223. set captureRenderTargetsRenderTime(value: boolean);
  62224. /**
  62225. * Gets the perf counter used for particles render time
  62226. */
  62227. get particlesRenderTimeCounter(): PerfCounter;
  62228. /**
  62229. * Gets the particles render time capture status
  62230. */
  62231. get captureParticlesRenderTime(): boolean;
  62232. /**
  62233. * Enable or disable the particles render time capture
  62234. */
  62235. set captureParticlesRenderTime(value: boolean);
  62236. /**
  62237. * Gets the perf counter used for sprites render time
  62238. */
  62239. get spritesRenderTimeCounter(): PerfCounter;
  62240. /**
  62241. * Gets the sprites render time capture status
  62242. */
  62243. get captureSpritesRenderTime(): boolean;
  62244. /**
  62245. * Enable or disable the sprites render time capture
  62246. */
  62247. set captureSpritesRenderTime(value: boolean);
  62248. /**
  62249. * Gets the perf counter used for physics time
  62250. */
  62251. get physicsTimeCounter(): PerfCounter;
  62252. /**
  62253. * Gets the physics time capture status
  62254. */
  62255. get capturePhysicsTime(): boolean;
  62256. /**
  62257. * Enable or disable the physics time capture
  62258. */
  62259. set capturePhysicsTime(value: boolean);
  62260. /**
  62261. * Gets the perf counter used for animations time
  62262. */
  62263. get animationsTimeCounter(): PerfCounter;
  62264. /**
  62265. * Gets the animations time capture status
  62266. */
  62267. get captureAnimationsTime(): boolean;
  62268. /**
  62269. * Enable or disable the animations time capture
  62270. */
  62271. set captureAnimationsTime(value: boolean);
  62272. /**
  62273. * Gets the perf counter used for frame time capture
  62274. */
  62275. get frameTimeCounter(): PerfCounter;
  62276. /**
  62277. * Gets the frame time capture status
  62278. */
  62279. get captureFrameTime(): boolean;
  62280. /**
  62281. * Enable or disable the frame time capture
  62282. */
  62283. set captureFrameTime(value: boolean);
  62284. /**
  62285. * Gets the perf counter used for inter-frames time capture
  62286. */
  62287. get interFrameTimeCounter(): PerfCounter;
  62288. /**
  62289. * Gets the inter-frames time capture status
  62290. */
  62291. get captureInterFrameTime(): boolean;
  62292. /**
  62293. * Enable or disable the inter-frames time capture
  62294. */
  62295. set captureInterFrameTime(value: boolean);
  62296. /**
  62297. * Gets the perf counter used for render time capture
  62298. */
  62299. get renderTimeCounter(): PerfCounter;
  62300. /**
  62301. * Gets the render time capture status
  62302. */
  62303. get captureRenderTime(): boolean;
  62304. /**
  62305. * Enable or disable the render time capture
  62306. */
  62307. set captureRenderTime(value: boolean);
  62308. /**
  62309. * Gets the perf counter used for camera render time capture
  62310. */
  62311. get cameraRenderTimeCounter(): PerfCounter;
  62312. /**
  62313. * Gets the camera render time capture status
  62314. */
  62315. get captureCameraRenderTime(): boolean;
  62316. /**
  62317. * Enable or disable the camera render time capture
  62318. */
  62319. set captureCameraRenderTime(value: boolean);
  62320. /**
  62321. * Gets the perf counter used for draw calls
  62322. */
  62323. get drawCallsCounter(): PerfCounter;
  62324. /**
  62325. * Instantiates a new scene instrumentation.
  62326. * This class can be used to get instrumentation data from a Babylon engine
  62327. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62328. * @param scene Defines the scene to instrument
  62329. */
  62330. constructor(
  62331. /**
  62332. * Defines the scene to instrument
  62333. */
  62334. scene: Scene);
  62335. /**
  62336. * Dispose and release associated resources.
  62337. */
  62338. dispose(): void;
  62339. }
  62340. }
  62341. declare module "babylonjs/Instrumentation/index" {
  62342. export * from "babylonjs/Instrumentation/engineInstrumentation";
  62343. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  62344. export * from "babylonjs/Instrumentation/timeToken";
  62345. }
  62346. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  62347. /** @hidden */
  62348. export var glowMapGenerationPixelShader: {
  62349. name: string;
  62350. shader: string;
  62351. };
  62352. }
  62353. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  62354. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62355. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62356. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62357. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62358. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62359. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62360. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62361. /** @hidden */
  62362. export var glowMapGenerationVertexShader: {
  62363. name: string;
  62364. shader: string;
  62365. };
  62366. }
  62367. declare module "babylonjs/Layers/effectLayer" {
  62368. import { Observable } from "babylonjs/Misc/observable";
  62369. import { Nullable } from "babylonjs/types";
  62370. import { Camera } from "babylonjs/Cameras/camera";
  62371. import { Scene } from "babylonjs/scene";
  62372. import { ISize } from "babylonjs/Maths/math.size";
  62373. import { Color4 } from "babylonjs/Maths/math.color";
  62374. import { Engine } from "babylonjs/Engines/engine";
  62375. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62377. import { Mesh } from "babylonjs/Meshes/mesh";
  62378. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62379. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62380. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62381. import { Effect } from "babylonjs/Materials/effect";
  62382. import { Material } from "babylonjs/Materials/material";
  62383. import "babylonjs/Shaders/glowMapGeneration.fragment";
  62384. import "babylonjs/Shaders/glowMapGeneration.vertex";
  62385. /**
  62386. * Effect layer options. This helps customizing the behaviour
  62387. * of the effect layer.
  62388. */
  62389. export interface IEffectLayerOptions {
  62390. /**
  62391. * Multiplication factor apply to the canvas size to compute the render target size
  62392. * used to generated the objects (the smaller the faster).
  62393. */
  62394. mainTextureRatio: number;
  62395. /**
  62396. * Enforces a fixed size texture to ensure effect stability across devices.
  62397. */
  62398. mainTextureFixedSize?: number;
  62399. /**
  62400. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  62401. */
  62402. alphaBlendingMode: number;
  62403. /**
  62404. * The camera attached to the layer.
  62405. */
  62406. camera: Nullable<Camera>;
  62407. /**
  62408. * The rendering group to draw the layer in.
  62409. */
  62410. renderingGroupId: number;
  62411. }
  62412. /**
  62413. * The effect layer Helps adding post process effect blended with the main pass.
  62414. *
  62415. * This can be for instance use to generate glow or higlight effects on the scene.
  62416. *
  62417. * The effect layer class can not be used directly and is intented to inherited from to be
  62418. * customized per effects.
  62419. */
  62420. export abstract class EffectLayer {
  62421. private _vertexBuffers;
  62422. private _indexBuffer;
  62423. private _cachedDefines;
  62424. private _effectLayerMapGenerationEffect;
  62425. private _effectLayerOptions;
  62426. private _mergeEffect;
  62427. protected _scene: Scene;
  62428. protected _engine: Engine;
  62429. protected _maxSize: number;
  62430. protected _mainTextureDesiredSize: ISize;
  62431. protected _mainTexture: RenderTargetTexture;
  62432. protected _shouldRender: boolean;
  62433. protected _postProcesses: PostProcess[];
  62434. protected _textures: BaseTexture[];
  62435. protected _emissiveTextureAndColor: {
  62436. texture: Nullable<BaseTexture>;
  62437. color: Color4;
  62438. };
  62439. /**
  62440. * The name of the layer
  62441. */
  62442. name: string;
  62443. /**
  62444. * The clear color of the texture used to generate the glow map.
  62445. */
  62446. neutralColor: Color4;
  62447. /**
  62448. * Specifies whether the highlight layer is enabled or not.
  62449. */
  62450. isEnabled: boolean;
  62451. /**
  62452. * Gets the camera attached to the layer.
  62453. */
  62454. get camera(): Nullable<Camera>;
  62455. /**
  62456. * Gets the rendering group id the layer should render in.
  62457. */
  62458. get renderingGroupId(): number;
  62459. set renderingGroupId(renderingGroupId: number);
  62460. /**
  62461. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  62462. */
  62463. disableBoundingBoxesFromEffectLayer: boolean;
  62464. /**
  62465. * An event triggered when the effect layer has been disposed.
  62466. */
  62467. onDisposeObservable: Observable<EffectLayer>;
  62468. /**
  62469. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  62470. */
  62471. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  62472. /**
  62473. * An event triggered when the generated texture is being merged in the scene.
  62474. */
  62475. onBeforeComposeObservable: Observable<EffectLayer>;
  62476. /**
  62477. * An event triggered when the mesh is rendered into the effect render target.
  62478. */
  62479. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  62480. /**
  62481. * An event triggered after the mesh has been rendered into the effect render target.
  62482. */
  62483. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  62484. /**
  62485. * An event triggered when the generated texture has been merged in the scene.
  62486. */
  62487. onAfterComposeObservable: Observable<EffectLayer>;
  62488. /**
  62489. * An event triggered when the efffect layer changes its size.
  62490. */
  62491. onSizeChangedObservable: Observable<EffectLayer>;
  62492. /** @hidden */
  62493. static _SceneComponentInitialization: (scene: Scene) => void;
  62494. /**
  62495. * Instantiates a new effect Layer and references it in the scene.
  62496. * @param name The name of the layer
  62497. * @param scene The scene to use the layer in
  62498. */
  62499. constructor(
  62500. /** The Friendly of the effect in the scene */
  62501. name: string, scene: Scene);
  62502. /**
  62503. * Get the effect name of the layer.
  62504. * @return The effect name
  62505. */
  62506. abstract getEffectName(): string;
  62507. /**
  62508. * Checks for the readiness of the element composing the layer.
  62509. * @param subMesh the mesh to check for
  62510. * @param useInstances specify whether or not to use instances to render the mesh
  62511. * @return true if ready otherwise, false
  62512. */
  62513. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62514. /**
  62515. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62516. * @returns true if the effect requires stencil during the main canvas render pass.
  62517. */
  62518. abstract needStencil(): boolean;
  62519. /**
  62520. * Create the merge effect. This is the shader use to blit the information back
  62521. * to the main canvas at the end of the scene rendering.
  62522. * @returns The effect containing the shader used to merge the effect on the main canvas
  62523. */
  62524. protected abstract _createMergeEffect(): Effect;
  62525. /**
  62526. * Creates the render target textures and post processes used in the effect layer.
  62527. */
  62528. protected abstract _createTextureAndPostProcesses(): void;
  62529. /**
  62530. * Implementation specific of rendering the generating effect on the main canvas.
  62531. * @param effect The effect used to render through
  62532. */
  62533. protected abstract _internalRender(effect: Effect): void;
  62534. /**
  62535. * Sets the required values for both the emissive texture and and the main color.
  62536. */
  62537. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62538. /**
  62539. * Free any resources and references associated to a mesh.
  62540. * Internal use
  62541. * @param mesh The mesh to free.
  62542. */
  62543. abstract _disposeMesh(mesh: Mesh): void;
  62544. /**
  62545. * Serializes this layer (Glow or Highlight for example)
  62546. * @returns a serialized layer object
  62547. */
  62548. abstract serialize?(): any;
  62549. /**
  62550. * Initializes the effect layer with the required options.
  62551. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  62552. */
  62553. protected _init(options: Partial<IEffectLayerOptions>): void;
  62554. /**
  62555. * Generates the index buffer of the full screen quad blending to the main canvas.
  62556. */
  62557. private _generateIndexBuffer;
  62558. /**
  62559. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  62560. */
  62561. private _generateVertexBuffer;
  62562. /**
  62563. * Sets the main texture desired size which is the closest power of two
  62564. * of the engine canvas size.
  62565. */
  62566. private _setMainTextureSize;
  62567. /**
  62568. * Creates the main texture for the effect layer.
  62569. */
  62570. protected _createMainTexture(): void;
  62571. /**
  62572. * Adds specific effects defines.
  62573. * @param defines The defines to add specifics to.
  62574. */
  62575. protected _addCustomEffectDefines(defines: string[]): void;
  62576. /**
  62577. * Checks for the readiness of the element composing the layer.
  62578. * @param subMesh the mesh to check for
  62579. * @param useInstances specify whether or not to use instances to render the mesh
  62580. * @param emissiveTexture the associated emissive texture used to generate the glow
  62581. * @return true if ready otherwise, false
  62582. */
  62583. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  62584. /**
  62585. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  62586. */
  62587. render(): void;
  62588. /**
  62589. * Determine if a given mesh will be used in the current effect.
  62590. * @param mesh mesh to test
  62591. * @returns true if the mesh will be used
  62592. */
  62593. hasMesh(mesh: AbstractMesh): boolean;
  62594. /**
  62595. * Returns true if the layer contains information to display, otherwise false.
  62596. * @returns true if the glow layer should be rendered
  62597. */
  62598. shouldRender(): boolean;
  62599. /**
  62600. * Returns true if the mesh should render, otherwise false.
  62601. * @param mesh The mesh to render
  62602. * @returns true if it should render otherwise false
  62603. */
  62604. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  62605. /**
  62606. * Returns true if the mesh can be rendered, otherwise false.
  62607. * @param mesh The mesh to render
  62608. * @param material The material used on the mesh
  62609. * @returns true if it can be rendered otherwise false
  62610. */
  62611. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62612. /**
  62613. * Returns true if the mesh should render, otherwise false.
  62614. * @param mesh The mesh to render
  62615. * @returns true if it should render otherwise false
  62616. */
  62617. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  62618. /**
  62619. * Renders the submesh passed in parameter to the generation map.
  62620. */
  62621. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  62622. /**
  62623. * Defines whether the current material of the mesh should be use to render the effect.
  62624. * @param mesh defines the current mesh to render
  62625. */
  62626. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62627. /**
  62628. * Rebuild the required buffers.
  62629. * @hidden Internal use only.
  62630. */
  62631. _rebuild(): void;
  62632. /**
  62633. * Dispose only the render target textures and post process.
  62634. */
  62635. private _disposeTextureAndPostProcesses;
  62636. /**
  62637. * Dispose the highlight layer and free resources.
  62638. */
  62639. dispose(): void;
  62640. /**
  62641. * Gets the class name of the effect layer
  62642. * @returns the string with the class name of the effect layer
  62643. */
  62644. getClassName(): string;
  62645. /**
  62646. * Creates an effect layer from parsed effect layer data
  62647. * @param parsedEffectLayer defines effect layer data
  62648. * @param scene defines the current scene
  62649. * @param rootUrl defines the root URL containing the effect layer information
  62650. * @returns a parsed effect Layer
  62651. */
  62652. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  62653. }
  62654. }
  62655. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  62656. import { Scene } from "babylonjs/scene";
  62657. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62658. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62659. import { AbstractScene } from "babylonjs/abstractScene";
  62660. module "babylonjs/abstractScene" {
  62661. interface AbstractScene {
  62662. /**
  62663. * The list of effect layers (highlights/glow) added to the scene
  62664. * @see https://doc.babylonjs.com/how_to/highlight_layer
  62665. * @see https://doc.babylonjs.com/how_to/glow_layer
  62666. */
  62667. effectLayers: Array<EffectLayer>;
  62668. /**
  62669. * Removes the given effect layer from this scene.
  62670. * @param toRemove defines the effect layer to remove
  62671. * @returns the index of the removed effect layer
  62672. */
  62673. removeEffectLayer(toRemove: EffectLayer): number;
  62674. /**
  62675. * Adds the given effect layer to this scene
  62676. * @param newEffectLayer defines the effect layer to add
  62677. */
  62678. addEffectLayer(newEffectLayer: EffectLayer): void;
  62679. }
  62680. }
  62681. /**
  62682. * Defines the layer scene component responsible to manage any effect layers
  62683. * in a given scene.
  62684. */
  62685. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  62686. /**
  62687. * The component name helpfull to identify the component in the list of scene components.
  62688. */
  62689. readonly name: string;
  62690. /**
  62691. * The scene the component belongs to.
  62692. */
  62693. scene: Scene;
  62694. private _engine;
  62695. private _renderEffects;
  62696. private _needStencil;
  62697. private _previousStencilState;
  62698. /**
  62699. * Creates a new instance of the component for the given scene
  62700. * @param scene Defines the scene to register the component in
  62701. */
  62702. constructor(scene: Scene);
  62703. /**
  62704. * Registers the component in a given scene
  62705. */
  62706. register(): void;
  62707. /**
  62708. * Rebuilds the elements related to this component in case of
  62709. * context lost for instance.
  62710. */
  62711. rebuild(): void;
  62712. /**
  62713. * Serializes the component data to the specified json object
  62714. * @param serializationObject The object to serialize to
  62715. */
  62716. serialize(serializationObject: any): void;
  62717. /**
  62718. * Adds all the elements from the container to the scene
  62719. * @param container the container holding the elements
  62720. */
  62721. addFromContainer(container: AbstractScene): void;
  62722. /**
  62723. * Removes all the elements in the container from the scene
  62724. * @param container contains the elements to remove
  62725. * @param dispose if the removed element should be disposed (default: false)
  62726. */
  62727. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62728. /**
  62729. * Disposes the component and the associated ressources.
  62730. */
  62731. dispose(): void;
  62732. private _isReadyForMesh;
  62733. private _renderMainTexture;
  62734. private _setStencil;
  62735. private _setStencilBack;
  62736. private _draw;
  62737. private _drawCamera;
  62738. private _drawRenderingGroup;
  62739. }
  62740. }
  62741. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  62742. /** @hidden */
  62743. export var glowMapMergePixelShader: {
  62744. name: string;
  62745. shader: string;
  62746. };
  62747. }
  62748. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  62749. /** @hidden */
  62750. export var glowMapMergeVertexShader: {
  62751. name: string;
  62752. shader: string;
  62753. };
  62754. }
  62755. declare module "babylonjs/Layers/glowLayer" {
  62756. import { Nullable } from "babylonjs/types";
  62757. import { Camera } from "babylonjs/Cameras/camera";
  62758. import { Scene } from "babylonjs/scene";
  62759. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62761. import { Mesh } from "babylonjs/Meshes/mesh";
  62762. import { Texture } from "babylonjs/Materials/Textures/texture";
  62763. import { Effect } from "babylonjs/Materials/effect";
  62764. import { Material } from "babylonjs/Materials/material";
  62765. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62766. import { Color4 } from "babylonjs/Maths/math.color";
  62767. import "babylonjs/Shaders/glowMapMerge.fragment";
  62768. import "babylonjs/Shaders/glowMapMerge.vertex";
  62769. import "babylonjs/Layers/effectLayerSceneComponent";
  62770. module "babylonjs/abstractScene" {
  62771. interface AbstractScene {
  62772. /**
  62773. * Return a the first highlight layer of the scene with a given name.
  62774. * @param name The name of the highlight layer to look for.
  62775. * @return The highlight layer if found otherwise null.
  62776. */
  62777. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  62778. }
  62779. }
  62780. /**
  62781. * Glow layer options. This helps customizing the behaviour
  62782. * of the glow layer.
  62783. */
  62784. export interface IGlowLayerOptions {
  62785. /**
  62786. * Multiplication factor apply to the canvas size to compute the render target size
  62787. * used to generated the glowing objects (the smaller the faster).
  62788. */
  62789. mainTextureRatio: number;
  62790. /**
  62791. * Enforces a fixed size texture to ensure resize independant blur.
  62792. */
  62793. mainTextureFixedSize?: number;
  62794. /**
  62795. * How big is the kernel of the blur texture.
  62796. */
  62797. blurKernelSize: number;
  62798. /**
  62799. * The camera attached to the layer.
  62800. */
  62801. camera: Nullable<Camera>;
  62802. /**
  62803. * Enable MSAA by chosing the number of samples.
  62804. */
  62805. mainTextureSamples?: number;
  62806. /**
  62807. * The rendering group to draw the layer in.
  62808. */
  62809. renderingGroupId: number;
  62810. }
  62811. /**
  62812. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  62813. *
  62814. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  62815. *
  62816. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  62817. */
  62818. export class GlowLayer extends EffectLayer {
  62819. /**
  62820. * Effect Name of the layer.
  62821. */
  62822. static readonly EffectName: string;
  62823. /**
  62824. * The default blur kernel size used for the glow.
  62825. */
  62826. static DefaultBlurKernelSize: number;
  62827. /**
  62828. * The default texture size ratio used for the glow.
  62829. */
  62830. static DefaultTextureRatio: number;
  62831. /**
  62832. * Sets the kernel size of the blur.
  62833. */
  62834. set blurKernelSize(value: number);
  62835. /**
  62836. * Gets the kernel size of the blur.
  62837. */
  62838. get blurKernelSize(): number;
  62839. /**
  62840. * Sets the glow intensity.
  62841. */
  62842. set intensity(value: number);
  62843. /**
  62844. * Gets the glow intensity.
  62845. */
  62846. get intensity(): number;
  62847. private _options;
  62848. private _intensity;
  62849. private _horizontalBlurPostprocess1;
  62850. private _verticalBlurPostprocess1;
  62851. private _horizontalBlurPostprocess2;
  62852. private _verticalBlurPostprocess2;
  62853. private _blurTexture1;
  62854. private _blurTexture2;
  62855. private _postProcesses1;
  62856. private _postProcesses2;
  62857. private _includedOnlyMeshes;
  62858. private _excludedMeshes;
  62859. private _meshesUsingTheirOwnMaterials;
  62860. /**
  62861. * Callback used to let the user override the color selection on a per mesh basis
  62862. */
  62863. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  62864. /**
  62865. * Callback used to let the user override the texture selection on a per mesh basis
  62866. */
  62867. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  62868. /**
  62869. * Instantiates a new glow Layer and references it to the scene.
  62870. * @param name The name of the layer
  62871. * @param scene The scene to use the layer in
  62872. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  62873. */
  62874. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  62875. /**
  62876. * Get the effect name of the layer.
  62877. * @return The effect name
  62878. */
  62879. getEffectName(): string;
  62880. /**
  62881. * Create the merge effect. This is the shader use to blit the information back
  62882. * to the main canvas at the end of the scene rendering.
  62883. */
  62884. protected _createMergeEffect(): Effect;
  62885. /**
  62886. * Creates the render target textures and post processes used in the glow layer.
  62887. */
  62888. protected _createTextureAndPostProcesses(): void;
  62889. /**
  62890. * Checks for the readiness of the element composing the layer.
  62891. * @param subMesh the mesh to check for
  62892. * @param useInstances specify wether or not to use instances to render the mesh
  62893. * @param emissiveTexture the associated emissive texture used to generate the glow
  62894. * @return true if ready otherwise, false
  62895. */
  62896. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62897. /**
  62898. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62899. */
  62900. needStencil(): boolean;
  62901. /**
  62902. * Returns true if the mesh can be rendered, otherwise false.
  62903. * @param mesh The mesh to render
  62904. * @param material The material used on the mesh
  62905. * @returns true if it can be rendered otherwise false
  62906. */
  62907. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62908. /**
  62909. * Implementation specific of rendering the generating effect on the main canvas.
  62910. * @param effect The effect used to render through
  62911. */
  62912. protected _internalRender(effect: Effect): void;
  62913. /**
  62914. * Sets the required values for both the emissive texture and and the main color.
  62915. */
  62916. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62917. /**
  62918. * Returns true if the mesh should render, otherwise false.
  62919. * @param mesh The mesh to render
  62920. * @returns true if it should render otherwise false
  62921. */
  62922. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62923. /**
  62924. * Adds specific effects defines.
  62925. * @param defines The defines to add specifics to.
  62926. */
  62927. protected _addCustomEffectDefines(defines: string[]): void;
  62928. /**
  62929. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  62930. * @param mesh The mesh to exclude from the glow layer
  62931. */
  62932. addExcludedMesh(mesh: Mesh): void;
  62933. /**
  62934. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  62935. * @param mesh The mesh to remove
  62936. */
  62937. removeExcludedMesh(mesh: Mesh): void;
  62938. /**
  62939. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  62940. * @param mesh The mesh to include in the glow layer
  62941. */
  62942. addIncludedOnlyMesh(mesh: Mesh): void;
  62943. /**
  62944. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  62945. * @param mesh The mesh to remove
  62946. */
  62947. removeIncludedOnlyMesh(mesh: Mesh): void;
  62948. /**
  62949. * Determine if a given mesh will be used in the glow layer
  62950. * @param mesh The mesh to test
  62951. * @returns true if the mesh will be highlighted by the current glow layer
  62952. */
  62953. hasMesh(mesh: AbstractMesh): boolean;
  62954. /**
  62955. * Defines whether the current material of the mesh should be use to render the effect.
  62956. * @param mesh defines the current mesh to render
  62957. */
  62958. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62959. /**
  62960. * Add a mesh to be rendered through its own material and not with emissive only.
  62961. * @param mesh The mesh for which we need to use its material
  62962. */
  62963. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  62964. /**
  62965. * Remove a mesh from being rendered through its own material and not with emissive only.
  62966. * @param mesh The mesh for which we need to not use its material
  62967. */
  62968. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  62969. /**
  62970. * Free any resources and references associated to a mesh.
  62971. * Internal use
  62972. * @param mesh The mesh to free.
  62973. * @hidden
  62974. */
  62975. _disposeMesh(mesh: Mesh): void;
  62976. /**
  62977. * Gets the class name of the effect layer
  62978. * @returns the string with the class name of the effect layer
  62979. */
  62980. getClassName(): string;
  62981. /**
  62982. * Serializes this glow layer
  62983. * @returns a serialized glow layer object
  62984. */
  62985. serialize(): any;
  62986. /**
  62987. * Creates a Glow Layer from parsed glow layer data
  62988. * @param parsedGlowLayer defines glow layer data
  62989. * @param scene defines the current scene
  62990. * @param rootUrl defines the root URL containing the glow layer information
  62991. * @returns a parsed Glow Layer
  62992. */
  62993. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  62994. }
  62995. }
  62996. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  62997. /** @hidden */
  62998. export var glowBlurPostProcessPixelShader: {
  62999. name: string;
  63000. shader: string;
  63001. };
  63002. }
  63003. declare module "babylonjs/Layers/highlightLayer" {
  63004. import { Observable } from "babylonjs/Misc/observable";
  63005. import { Nullable } from "babylonjs/types";
  63006. import { Camera } from "babylonjs/Cameras/camera";
  63007. import { Scene } from "babylonjs/scene";
  63008. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63010. import { Mesh } from "babylonjs/Meshes/mesh";
  63011. import { Effect } from "babylonjs/Materials/effect";
  63012. import { Material } from "babylonjs/Materials/material";
  63013. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  63014. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  63015. import "babylonjs/Shaders/glowMapMerge.fragment";
  63016. import "babylonjs/Shaders/glowMapMerge.vertex";
  63017. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  63018. module "babylonjs/abstractScene" {
  63019. interface AbstractScene {
  63020. /**
  63021. * Return a the first highlight layer of the scene with a given name.
  63022. * @param name The name of the highlight layer to look for.
  63023. * @return The highlight layer if found otherwise null.
  63024. */
  63025. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  63026. }
  63027. }
  63028. /**
  63029. * Highlight layer options. This helps customizing the behaviour
  63030. * of the highlight layer.
  63031. */
  63032. export interface IHighlightLayerOptions {
  63033. /**
  63034. * Multiplication factor apply to the canvas size to compute the render target size
  63035. * used to generated the glowing objects (the smaller the faster).
  63036. */
  63037. mainTextureRatio: number;
  63038. /**
  63039. * Enforces a fixed size texture to ensure resize independant blur.
  63040. */
  63041. mainTextureFixedSize?: number;
  63042. /**
  63043. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  63044. * of the picture to blur (the smaller the faster).
  63045. */
  63046. blurTextureSizeRatio: number;
  63047. /**
  63048. * How big in texel of the blur texture is the vertical blur.
  63049. */
  63050. blurVerticalSize: number;
  63051. /**
  63052. * How big in texel of the blur texture is the horizontal blur.
  63053. */
  63054. blurHorizontalSize: number;
  63055. /**
  63056. * Alpha blending mode used to apply the blur. Default is combine.
  63057. */
  63058. alphaBlendingMode: number;
  63059. /**
  63060. * The camera attached to the layer.
  63061. */
  63062. camera: Nullable<Camera>;
  63063. /**
  63064. * Should we display highlight as a solid stroke?
  63065. */
  63066. isStroke?: boolean;
  63067. /**
  63068. * The rendering group to draw the layer in.
  63069. */
  63070. renderingGroupId: number;
  63071. }
  63072. /**
  63073. * The highlight layer Helps adding a glow effect around a mesh.
  63074. *
  63075. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  63076. * glowy meshes to your scene.
  63077. *
  63078. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  63079. */
  63080. export class HighlightLayer extends EffectLayer {
  63081. name: string;
  63082. /**
  63083. * Effect Name of the highlight layer.
  63084. */
  63085. static readonly EffectName: string;
  63086. /**
  63087. * The neutral color used during the preparation of the glow effect.
  63088. * This is black by default as the blend operation is a blend operation.
  63089. */
  63090. static NeutralColor: Color4;
  63091. /**
  63092. * Stencil value used for glowing meshes.
  63093. */
  63094. static GlowingMeshStencilReference: number;
  63095. /**
  63096. * Stencil value used for the other meshes in the scene.
  63097. */
  63098. static NormalMeshStencilReference: number;
  63099. /**
  63100. * Specifies whether or not the inner glow is ACTIVE in the layer.
  63101. */
  63102. innerGlow: boolean;
  63103. /**
  63104. * Specifies whether or not the outer glow is ACTIVE in the layer.
  63105. */
  63106. outerGlow: boolean;
  63107. /**
  63108. * Specifies the horizontal size of the blur.
  63109. */
  63110. set blurHorizontalSize(value: number);
  63111. /**
  63112. * Specifies the vertical size of the blur.
  63113. */
  63114. set blurVerticalSize(value: number);
  63115. /**
  63116. * Gets the horizontal size of the blur.
  63117. */
  63118. get blurHorizontalSize(): number;
  63119. /**
  63120. * Gets the vertical size of the blur.
  63121. */
  63122. get blurVerticalSize(): number;
  63123. /**
  63124. * An event triggered when the highlight layer is being blurred.
  63125. */
  63126. onBeforeBlurObservable: Observable<HighlightLayer>;
  63127. /**
  63128. * An event triggered when the highlight layer has been blurred.
  63129. */
  63130. onAfterBlurObservable: Observable<HighlightLayer>;
  63131. private _instanceGlowingMeshStencilReference;
  63132. private _options;
  63133. private _downSamplePostprocess;
  63134. private _horizontalBlurPostprocess;
  63135. private _verticalBlurPostprocess;
  63136. private _blurTexture;
  63137. private _meshes;
  63138. private _excludedMeshes;
  63139. /**
  63140. * Instantiates a new highlight Layer and references it to the scene..
  63141. * @param name The name of the layer
  63142. * @param scene The scene to use the layer in
  63143. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  63144. */
  63145. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  63146. /**
  63147. * Get the effect name of the layer.
  63148. * @return The effect name
  63149. */
  63150. getEffectName(): string;
  63151. /**
  63152. * Create the merge effect. This is the shader use to blit the information back
  63153. * to the main canvas at the end of the scene rendering.
  63154. */
  63155. protected _createMergeEffect(): Effect;
  63156. /**
  63157. * Creates the render target textures and post processes used in the highlight layer.
  63158. */
  63159. protected _createTextureAndPostProcesses(): void;
  63160. /**
  63161. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  63162. */
  63163. needStencil(): boolean;
  63164. /**
  63165. * Checks for the readiness of the element composing the layer.
  63166. * @param subMesh the mesh to check for
  63167. * @param useInstances specify wether or not to use instances to render the mesh
  63168. * @param emissiveTexture the associated emissive texture used to generate the glow
  63169. * @return true if ready otherwise, false
  63170. */
  63171. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63172. /**
  63173. * Implementation specific of rendering the generating effect on the main canvas.
  63174. * @param effect The effect used to render through
  63175. */
  63176. protected _internalRender(effect: Effect): void;
  63177. /**
  63178. * Returns true if the layer contains information to display, otherwise false.
  63179. */
  63180. shouldRender(): boolean;
  63181. /**
  63182. * Returns true if the mesh should render, otherwise false.
  63183. * @param mesh The mesh to render
  63184. * @returns true if it should render otherwise false
  63185. */
  63186. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63187. /**
  63188. * Returns true if the mesh can be rendered, otherwise false.
  63189. * @param mesh The mesh to render
  63190. * @param material The material used on the mesh
  63191. * @returns true if it can be rendered otherwise false
  63192. */
  63193. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63194. /**
  63195. * Adds specific effects defines.
  63196. * @param defines The defines to add specifics to.
  63197. */
  63198. protected _addCustomEffectDefines(defines: string[]): void;
  63199. /**
  63200. * Sets the required values for both the emissive texture and and the main color.
  63201. */
  63202. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63203. /**
  63204. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  63205. * @param mesh The mesh to exclude from the highlight layer
  63206. */
  63207. addExcludedMesh(mesh: Mesh): void;
  63208. /**
  63209. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  63210. * @param mesh The mesh to highlight
  63211. */
  63212. removeExcludedMesh(mesh: Mesh): void;
  63213. /**
  63214. * Determine if a given mesh will be highlighted by the current HighlightLayer
  63215. * @param mesh mesh to test
  63216. * @returns true if the mesh will be highlighted by the current HighlightLayer
  63217. */
  63218. hasMesh(mesh: AbstractMesh): boolean;
  63219. /**
  63220. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  63221. * @param mesh The mesh to highlight
  63222. * @param color The color of the highlight
  63223. * @param glowEmissiveOnly Extract the glow from the emissive texture
  63224. */
  63225. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  63226. /**
  63227. * Remove a mesh from the highlight layer in order to make it stop glowing.
  63228. * @param mesh The mesh to highlight
  63229. */
  63230. removeMesh(mesh: Mesh): void;
  63231. /**
  63232. * Remove all the meshes currently referenced in the highlight layer
  63233. */
  63234. removeAllMeshes(): void;
  63235. /**
  63236. * Force the stencil to the normal expected value for none glowing parts
  63237. */
  63238. private _defaultStencilReference;
  63239. /**
  63240. * Free any resources and references associated to a mesh.
  63241. * Internal use
  63242. * @param mesh The mesh to free.
  63243. * @hidden
  63244. */
  63245. _disposeMesh(mesh: Mesh): void;
  63246. /**
  63247. * Dispose the highlight layer and free resources.
  63248. */
  63249. dispose(): void;
  63250. /**
  63251. * Gets the class name of the effect layer
  63252. * @returns the string with the class name of the effect layer
  63253. */
  63254. getClassName(): string;
  63255. /**
  63256. * Serializes this Highlight layer
  63257. * @returns a serialized Highlight layer object
  63258. */
  63259. serialize(): any;
  63260. /**
  63261. * Creates a Highlight layer from parsed Highlight layer data
  63262. * @param parsedHightlightLayer defines the Highlight layer data
  63263. * @param scene defines the current scene
  63264. * @param rootUrl defines the root URL containing the Highlight layer information
  63265. * @returns a parsed Highlight layer
  63266. */
  63267. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  63268. }
  63269. }
  63270. declare module "babylonjs/Layers/layerSceneComponent" {
  63271. import { Scene } from "babylonjs/scene";
  63272. import { ISceneComponent } from "babylonjs/sceneComponent";
  63273. import { Layer } from "babylonjs/Layers/layer";
  63274. import { AbstractScene } from "babylonjs/abstractScene";
  63275. module "babylonjs/abstractScene" {
  63276. interface AbstractScene {
  63277. /**
  63278. * The list of layers (background and foreground) of the scene
  63279. */
  63280. layers: Array<Layer>;
  63281. }
  63282. }
  63283. /**
  63284. * Defines the layer scene component responsible to manage any layers
  63285. * in a given scene.
  63286. */
  63287. export class LayerSceneComponent implements ISceneComponent {
  63288. /**
  63289. * The component name helpfull to identify the component in the list of scene components.
  63290. */
  63291. readonly name: string;
  63292. /**
  63293. * The scene the component belongs to.
  63294. */
  63295. scene: Scene;
  63296. private _engine;
  63297. /**
  63298. * Creates a new instance of the component for the given scene
  63299. * @param scene Defines the scene to register the component in
  63300. */
  63301. constructor(scene: Scene);
  63302. /**
  63303. * Registers the component in a given scene
  63304. */
  63305. register(): void;
  63306. /**
  63307. * Rebuilds the elements related to this component in case of
  63308. * context lost for instance.
  63309. */
  63310. rebuild(): void;
  63311. /**
  63312. * Disposes the component and the associated ressources.
  63313. */
  63314. dispose(): void;
  63315. private _draw;
  63316. private _drawCameraPredicate;
  63317. private _drawCameraBackground;
  63318. private _drawCameraForeground;
  63319. private _drawRenderTargetPredicate;
  63320. private _drawRenderTargetBackground;
  63321. private _drawRenderTargetForeground;
  63322. /**
  63323. * Adds all the elements from the container to the scene
  63324. * @param container the container holding the elements
  63325. */
  63326. addFromContainer(container: AbstractScene): void;
  63327. /**
  63328. * Removes all the elements in the container from the scene
  63329. * @param container contains the elements to remove
  63330. * @param dispose if the removed element should be disposed (default: false)
  63331. */
  63332. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63333. }
  63334. }
  63335. declare module "babylonjs/Shaders/layer.fragment" {
  63336. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63337. /** @hidden */
  63338. export var layerPixelShader: {
  63339. name: string;
  63340. shader: string;
  63341. };
  63342. }
  63343. declare module "babylonjs/Shaders/layer.vertex" {
  63344. /** @hidden */
  63345. export var layerVertexShader: {
  63346. name: string;
  63347. shader: string;
  63348. };
  63349. }
  63350. declare module "babylonjs/Layers/layer" {
  63351. import { Observable } from "babylonjs/Misc/observable";
  63352. import { Nullable } from "babylonjs/types";
  63353. import { Scene } from "babylonjs/scene";
  63354. import { Vector2 } from "babylonjs/Maths/math.vector";
  63355. import { Color4 } from "babylonjs/Maths/math.color";
  63356. import { Texture } from "babylonjs/Materials/Textures/texture";
  63357. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63358. import "babylonjs/Shaders/layer.fragment";
  63359. import "babylonjs/Shaders/layer.vertex";
  63360. /**
  63361. * This represents a full screen 2d layer.
  63362. * This can be useful to display a picture in the background of your scene for instance.
  63363. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63364. */
  63365. export class Layer {
  63366. /**
  63367. * Define the name of the layer.
  63368. */
  63369. name: string;
  63370. /**
  63371. * Define the texture the layer should display.
  63372. */
  63373. texture: Nullable<Texture>;
  63374. /**
  63375. * Is the layer in background or foreground.
  63376. */
  63377. isBackground: boolean;
  63378. /**
  63379. * Define the color of the layer (instead of texture).
  63380. */
  63381. color: Color4;
  63382. /**
  63383. * Define the scale of the layer in order to zoom in out of the texture.
  63384. */
  63385. scale: Vector2;
  63386. /**
  63387. * Define an offset for the layer in order to shift the texture.
  63388. */
  63389. offset: Vector2;
  63390. /**
  63391. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  63392. */
  63393. alphaBlendingMode: number;
  63394. /**
  63395. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  63396. * Alpha test will not mix with the background color in case of transparency.
  63397. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  63398. */
  63399. alphaTest: boolean;
  63400. /**
  63401. * Define a mask to restrict the layer to only some of the scene cameras.
  63402. */
  63403. layerMask: number;
  63404. /**
  63405. * Define the list of render target the layer is visible into.
  63406. */
  63407. renderTargetTextures: RenderTargetTexture[];
  63408. /**
  63409. * Define if the layer is only used in renderTarget or if it also
  63410. * renders in the main frame buffer of the canvas.
  63411. */
  63412. renderOnlyInRenderTargetTextures: boolean;
  63413. private _scene;
  63414. private _vertexBuffers;
  63415. private _indexBuffer;
  63416. private _effect;
  63417. private _previousDefines;
  63418. /**
  63419. * An event triggered when the layer is disposed.
  63420. */
  63421. onDisposeObservable: Observable<Layer>;
  63422. private _onDisposeObserver;
  63423. /**
  63424. * Back compatibility with callback before the onDisposeObservable existed.
  63425. * The set callback will be triggered when the layer has been disposed.
  63426. */
  63427. set onDispose(callback: () => void);
  63428. /**
  63429. * An event triggered before rendering the scene
  63430. */
  63431. onBeforeRenderObservable: Observable<Layer>;
  63432. private _onBeforeRenderObserver;
  63433. /**
  63434. * Back compatibility with callback before the onBeforeRenderObservable existed.
  63435. * The set callback will be triggered just before rendering the layer.
  63436. */
  63437. set onBeforeRender(callback: () => void);
  63438. /**
  63439. * An event triggered after rendering the scene
  63440. */
  63441. onAfterRenderObservable: Observable<Layer>;
  63442. private _onAfterRenderObserver;
  63443. /**
  63444. * Back compatibility with callback before the onAfterRenderObservable existed.
  63445. * The set callback will be triggered just after rendering the layer.
  63446. */
  63447. set onAfterRender(callback: () => void);
  63448. /**
  63449. * Instantiates a new layer.
  63450. * This represents a full screen 2d layer.
  63451. * This can be useful to display a picture in the background of your scene for instance.
  63452. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63453. * @param name Define the name of the layer in the scene
  63454. * @param imgUrl Define the url of the texture to display in the layer
  63455. * @param scene Define the scene the layer belongs to
  63456. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  63457. * @param color Defines a color for the layer
  63458. */
  63459. constructor(
  63460. /**
  63461. * Define the name of the layer.
  63462. */
  63463. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  63464. private _createIndexBuffer;
  63465. /** @hidden */
  63466. _rebuild(): void;
  63467. /**
  63468. * Renders the layer in the scene.
  63469. */
  63470. render(): void;
  63471. /**
  63472. * Disposes and releases the associated ressources.
  63473. */
  63474. dispose(): void;
  63475. }
  63476. }
  63477. declare module "babylonjs/Layers/index" {
  63478. export * from "babylonjs/Layers/effectLayer";
  63479. export * from "babylonjs/Layers/effectLayerSceneComponent";
  63480. export * from "babylonjs/Layers/glowLayer";
  63481. export * from "babylonjs/Layers/highlightLayer";
  63482. export * from "babylonjs/Layers/layer";
  63483. export * from "babylonjs/Layers/layerSceneComponent";
  63484. }
  63485. declare module "babylonjs/Shaders/lensFlare.fragment" {
  63486. /** @hidden */
  63487. export var lensFlarePixelShader: {
  63488. name: string;
  63489. shader: string;
  63490. };
  63491. }
  63492. declare module "babylonjs/Shaders/lensFlare.vertex" {
  63493. /** @hidden */
  63494. export var lensFlareVertexShader: {
  63495. name: string;
  63496. shader: string;
  63497. };
  63498. }
  63499. declare module "babylonjs/LensFlares/lensFlareSystem" {
  63500. import { Scene } from "babylonjs/scene";
  63501. import { Vector3 } from "babylonjs/Maths/math.vector";
  63502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63503. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  63504. import "babylonjs/Shaders/lensFlare.fragment";
  63505. import "babylonjs/Shaders/lensFlare.vertex";
  63506. import { Viewport } from "babylonjs/Maths/math.viewport";
  63507. /**
  63508. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63509. * It is usually composed of several `lensFlare`.
  63510. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63511. */
  63512. export class LensFlareSystem {
  63513. /**
  63514. * Define the name of the lens flare system
  63515. */
  63516. name: string;
  63517. /**
  63518. * List of lens flares used in this system.
  63519. */
  63520. lensFlares: LensFlare[];
  63521. /**
  63522. * Define a limit from the border the lens flare can be visible.
  63523. */
  63524. borderLimit: number;
  63525. /**
  63526. * Define a viewport border we do not want to see the lens flare in.
  63527. */
  63528. viewportBorder: number;
  63529. /**
  63530. * Define a predicate which could limit the list of meshes able to occlude the effect.
  63531. */
  63532. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  63533. /**
  63534. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  63535. */
  63536. layerMask: number;
  63537. /**
  63538. * Define the id of the lens flare system in the scene.
  63539. * (equal to name by default)
  63540. */
  63541. id: string;
  63542. private _scene;
  63543. private _emitter;
  63544. private _vertexBuffers;
  63545. private _indexBuffer;
  63546. private _effect;
  63547. private _positionX;
  63548. private _positionY;
  63549. private _isEnabled;
  63550. /** @hidden */
  63551. static _SceneComponentInitialization: (scene: Scene) => void;
  63552. /**
  63553. * Instantiates a lens flare system.
  63554. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63555. * It is usually composed of several `lensFlare`.
  63556. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63557. * @param name Define the name of the lens flare system in the scene
  63558. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  63559. * @param scene Define the scene the lens flare system belongs to
  63560. */
  63561. constructor(
  63562. /**
  63563. * Define the name of the lens flare system
  63564. */
  63565. name: string, emitter: any, scene: Scene);
  63566. /**
  63567. * Define if the lens flare system is enabled.
  63568. */
  63569. get isEnabled(): boolean;
  63570. set isEnabled(value: boolean);
  63571. /**
  63572. * Get the scene the effects belongs to.
  63573. * @returns the scene holding the lens flare system
  63574. */
  63575. getScene(): Scene;
  63576. /**
  63577. * Get the emitter of the lens flare system.
  63578. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63579. * @returns the emitter of the lens flare system
  63580. */
  63581. getEmitter(): any;
  63582. /**
  63583. * Set the emitter of the lens flare system.
  63584. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63585. * @param newEmitter Define the new emitter of the system
  63586. */
  63587. setEmitter(newEmitter: any): void;
  63588. /**
  63589. * Get the lens flare system emitter position.
  63590. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  63591. * @returns the position
  63592. */
  63593. getEmitterPosition(): Vector3;
  63594. /**
  63595. * @hidden
  63596. */
  63597. computeEffectivePosition(globalViewport: Viewport): boolean;
  63598. /** @hidden */
  63599. _isVisible(): boolean;
  63600. /**
  63601. * @hidden
  63602. */
  63603. render(): boolean;
  63604. /**
  63605. * Dispose and release the lens flare with its associated resources.
  63606. */
  63607. dispose(): void;
  63608. /**
  63609. * Parse a lens flare system from a JSON repressentation
  63610. * @param parsedLensFlareSystem Define the JSON to parse
  63611. * @param scene Define the scene the parsed system should be instantiated in
  63612. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  63613. * @returns the parsed system
  63614. */
  63615. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  63616. /**
  63617. * Serialize the current Lens Flare System into a JSON representation.
  63618. * @returns the serialized JSON
  63619. */
  63620. serialize(): any;
  63621. }
  63622. }
  63623. declare module "babylonjs/LensFlares/lensFlare" {
  63624. import { Nullable } from "babylonjs/types";
  63625. import { Color3 } from "babylonjs/Maths/math.color";
  63626. import { Texture } from "babylonjs/Materials/Textures/texture";
  63627. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  63628. /**
  63629. * This represents one of the lens effect in a `lensFlareSystem`.
  63630. * It controls one of the indiviual texture used in the effect.
  63631. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63632. */
  63633. export class LensFlare {
  63634. /**
  63635. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63636. */
  63637. size: number;
  63638. /**
  63639. * 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.
  63640. */
  63641. position: number;
  63642. /**
  63643. * Define the lens color.
  63644. */
  63645. color: Color3;
  63646. /**
  63647. * Define the lens texture.
  63648. */
  63649. texture: Nullable<Texture>;
  63650. /**
  63651. * Define the alpha mode to render this particular lens.
  63652. */
  63653. alphaMode: number;
  63654. private _system;
  63655. /**
  63656. * Creates a new Lens Flare.
  63657. * This represents one of the lens effect in a `lensFlareSystem`.
  63658. * It controls one of the indiviual texture used in the effect.
  63659. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63660. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  63661. * @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.
  63662. * @param color Define the lens color
  63663. * @param imgUrl Define the lens texture url
  63664. * @param system Define the `lensFlareSystem` this flare is part of
  63665. * @returns The newly created Lens Flare
  63666. */
  63667. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  63668. /**
  63669. * Instantiates a new Lens Flare.
  63670. * This represents one of the lens effect in a `lensFlareSystem`.
  63671. * It controls one of the indiviual texture used in the effect.
  63672. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63673. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  63674. * @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.
  63675. * @param color Define the lens color
  63676. * @param imgUrl Define the lens texture url
  63677. * @param system Define the `lensFlareSystem` this flare is part of
  63678. */
  63679. constructor(
  63680. /**
  63681. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63682. */
  63683. size: number,
  63684. /**
  63685. * 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.
  63686. */
  63687. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  63688. /**
  63689. * Dispose and release the lens flare with its associated resources.
  63690. */
  63691. dispose(): void;
  63692. }
  63693. }
  63694. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  63695. import { Nullable } from "babylonjs/types";
  63696. import { Scene } from "babylonjs/scene";
  63697. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63698. import { AbstractScene } from "babylonjs/abstractScene";
  63699. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  63700. module "babylonjs/abstractScene" {
  63701. interface AbstractScene {
  63702. /**
  63703. * The list of lens flare system added to the scene
  63704. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63705. */
  63706. lensFlareSystems: Array<LensFlareSystem>;
  63707. /**
  63708. * Removes the given lens flare system from this scene.
  63709. * @param toRemove The lens flare system to remove
  63710. * @returns The index of the removed lens flare system
  63711. */
  63712. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  63713. /**
  63714. * Adds the given lens flare system to this scene
  63715. * @param newLensFlareSystem The lens flare system to add
  63716. */
  63717. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  63718. /**
  63719. * Gets a lens flare system using its name
  63720. * @param name defines the name to look for
  63721. * @returns the lens flare system or null if not found
  63722. */
  63723. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  63724. /**
  63725. * Gets a lens flare system using its id
  63726. * @param id defines the id to look for
  63727. * @returns the lens flare system or null if not found
  63728. */
  63729. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  63730. }
  63731. }
  63732. /**
  63733. * Defines the lens flare scene component responsible to manage any lens flares
  63734. * in a given scene.
  63735. */
  63736. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  63737. /**
  63738. * The component name helpfull to identify the component in the list of scene components.
  63739. */
  63740. readonly name: string;
  63741. /**
  63742. * The scene the component belongs to.
  63743. */
  63744. scene: Scene;
  63745. /**
  63746. * Creates a new instance of the component for the given scene
  63747. * @param scene Defines the scene to register the component in
  63748. */
  63749. constructor(scene: Scene);
  63750. /**
  63751. * Registers the component in a given scene
  63752. */
  63753. register(): void;
  63754. /**
  63755. * Rebuilds the elements related to this component in case of
  63756. * context lost for instance.
  63757. */
  63758. rebuild(): void;
  63759. /**
  63760. * Adds all the elements from the container to the scene
  63761. * @param container the container holding the elements
  63762. */
  63763. addFromContainer(container: AbstractScene): void;
  63764. /**
  63765. * Removes all the elements in the container from the scene
  63766. * @param container contains the elements to remove
  63767. * @param dispose if the removed element should be disposed (default: false)
  63768. */
  63769. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63770. /**
  63771. * Serializes the component data to the specified json object
  63772. * @param serializationObject The object to serialize to
  63773. */
  63774. serialize(serializationObject: any): void;
  63775. /**
  63776. * Disposes the component and the associated ressources.
  63777. */
  63778. dispose(): void;
  63779. private _draw;
  63780. }
  63781. }
  63782. declare module "babylonjs/LensFlares/index" {
  63783. export * from "babylonjs/LensFlares/lensFlare";
  63784. export * from "babylonjs/LensFlares/lensFlareSystem";
  63785. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  63786. }
  63787. declare module "babylonjs/Shaders/depth.fragment" {
  63788. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63789. /** @hidden */
  63790. export var depthPixelShader: {
  63791. name: string;
  63792. shader: string;
  63793. };
  63794. }
  63795. declare module "babylonjs/Shaders/depth.vertex" {
  63796. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63797. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63798. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63799. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63800. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63801. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63802. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63803. /** @hidden */
  63804. export var depthVertexShader: {
  63805. name: string;
  63806. shader: string;
  63807. };
  63808. }
  63809. declare module "babylonjs/Rendering/depthRenderer" {
  63810. import { Nullable } from "babylonjs/types";
  63811. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63812. import { Scene } from "babylonjs/scene";
  63813. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63814. import { Camera } from "babylonjs/Cameras/camera";
  63815. import "babylonjs/Shaders/depth.fragment";
  63816. import "babylonjs/Shaders/depth.vertex";
  63817. /**
  63818. * This represents a depth renderer in Babylon.
  63819. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63820. */
  63821. export class DepthRenderer {
  63822. private _scene;
  63823. private _depthMap;
  63824. private _effect;
  63825. private readonly _storeNonLinearDepth;
  63826. private readonly _clearColor;
  63827. /** Get if the depth renderer is using packed depth or not */
  63828. readonly isPacked: boolean;
  63829. private _cachedDefines;
  63830. private _camera;
  63831. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  63832. enabled: boolean;
  63833. /**
  63834. * Specifiess that the depth renderer will only be used within
  63835. * the camera it is created for.
  63836. * This can help forcing its rendering during the camera processing.
  63837. */
  63838. useOnlyInActiveCamera: boolean;
  63839. /** @hidden */
  63840. static _SceneComponentInitialization: (scene: Scene) => void;
  63841. /**
  63842. * Instantiates a depth renderer
  63843. * @param scene The scene the renderer belongs to
  63844. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63845. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63846. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63847. */
  63848. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63849. /**
  63850. * Creates the depth rendering effect and checks if the effect is ready.
  63851. * @param subMesh The submesh to be used to render the depth map of
  63852. * @param useInstances If multiple world instances should be used
  63853. * @returns if the depth renderer is ready to render the depth map
  63854. */
  63855. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63856. /**
  63857. * Gets the texture which the depth map will be written to.
  63858. * @returns The depth map texture
  63859. */
  63860. getDepthMap(): RenderTargetTexture;
  63861. /**
  63862. * Disposes of the depth renderer.
  63863. */
  63864. dispose(): void;
  63865. }
  63866. }
  63867. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  63868. /** @hidden */
  63869. export var minmaxReduxPixelShader: {
  63870. name: string;
  63871. shader: string;
  63872. };
  63873. }
  63874. declare module "babylonjs/Misc/minMaxReducer" {
  63875. import { Nullable } from "babylonjs/types";
  63876. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63877. import { Camera } from "babylonjs/Cameras/camera";
  63878. import { Observer } from "babylonjs/Misc/observable";
  63879. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63880. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  63881. import { Observable } from "babylonjs/Misc/observable";
  63882. import "babylonjs/Shaders/minmaxRedux.fragment";
  63883. /**
  63884. * This class computes a min/max reduction from a texture: it means it computes the minimum
  63885. * and maximum values from all values of the texture.
  63886. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  63887. * The source values are read from the red channel of the texture.
  63888. */
  63889. export class MinMaxReducer {
  63890. /**
  63891. * Observable triggered when the computation has been performed
  63892. */
  63893. onAfterReductionPerformed: Observable<{
  63894. min: number;
  63895. max: number;
  63896. }>;
  63897. protected _camera: Camera;
  63898. protected _sourceTexture: Nullable<RenderTargetTexture>;
  63899. protected _reductionSteps: Nullable<Array<PostProcess>>;
  63900. protected _postProcessManager: PostProcessManager;
  63901. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  63902. protected _forceFullscreenViewport: boolean;
  63903. /**
  63904. * Creates a min/max reducer
  63905. * @param camera The camera to use for the post processes
  63906. */
  63907. constructor(camera: Camera);
  63908. /**
  63909. * Gets the texture used to read the values from.
  63910. */
  63911. get sourceTexture(): Nullable<RenderTargetTexture>;
  63912. /**
  63913. * Sets the source texture to read the values from.
  63914. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  63915. * because in such textures '1' value must not be taken into account to compute the maximum
  63916. * as this value is used to clear the texture.
  63917. * Note that the computation is not activated by calling this function, you must call activate() for that!
  63918. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  63919. * @param depthRedux Indicates if the texture is a depth texture or not
  63920. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  63921. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63922. */
  63923. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63924. /**
  63925. * Defines the refresh rate of the computation.
  63926. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63927. */
  63928. get refreshRate(): number;
  63929. set refreshRate(value: number);
  63930. protected _activated: boolean;
  63931. /**
  63932. * Gets the activation status of the reducer
  63933. */
  63934. get activated(): boolean;
  63935. /**
  63936. * Activates the reduction computation.
  63937. * When activated, the observers registered in onAfterReductionPerformed are
  63938. * called after the compuation is performed
  63939. */
  63940. activate(): void;
  63941. /**
  63942. * Deactivates the reduction computation.
  63943. */
  63944. deactivate(): void;
  63945. /**
  63946. * Disposes the min/max reducer
  63947. * @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.
  63948. */
  63949. dispose(disposeAll?: boolean): void;
  63950. }
  63951. }
  63952. declare module "babylonjs/Misc/depthReducer" {
  63953. import { Nullable } from "babylonjs/types";
  63954. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63955. import { Camera } from "babylonjs/Cameras/camera";
  63956. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63957. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  63958. /**
  63959. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  63960. */
  63961. export class DepthReducer extends MinMaxReducer {
  63962. private _depthRenderer;
  63963. private _depthRendererId;
  63964. /**
  63965. * Gets the depth renderer used for the computation.
  63966. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  63967. */
  63968. get depthRenderer(): Nullable<DepthRenderer>;
  63969. /**
  63970. * Creates a depth reducer
  63971. * @param camera The camera used to render the depth texture
  63972. */
  63973. constructor(camera: Camera);
  63974. /**
  63975. * Sets the depth renderer to use to generate the depth map
  63976. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  63977. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  63978. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63979. */
  63980. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  63981. /** @hidden */
  63982. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63983. /**
  63984. * Activates the reduction computation.
  63985. * When activated, the observers registered in onAfterReductionPerformed are
  63986. * called after the compuation is performed
  63987. */
  63988. activate(): void;
  63989. /**
  63990. * Deactivates the reduction computation.
  63991. */
  63992. deactivate(): void;
  63993. /**
  63994. * Disposes the depth reducer
  63995. * @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.
  63996. */
  63997. dispose(disposeAll?: boolean): void;
  63998. }
  63999. }
  64000. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  64001. import { Nullable } from "babylonjs/types";
  64002. import { Scene } from "babylonjs/scene";
  64003. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64004. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64006. import { Effect } from "babylonjs/Materials/effect";
  64007. import "babylonjs/Shaders/shadowMap.fragment";
  64008. import "babylonjs/Shaders/shadowMap.vertex";
  64009. import "babylonjs/Shaders/depthBoxBlur.fragment";
  64010. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  64011. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  64012. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  64013. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64014. /**
  64015. * A CSM implementation allowing casting shadows on large scenes.
  64016. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64017. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  64018. */
  64019. export class CascadedShadowGenerator extends ShadowGenerator {
  64020. private static readonly frustumCornersNDCSpace;
  64021. /**
  64022. * Name of the CSM class
  64023. */
  64024. static CLASSNAME: string;
  64025. /**
  64026. * Defines the default number of cascades used by the CSM.
  64027. */
  64028. static readonly DEFAULT_CASCADES_COUNT: number;
  64029. /**
  64030. * Defines the minimum number of cascades used by the CSM.
  64031. */
  64032. static readonly MIN_CASCADES_COUNT: number;
  64033. /**
  64034. * Defines the maximum number of cascades used by the CSM.
  64035. */
  64036. static readonly MAX_CASCADES_COUNT: number;
  64037. protected _validateFilter(filter: number): number;
  64038. /**
  64039. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  64040. */
  64041. penumbraDarkness: number;
  64042. private _numCascades;
  64043. /**
  64044. * Gets or set the number of cascades used by the CSM.
  64045. */
  64046. get numCascades(): number;
  64047. set numCascades(value: number);
  64048. /**
  64049. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  64050. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  64051. */
  64052. stabilizeCascades: boolean;
  64053. private _freezeShadowCastersBoundingInfo;
  64054. private _freezeShadowCastersBoundingInfoObservable;
  64055. /**
  64056. * Enables or disables the shadow casters bounding info computation.
  64057. * If your shadow casters don't move, you can disable this feature.
  64058. * If it is enabled, the bounding box computation is done every frame.
  64059. */
  64060. get freezeShadowCastersBoundingInfo(): boolean;
  64061. set freezeShadowCastersBoundingInfo(freeze: boolean);
  64062. private _scbiMin;
  64063. private _scbiMax;
  64064. protected _computeShadowCastersBoundingInfo(): void;
  64065. protected _shadowCastersBoundingInfo: BoundingInfo;
  64066. /**
  64067. * Gets or sets the shadow casters bounding info.
  64068. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  64069. * so that the system won't overwrite the bounds you provide
  64070. */
  64071. get shadowCastersBoundingInfo(): BoundingInfo;
  64072. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  64073. protected _breaksAreDirty: boolean;
  64074. protected _minDistance: number;
  64075. protected _maxDistance: number;
  64076. /**
  64077. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  64078. *
  64079. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  64080. * If you don't know these values, simply leave them to their defaults and don't call this function.
  64081. * @param min minimal distance for the breaks (default to 0.)
  64082. * @param max maximal distance for the breaks (default to 1.)
  64083. */
  64084. setMinMaxDistance(min: number, max: number): void;
  64085. /** Gets the minimal distance used in the cascade break computation */
  64086. get minDistance(): number;
  64087. /** Gets the maximal distance used in the cascade break computation */
  64088. get maxDistance(): number;
  64089. /**
  64090. * Gets the class name of that object
  64091. * @returns "CascadedShadowGenerator"
  64092. */
  64093. getClassName(): string;
  64094. private _cascadeMinExtents;
  64095. private _cascadeMaxExtents;
  64096. /**
  64097. * Gets a cascade minimum extents
  64098. * @param cascadeIndex index of the cascade
  64099. * @returns the minimum cascade extents
  64100. */
  64101. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  64102. /**
  64103. * Gets a cascade maximum extents
  64104. * @param cascadeIndex index of the cascade
  64105. * @returns the maximum cascade extents
  64106. */
  64107. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  64108. private _cascades;
  64109. private _currentLayer;
  64110. private _viewSpaceFrustumsZ;
  64111. private _viewMatrices;
  64112. private _projectionMatrices;
  64113. private _transformMatrices;
  64114. private _transformMatricesAsArray;
  64115. private _frustumLengths;
  64116. private _lightSizeUVCorrection;
  64117. private _depthCorrection;
  64118. private _frustumCornersWorldSpace;
  64119. private _frustumCenter;
  64120. private _shadowCameraPos;
  64121. private _shadowMaxZ;
  64122. /**
  64123. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  64124. * It defaults to camera.maxZ
  64125. */
  64126. get shadowMaxZ(): number;
  64127. /**
  64128. * Sets the shadow max z distance.
  64129. */
  64130. set shadowMaxZ(value: number);
  64131. protected _debug: boolean;
  64132. /**
  64133. * Gets or sets the debug flag.
  64134. * When enabled, the cascades are materialized by different colors on the screen.
  64135. */
  64136. get debug(): boolean;
  64137. set debug(dbg: boolean);
  64138. private _depthClamp;
  64139. /**
  64140. * Gets or sets the depth clamping value.
  64141. *
  64142. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  64143. * to account for the shadow casters far away.
  64144. *
  64145. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  64146. */
  64147. get depthClamp(): boolean;
  64148. set depthClamp(value: boolean);
  64149. private _cascadeBlendPercentage;
  64150. /**
  64151. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  64152. * It defaults to 0.1 (10% blending).
  64153. */
  64154. get cascadeBlendPercentage(): number;
  64155. set cascadeBlendPercentage(value: number);
  64156. private _lambda;
  64157. /**
  64158. * Gets or set the lambda parameter.
  64159. * This parameter is used to split the camera frustum and create the cascades.
  64160. * 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.
  64161. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  64162. */
  64163. get lambda(): number;
  64164. set lambda(value: number);
  64165. /**
  64166. * Gets the view matrix corresponding to a given cascade
  64167. * @param cascadeNum cascade to retrieve the view matrix from
  64168. * @returns the cascade view matrix
  64169. */
  64170. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  64171. /**
  64172. * Gets the projection matrix corresponding to a given cascade
  64173. * @param cascadeNum cascade to retrieve the projection matrix from
  64174. * @returns the cascade projection matrix
  64175. */
  64176. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  64177. /**
  64178. * Gets the transformation matrix corresponding to a given cascade
  64179. * @param cascadeNum cascade to retrieve the transformation matrix from
  64180. * @returns the cascade transformation matrix
  64181. */
  64182. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  64183. private _depthRenderer;
  64184. /**
  64185. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  64186. *
  64187. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  64188. *
  64189. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  64190. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  64191. * @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
  64192. */
  64193. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  64194. private _depthReducer;
  64195. private _autoCalcDepthBounds;
  64196. /**
  64197. * Gets or sets the autoCalcDepthBounds property.
  64198. *
  64199. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  64200. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  64201. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  64202. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  64203. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  64204. */
  64205. get autoCalcDepthBounds(): boolean;
  64206. set autoCalcDepthBounds(value: boolean);
  64207. /**
  64208. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  64209. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64210. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  64211. * for setting the refresh rate on the renderer yourself!
  64212. */
  64213. get autoCalcDepthBoundsRefreshRate(): number;
  64214. set autoCalcDepthBoundsRefreshRate(value: number);
  64215. /**
  64216. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  64217. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  64218. * you change the camera near/far planes!
  64219. */
  64220. splitFrustum(): void;
  64221. private _splitFrustum;
  64222. private _computeMatrices;
  64223. private _computeFrustumInWorldSpace;
  64224. private _computeCascadeFrustum;
  64225. /**
  64226. * Support test.
  64227. */
  64228. static get IsSupported(): boolean;
  64229. /** @hidden */
  64230. static _SceneComponentInitialization: (scene: Scene) => void;
  64231. /**
  64232. * Creates a Cascaded Shadow Generator object.
  64233. * A ShadowGenerator is the required tool to use the shadows.
  64234. * Each directional light casting shadows needs to use its own ShadowGenerator.
  64235. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64236. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  64237. * @param light The directional light object generating the shadows.
  64238. * @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.
  64239. */
  64240. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  64241. protected _initializeGenerator(): void;
  64242. protected _createTargetRenderTexture(): void;
  64243. protected _initializeShadowMap(): void;
  64244. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  64245. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  64246. /**
  64247. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  64248. * @param defines Defines of the material we want to update
  64249. * @param lightIndex Index of the light in the enabled light list of the material
  64250. */
  64251. prepareDefines(defines: any, lightIndex: number): void;
  64252. /**
  64253. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  64254. * defined in the generator but impacting the effect).
  64255. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  64256. * @param effect The effect we are binfing the information for
  64257. */
  64258. bindShadowLight(lightIndex: string, effect: Effect): void;
  64259. /**
  64260. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  64261. * (eq to view projection * shadow projection matrices)
  64262. * @returns The transform matrix used to create the shadow map
  64263. */
  64264. getTransformMatrix(): Matrix;
  64265. /**
  64266. * Disposes the ShadowGenerator.
  64267. * Returns nothing.
  64268. */
  64269. dispose(): void;
  64270. /**
  64271. * Serializes the shadow generator setup to a json object.
  64272. * @returns The serialized JSON object
  64273. */
  64274. serialize(): any;
  64275. /**
  64276. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  64277. * @param parsedShadowGenerator The JSON object to parse
  64278. * @param scene The scene to create the shadow map for
  64279. * @returns The parsed shadow generator
  64280. */
  64281. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  64282. }
  64283. }
  64284. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  64285. import { Scene } from "babylonjs/scene";
  64286. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  64287. import { AbstractScene } from "babylonjs/abstractScene";
  64288. /**
  64289. * Defines the shadow generator component responsible to manage any shadow generators
  64290. * in a given scene.
  64291. */
  64292. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  64293. /**
  64294. * The component name helpfull to identify the component in the list of scene components.
  64295. */
  64296. readonly name: string;
  64297. /**
  64298. * The scene the component belongs to.
  64299. */
  64300. scene: Scene;
  64301. /**
  64302. * Creates a new instance of the component for the given scene
  64303. * @param scene Defines the scene to register the component in
  64304. */
  64305. constructor(scene: Scene);
  64306. /**
  64307. * Registers the component in a given scene
  64308. */
  64309. register(): void;
  64310. /**
  64311. * Rebuilds the elements related to this component in case of
  64312. * context lost for instance.
  64313. */
  64314. rebuild(): void;
  64315. /**
  64316. * Serializes the component data to the specified json object
  64317. * @param serializationObject The object to serialize to
  64318. */
  64319. serialize(serializationObject: any): void;
  64320. /**
  64321. * Adds all the elements from the container to the scene
  64322. * @param container the container holding the elements
  64323. */
  64324. addFromContainer(container: AbstractScene): void;
  64325. /**
  64326. * Removes all the elements in the container from the scene
  64327. * @param container contains the elements to remove
  64328. * @param dispose if the removed element should be disposed (default: false)
  64329. */
  64330. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64331. /**
  64332. * Rebuilds the elements related to this component in case of
  64333. * context lost for instance.
  64334. */
  64335. dispose(): void;
  64336. private _gatherRenderTargets;
  64337. }
  64338. }
  64339. declare module "babylonjs/Lights/Shadows/index" {
  64340. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  64341. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  64342. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  64343. }
  64344. declare module "babylonjs/Lights/pointLight" {
  64345. import { Scene } from "babylonjs/scene";
  64346. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64348. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  64349. import { Effect } from "babylonjs/Materials/effect";
  64350. /**
  64351. * A point light is a light defined by an unique point in world space.
  64352. * The light is emitted in every direction from this point.
  64353. * A good example of a point light is a standard light bulb.
  64354. * Documentation: https://doc.babylonjs.com/babylon101/lights
  64355. */
  64356. export class PointLight extends ShadowLight {
  64357. private _shadowAngle;
  64358. /**
  64359. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64360. * This specifies what angle the shadow will use to be created.
  64361. *
  64362. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64363. */
  64364. get shadowAngle(): number;
  64365. /**
  64366. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64367. * This specifies what angle the shadow will use to be created.
  64368. *
  64369. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64370. */
  64371. set shadowAngle(value: number);
  64372. /**
  64373. * Gets the direction if it has been set.
  64374. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64375. */
  64376. get direction(): Vector3;
  64377. /**
  64378. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64379. */
  64380. set direction(value: Vector3);
  64381. /**
  64382. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  64383. * A PointLight emits the light in every direction.
  64384. * It can cast shadows.
  64385. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  64386. * ```javascript
  64387. * var pointLight = new PointLight("pl", camera.position, scene);
  64388. * ```
  64389. * Documentation : https://doc.babylonjs.com/babylon101/lights
  64390. * @param name The light friendly name
  64391. * @param position The position of the point light in the scene
  64392. * @param scene The scene the lights belongs to
  64393. */
  64394. constructor(name: string, position: Vector3, scene: Scene);
  64395. /**
  64396. * Returns the string "PointLight"
  64397. * @returns the class name
  64398. */
  64399. getClassName(): string;
  64400. /**
  64401. * Returns the integer 0.
  64402. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  64403. */
  64404. getTypeID(): number;
  64405. /**
  64406. * Specifies wether or not the shadowmap should be a cube texture.
  64407. * @returns true if the shadowmap needs to be a cube texture.
  64408. */
  64409. needCube(): boolean;
  64410. /**
  64411. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  64412. * @param faceIndex The index of the face we are computed the direction to generate shadow
  64413. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  64414. */
  64415. getShadowDirection(faceIndex?: number): Vector3;
  64416. /**
  64417. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  64418. * - fov = PI / 2
  64419. * - aspect ratio : 1.0
  64420. * - z-near and far equal to the active camera minZ and maxZ.
  64421. * Returns the PointLight.
  64422. */
  64423. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  64424. protected _buildUniformLayout(): void;
  64425. /**
  64426. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  64427. * @param effect The effect to update
  64428. * @param lightIndex The index of the light in the effect to update
  64429. * @returns The point light
  64430. */
  64431. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  64432. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  64433. /**
  64434. * Prepares the list of defines specific to the light type.
  64435. * @param defines the list of defines
  64436. * @param lightIndex defines the index of the light for the effect
  64437. */
  64438. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  64439. }
  64440. }
  64441. declare module "babylonjs/Lights/index" {
  64442. export * from "babylonjs/Lights/light";
  64443. export * from "babylonjs/Lights/shadowLight";
  64444. export * from "babylonjs/Lights/Shadows/index";
  64445. export * from "babylonjs/Lights/directionalLight";
  64446. export * from "babylonjs/Lights/hemisphericLight";
  64447. export * from "babylonjs/Lights/pointLight";
  64448. export * from "babylonjs/Lights/spotLight";
  64449. }
  64450. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  64451. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  64452. /**
  64453. * Header information of HDR texture files.
  64454. */
  64455. export interface HDRInfo {
  64456. /**
  64457. * The height of the texture in pixels.
  64458. */
  64459. height: number;
  64460. /**
  64461. * The width of the texture in pixels.
  64462. */
  64463. width: number;
  64464. /**
  64465. * The index of the beginning of the data in the binary file.
  64466. */
  64467. dataPosition: number;
  64468. }
  64469. /**
  64470. * This groups tools to convert HDR texture to native colors array.
  64471. */
  64472. export class HDRTools {
  64473. private static Ldexp;
  64474. private static Rgbe2float;
  64475. private static readStringLine;
  64476. /**
  64477. * Reads header information from an RGBE texture stored in a native array.
  64478. * More information on this format are available here:
  64479. * https://en.wikipedia.org/wiki/RGBE_image_format
  64480. *
  64481. * @param uint8array The binary file stored in native array.
  64482. * @return The header information.
  64483. */
  64484. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  64485. /**
  64486. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  64487. * This RGBE texture needs to store the information as a panorama.
  64488. *
  64489. * More information on this format are available here:
  64490. * https://en.wikipedia.org/wiki/RGBE_image_format
  64491. *
  64492. * @param buffer The binary file stored in an array buffer.
  64493. * @param size The expected size of the extracted cubemap.
  64494. * @return The Cube Map information.
  64495. */
  64496. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  64497. /**
  64498. * Returns the pixels data extracted from an RGBE texture.
  64499. * This pixels will be stored left to right up to down in the R G B order in one array.
  64500. *
  64501. * More information on this format are available here:
  64502. * https://en.wikipedia.org/wiki/RGBE_image_format
  64503. *
  64504. * @param uint8array The binary file stored in an array buffer.
  64505. * @param hdrInfo The header information of the file.
  64506. * @return The pixels data in RGB right to left up to down order.
  64507. */
  64508. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  64509. private static RGBE_ReadPixels_RLE;
  64510. private static RGBE_ReadPixels_NOT_RLE;
  64511. }
  64512. }
  64513. declare module "babylonjs/Materials/effectRenderer" {
  64514. import { Nullable } from "babylonjs/types";
  64515. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64516. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64517. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64518. import { Viewport } from "babylonjs/Maths/math.viewport";
  64519. import { Observable } from "babylonjs/Misc/observable";
  64520. import { Effect } from "babylonjs/Materials/effect";
  64521. import "babylonjs/Shaders/postprocess.vertex";
  64522. /**
  64523. * Effect Render Options
  64524. */
  64525. export interface IEffectRendererOptions {
  64526. /**
  64527. * Defines the vertices positions.
  64528. */
  64529. positions?: number[];
  64530. /**
  64531. * Defines the indices.
  64532. */
  64533. indices?: number[];
  64534. }
  64535. /**
  64536. * Helper class to render one or more effects.
  64537. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  64538. */
  64539. export class EffectRenderer {
  64540. private engine;
  64541. private static _DefaultOptions;
  64542. private _vertexBuffers;
  64543. private _indexBuffer;
  64544. private _fullscreenViewport;
  64545. /**
  64546. * Creates an effect renderer
  64547. * @param engine the engine to use for rendering
  64548. * @param options defines the options of the effect renderer
  64549. */
  64550. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  64551. /**
  64552. * Sets the current viewport in normalized coordinates 0-1
  64553. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  64554. */
  64555. setViewport(viewport?: Viewport): void;
  64556. /**
  64557. * Binds the embedded attributes buffer to the effect.
  64558. * @param effect Defines the effect to bind the attributes for
  64559. */
  64560. bindBuffers(effect: Effect): void;
  64561. /**
  64562. * Sets the current effect wrapper to use during draw.
  64563. * The effect needs to be ready before calling this api.
  64564. * This also sets the default full screen position attribute.
  64565. * @param effectWrapper Defines the effect to draw with
  64566. */
  64567. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  64568. /**
  64569. * Restores engine states
  64570. */
  64571. restoreStates(): void;
  64572. /**
  64573. * Draws a full screen quad.
  64574. */
  64575. draw(): void;
  64576. private isRenderTargetTexture;
  64577. /**
  64578. * renders one or more effects to a specified texture
  64579. * @param effectWrapper the effect to renderer
  64580. * @param outputTexture texture to draw to, if null it will render to the screen.
  64581. */
  64582. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  64583. /**
  64584. * Disposes of the effect renderer
  64585. */
  64586. dispose(): void;
  64587. }
  64588. /**
  64589. * Options to create an EffectWrapper
  64590. */
  64591. interface EffectWrapperCreationOptions {
  64592. /**
  64593. * Engine to use to create the effect
  64594. */
  64595. engine: ThinEngine;
  64596. /**
  64597. * Fragment shader for the effect
  64598. */
  64599. fragmentShader: string;
  64600. /**
  64601. * Use the shader store instead of direct source code
  64602. */
  64603. useShaderStore?: boolean;
  64604. /**
  64605. * Vertex shader for the effect
  64606. */
  64607. vertexShader?: string;
  64608. /**
  64609. * Attributes to use in the shader
  64610. */
  64611. attributeNames?: Array<string>;
  64612. /**
  64613. * Uniforms to use in the shader
  64614. */
  64615. uniformNames?: Array<string>;
  64616. /**
  64617. * Texture sampler names to use in the shader
  64618. */
  64619. samplerNames?: Array<string>;
  64620. /**
  64621. * Defines to use in the shader
  64622. */
  64623. defines?: Array<string>;
  64624. /**
  64625. * Callback when effect is compiled
  64626. */
  64627. onCompiled?: Nullable<(effect: Effect) => void>;
  64628. /**
  64629. * The friendly name of the effect displayed in Spector.
  64630. */
  64631. name?: string;
  64632. }
  64633. /**
  64634. * Wraps an effect to be used for rendering
  64635. */
  64636. export class EffectWrapper {
  64637. /**
  64638. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  64639. */
  64640. onApplyObservable: Observable<{}>;
  64641. /**
  64642. * The underlying effect
  64643. */
  64644. effect: Effect;
  64645. /**
  64646. * Creates an effect to be renderer
  64647. * @param creationOptions options to create the effect
  64648. */
  64649. constructor(creationOptions: EffectWrapperCreationOptions);
  64650. /**
  64651. * Disposes of the effect wrapper
  64652. */
  64653. dispose(): void;
  64654. }
  64655. }
  64656. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  64657. /** @hidden */
  64658. export var hdrFilteringVertexShader: {
  64659. name: string;
  64660. shader: string;
  64661. };
  64662. }
  64663. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  64664. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64665. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  64666. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  64667. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  64668. /** @hidden */
  64669. export var hdrFilteringPixelShader: {
  64670. name: string;
  64671. shader: string;
  64672. };
  64673. }
  64674. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  64675. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64676. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64677. import { Nullable } from "babylonjs/types";
  64678. import "babylonjs/Shaders/hdrFiltering.vertex";
  64679. import "babylonjs/Shaders/hdrFiltering.fragment";
  64680. /**
  64681. * Options for texture filtering
  64682. */
  64683. interface IHDRFilteringOptions {
  64684. /**
  64685. * Scales pixel intensity for the input HDR map.
  64686. */
  64687. hdrScale?: number;
  64688. /**
  64689. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  64690. */
  64691. quality?: number;
  64692. }
  64693. /**
  64694. * Filters HDR maps to get correct renderings of PBR reflections
  64695. */
  64696. export class HDRFiltering {
  64697. private _engine;
  64698. private _effectRenderer;
  64699. private _effectWrapper;
  64700. private _lodGenerationOffset;
  64701. private _lodGenerationScale;
  64702. /**
  64703. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  64704. * you care about baking speed.
  64705. */
  64706. quality: number;
  64707. /**
  64708. * Scales pixel intensity for the input HDR map.
  64709. */
  64710. hdrScale: number;
  64711. /**
  64712. * Instantiates HDR filter for reflection maps
  64713. *
  64714. * @param engine Thin engine
  64715. * @param options Options
  64716. */
  64717. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  64718. private _createRenderTarget;
  64719. private _prefilterInternal;
  64720. private _createEffect;
  64721. /**
  64722. * Get a value indicating if the filter is ready to be used
  64723. * @param texture Texture to filter
  64724. * @returns true if the filter is ready
  64725. */
  64726. isReady(texture: BaseTexture): boolean;
  64727. /**
  64728. * Prefilters a cube texture to have mipmap levels representing roughness values.
  64729. * Prefiltering will be invoked at the end of next rendering pass.
  64730. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  64731. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  64732. * @param texture Texture to filter
  64733. * @param onFinished Callback when filtering is done
  64734. * @return Promise called when prefiltering is done
  64735. */
  64736. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  64737. }
  64738. }
  64739. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  64740. import { Nullable } from "babylonjs/types";
  64741. import { Scene } from "babylonjs/scene";
  64742. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64743. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64744. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64745. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64746. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  64747. /**
  64748. * This represents a texture coming from an HDR input.
  64749. *
  64750. * The only supported format is currently panorama picture stored in RGBE format.
  64751. * Example of such files can be found on HDRLib: http://hdrlib.com/
  64752. */
  64753. export class HDRCubeTexture extends BaseTexture {
  64754. private static _facesMapping;
  64755. private _generateHarmonics;
  64756. private _noMipmap;
  64757. private _prefilterOnLoad;
  64758. private _textureMatrix;
  64759. private _size;
  64760. private _onLoad;
  64761. private _onError;
  64762. /**
  64763. * The texture URL.
  64764. */
  64765. url: string;
  64766. protected _isBlocking: boolean;
  64767. /**
  64768. * Sets wether or not the texture is blocking during loading.
  64769. */
  64770. set isBlocking(value: boolean);
  64771. /**
  64772. * Gets wether or not the texture is blocking during loading.
  64773. */
  64774. get isBlocking(): boolean;
  64775. protected _rotationY: number;
  64776. /**
  64777. * Sets texture matrix rotation angle around Y axis in radians.
  64778. */
  64779. set rotationY(value: number);
  64780. /**
  64781. * Gets texture matrix rotation angle around Y axis radians.
  64782. */
  64783. get rotationY(): number;
  64784. /**
  64785. * Gets or sets the center of the bounding box associated with the cube texture
  64786. * It must define where the camera used to render the texture was set
  64787. */
  64788. boundingBoxPosition: Vector3;
  64789. private _boundingBoxSize;
  64790. /**
  64791. * Gets or sets the size of the bounding box associated with the cube texture
  64792. * When defined, the cubemap will switch to local mode
  64793. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64794. * @example https://www.babylonjs-playground.com/#RNASML
  64795. */
  64796. set boundingBoxSize(value: Vector3);
  64797. get boundingBoxSize(): Vector3;
  64798. /**
  64799. * Instantiates an HDRTexture from the following parameters.
  64800. *
  64801. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  64802. * @param sceneOrEngine The scene or engine the texture will be used in
  64803. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64804. * @param noMipmap Forces to not generate the mipmap if true
  64805. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  64806. * @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)
  64807. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  64808. */
  64809. 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>);
  64810. /**
  64811. * Get the current class name of the texture useful for serialization or dynamic coding.
  64812. * @returns "HDRCubeTexture"
  64813. */
  64814. getClassName(): string;
  64815. /**
  64816. * Occurs when the file is raw .hdr file.
  64817. */
  64818. private loadTexture;
  64819. clone(): HDRCubeTexture;
  64820. delayLoad(): void;
  64821. /**
  64822. * Get the texture reflection matrix used to rotate/transform the reflection.
  64823. * @returns the reflection matrix
  64824. */
  64825. getReflectionTextureMatrix(): Matrix;
  64826. /**
  64827. * Set the texture reflection matrix used to rotate/transform the reflection.
  64828. * @param value Define the reflection matrix to set
  64829. */
  64830. setReflectionTextureMatrix(value: Matrix): void;
  64831. /**
  64832. * Parses a JSON representation of an HDR Texture in order to create the texture
  64833. * @param parsedTexture Define the JSON representation
  64834. * @param scene Define the scene the texture should be created in
  64835. * @param rootUrl Define the root url in case we need to load relative dependencies
  64836. * @returns the newly created texture after parsing
  64837. */
  64838. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  64839. serialize(): any;
  64840. }
  64841. }
  64842. declare module "babylonjs/Physics/physicsEngine" {
  64843. import { Nullable } from "babylonjs/types";
  64844. import { Vector3 } from "babylonjs/Maths/math.vector";
  64845. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64846. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  64847. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  64848. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64849. /**
  64850. * Class used to control physics engine
  64851. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64852. */
  64853. export class PhysicsEngine implements IPhysicsEngine {
  64854. private _physicsPlugin;
  64855. /**
  64856. * Global value used to control the smallest number supported by the simulation
  64857. */
  64858. static Epsilon: number;
  64859. private _impostors;
  64860. private _joints;
  64861. private _subTimeStep;
  64862. /**
  64863. * Gets the gravity vector used by the simulation
  64864. */
  64865. gravity: Vector3;
  64866. /**
  64867. * Factory used to create the default physics plugin.
  64868. * @returns The default physics plugin
  64869. */
  64870. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  64871. /**
  64872. * Creates a new Physics Engine
  64873. * @param gravity defines the gravity vector used by the simulation
  64874. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  64875. */
  64876. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  64877. /**
  64878. * Sets the gravity vector used by the simulation
  64879. * @param gravity defines the gravity vector to use
  64880. */
  64881. setGravity(gravity: Vector3): void;
  64882. /**
  64883. * Set the time step of the physics engine.
  64884. * Default is 1/60.
  64885. * To slow it down, enter 1/600 for example.
  64886. * To speed it up, 1/30
  64887. * @param newTimeStep defines the new timestep to apply to this world.
  64888. */
  64889. setTimeStep(newTimeStep?: number): void;
  64890. /**
  64891. * Get the time step of the physics engine.
  64892. * @returns the current time step
  64893. */
  64894. getTimeStep(): number;
  64895. /**
  64896. * Set the sub time step of the physics engine.
  64897. * Default is 0 meaning there is no sub steps
  64898. * To increase physics resolution precision, set a small value (like 1 ms)
  64899. * @param subTimeStep defines the new sub timestep used for physics resolution.
  64900. */
  64901. setSubTimeStep(subTimeStep?: number): void;
  64902. /**
  64903. * Get the sub time step of the physics engine.
  64904. * @returns the current sub time step
  64905. */
  64906. getSubTimeStep(): number;
  64907. /**
  64908. * Release all resources
  64909. */
  64910. dispose(): void;
  64911. /**
  64912. * Gets the name of the current physics plugin
  64913. * @returns the name of the plugin
  64914. */
  64915. getPhysicsPluginName(): string;
  64916. /**
  64917. * Adding a new impostor for the impostor tracking.
  64918. * This will be done by the impostor itself.
  64919. * @param impostor the impostor to add
  64920. */
  64921. addImpostor(impostor: PhysicsImpostor): void;
  64922. /**
  64923. * Remove an impostor from the engine.
  64924. * This impostor and its mesh will not longer be updated by the physics engine.
  64925. * @param impostor the impostor to remove
  64926. */
  64927. removeImpostor(impostor: PhysicsImpostor): void;
  64928. /**
  64929. * Add a joint to the physics engine
  64930. * @param mainImpostor defines the main impostor to which the joint is added.
  64931. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  64932. * @param joint defines the joint that will connect both impostors.
  64933. */
  64934. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64935. /**
  64936. * Removes a joint from the simulation
  64937. * @param mainImpostor defines the impostor used with the joint
  64938. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  64939. * @param joint defines the joint to remove
  64940. */
  64941. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64942. /**
  64943. * Called by the scene. No need to call it.
  64944. * @param delta defines the timespam between frames
  64945. */
  64946. _step(delta: number): void;
  64947. /**
  64948. * Gets the current plugin used to run the simulation
  64949. * @returns current plugin
  64950. */
  64951. getPhysicsPlugin(): IPhysicsEnginePlugin;
  64952. /**
  64953. * Gets the list of physic impostors
  64954. * @returns an array of PhysicsImpostor
  64955. */
  64956. getImpostors(): Array<PhysicsImpostor>;
  64957. /**
  64958. * Gets the impostor for a physics enabled object
  64959. * @param object defines the object impersonated by the impostor
  64960. * @returns the PhysicsImpostor or null if not found
  64961. */
  64962. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  64963. /**
  64964. * Gets the impostor for a physics body object
  64965. * @param body defines physics body used by the impostor
  64966. * @returns the PhysicsImpostor or null if not found
  64967. */
  64968. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  64969. /**
  64970. * Does a raycast in the physics world
  64971. * @param from when should the ray start?
  64972. * @param to when should the ray end?
  64973. * @returns PhysicsRaycastResult
  64974. */
  64975. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64976. }
  64977. }
  64978. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  64979. import { Nullable } from "babylonjs/types";
  64980. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64982. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64983. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64984. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64985. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64986. /** @hidden */
  64987. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  64988. private _useDeltaForWorldStep;
  64989. world: any;
  64990. name: string;
  64991. private _physicsMaterials;
  64992. private _fixedTimeStep;
  64993. private _cannonRaycastResult;
  64994. private _raycastResult;
  64995. private _physicsBodysToRemoveAfterStep;
  64996. private _firstFrame;
  64997. BJSCANNON: any;
  64998. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  64999. setGravity(gravity: Vector3): void;
  65000. setTimeStep(timeStep: number): void;
  65001. getTimeStep(): number;
  65002. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65003. private _removeMarkedPhysicsBodiesFromWorld;
  65004. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65005. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65006. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65007. private _processChildMeshes;
  65008. removePhysicsBody(impostor: PhysicsImpostor): void;
  65009. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65010. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65011. private _addMaterial;
  65012. private _checkWithEpsilon;
  65013. private _createShape;
  65014. private _createHeightmap;
  65015. private _minus90X;
  65016. private _plus90X;
  65017. private _tmpPosition;
  65018. private _tmpDeltaPosition;
  65019. private _tmpUnityRotation;
  65020. private _updatePhysicsBodyTransformation;
  65021. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65022. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65023. isSupported(): boolean;
  65024. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65025. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65026. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65027. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65028. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65029. getBodyMass(impostor: PhysicsImpostor): number;
  65030. getBodyFriction(impostor: PhysicsImpostor): number;
  65031. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65032. getBodyRestitution(impostor: PhysicsImpostor): number;
  65033. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65034. sleepBody(impostor: PhysicsImpostor): void;
  65035. wakeUpBody(impostor: PhysicsImpostor): void;
  65036. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  65037. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65038. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65039. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65040. getRadius(impostor: PhysicsImpostor): number;
  65041. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65042. dispose(): void;
  65043. private _extendNamespace;
  65044. /**
  65045. * Does a raycast in the physics world
  65046. * @param from when should the ray start?
  65047. * @param to when should the ray end?
  65048. * @returns PhysicsRaycastResult
  65049. */
  65050. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65051. }
  65052. }
  65053. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  65054. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  65055. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  65056. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  65057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65058. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  65059. import { Nullable } from "babylonjs/types";
  65060. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  65061. /** @hidden */
  65062. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  65063. private _useDeltaForWorldStep;
  65064. world: any;
  65065. name: string;
  65066. BJSOIMO: any;
  65067. private _raycastResult;
  65068. private _fixedTimeStep;
  65069. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  65070. setGravity(gravity: Vector3): void;
  65071. setTimeStep(timeStep: number): void;
  65072. getTimeStep(): number;
  65073. private _tmpImpostorsArray;
  65074. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65075. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65076. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65077. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65078. private _tmpPositionVector;
  65079. removePhysicsBody(impostor: PhysicsImpostor): void;
  65080. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65081. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65082. isSupported(): boolean;
  65083. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65084. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65085. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65086. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65087. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65088. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65089. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65090. getBodyMass(impostor: PhysicsImpostor): number;
  65091. getBodyFriction(impostor: PhysicsImpostor): number;
  65092. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65093. getBodyRestitution(impostor: PhysicsImpostor): number;
  65094. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65095. sleepBody(impostor: PhysicsImpostor): void;
  65096. wakeUpBody(impostor: PhysicsImpostor): void;
  65097. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65098. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  65099. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  65100. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65101. getRadius(impostor: PhysicsImpostor): number;
  65102. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65103. dispose(): void;
  65104. /**
  65105. * Does a raycast in the physics world
  65106. * @param from when should the ray start?
  65107. * @param to when should the ray end?
  65108. * @returns PhysicsRaycastResult
  65109. */
  65110. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65111. }
  65112. }
  65113. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  65114. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  65115. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  65116. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  65117. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  65118. import { Nullable } from "babylonjs/types";
  65119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65120. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  65121. /**
  65122. * AmmoJS Physics plugin
  65123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65124. * @see https://github.com/kripken/ammo.js/
  65125. */
  65126. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  65127. private _useDeltaForWorldStep;
  65128. /**
  65129. * Reference to the Ammo library
  65130. */
  65131. bjsAMMO: any;
  65132. /**
  65133. * Created ammoJS world which physics bodies are added to
  65134. */
  65135. world: any;
  65136. /**
  65137. * Name of the plugin
  65138. */
  65139. name: string;
  65140. private _timeStep;
  65141. private _fixedTimeStep;
  65142. private _maxSteps;
  65143. private _tmpQuaternion;
  65144. private _tmpAmmoTransform;
  65145. private _tmpAmmoQuaternion;
  65146. private _tmpAmmoConcreteContactResultCallback;
  65147. private _collisionConfiguration;
  65148. private _dispatcher;
  65149. private _overlappingPairCache;
  65150. private _solver;
  65151. private _softBodySolver;
  65152. private _tmpAmmoVectorA;
  65153. private _tmpAmmoVectorB;
  65154. private _tmpAmmoVectorC;
  65155. private _tmpAmmoVectorD;
  65156. private _tmpContactCallbackResult;
  65157. private _tmpAmmoVectorRCA;
  65158. private _tmpAmmoVectorRCB;
  65159. private _raycastResult;
  65160. private _tmpContactPoint;
  65161. private static readonly DISABLE_COLLISION_FLAG;
  65162. private static readonly KINEMATIC_FLAG;
  65163. private static readonly DISABLE_DEACTIVATION_FLAG;
  65164. /**
  65165. * Initializes the ammoJS plugin
  65166. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  65167. * @param ammoInjection can be used to inject your own ammo reference
  65168. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  65169. */
  65170. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  65171. /**
  65172. * Sets the gravity of the physics world (m/(s^2))
  65173. * @param gravity Gravity to set
  65174. */
  65175. setGravity(gravity: Vector3): void;
  65176. /**
  65177. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  65178. * @param timeStep timestep to use in seconds
  65179. */
  65180. setTimeStep(timeStep: number): void;
  65181. /**
  65182. * 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)
  65183. * @param fixedTimeStep fixedTimeStep to use in seconds
  65184. */
  65185. setFixedTimeStep(fixedTimeStep: number): void;
  65186. /**
  65187. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  65188. * @param maxSteps the maximum number of steps by the physics engine per frame
  65189. */
  65190. setMaxSteps(maxSteps: number): void;
  65191. /**
  65192. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  65193. * @returns the current timestep in seconds
  65194. */
  65195. getTimeStep(): number;
  65196. /**
  65197. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  65198. */
  65199. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  65200. private _isImpostorInContact;
  65201. private _isImpostorPairInContact;
  65202. private _stepSimulation;
  65203. /**
  65204. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  65205. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  65206. * After the step the babylon meshes are set to the position of the physics imposters
  65207. * @param delta amount of time to step forward
  65208. * @param impostors array of imposters to update before/after the step
  65209. */
  65210. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65211. /**
  65212. * Update babylon mesh to match physics world object
  65213. * @param impostor imposter to match
  65214. */
  65215. private _afterSoftStep;
  65216. /**
  65217. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65218. * @param impostor imposter to match
  65219. */
  65220. private _ropeStep;
  65221. /**
  65222. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65223. * @param impostor imposter to match
  65224. */
  65225. private _softbodyOrClothStep;
  65226. private _tmpMatrix;
  65227. /**
  65228. * Applies an impulse on the imposter
  65229. * @param impostor imposter to apply impulse to
  65230. * @param force amount of force to be applied to the imposter
  65231. * @param contactPoint the location to apply the impulse on the imposter
  65232. */
  65233. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65234. /**
  65235. * Applies a force on the imposter
  65236. * @param impostor imposter to apply force
  65237. * @param force amount of force to be applied to the imposter
  65238. * @param contactPoint the location to apply the force on the imposter
  65239. */
  65240. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65241. /**
  65242. * Creates a physics body using the plugin
  65243. * @param impostor the imposter to create the physics body on
  65244. */
  65245. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65246. /**
  65247. * Removes the physics body from the imposter and disposes of the body's memory
  65248. * @param impostor imposter to remove the physics body from
  65249. */
  65250. removePhysicsBody(impostor: PhysicsImpostor): void;
  65251. /**
  65252. * Generates a joint
  65253. * @param impostorJoint the imposter joint to create the joint with
  65254. */
  65255. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65256. /**
  65257. * Removes a joint
  65258. * @param impostorJoint the imposter joint to remove the joint from
  65259. */
  65260. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65261. private _addMeshVerts;
  65262. /**
  65263. * Initialise the soft body vertices to match its object's (mesh) vertices
  65264. * Softbody vertices (nodes) are in world space and to match this
  65265. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  65266. * @param impostor to create the softbody for
  65267. */
  65268. private _softVertexData;
  65269. /**
  65270. * Create an impostor's soft body
  65271. * @param impostor to create the softbody for
  65272. */
  65273. private _createSoftbody;
  65274. /**
  65275. * Create cloth for an impostor
  65276. * @param impostor to create the softbody for
  65277. */
  65278. private _createCloth;
  65279. /**
  65280. * Create rope for an impostor
  65281. * @param impostor to create the softbody for
  65282. */
  65283. private _createRope;
  65284. /**
  65285. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  65286. * @param impostor to create the custom physics shape for
  65287. */
  65288. private _createCustom;
  65289. private _addHullVerts;
  65290. private _createShape;
  65291. /**
  65292. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  65293. * @param impostor imposter containing the physics body and babylon object
  65294. */
  65295. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65296. /**
  65297. * Sets the babylon object's position/rotation from the physics body's position/rotation
  65298. * @param impostor imposter containing the physics body and babylon object
  65299. * @param newPosition new position
  65300. * @param newRotation new rotation
  65301. */
  65302. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65303. /**
  65304. * If this plugin is supported
  65305. * @returns true if its supported
  65306. */
  65307. isSupported(): boolean;
  65308. /**
  65309. * Sets the linear velocity of the physics body
  65310. * @param impostor imposter to set the velocity on
  65311. * @param velocity velocity to set
  65312. */
  65313. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65314. /**
  65315. * Sets the angular velocity of the physics body
  65316. * @param impostor imposter to set the velocity on
  65317. * @param velocity velocity to set
  65318. */
  65319. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65320. /**
  65321. * gets the linear velocity
  65322. * @param impostor imposter to get linear velocity from
  65323. * @returns linear velocity
  65324. */
  65325. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65326. /**
  65327. * gets the angular velocity
  65328. * @param impostor imposter to get angular velocity from
  65329. * @returns angular velocity
  65330. */
  65331. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65332. /**
  65333. * Sets the mass of physics body
  65334. * @param impostor imposter to set the mass on
  65335. * @param mass mass to set
  65336. */
  65337. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65338. /**
  65339. * Gets the mass of the physics body
  65340. * @param impostor imposter to get the mass from
  65341. * @returns mass
  65342. */
  65343. getBodyMass(impostor: PhysicsImpostor): number;
  65344. /**
  65345. * Gets friction of the impostor
  65346. * @param impostor impostor to get friction from
  65347. * @returns friction value
  65348. */
  65349. getBodyFriction(impostor: PhysicsImpostor): number;
  65350. /**
  65351. * Sets friction of the impostor
  65352. * @param impostor impostor to set friction on
  65353. * @param friction friction value
  65354. */
  65355. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65356. /**
  65357. * Gets restitution of the impostor
  65358. * @param impostor impostor to get restitution from
  65359. * @returns restitution value
  65360. */
  65361. getBodyRestitution(impostor: PhysicsImpostor): number;
  65362. /**
  65363. * Sets resitution of the impostor
  65364. * @param impostor impostor to set resitution on
  65365. * @param restitution resitution value
  65366. */
  65367. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65368. /**
  65369. * Gets pressure inside the impostor
  65370. * @param impostor impostor to get pressure from
  65371. * @returns pressure value
  65372. */
  65373. getBodyPressure(impostor: PhysicsImpostor): number;
  65374. /**
  65375. * Sets pressure inside a soft body impostor
  65376. * Cloth and rope must remain 0 pressure
  65377. * @param impostor impostor to set pressure on
  65378. * @param pressure pressure value
  65379. */
  65380. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  65381. /**
  65382. * Gets stiffness of the impostor
  65383. * @param impostor impostor to get stiffness from
  65384. * @returns pressure value
  65385. */
  65386. getBodyStiffness(impostor: PhysicsImpostor): number;
  65387. /**
  65388. * Sets stiffness of the impostor
  65389. * @param impostor impostor to set stiffness on
  65390. * @param stiffness stiffness value from 0 to 1
  65391. */
  65392. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  65393. /**
  65394. * Gets velocityIterations of the impostor
  65395. * @param impostor impostor to get velocity iterations from
  65396. * @returns velocityIterations value
  65397. */
  65398. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  65399. /**
  65400. * Sets velocityIterations of the impostor
  65401. * @param impostor impostor to set velocity iterations on
  65402. * @param velocityIterations velocityIterations value
  65403. */
  65404. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  65405. /**
  65406. * Gets positionIterations of the impostor
  65407. * @param impostor impostor to get position iterations from
  65408. * @returns positionIterations value
  65409. */
  65410. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  65411. /**
  65412. * Sets positionIterations of the impostor
  65413. * @param impostor impostor to set position on
  65414. * @param positionIterations positionIterations value
  65415. */
  65416. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  65417. /**
  65418. * Append an anchor to a cloth object
  65419. * @param impostor is the cloth impostor to add anchor to
  65420. * @param otherImpostor is the rigid impostor to anchor to
  65421. * @param width ratio across width from 0 to 1
  65422. * @param height ratio up height from 0 to 1
  65423. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  65424. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65425. */
  65426. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65427. /**
  65428. * Append an hook to a rope object
  65429. * @param impostor is the rope impostor to add hook to
  65430. * @param otherImpostor is the rigid impostor to hook to
  65431. * @param length ratio along the rope from 0 to 1
  65432. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  65433. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65434. */
  65435. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65436. /**
  65437. * Sleeps the physics body and stops it from being active
  65438. * @param impostor impostor to sleep
  65439. */
  65440. sleepBody(impostor: PhysicsImpostor): void;
  65441. /**
  65442. * Activates the physics body
  65443. * @param impostor impostor to activate
  65444. */
  65445. wakeUpBody(impostor: PhysicsImpostor): void;
  65446. /**
  65447. * Updates the distance parameters of the joint
  65448. * @param joint joint to update
  65449. * @param maxDistance maximum distance of the joint
  65450. * @param minDistance minimum distance of the joint
  65451. */
  65452. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65453. /**
  65454. * Sets a motor on the joint
  65455. * @param joint joint to set motor on
  65456. * @param speed speed of the motor
  65457. * @param maxForce maximum force of the motor
  65458. * @param motorIndex index of the motor
  65459. */
  65460. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65461. /**
  65462. * Sets the motors limit
  65463. * @param joint joint to set limit on
  65464. * @param upperLimit upper limit
  65465. * @param lowerLimit lower limit
  65466. */
  65467. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65468. /**
  65469. * Syncs the position and rotation of a mesh with the impostor
  65470. * @param mesh mesh to sync
  65471. * @param impostor impostor to update the mesh with
  65472. */
  65473. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65474. /**
  65475. * Gets the radius of the impostor
  65476. * @param impostor impostor to get radius from
  65477. * @returns the radius
  65478. */
  65479. getRadius(impostor: PhysicsImpostor): number;
  65480. /**
  65481. * Gets the box size of the impostor
  65482. * @param impostor impostor to get box size from
  65483. * @param result the resulting box size
  65484. */
  65485. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65486. /**
  65487. * Disposes of the impostor
  65488. */
  65489. dispose(): void;
  65490. /**
  65491. * Does a raycast in the physics world
  65492. * @param from when should the ray start?
  65493. * @param to when should the ray end?
  65494. * @returns PhysicsRaycastResult
  65495. */
  65496. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65497. }
  65498. }
  65499. declare module "babylonjs/Probes/reflectionProbe" {
  65500. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65501. import { Vector3 } from "babylonjs/Maths/math.vector";
  65502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65503. import { Nullable } from "babylonjs/types";
  65504. import { Scene } from "babylonjs/scene";
  65505. module "babylonjs/abstractScene" {
  65506. interface AbstractScene {
  65507. /**
  65508. * The list of reflection probes added to the scene
  65509. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65510. */
  65511. reflectionProbes: Array<ReflectionProbe>;
  65512. /**
  65513. * Removes the given reflection probe from this scene.
  65514. * @param toRemove The reflection probe to remove
  65515. * @returns The index of the removed reflection probe
  65516. */
  65517. removeReflectionProbe(toRemove: ReflectionProbe): number;
  65518. /**
  65519. * Adds the given reflection probe to this scene.
  65520. * @param newReflectionProbe The reflection probe to add
  65521. */
  65522. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  65523. }
  65524. }
  65525. /**
  65526. * Class used to generate realtime reflection / refraction cube textures
  65527. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65528. */
  65529. export class ReflectionProbe {
  65530. /** defines the name of the probe */
  65531. name: string;
  65532. private _scene;
  65533. private _renderTargetTexture;
  65534. private _projectionMatrix;
  65535. private _viewMatrix;
  65536. private _target;
  65537. private _add;
  65538. private _attachedMesh;
  65539. private _invertYAxis;
  65540. /** Gets or sets probe position (center of the cube map) */
  65541. position: Vector3;
  65542. /**
  65543. * Creates a new reflection probe
  65544. * @param name defines the name of the probe
  65545. * @param size defines the texture resolution (for each face)
  65546. * @param scene defines the hosting scene
  65547. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  65548. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  65549. */
  65550. constructor(
  65551. /** defines the name of the probe */
  65552. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  65553. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  65554. get samples(): number;
  65555. set samples(value: number);
  65556. /** Gets or sets the refresh rate to use (on every frame by default) */
  65557. get refreshRate(): number;
  65558. set refreshRate(value: number);
  65559. /**
  65560. * Gets the hosting scene
  65561. * @returns a Scene
  65562. */
  65563. getScene(): Scene;
  65564. /** Gets the internal CubeTexture used to render to */
  65565. get cubeTexture(): RenderTargetTexture;
  65566. /** Gets the list of meshes to render */
  65567. get renderList(): Nullable<AbstractMesh[]>;
  65568. /**
  65569. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  65570. * @param mesh defines the mesh to attach to
  65571. */
  65572. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  65573. /**
  65574. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  65575. * @param renderingGroupId The rendering group id corresponding to its index
  65576. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  65577. */
  65578. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  65579. /**
  65580. * Clean all associated resources
  65581. */
  65582. dispose(): void;
  65583. /**
  65584. * Converts the reflection probe information to a readable string for debug purpose.
  65585. * @param fullDetails Supports for multiple levels of logging within scene loading
  65586. * @returns the human readable reflection probe info
  65587. */
  65588. toString(fullDetails?: boolean): string;
  65589. /**
  65590. * Get the class name of the relfection probe.
  65591. * @returns "ReflectionProbe"
  65592. */
  65593. getClassName(): string;
  65594. /**
  65595. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  65596. * @returns The JSON representation of the texture
  65597. */
  65598. serialize(): any;
  65599. /**
  65600. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  65601. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  65602. * @param scene Define the scene the parsed reflection probe should be instantiated in
  65603. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  65604. * @returns The parsed reflection probe if successful
  65605. */
  65606. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  65607. }
  65608. }
  65609. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  65610. /** @hidden */
  65611. export var _BabylonLoaderRegistered: boolean;
  65612. /**
  65613. * Helps setting up some configuration for the babylon file loader.
  65614. */
  65615. export class BabylonFileLoaderConfiguration {
  65616. /**
  65617. * The loader does not allow injecting custom physix engine into the plugins.
  65618. * Unfortunately in ES6, we need to manually inject them into the plugin.
  65619. * So you could set this variable to your engine import to make it work.
  65620. */
  65621. static LoaderInjectedPhysicsEngine: any;
  65622. }
  65623. }
  65624. declare module "babylonjs/Loading/Plugins/index" {
  65625. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  65626. }
  65627. declare module "babylonjs/Loading/index" {
  65628. export * from "babylonjs/Loading/loadingScreen";
  65629. export * from "babylonjs/Loading/Plugins/index";
  65630. export * from "babylonjs/Loading/sceneLoader";
  65631. export * from "babylonjs/Loading/sceneLoaderFlags";
  65632. }
  65633. declare module "babylonjs/Materials/Background/index" {
  65634. export * from "babylonjs/Materials/Background/backgroundMaterial";
  65635. }
  65636. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  65637. import { Scene } from "babylonjs/scene";
  65638. import { Color3 } from "babylonjs/Maths/math.color";
  65639. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65640. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65641. /**
  65642. * The Physically based simple base material of BJS.
  65643. *
  65644. * This enables better naming and convention enforcements on top of the pbrMaterial.
  65645. * It is used as the base class for both the specGloss and metalRough conventions.
  65646. */
  65647. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  65648. /**
  65649. * Number of Simultaneous lights allowed on the material.
  65650. */
  65651. maxSimultaneousLights: number;
  65652. /**
  65653. * If sets to true, disables all the lights affecting the material.
  65654. */
  65655. disableLighting: boolean;
  65656. /**
  65657. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  65658. */
  65659. environmentTexture: BaseTexture;
  65660. /**
  65661. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  65662. */
  65663. invertNormalMapX: boolean;
  65664. /**
  65665. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  65666. */
  65667. invertNormalMapY: boolean;
  65668. /**
  65669. * Normal map used in the model.
  65670. */
  65671. normalTexture: BaseTexture;
  65672. /**
  65673. * Emissivie color used to self-illuminate the model.
  65674. */
  65675. emissiveColor: Color3;
  65676. /**
  65677. * Emissivie texture used to self-illuminate the model.
  65678. */
  65679. emissiveTexture: BaseTexture;
  65680. /**
  65681. * Occlusion Channel Strenght.
  65682. */
  65683. occlusionStrength: number;
  65684. /**
  65685. * Occlusion Texture of the material (adding extra occlusion effects).
  65686. */
  65687. occlusionTexture: BaseTexture;
  65688. /**
  65689. * Defines the alpha limits in alpha test mode.
  65690. */
  65691. alphaCutOff: number;
  65692. /**
  65693. * Gets the current double sided mode.
  65694. */
  65695. get doubleSided(): boolean;
  65696. /**
  65697. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  65698. */
  65699. set doubleSided(value: boolean);
  65700. /**
  65701. * Stores the pre-calculated light information of a mesh in a texture.
  65702. */
  65703. lightmapTexture: BaseTexture;
  65704. /**
  65705. * If true, the light map contains occlusion information instead of lighting info.
  65706. */
  65707. useLightmapAsShadowmap: boolean;
  65708. /**
  65709. * Instantiates a new PBRMaterial instance.
  65710. *
  65711. * @param name The material name
  65712. * @param scene The scene the material will be use in.
  65713. */
  65714. constructor(name: string, scene: Scene);
  65715. getClassName(): string;
  65716. }
  65717. }
  65718. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  65719. import { Scene } from "babylonjs/scene";
  65720. import { Color3 } from "babylonjs/Maths/math.color";
  65721. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65722. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65723. /**
  65724. * The PBR material of BJS following the metal roughness convention.
  65725. *
  65726. * This fits to the PBR convention in the GLTF definition:
  65727. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  65728. */
  65729. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  65730. /**
  65731. * The base color has two different interpretations depending on the value of metalness.
  65732. * When the material is a metal, the base color is the specific measured reflectance value
  65733. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  65734. * of the material.
  65735. */
  65736. baseColor: Color3;
  65737. /**
  65738. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  65739. * well as opacity information in the alpha channel.
  65740. */
  65741. baseTexture: BaseTexture;
  65742. /**
  65743. * Specifies the metallic scalar value of the material.
  65744. * Can also be used to scale the metalness values of the metallic texture.
  65745. */
  65746. metallic: number;
  65747. /**
  65748. * Specifies the roughness scalar value of the material.
  65749. * Can also be used to scale the roughness values of the metallic texture.
  65750. */
  65751. roughness: number;
  65752. /**
  65753. * Texture containing both the metallic value in the B channel and the
  65754. * roughness value in the G channel to keep better precision.
  65755. */
  65756. metallicRoughnessTexture: BaseTexture;
  65757. /**
  65758. * Instantiates a new PBRMetalRoughnessMaterial instance.
  65759. *
  65760. * @param name The material name
  65761. * @param scene The scene the material will be use in.
  65762. */
  65763. constructor(name: string, scene: Scene);
  65764. /**
  65765. * Return the currrent class name of the material.
  65766. */
  65767. getClassName(): string;
  65768. /**
  65769. * Makes a duplicate of the current material.
  65770. * @param name - name to use for the new material.
  65771. */
  65772. clone(name: string): PBRMetallicRoughnessMaterial;
  65773. /**
  65774. * Serialize the material to a parsable JSON object.
  65775. */
  65776. serialize(): any;
  65777. /**
  65778. * Parses a JSON object correponding to the serialize function.
  65779. */
  65780. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  65781. }
  65782. }
  65783. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  65784. import { Scene } from "babylonjs/scene";
  65785. import { Color3 } from "babylonjs/Maths/math.color";
  65786. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65787. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65788. /**
  65789. * The PBR material of BJS following the specular glossiness convention.
  65790. *
  65791. * This fits to the PBR convention in the GLTF definition:
  65792. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  65793. */
  65794. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65795. /**
  65796. * Specifies the diffuse color of the material.
  65797. */
  65798. diffuseColor: Color3;
  65799. /**
  65800. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65801. * channel.
  65802. */
  65803. diffuseTexture: BaseTexture;
  65804. /**
  65805. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65806. */
  65807. specularColor: Color3;
  65808. /**
  65809. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65810. */
  65811. glossiness: number;
  65812. /**
  65813. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65814. */
  65815. specularGlossinessTexture: BaseTexture;
  65816. /**
  65817. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65818. *
  65819. * @param name The material name
  65820. * @param scene The scene the material will be use in.
  65821. */
  65822. constructor(name: string, scene: Scene);
  65823. /**
  65824. * Return the currrent class name of the material.
  65825. */
  65826. getClassName(): string;
  65827. /**
  65828. * Makes a duplicate of the current material.
  65829. * @param name - name to use for the new material.
  65830. */
  65831. clone(name: string): PBRSpecularGlossinessMaterial;
  65832. /**
  65833. * Serialize the material to a parsable JSON object.
  65834. */
  65835. serialize(): any;
  65836. /**
  65837. * Parses a JSON object correponding to the serialize function.
  65838. */
  65839. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65840. }
  65841. }
  65842. declare module "babylonjs/Materials/PBR/index" {
  65843. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65844. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65845. export * from "babylonjs/Materials/PBR/pbrMaterial";
  65846. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  65847. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  65848. }
  65849. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  65850. import { Nullable } from "babylonjs/types";
  65851. import { Scene } from "babylonjs/scene";
  65852. import { Matrix } from "babylonjs/Maths/math.vector";
  65853. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65854. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65855. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65856. /**
  65857. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65858. * It can help converting any input color in a desired output one. This can then be used to create effects
  65859. * from sepia, black and white to sixties or futuristic rendering...
  65860. *
  65861. * The only supported format is currently 3dl.
  65862. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  65863. */
  65864. export class ColorGradingTexture extends BaseTexture {
  65865. /**
  65866. * The texture URL.
  65867. */
  65868. url: string;
  65869. /**
  65870. * Empty line regex stored for GC.
  65871. */
  65872. private static _noneEmptyLineRegex;
  65873. private _textureMatrix;
  65874. private _onLoad;
  65875. /**
  65876. * Instantiates a ColorGradingTexture from the following parameters.
  65877. *
  65878. * @param url The location of the color gradind data (currently only supporting 3dl)
  65879. * @param sceneOrEngine The scene or engine the texture will be used in
  65880. * @param onLoad defines a callback triggered when the texture has been loaded
  65881. */
  65882. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  65883. /**
  65884. * Fires the onload event from the constructor if requested.
  65885. */
  65886. private _triggerOnLoad;
  65887. /**
  65888. * Returns the texture matrix used in most of the material.
  65889. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  65890. */
  65891. getTextureMatrix(): Matrix;
  65892. /**
  65893. * Occurs when the file being loaded is a .3dl LUT file.
  65894. */
  65895. private load3dlTexture;
  65896. /**
  65897. * Starts the loading process of the texture.
  65898. */
  65899. private loadTexture;
  65900. /**
  65901. * Clones the color gradind texture.
  65902. */
  65903. clone(): ColorGradingTexture;
  65904. /**
  65905. * Called during delayed load for textures.
  65906. */
  65907. delayLoad(): void;
  65908. /**
  65909. * Parses a color grading texture serialized by Babylon.
  65910. * @param parsedTexture The texture information being parsedTexture
  65911. * @param scene The scene to load the texture in
  65912. * @param rootUrl The root url of the data assets to load
  65913. * @return A color gradind texture
  65914. */
  65915. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  65916. /**
  65917. * Serializes the LUT texture to json format.
  65918. */
  65919. serialize(): any;
  65920. }
  65921. }
  65922. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  65923. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65924. import { Scene } from "babylonjs/scene";
  65925. import { Nullable } from "babylonjs/types";
  65926. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65927. /**
  65928. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  65929. */
  65930. export class EquiRectangularCubeTexture extends BaseTexture {
  65931. /** The six faces of the cube. */
  65932. private static _FacesMapping;
  65933. private _noMipmap;
  65934. private _onLoad;
  65935. private _onError;
  65936. /** The size of the cubemap. */
  65937. private _size;
  65938. /** The buffer of the image. */
  65939. private _buffer;
  65940. /** The width of the input image. */
  65941. private _width;
  65942. /** The height of the input image. */
  65943. private _height;
  65944. /** The URL to the image. */
  65945. url: string;
  65946. /**
  65947. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  65948. * @param url The location of the image
  65949. * @param scene The scene the texture will be used in
  65950. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65951. * @param noMipmap Forces to not generate the mipmap if true
  65952. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65953. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65954. * @param onLoad — defines a callback called when texture is loaded
  65955. * @param onError — defines a callback called if there is an error
  65956. */
  65957. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  65958. /**
  65959. * Load the image data, by putting the image on a canvas and extracting its buffer.
  65960. */
  65961. private loadImage;
  65962. /**
  65963. * Convert the image buffer into a cubemap and create a CubeTexture.
  65964. */
  65965. private loadTexture;
  65966. /**
  65967. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  65968. * @param buffer The ArrayBuffer that should be converted.
  65969. * @returns The buffer as Float32Array.
  65970. */
  65971. private getFloat32ArrayFromArrayBuffer;
  65972. /**
  65973. * Get the current class name of the texture useful for serialization or dynamic coding.
  65974. * @returns "EquiRectangularCubeTexture"
  65975. */
  65976. getClassName(): string;
  65977. /**
  65978. * Create a clone of the current EquiRectangularCubeTexture and return it.
  65979. * @returns A clone of the current EquiRectangularCubeTexture.
  65980. */
  65981. clone(): EquiRectangularCubeTexture;
  65982. }
  65983. }
  65984. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  65985. import { Nullable } from "babylonjs/types";
  65986. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65987. import { Matrix } from "babylonjs/Maths/math.vector";
  65988. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  65989. import "babylonjs/Engines/Extensions/engine.videoTexture";
  65990. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65991. import { Scene } from "babylonjs/scene";
  65992. /**
  65993. * Defines the options related to the creation of an HtmlElementTexture
  65994. */
  65995. export interface IHtmlElementTextureOptions {
  65996. /**
  65997. * Defines wether mip maps should be created or not.
  65998. */
  65999. generateMipMaps?: boolean;
  66000. /**
  66001. * Defines the sampling mode of the texture.
  66002. */
  66003. samplingMode?: number;
  66004. /**
  66005. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  66006. */
  66007. engine: Nullable<ThinEngine>;
  66008. /**
  66009. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  66010. */
  66011. scene: Nullable<Scene>;
  66012. }
  66013. /**
  66014. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  66015. * To be as efficient as possible depending on your constraints nothing aside the first upload
  66016. * is automatically managed.
  66017. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  66018. * in your application.
  66019. *
  66020. * As the update is not automatic, you need to call them manually.
  66021. */
  66022. export class HtmlElementTexture extends BaseTexture {
  66023. /**
  66024. * The texture URL.
  66025. */
  66026. element: HTMLVideoElement | HTMLCanvasElement;
  66027. private static readonly DefaultOptions;
  66028. private _textureMatrix;
  66029. private _isVideo;
  66030. private _generateMipMaps;
  66031. private _samplingMode;
  66032. /**
  66033. * Instantiates a HtmlElementTexture from the following parameters.
  66034. *
  66035. * @param name Defines the name of the texture
  66036. * @param element Defines the video or canvas the texture is filled with
  66037. * @param options Defines the other none mandatory texture creation options
  66038. */
  66039. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  66040. private _createInternalTexture;
  66041. /**
  66042. * Returns the texture matrix used in most of the material.
  66043. */
  66044. getTextureMatrix(): Matrix;
  66045. /**
  66046. * Updates the content of the texture.
  66047. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  66048. */
  66049. update(invertY?: Nullable<boolean>): void;
  66050. }
  66051. }
  66052. declare module "babylonjs/Misc/tga" {
  66053. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66054. /**
  66055. * Based on jsTGALoader - Javascript loader for TGA file
  66056. * By Vincent Thibault
  66057. * @see http://blog.robrowser.com/javascript-tga-loader.html
  66058. */
  66059. export class TGATools {
  66060. private static _TYPE_INDEXED;
  66061. private static _TYPE_RGB;
  66062. private static _TYPE_GREY;
  66063. private static _TYPE_RLE_INDEXED;
  66064. private static _TYPE_RLE_RGB;
  66065. private static _TYPE_RLE_GREY;
  66066. private static _ORIGIN_MASK;
  66067. private static _ORIGIN_SHIFT;
  66068. private static _ORIGIN_BL;
  66069. private static _ORIGIN_BR;
  66070. private static _ORIGIN_UL;
  66071. private static _ORIGIN_UR;
  66072. /**
  66073. * Gets the header of a TGA file
  66074. * @param data defines the TGA data
  66075. * @returns the header
  66076. */
  66077. static GetTGAHeader(data: Uint8Array): any;
  66078. /**
  66079. * Uploads TGA content to a Babylon Texture
  66080. * @hidden
  66081. */
  66082. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  66083. /** @hidden */
  66084. 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;
  66085. /** @hidden */
  66086. 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;
  66087. /** @hidden */
  66088. 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;
  66089. /** @hidden */
  66090. 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;
  66091. /** @hidden */
  66092. 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;
  66093. /** @hidden */
  66094. 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;
  66095. }
  66096. }
  66097. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  66098. import { Nullable } from "babylonjs/types";
  66099. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66100. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  66101. /**
  66102. * Implementation of the TGA Texture Loader.
  66103. * @hidden
  66104. */
  66105. export class _TGATextureLoader implements IInternalTextureLoader {
  66106. /**
  66107. * Defines wether the loader supports cascade loading the different faces.
  66108. */
  66109. readonly supportCascades: boolean;
  66110. /**
  66111. * This returns if the loader support the current file information.
  66112. * @param extension defines the file extension of the file being loaded
  66113. * @returns true if the loader can load the specified file
  66114. */
  66115. canLoad(extension: string): boolean;
  66116. /**
  66117. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66118. * @param data contains the texture data
  66119. * @param texture defines the BabylonJS internal texture
  66120. * @param createPolynomials will be true if polynomials have been requested
  66121. * @param onLoad defines the callback to trigger once the texture is ready
  66122. * @param onError defines the callback to trigger in case of error
  66123. */
  66124. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66125. /**
  66126. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66127. * @param data contains the texture data
  66128. * @param texture defines the BabylonJS internal texture
  66129. * @param callback defines the method to call once ready to upload
  66130. */
  66131. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66132. }
  66133. }
  66134. declare module "babylonjs/Misc/basis" {
  66135. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66136. /**
  66137. * Info about the .basis files
  66138. */
  66139. class BasisFileInfo {
  66140. /**
  66141. * If the file has alpha
  66142. */
  66143. hasAlpha: boolean;
  66144. /**
  66145. * Info about each image of the basis file
  66146. */
  66147. images: Array<{
  66148. levels: Array<{
  66149. width: number;
  66150. height: number;
  66151. transcodedPixels: ArrayBufferView;
  66152. }>;
  66153. }>;
  66154. }
  66155. /**
  66156. * Result of transcoding a basis file
  66157. */
  66158. class TranscodeResult {
  66159. /**
  66160. * Info about the .basis file
  66161. */
  66162. fileInfo: BasisFileInfo;
  66163. /**
  66164. * Format to use when loading the file
  66165. */
  66166. format: number;
  66167. }
  66168. /**
  66169. * Configuration options for the Basis transcoder
  66170. */
  66171. export class BasisTranscodeConfiguration {
  66172. /**
  66173. * Supported compression formats used to determine the supported output format of the transcoder
  66174. */
  66175. supportedCompressionFormats?: {
  66176. /**
  66177. * etc1 compression format
  66178. */
  66179. etc1?: boolean;
  66180. /**
  66181. * s3tc compression format
  66182. */
  66183. s3tc?: boolean;
  66184. /**
  66185. * pvrtc compression format
  66186. */
  66187. pvrtc?: boolean;
  66188. /**
  66189. * etc2 compression format
  66190. */
  66191. etc2?: boolean;
  66192. };
  66193. /**
  66194. * If mipmap levels should be loaded for transcoded images (Default: true)
  66195. */
  66196. loadMipmapLevels?: boolean;
  66197. /**
  66198. * Index of a single image to load (Default: all images)
  66199. */
  66200. loadSingleImage?: number;
  66201. }
  66202. /**
  66203. * Used to load .Basis files
  66204. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  66205. */
  66206. export class BasisTools {
  66207. private static _IgnoreSupportedFormats;
  66208. /**
  66209. * URL to use when loading the basis transcoder
  66210. */
  66211. static JSModuleURL: string;
  66212. /**
  66213. * URL to use when loading the wasm module for the transcoder
  66214. */
  66215. static WasmModuleURL: string;
  66216. /**
  66217. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  66218. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  66219. * @returns internal format corresponding to the Basis format
  66220. */
  66221. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  66222. private static _WorkerPromise;
  66223. private static _Worker;
  66224. private static _actionId;
  66225. private static _CreateWorkerAsync;
  66226. /**
  66227. * Transcodes a loaded image file to compressed pixel data
  66228. * @param data image data to transcode
  66229. * @param config configuration options for the transcoding
  66230. * @returns a promise resulting in the transcoded image
  66231. */
  66232. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  66233. /**
  66234. * Loads a texture from the transcode result
  66235. * @param texture texture load to
  66236. * @param transcodeResult the result of transcoding the basis file to load from
  66237. */
  66238. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  66239. }
  66240. }
  66241. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  66242. import { Nullable } from "babylonjs/types";
  66243. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66244. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  66245. /**
  66246. * Loader for .basis file format
  66247. */
  66248. export class _BasisTextureLoader implements IInternalTextureLoader {
  66249. /**
  66250. * Defines whether the loader supports cascade loading the different faces.
  66251. */
  66252. readonly supportCascades: boolean;
  66253. /**
  66254. * This returns if the loader support the current file information.
  66255. * @param extension defines the file extension of the file being loaded
  66256. * @returns true if the loader can load the specified file
  66257. */
  66258. canLoad(extension: string): boolean;
  66259. /**
  66260. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66261. * @param data contains the texture data
  66262. * @param texture defines the BabylonJS internal texture
  66263. * @param createPolynomials will be true if polynomials have been requested
  66264. * @param onLoad defines the callback to trigger once the texture is ready
  66265. * @param onError defines the callback to trigger in case of error
  66266. */
  66267. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66268. /**
  66269. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66270. * @param data contains the texture data
  66271. * @param texture defines the BabylonJS internal texture
  66272. * @param callback defines the method to call once ready to upload
  66273. */
  66274. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66275. }
  66276. }
  66277. declare module "babylonjs/Materials/Textures/Loaders/index" {
  66278. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  66279. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  66280. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  66281. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  66282. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  66283. }
  66284. declare module "babylonjs/Materials/Textures/Packer/frame" {
  66285. import { Vector2 } from "babylonjs/Maths/math.vector";
  66286. /**
  66287. * Defines the basic options interface of a TexturePacker Frame
  66288. */
  66289. export interface ITexturePackerFrame {
  66290. /**
  66291. * The frame ID
  66292. */
  66293. id: number;
  66294. /**
  66295. * The frames Scale
  66296. */
  66297. scale: Vector2;
  66298. /**
  66299. * The Frames offset
  66300. */
  66301. offset: Vector2;
  66302. }
  66303. /**
  66304. * This is a support class for frame Data on texture packer sets.
  66305. */
  66306. export class TexturePackerFrame implements ITexturePackerFrame {
  66307. /**
  66308. * The frame ID
  66309. */
  66310. id: number;
  66311. /**
  66312. * The frames Scale
  66313. */
  66314. scale: Vector2;
  66315. /**
  66316. * The Frames offset
  66317. */
  66318. offset: Vector2;
  66319. /**
  66320. * Initializes a texture package frame.
  66321. * @param id The numerical frame identifier
  66322. * @param scale Scalar Vector2 for UV frame
  66323. * @param offset Vector2 for the frame position in UV units.
  66324. * @returns TexturePackerFrame
  66325. */
  66326. constructor(id: number, scale: Vector2, offset: Vector2);
  66327. }
  66328. }
  66329. declare module "babylonjs/Materials/Textures/Packer/packer" {
  66330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66331. import { Scene } from "babylonjs/scene";
  66332. import { Nullable } from "babylonjs/types";
  66333. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  66334. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  66335. /**
  66336. * Defines the basic options interface of a TexturePacker
  66337. */
  66338. export interface ITexturePackerOptions {
  66339. /**
  66340. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  66341. */
  66342. map?: string[];
  66343. /**
  66344. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66345. */
  66346. uvsIn?: string;
  66347. /**
  66348. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66349. */
  66350. uvsOut?: string;
  66351. /**
  66352. * number representing the layout style. Defaults to LAYOUT_STRIP
  66353. */
  66354. layout?: number;
  66355. /**
  66356. * number of columns if using custom column count layout(2). This defaults to 4.
  66357. */
  66358. colnum?: number;
  66359. /**
  66360. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  66361. */
  66362. updateInputMeshes?: boolean;
  66363. /**
  66364. * boolean flag to dispose all the source textures. Defaults to true.
  66365. */
  66366. disposeSources?: boolean;
  66367. /**
  66368. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  66369. */
  66370. fillBlanks?: boolean;
  66371. /**
  66372. * string value representing the context fill style color. Defaults to 'black'.
  66373. */
  66374. customFillColor?: string;
  66375. /**
  66376. * Width and Height Value of each Frame in the TexturePacker Sets
  66377. */
  66378. frameSize?: number;
  66379. /**
  66380. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  66381. */
  66382. paddingRatio?: number;
  66383. /**
  66384. * Number that declares the fill method for the padding gutter.
  66385. */
  66386. paddingMode?: number;
  66387. /**
  66388. * If in SUBUV_COLOR padding mode what color to use.
  66389. */
  66390. paddingColor?: Color3 | Color4;
  66391. }
  66392. /**
  66393. * Defines the basic interface of a TexturePacker JSON File
  66394. */
  66395. export interface ITexturePackerJSON {
  66396. /**
  66397. * The frame ID
  66398. */
  66399. name: string;
  66400. /**
  66401. * The base64 channel data
  66402. */
  66403. sets: any;
  66404. /**
  66405. * The options of the Packer
  66406. */
  66407. options: ITexturePackerOptions;
  66408. /**
  66409. * The frame data of the Packer
  66410. */
  66411. frames: Array<number>;
  66412. }
  66413. /**
  66414. * This is a support class that generates a series of packed texture sets.
  66415. * @see https://doc.babylonjs.com/babylon101/materials
  66416. */
  66417. export class TexturePacker {
  66418. /** Packer Layout Constant 0 */
  66419. static readonly LAYOUT_STRIP: number;
  66420. /** Packer Layout Constant 1 */
  66421. static readonly LAYOUT_POWER2: number;
  66422. /** Packer Layout Constant 2 */
  66423. static readonly LAYOUT_COLNUM: number;
  66424. /** Packer Layout Constant 0 */
  66425. static readonly SUBUV_WRAP: number;
  66426. /** Packer Layout Constant 1 */
  66427. static readonly SUBUV_EXTEND: number;
  66428. /** Packer Layout Constant 2 */
  66429. static readonly SUBUV_COLOR: number;
  66430. /** The Name of the Texture Package */
  66431. name: string;
  66432. /** The scene scope of the TexturePacker */
  66433. scene: Scene;
  66434. /** The Meshes to target */
  66435. meshes: AbstractMesh[];
  66436. /** Arguments passed with the Constructor */
  66437. options: ITexturePackerOptions;
  66438. /** The promise that is started upon initialization */
  66439. promise: Nullable<Promise<TexturePacker | string>>;
  66440. /** The Container object for the channel sets that are generated */
  66441. sets: object;
  66442. /** The Container array for the frames that are generated */
  66443. frames: TexturePackerFrame[];
  66444. /** The expected number of textures the system is parsing. */
  66445. private _expecting;
  66446. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  66447. private _paddingValue;
  66448. /**
  66449. * Initializes a texture package series from an array of meshes or a single mesh.
  66450. * @param name The name of the package
  66451. * @param meshes The target meshes to compose the package from
  66452. * @param options The arguments that texture packer should follow while building.
  66453. * @param scene The scene which the textures are scoped to.
  66454. * @returns TexturePacker
  66455. */
  66456. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  66457. /**
  66458. * Starts the package process
  66459. * @param resolve The promises resolution function
  66460. * @returns TexturePacker
  66461. */
  66462. private _createFrames;
  66463. /**
  66464. * Calculates the Size of the Channel Sets
  66465. * @returns Vector2
  66466. */
  66467. private _calculateSize;
  66468. /**
  66469. * Calculates the UV data for the frames.
  66470. * @param baseSize the base frameSize
  66471. * @param padding the base frame padding
  66472. * @param dtSize size of the Dynamic Texture for that channel
  66473. * @param dtUnits is 1/dtSize
  66474. * @param update flag to update the input meshes
  66475. */
  66476. private _calculateMeshUVFrames;
  66477. /**
  66478. * Calculates the frames Offset.
  66479. * @param index of the frame
  66480. * @returns Vector2
  66481. */
  66482. private _getFrameOffset;
  66483. /**
  66484. * Updates a Mesh to the frame data
  66485. * @param mesh that is the target
  66486. * @param frameID or the frame index
  66487. */
  66488. private _updateMeshUV;
  66489. /**
  66490. * Updates a Meshes materials to use the texture packer channels
  66491. * @param m is the mesh to target
  66492. * @param force all channels on the packer to be set.
  66493. */
  66494. private _updateTextureReferences;
  66495. /**
  66496. * Public method to set a Mesh to a frame
  66497. * @param m that is the target
  66498. * @param frameID or the frame index
  66499. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  66500. */
  66501. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  66502. /**
  66503. * Starts the async promise to compile the texture packer.
  66504. * @returns Promise<void>
  66505. */
  66506. processAsync(): Promise<void>;
  66507. /**
  66508. * Disposes all textures associated with this packer
  66509. */
  66510. dispose(): void;
  66511. /**
  66512. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  66513. * @param imageType is the image type to use.
  66514. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  66515. */
  66516. download(imageType?: string, quality?: number): void;
  66517. /**
  66518. * Public method to load a texturePacker JSON file.
  66519. * @param data of the JSON file in string format.
  66520. */
  66521. updateFromJSON(data: string): void;
  66522. }
  66523. }
  66524. declare module "babylonjs/Materials/Textures/Packer/index" {
  66525. export * from "babylonjs/Materials/Textures/Packer/packer";
  66526. export * from "babylonjs/Materials/Textures/Packer/frame";
  66527. }
  66528. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  66529. import { Scene } from "babylonjs/scene";
  66530. import { Texture } from "babylonjs/Materials/Textures/texture";
  66531. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66532. /**
  66533. * 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.
  66534. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66535. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66536. */
  66537. export class CustomProceduralTexture extends ProceduralTexture {
  66538. private _animate;
  66539. private _time;
  66540. private _config;
  66541. private _texturePath;
  66542. /**
  66543. * Instantiates a new Custom Procedural Texture.
  66544. * 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.
  66545. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66546. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66547. * @param name Define the name of the texture
  66548. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  66549. * @param size Define the size of the texture to create
  66550. * @param scene Define the scene the texture belongs to
  66551. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  66552. * @param generateMipMaps Define if the texture should creates mip maps or not
  66553. */
  66554. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66555. private _loadJson;
  66556. /**
  66557. * Is the texture ready to be used ? (rendered at least once)
  66558. * @returns true if ready, otherwise, false.
  66559. */
  66560. isReady(): boolean;
  66561. /**
  66562. * Render the texture to its associated render target.
  66563. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  66564. */
  66565. render(useCameraPostProcess?: boolean): void;
  66566. /**
  66567. * Update the list of dependant textures samplers in the shader.
  66568. */
  66569. updateTextures(): void;
  66570. /**
  66571. * Update the uniform values of the procedural texture in the shader.
  66572. */
  66573. updateShaderUniforms(): void;
  66574. /**
  66575. * Define if the texture animates or not.
  66576. */
  66577. get animate(): boolean;
  66578. set animate(value: boolean);
  66579. }
  66580. }
  66581. declare module "babylonjs/Shaders/noise.fragment" {
  66582. /** @hidden */
  66583. export var noisePixelShader: {
  66584. name: string;
  66585. shader: string;
  66586. };
  66587. }
  66588. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  66589. import { Nullable } from "babylonjs/types";
  66590. import { Scene } from "babylonjs/scene";
  66591. import { Texture } from "babylonjs/Materials/Textures/texture";
  66592. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66593. import "babylonjs/Shaders/noise.fragment";
  66594. /**
  66595. * Class used to generate noise procedural textures
  66596. */
  66597. export class NoiseProceduralTexture extends ProceduralTexture {
  66598. /** Gets or sets the start time (default is 0) */
  66599. time: number;
  66600. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  66601. brightness: number;
  66602. /** Defines the number of octaves to process */
  66603. octaves: number;
  66604. /** Defines the level of persistence (0.8 by default) */
  66605. persistence: number;
  66606. /** Gets or sets animation speed factor (default is 1) */
  66607. animationSpeedFactor: number;
  66608. /**
  66609. * Creates a new NoiseProceduralTexture
  66610. * @param name defines the name fo the texture
  66611. * @param size defines the size of the texture (default is 256)
  66612. * @param scene defines the hosting scene
  66613. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  66614. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  66615. */
  66616. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66617. private _updateShaderUniforms;
  66618. protected _getDefines(): string;
  66619. /** Generate the current state of the procedural texture */
  66620. render(useCameraPostProcess?: boolean): void;
  66621. /**
  66622. * Serializes this noise procedural texture
  66623. * @returns a serialized noise procedural texture object
  66624. */
  66625. serialize(): any;
  66626. /**
  66627. * Clone the texture.
  66628. * @returns the cloned texture
  66629. */
  66630. clone(): NoiseProceduralTexture;
  66631. /**
  66632. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  66633. * @param parsedTexture defines parsed texture data
  66634. * @param scene defines the current scene
  66635. * @param rootUrl defines the root URL containing noise procedural texture information
  66636. * @returns a parsed NoiseProceduralTexture
  66637. */
  66638. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  66639. }
  66640. }
  66641. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  66642. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  66643. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  66644. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66645. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  66646. }
  66647. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  66648. import { Nullable } from "babylonjs/types";
  66649. import { Scene } from "babylonjs/scene";
  66650. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  66651. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66652. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  66653. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66654. /**
  66655. * Raw cube texture where the raw buffers are passed in
  66656. */
  66657. export class RawCubeTexture extends CubeTexture {
  66658. /**
  66659. * Creates a cube texture where the raw buffers are passed in.
  66660. * @param scene defines the scene the texture is attached to
  66661. * @param data defines the array of data to use to create each face
  66662. * @param size defines the size of the textures
  66663. * @param format defines the format of the data
  66664. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  66665. * @param generateMipMaps defines if the engine should generate the mip levels
  66666. * @param invertY defines if data must be stored with Y axis inverted
  66667. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  66668. * @param compression defines the compression used (null by default)
  66669. */
  66670. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  66671. /**
  66672. * Updates the raw cube texture.
  66673. * @param data defines the data to store
  66674. * @param format defines the data format
  66675. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66676. * @param invertY defines if data must be stored with Y axis inverted
  66677. * @param compression defines the compression used (null by default)
  66678. * @param level defines which level of the texture to update
  66679. */
  66680. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  66681. /**
  66682. * Updates a raw cube texture with RGBD encoded data.
  66683. * @param data defines the array of data [mipmap][face] to use to create each face
  66684. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  66685. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66686. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66687. * @returns a promsie that resolves when the operation is complete
  66688. */
  66689. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  66690. /**
  66691. * Clones the raw cube texture.
  66692. * @return a new cube texture
  66693. */
  66694. clone(): CubeTexture;
  66695. /** @hidden */
  66696. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  66697. }
  66698. }
  66699. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  66700. import { Scene } from "babylonjs/scene";
  66701. import { Texture } from "babylonjs/Materials/Textures/texture";
  66702. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66703. /**
  66704. * Class used to store 2D array textures containing user data
  66705. */
  66706. export class RawTexture2DArray extends Texture {
  66707. /** Gets or sets the texture format to use */
  66708. format: number;
  66709. /**
  66710. * Create a new RawTexture2DArray
  66711. * @param data defines the data of the texture
  66712. * @param width defines the width of the texture
  66713. * @param height defines the height of the texture
  66714. * @param depth defines the number of layers of the texture
  66715. * @param format defines the texture format to use
  66716. * @param scene defines the hosting scene
  66717. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66718. * @param invertY defines if texture must be stored with Y axis inverted
  66719. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66720. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66721. */
  66722. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66723. /** Gets or sets the texture format to use */
  66724. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66725. /**
  66726. * Update the texture with new data
  66727. * @param data defines the data to store in the texture
  66728. */
  66729. update(data: ArrayBufferView): void;
  66730. }
  66731. }
  66732. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  66733. import { Scene } from "babylonjs/scene";
  66734. import { Texture } from "babylonjs/Materials/Textures/texture";
  66735. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66736. /**
  66737. * Class used to store 3D textures containing user data
  66738. */
  66739. export class RawTexture3D extends Texture {
  66740. /** Gets or sets the texture format to use */
  66741. format: number;
  66742. /**
  66743. * Create a new RawTexture3D
  66744. * @param data defines the data of the texture
  66745. * @param width defines the width of the texture
  66746. * @param height defines the height of the texture
  66747. * @param depth defines the depth of the texture
  66748. * @param format defines the texture format to use
  66749. * @param scene defines the hosting scene
  66750. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66751. * @param invertY defines if texture must be stored with Y axis inverted
  66752. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66753. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66754. */
  66755. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66756. /** Gets or sets the texture format to use */
  66757. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66758. /**
  66759. * Update the texture with new data
  66760. * @param data defines the data to store in the texture
  66761. */
  66762. update(data: ArrayBufferView): void;
  66763. }
  66764. }
  66765. declare module "babylonjs/Materials/Textures/refractionTexture" {
  66766. import { Scene } from "babylonjs/scene";
  66767. import { Plane } from "babylonjs/Maths/math.plane";
  66768. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66769. /**
  66770. * Creates a refraction texture used by refraction channel of the standard material.
  66771. * It is like a mirror but to see through a material.
  66772. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66773. */
  66774. export class RefractionTexture extends RenderTargetTexture {
  66775. /**
  66776. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  66777. * 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.
  66778. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66779. */
  66780. refractionPlane: Plane;
  66781. /**
  66782. * Define how deep under the surface we should see.
  66783. */
  66784. depth: number;
  66785. /**
  66786. * Creates a refraction texture used by refraction channel of the standard material.
  66787. * It is like a mirror but to see through a material.
  66788. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66789. * @param name Define the texture name
  66790. * @param size Define the size of the underlying texture
  66791. * @param scene Define the scene the refraction belongs to
  66792. * @param generateMipMaps Define if we need to generate mips level for the refraction
  66793. */
  66794. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66795. /**
  66796. * Clone the refraction texture.
  66797. * @returns the cloned texture
  66798. */
  66799. clone(): RefractionTexture;
  66800. /**
  66801. * Serialize the texture to a JSON representation you could use in Parse later on
  66802. * @returns the serialized JSON representation
  66803. */
  66804. serialize(): any;
  66805. }
  66806. }
  66807. declare module "babylonjs/Materials/Textures/index" {
  66808. export * from "babylonjs/Materials/Textures/baseTexture";
  66809. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  66810. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  66811. export * from "babylonjs/Materials/Textures/cubeTexture";
  66812. export * from "babylonjs/Materials/Textures/dynamicTexture";
  66813. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66814. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  66815. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  66816. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  66817. export * from "babylonjs/Materials/Textures/internalTexture";
  66818. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  66819. export * from "babylonjs/Materials/Textures/Loaders/index";
  66820. export * from "babylonjs/Materials/Textures/mirrorTexture";
  66821. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  66822. export * from "babylonjs/Materials/Textures/Packer/index";
  66823. export * from "babylonjs/Materials/Textures/Procedurals/index";
  66824. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  66825. export * from "babylonjs/Materials/Textures/rawTexture";
  66826. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  66827. export * from "babylonjs/Materials/Textures/rawTexture3D";
  66828. export * from "babylonjs/Materials/Textures/refractionTexture";
  66829. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  66830. export * from "babylonjs/Materials/Textures/texture";
  66831. export * from "babylonjs/Materials/Textures/videoTexture";
  66832. }
  66833. declare module "babylonjs/Materials/Node/Enums/index" {
  66834. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  66835. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  66836. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  66837. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  66838. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  66839. }
  66840. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  66841. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66842. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66844. import { Mesh } from "babylonjs/Meshes/mesh";
  66845. import { Effect } from "babylonjs/Materials/effect";
  66846. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66847. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66848. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66849. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66850. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66851. /**
  66852. * Block used to add support for vertex skinning (bones)
  66853. */
  66854. export class BonesBlock extends NodeMaterialBlock {
  66855. /**
  66856. * Creates a new BonesBlock
  66857. * @param name defines the block name
  66858. */
  66859. constructor(name: string);
  66860. /**
  66861. * Initialize the block and prepare the context for build
  66862. * @param state defines the state that will be used for the build
  66863. */
  66864. initialize(state: NodeMaterialBuildState): void;
  66865. /**
  66866. * Gets the current class name
  66867. * @returns the class name
  66868. */
  66869. getClassName(): string;
  66870. /**
  66871. * Gets the matrix indices input component
  66872. */
  66873. get matricesIndices(): NodeMaterialConnectionPoint;
  66874. /**
  66875. * Gets the matrix weights input component
  66876. */
  66877. get matricesWeights(): NodeMaterialConnectionPoint;
  66878. /**
  66879. * Gets the extra matrix indices input component
  66880. */
  66881. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66882. /**
  66883. * Gets the extra matrix weights input component
  66884. */
  66885. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66886. /**
  66887. * Gets the world input component
  66888. */
  66889. get world(): NodeMaterialConnectionPoint;
  66890. /**
  66891. * Gets the output component
  66892. */
  66893. get output(): NodeMaterialConnectionPoint;
  66894. autoConfigure(material: NodeMaterial): void;
  66895. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66896. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66897. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66898. protected _buildBlock(state: NodeMaterialBuildState): this;
  66899. }
  66900. }
  66901. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  66902. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66903. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66904. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66906. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66907. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66908. /**
  66909. * Block used to add support for instances
  66910. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  66911. */
  66912. export class InstancesBlock extends NodeMaterialBlock {
  66913. /**
  66914. * Creates a new InstancesBlock
  66915. * @param name defines the block name
  66916. */
  66917. constructor(name: string);
  66918. /**
  66919. * Gets the current class name
  66920. * @returns the class name
  66921. */
  66922. getClassName(): string;
  66923. /**
  66924. * Gets the first world row input component
  66925. */
  66926. get world0(): NodeMaterialConnectionPoint;
  66927. /**
  66928. * Gets the second world row input component
  66929. */
  66930. get world1(): NodeMaterialConnectionPoint;
  66931. /**
  66932. * Gets the third world row input component
  66933. */
  66934. get world2(): NodeMaterialConnectionPoint;
  66935. /**
  66936. * Gets the forth world row input component
  66937. */
  66938. get world3(): NodeMaterialConnectionPoint;
  66939. /**
  66940. * Gets the world input component
  66941. */
  66942. get world(): NodeMaterialConnectionPoint;
  66943. /**
  66944. * Gets the output component
  66945. */
  66946. get output(): NodeMaterialConnectionPoint;
  66947. /**
  66948. * Gets the isntanceID component
  66949. */
  66950. get instanceID(): NodeMaterialConnectionPoint;
  66951. autoConfigure(material: NodeMaterial): void;
  66952. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  66953. protected _buildBlock(state: NodeMaterialBuildState): this;
  66954. }
  66955. }
  66956. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  66957. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66958. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66959. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66961. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66962. import { Effect } from "babylonjs/Materials/effect";
  66963. import { Mesh } from "babylonjs/Meshes/mesh";
  66964. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66965. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66966. /**
  66967. * Block used to add morph targets support to vertex shader
  66968. */
  66969. export class MorphTargetsBlock extends NodeMaterialBlock {
  66970. private _repeatableContentAnchor;
  66971. /**
  66972. * Create a new MorphTargetsBlock
  66973. * @param name defines the block name
  66974. */
  66975. constructor(name: string);
  66976. /**
  66977. * Gets the current class name
  66978. * @returns the class name
  66979. */
  66980. getClassName(): string;
  66981. /**
  66982. * Gets the position input component
  66983. */
  66984. get position(): NodeMaterialConnectionPoint;
  66985. /**
  66986. * Gets the normal input component
  66987. */
  66988. get normal(): NodeMaterialConnectionPoint;
  66989. /**
  66990. * Gets the tangent input component
  66991. */
  66992. get tangent(): NodeMaterialConnectionPoint;
  66993. /**
  66994. * Gets the tangent input component
  66995. */
  66996. get uv(): NodeMaterialConnectionPoint;
  66997. /**
  66998. * Gets the position output component
  66999. */
  67000. get positionOutput(): NodeMaterialConnectionPoint;
  67001. /**
  67002. * Gets the normal output component
  67003. */
  67004. get normalOutput(): NodeMaterialConnectionPoint;
  67005. /**
  67006. * Gets the tangent output component
  67007. */
  67008. get tangentOutput(): NodeMaterialConnectionPoint;
  67009. /**
  67010. * Gets the tangent output component
  67011. */
  67012. get uvOutput(): NodeMaterialConnectionPoint;
  67013. initialize(state: NodeMaterialBuildState): void;
  67014. autoConfigure(material: NodeMaterial): void;
  67015. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67016. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67017. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  67018. protected _buildBlock(state: NodeMaterialBuildState): this;
  67019. }
  67020. }
  67021. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  67022. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67023. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67024. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67025. import { Nullable } from "babylonjs/types";
  67026. import { Scene } from "babylonjs/scene";
  67027. import { Effect } from "babylonjs/Materials/effect";
  67028. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67029. import { Mesh } from "babylonjs/Meshes/mesh";
  67030. import { Light } from "babylonjs/Lights/light";
  67031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67032. /**
  67033. * Block used to get data information from a light
  67034. */
  67035. export class LightInformationBlock extends NodeMaterialBlock {
  67036. private _lightDataUniformName;
  67037. private _lightColorUniformName;
  67038. private _lightTypeDefineName;
  67039. /**
  67040. * Gets or sets the light associated with this block
  67041. */
  67042. light: Nullable<Light>;
  67043. /**
  67044. * Creates a new LightInformationBlock
  67045. * @param name defines the block name
  67046. */
  67047. constructor(name: string);
  67048. /**
  67049. * Gets the current class name
  67050. * @returns the class name
  67051. */
  67052. getClassName(): string;
  67053. /**
  67054. * Gets the world position input component
  67055. */
  67056. get worldPosition(): NodeMaterialConnectionPoint;
  67057. /**
  67058. * Gets the direction output component
  67059. */
  67060. get direction(): NodeMaterialConnectionPoint;
  67061. /**
  67062. * Gets the direction output component
  67063. */
  67064. get color(): NodeMaterialConnectionPoint;
  67065. /**
  67066. * Gets the direction output component
  67067. */
  67068. get intensity(): NodeMaterialConnectionPoint;
  67069. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67070. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67071. protected _buildBlock(state: NodeMaterialBuildState): this;
  67072. serialize(): any;
  67073. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67074. }
  67075. }
  67076. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  67077. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  67078. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  67079. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  67080. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  67081. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  67082. }
  67083. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  67084. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67085. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67086. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67088. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67089. import { Effect } from "babylonjs/Materials/effect";
  67090. import { Mesh } from "babylonjs/Meshes/mesh";
  67091. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67092. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  67093. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  67094. /**
  67095. * Block used to add image processing support to fragment shader
  67096. */
  67097. export class ImageProcessingBlock extends NodeMaterialBlock {
  67098. /**
  67099. * Create a new ImageProcessingBlock
  67100. * @param name defines the block name
  67101. */
  67102. constructor(name: string);
  67103. /**
  67104. * Gets the current class name
  67105. * @returns the class name
  67106. */
  67107. getClassName(): string;
  67108. /**
  67109. * Gets the color input component
  67110. */
  67111. get color(): NodeMaterialConnectionPoint;
  67112. /**
  67113. * Gets the output component
  67114. */
  67115. get output(): NodeMaterialConnectionPoint;
  67116. /**
  67117. * Initialize the block and prepare the context for build
  67118. * @param state defines the state that will be used for the build
  67119. */
  67120. initialize(state: NodeMaterialBuildState): void;
  67121. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  67122. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67123. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67124. protected _buildBlock(state: NodeMaterialBuildState): this;
  67125. }
  67126. }
  67127. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  67128. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67129. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67130. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67131. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67133. import { Effect } from "babylonjs/Materials/effect";
  67134. import { Mesh } from "babylonjs/Meshes/mesh";
  67135. import { Scene } from "babylonjs/scene";
  67136. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  67137. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67138. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67139. /**
  67140. * Block used to pertub normals based on a normal map
  67141. */
  67142. export class PerturbNormalBlock extends NodeMaterialBlock {
  67143. private _tangentSpaceParameterName;
  67144. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67145. invertX: boolean;
  67146. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  67147. invertY: boolean;
  67148. /**
  67149. * Create a new PerturbNormalBlock
  67150. * @param name defines the block name
  67151. */
  67152. constructor(name: string);
  67153. /**
  67154. * Gets the current class name
  67155. * @returns the class name
  67156. */
  67157. getClassName(): string;
  67158. /**
  67159. * Gets the world position input component
  67160. */
  67161. get worldPosition(): NodeMaterialConnectionPoint;
  67162. /**
  67163. * Gets the world normal input component
  67164. */
  67165. get worldNormal(): NodeMaterialConnectionPoint;
  67166. /**
  67167. * Gets the world tangent input component
  67168. */
  67169. get worldTangent(): NodeMaterialConnectionPoint;
  67170. /**
  67171. * Gets the uv input component
  67172. */
  67173. get uv(): NodeMaterialConnectionPoint;
  67174. /**
  67175. * Gets the normal map color input component
  67176. */
  67177. get normalMapColor(): NodeMaterialConnectionPoint;
  67178. /**
  67179. * Gets the strength input component
  67180. */
  67181. get strength(): NodeMaterialConnectionPoint;
  67182. /**
  67183. * Gets the output component
  67184. */
  67185. get output(): NodeMaterialConnectionPoint;
  67186. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67187. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67188. autoConfigure(material: NodeMaterial): void;
  67189. protected _buildBlock(state: NodeMaterialBuildState): this;
  67190. protected _dumpPropertiesCode(): string;
  67191. serialize(): any;
  67192. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67193. }
  67194. }
  67195. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  67196. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67197. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67198. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67199. /**
  67200. * Block used to discard a pixel if a value is smaller than a cutoff
  67201. */
  67202. export class DiscardBlock extends NodeMaterialBlock {
  67203. /**
  67204. * Create a new DiscardBlock
  67205. * @param name defines the block name
  67206. */
  67207. constructor(name: string);
  67208. /**
  67209. * Gets the current class name
  67210. * @returns the class name
  67211. */
  67212. getClassName(): string;
  67213. /**
  67214. * Gets the color input component
  67215. */
  67216. get value(): NodeMaterialConnectionPoint;
  67217. /**
  67218. * Gets the cutoff input component
  67219. */
  67220. get cutoff(): NodeMaterialConnectionPoint;
  67221. protected _buildBlock(state: NodeMaterialBuildState): this;
  67222. }
  67223. }
  67224. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  67225. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67226. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67227. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67228. /**
  67229. * Block used to test if the fragment shader is front facing
  67230. */
  67231. export class FrontFacingBlock extends NodeMaterialBlock {
  67232. /**
  67233. * Creates a new FrontFacingBlock
  67234. * @param name defines the block name
  67235. */
  67236. constructor(name: string);
  67237. /**
  67238. * Gets the current class name
  67239. * @returns the class name
  67240. */
  67241. getClassName(): string;
  67242. /**
  67243. * Gets the output component
  67244. */
  67245. get output(): NodeMaterialConnectionPoint;
  67246. protected _buildBlock(state: NodeMaterialBuildState): this;
  67247. }
  67248. }
  67249. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  67250. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67251. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67252. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67253. /**
  67254. * Block used to get the derivative value on x and y of a given input
  67255. */
  67256. export class DerivativeBlock extends NodeMaterialBlock {
  67257. /**
  67258. * Create a new DerivativeBlock
  67259. * @param name defines the block name
  67260. */
  67261. constructor(name: string);
  67262. /**
  67263. * Gets the current class name
  67264. * @returns the class name
  67265. */
  67266. getClassName(): string;
  67267. /**
  67268. * Gets the input component
  67269. */
  67270. get input(): NodeMaterialConnectionPoint;
  67271. /**
  67272. * Gets the derivative output on x
  67273. */
  67274. get dx(): NodeMaterialConnectionPoint;
  67275. /**
  67276. * Gets the derivative output on y
  67277. */
  67278. get dy(): NodeMaterialConnectionPoint;
  67279. protected _buildBlock(state: NodeMaterialBuildState): this;
  67280. }
  67281. }
  67282. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  67283. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67284. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67285. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67286. /**
  67287. * Block used to make gl_FragCoord available
  67288. */
  67289. export class FragCoordBlock extends NodeMaterialBlock {
  67290. /**
  67291. * Creates a new FragCoordBlock
  67292. * @param name defines the block name
  67293. */
  67294. constructor(name: string);
  67295. /**
  67296. * Gets the current class name
  67297. * @returns the class name
  67298. */
  67299. getClassName(): string;
  67300. /**
  67301. * Gets the xy component
  67302. */
  67303. get xy(): NodeMaterialConnectionPoint;
  67304. /**
  67305. * Gets the xyz component
  67306. */
  67307. get xyz(): NodeMaterialConnectionPoint;
  67308. /**
  67309. * Gets the xyzw component
  67310. */
  67311. get xyzw(): NodeMaterialConnectionPoint;
  67312. /**
  67313. * Gets the x component
  67314. */
  67315. get x(): NodeMaterialConnectionPoint;
  67316. /**
  67317. * Gets the y component
  67318. */
  67319. get y(): NodeMaterialConnectionPoint;
  67320. /**
  67321. * Gets the z component
  67322. */
  67323. get z(): NodeMaterialConnectionPoint;
  67324. /**
  67325. * Gets the w component
  67326. */
  67327. get output(): NodeMaterialConnectionPoint;
  67328. protected writeOutputs(state: NodeMaterialBuildState): string;
  67329. protected _buildBlock(state: NodeMaterialBuildState): this;
  67330. }
  67331. }
  67332. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  67333. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67334. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67335. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67336. import { Effect } from "babylonjs/Materials/effect";
  67337. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67338. import { Mesh } from "babylonjs/Meshes/mesh";
  67339. /**
  67340. * Block used to get the screen sizes
  67341. */
  67342. export class ScreenSizeBlock extends NodeMaterialBlock {
  67343. private _varName;
  67344. private _scene;
  67345. /**
  67346. * Creates a new ScreenSizeBlock
  67347. * @param name defines the block name
  67348. */
  67349. constructor(name: string);
  67350. /**
  67351. * Gets the current class name
  67352. * @returns the class name
  67353. */
  67354. getClassName(): string;
  67355. /**
  67356. * Gets the xy component
  67357. */
  67358. get xy(): NodeMaterialConnectionPoint;
  67359. /**
  67360. * Gets the x component
  67361. */
  67362. get x(): NodeMaterialConnectionPoint;
  67363. /**
  67364. * Gets the y component
  67365. */
  67366. get y(): NodeMaterialConnectionPoint;
  67367. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67368. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  67369. protected _buildBlock(state: NodeMaterialBuildState): this;
  67370. }
  67371. }
  67372. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  67373. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  67374. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  67375. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  67376. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  67377. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  67378. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  67379. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  67380. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  67381. }
  67382. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  67383. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67384. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67385. import { Mesh } from "babylonjs/Meshes/mesh";
  67386. import { Effect } from "babylonjs/Materials/effect";
  67387. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67389. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67390. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  67391. /**
  67392. * Block used to add support for scene fog
  67393. */
  67394. export class FogBlock extends NodeMaterialBlock {
  67395. private _fogDistanceName;
  67396. private _fogParameters;
  67397. /**
  67398. * Create a new FogBlock
  67399. * @param name defines the block name
  67400. */
  67401. constructor(name: string);
  67402. /**
  67403. * Gets the current class name
  67404. * @returns the class name
  67405. */
  67406. getClassName(): string;
  67407. /**
  67408. * Gets the world position input component
  67409. */
  67410. get worldPosition(): NodeMaterialConnectionPoint;
  67411. /**
  67412. * Gets the view input component
  67413. */
  67414. get view(): NodeMaterialConnectionPoint;
  67415. /**
  67416. * Gets the color input component
  67417. */
  67418. get input(): NodeMaterialConnectionPoint;
  67419. /**
  67420. * Gets the fog color input component
  67421. */
  67422. get fogColor(): NodeMaterialConnectionPoint;
  67423. /**
  67424. * Gets the output component
  67425. */
  67426. get output(): NodeMaterialConnectionPoint;
  67427. autoConfigure(material: NodeMaterial): void;
  67428. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67429. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67430. protected _buildBlock(state: NodeMaterialBuildState): this;
  67431. }
  67432. }
  67433. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  67434. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67435. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67436. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67438. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67439. import { Effect } from "babylonjs/Materials/effect";
  67440. import { Mesh } from "babylonjs/Meshes/mesh";
  67441. import { Light } from "babylonjs/Lights/light";
  67442. import { Nullable } from "babylonjs/types";
  67443. import { Scene } from "babylonjs/scene";
  67444. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  67445. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  67446. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  67447. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67448. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  67449. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  67450. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  67451. /**
  67452. * Block used to add light in the fragment shader
  67453. */
  67454. export class LightBlock extends NodeMaterialBlock {
  67455. private _lightId;
  67456. /**
  67457. * Gets or sets the light associated with this block
  67458. */
  67459. light: Nullable<Light>;
  67460. /**
  67461. * Create a new LightBlock
  67462. * @param name defines the block name
  67463. */
  67464. constructor(name: string);
  67465. /**
  67466. * Gets the current class name
  67467. * @returns the class name
  67468. */
  67469. getClassName(): string;
  67470. /**
  67471. * Gets the world position input component
  67472. */
  67473. get worldPosition(): NodeMaterialConnectionPoint;
  67474. /**
  67475. * Gets the world normal input component
  67476. */
  67477. get worldNormal(): NodeMaterialConnectionPoint;
  67478. /**
  67479. * Gets the camera (or eye) position component
  67480. */
  67481. get cameraPosition(): NodeMaterialConnectionPoint;
  67482. /**
  67483. * Gets the glossiness component
  67484. */
  67485. get glossiness(): NodeMaterialConnectionPoint;
  67486. /**
  67487. * Gets the glossinness power component
  67488. */
  67489. get glossPower(): NodeMaterialConnectionPoint;
  67490. /**
  67491. * Gets the diffuse color component
  67492. */
  67493. get diffuseColor(): NodeMaterialConnectionPoint;
  67494. /**
  67495. * Gets the specular color component
  67496. */
  67497. get specularColor(): NodeMaterialConnectionPoint;
  67498. /**
  67499. * Gets the view matrix component
  67500. */
  67501. get view(): NodeMaterialConnectionPoint;
  67502. /**
  67503. * Gets the diffuse output component
  67504. */
  67505. get diffuseOutput(): NodeMaterialConnectionPoint;
  67506. /**
  67507. * Gets the specular output component
  67508. */
  67509. get specularOutput(): NodeMaterialConnectionPoint;
  67510. /**
  67511. * Gets the shadow output component
  67512. */
  67513. get shadow(): NodeMaterialConnectionPoint;
  67514. autoConfigure(material: NodeMaterial): void;
  67515. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67516. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67517. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67518. private _injectVertexCode;
  67519. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67520. serialize(): any;
  67521. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67522. }
  67523. }
  67524. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  67525. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67526. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67527. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67528. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67529. /**
  67530. * Block used to read a reflection texture from a sampler
  67531. */
  67532. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67533. /**
  67534. * Create a new ReflectionTextureBlock
  67535. * @param name defines the block name
  67536. */
  67537. constructor(name: string);
  67538. /**
  67539. * Gets the current class name
  67540. * @returns the class name
  67541. */
  67542. getClassName(): string;
  67543. /**
  67544. * Gets the world position input component
  67545. */
  67546. get position(): NodeMaterialConnectionPoint;
  67547. /**
  67548. * Gets the world position input component
  67549. */
  67550. get worldPosition(): NodeMaterialConnectionPoint;
  67551. /**
  67552. * Gets the world normal input component
  67553. */
  67554. get worldNormal(): NodeMaterialConnectionPoint;
  67555. /**
  67556. * Gets the world input component
  67557. */
  67558. get world(): NodeMaterialConnectionPoint;
  67559. /**
  67560. * Gets the camera (or eye) position component
  67561. */
  67562. get cameraPosition(): NodeMaterialConnectionPoint;
  67563. /**
  67564. * Gets the view input component
  67565. */
  67566. get view(): NodeMaterialConnectionPoint;
  67567. /**
  67568. * Gets the rgb output component
  67569. */
  67570. get rgb(): NodeMaterialConnectionPoint;
  67571. /**
  67572. * Gets the rgba output component
  67573. */
  67574. get rgba(): NodeMaterialConnectionPoint;
  67575. /**
  67576. * Gets the r output component
  67577. */
  67578. get r(): NodeMaterialConnectionPoint;
  67579. /**
  67580. * Gets the g output component
  67581. */
  67582. get g(): NodeMaterialConnectionPoint;
  67583. /**
  67584. * Gets the b output component
  67585. */
  67586. get b(): NodeMaterialConnectionPoint;
  67587. /**
  67588. * Gets the a output component
  67589. */
  67590. get a(): NodeMaterialConnectionPoint;
  67591. autoConfigure(material: NodeMaterial): void;
  67592. protected _buildBlock(state: NodeMaterialBuildState): this;
  67593. }
  67594. }
  67595. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  67596. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  67597. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  67598. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  67599. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  67600. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  67601. }
  67602. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  67603. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  67604. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  67605. }
  67606. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  67607. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67608. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67609. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67610. /**
  67611. * Block used to add 2 vectors
  67612. */
  67613. export class AddBlock extends NodeMaterialBlock {
  67614. /**
  67615. * Creates a new AddBlock
  67616. * @param name defines the block name
  67617. */
  67618. constructor(name: string);
  67619. /**
  67620. * Gets the current class name
  67621. * @returns the class name
  67622. */
  67623. getClassName(): string;
  67624. /**
  67625. * Gets the left operand input component
  67626. */
  67627. get left(): NodeMaterialConnectionPoint;
  67628. /**
  67629. * Gets the right operand input component
  67630. */
  67631. get right(): NodeMaterialConnectionPoint;
  67632. /**
  67633. * Gets the output component
  67634. */
  67635. get output(): NodeMaterialConnectionPoint;
  67636. protected _buildBlock(state: NodeMaterialBuildState): this;
  67637. }
  67638. }
  67639. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  67640. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67641. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67642. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67643. /**
  67644. * Block used to scale a vector by a float
  67645. */
  67646. export class ScaleBlock extends NodeMaterialBlock {
  67647. /**
  67648. * Creates a new ScaleBlock
  67649. * @param name defines the block name
  67650. */
  67651. constructor(name: string);
  67652. /**
  67653. * Gets the current class name
  67654. * @returns the class name
  67655. */
  67656. getClassName(): string;
  67657. /**
  67658. * Gets the input component
  67659. */
  67660. get input(): NodeMaterialConnectionPoint;
  67661. /**
  67662. * Gets the factor input component
  67663. */
  67664. get factor(): NodeMaterialConnectionPoint;
  67665. /**
  67666. * Gets the output component
  67667. */
  67668. get output(): NodeMaterialConnectionPoint;
  67669. protected _buildBlock(state: NodeMaterialBuildState): this;
  67670. }
  67671. }
  67672. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  67673. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67674. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67675. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67676. import { Scene } from "babylonjs/scene";
  67677. /**
  67678. * Block used to clamp a float
  67679. */
  67680. export class ClampBlock extends NodeMaterialBlock {
  67681. /** Gets or sets the minimum range */
  67682. minimum: number;
  67683. /** Gets or sets the maximum range */
  67684. maximum: number;
  67685. /**
  67686. * Creates a new ClampBlock
  67687. * @param name defines the block name
  67688. */
  67689. constructor(name: string);
  67690. /**
  67691. * Gets the current class name
  67692. * @returns the class name
  67693. */
  67694. getClassName(): string;
  67695. /**
  67696. * Gets the value input component
  67697. */
  67698. get value(): NodeMaterialConnectionPoint;
  67699. /**
  67700. * Gets the output component
  67701. */
  67702. get output(): NodeMaterialConnectionPoint;
  67703. protected _buildBlock(state: NodeMaterialBuildState): this;
  67704. protected _dumpPropertiesCode(): string;
  67705. serialize(): any;
  67706. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67707. }
  67708. }
  67709. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  67710. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67711. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67712. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67713. /**
  67714. * Block used to apply a cross product between 2 vectors
  67715. */
  67716. export class CrossBlock extends NodeMaterialBlock {
  67717. /**
  67718. * Creates a new CrossBlock
  67719. * @param name defines the block name
  67720. */
  67721. constructor(name: string);
  67722. /**
  67723. * Gets the current class name
  67724. * @returns the class name
  67725. */
  67726. getClassName(): string;
  67727. /**
  67728. * Gets the left operand input component
  67729. */
  67730. get left(): NodeMaterialConnectionPoint;
  67731. /**
  67732. * Gets the right operand input component
  67733. */
  67734. get right(): NodeMaterialConnectionPoint;
  67735. /**
  67736. * Gets the output component
  67737. */
  67738. get output(): NodeMaterialConnectionPoint;
  67739. protected _buildBlock(state: NodeMaterialBuildState): this;
  67740. }
  67741. }
  67742. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  67743. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67744. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67745. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67746. /**
  67747. * Block used to apply a dot product between 2 vectors
  67748. */
  67749. export class DotBlock extends NodeMaterialBlock {
  67750. /**
  67751. * Creates a new DotBlock
  67752. * @param name defines the block name
  67753. */
  67754. constructor(name: string);
  67755. /**
  67756. * Gets the current class name
  67757. * @returns the class name
  67758. */
  67759. getClassName(): string;
  67760. /**
  67761. * Gets the left operand input component
  67762. */
  67763. get left(): NodeMaterialConnectionPoint;
  67764. /**
  67765. * Gets the right operand input component
  67766. */
  67767. get right(): NodeMaterialConnectionPoint;
  67768. /**
  67769. * Gets the output component
  67770. */
  67771. get output(): NodeMaterialConnectionPoint;
  67772. protected _buildBlock(state: NodeMaterialBuildState): this;
  67773. }
  67774. }
  67775. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  67776. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67777. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67778. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67779. /**
  67780. * Block used to normalize a vector
  67781. */
  67782. export class NormalizeBlock extends NodeMaterialBlock {
  67783. /**
  67784. * Creates a new NormalizeBlock
  67785. * @param name defines the block name
  67786. */
  67787. constructor(name: string);
  67788. /**
  67789. * Gets the current class name
  67790. * @returns the class name
  67791. */
  67792. getClassName(): string;
  67793. /**
  67794. * Gets the input component
  67795. */
  67796. get input(): NodeMaterialConnectionPoint;
  67797. /**
  67798. * Gets the output component
  67799. */
  67800. get output(): NodeMaterialConnectionPoint;
  67801. protected _buildBlock(state: NodeMaterialBuildState): this;
  67802. }
  67803. }
  67804. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  67805. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67806. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67807. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67808. /**
  67809. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67810. */
  67811. export class ColorMergerBlock extends NodeMaterialBlock {
  67812. /**
  67813. * Create a new ColorMergerBlock
  67814. * @param name defines the block name
  67815. */
  67816. constructor(name: string);
  67817. /**
  67818. * Gets the current class name
  67819. * @returns the class name
  67820. */
  67821. getClassName(): string;
  67822. /**
  67823. * Gets the rgb component (input)
  67824. */
  67825. get rgbIn(): NodeMaterialConnectionPoint;
  67826. /**
  67827. * Gets the r component (input)
  67828. */
  67829. get r(): NodeMaterialConnectionPoint;
  67830. /**
  67831. * Gets the g component (input)
  67832. */
  67833. get g(): NodeMaterialConnectionPoint;
  67834. /**
  67835. * Gets the b component (input)
  67836. */
  67837. get b(): NodeMaterialConnectionPoint;
  67838. /**
  67839. * Gets the a component (input)
  67840. */
  67841. get a(): NodeMaterialConnectionPoint;
  67842. /**
  67843. * Gets the rgba component (output)
  67844. */
  67845. get rgba(): NodeMaterialConnectionPoint;
  67846. /**
  67847. * Gets the rgb component (output)
  67848. */
  67849. get rgbOut(): NodeMaterialConnectionPoint;
  67850. /**
  67851. * Gets the rgb component (output)
  67852. * @deprecated Please use rgbOut instead.
  67853. */
  67854. get rgb(): NodeMaterialConnectionPoint;
  67855. protected _buildBlock(state: NodeMaterialBuildState): this;
  67856. }
  67857. }
  67858. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  67859. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67860. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67861. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67862. /**
  67863. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67864. */
  67865. export class VectorSplitterBlock extends NodeMaterialBlock {
  67866. /**
  67867. * Create a new VectorSplitterBlock
  67868. * @param name defines the block name
  67869. */
  67870. constructor(name: string);
  67871. /**
  67872. * Gets the current class name
  67873. * @returns the class name
  67874. */
  67875. getClassName(): string;
  67876. /**
  67877. * Gets the xyzw component (input)
  67878. */
  67879. get xyzw(): NodeMaterialConnectionPoint;
  67880. /**
  67881. * Gets the xyz component (input)
  67882. */
  67883. get xyzIn(): NodeMaterialConnectionPoint;
  67884. /**
  67885. * Gets the xy component (input)
  67886. */
  67887. get xyIn(): NodeMaterialConnectionPoint;
  67888. /**
  67889. * Gets the xyz component (output)
  67890. */
  67891. get xyzOut(): NodeMaterialConnectionPoint;
  67892. /**
  67893. * Gets the xy component (output)
  67894. */
  67895. get xyOut(): NodeMaterialConnectionPoint;
  67896. /**
  67897. * Gets the x component (output)
  67898. */
  67899. get x(): NodeMaterialConnectionPoint;
  67900. /**
  67901. * Gets the y component (output)
  67902. */
  67903. get y(): NodeMaterialConnectionPoint;
  67904. /**
  67905. * Gets the z component (output)
  67906. */
  67907. get z(): NodeMaterialConnectionPoint;
  67908. /**
  67909. * Gets the w component (output)
  67910. */
  67911. get w(): NodeMaterialConnectionPoint;
  67912. protected _inputRename(name: string): string;
  67913. protected _outputRename(name: string): string;
  67914. protected _buildBlock(state: NodeMaterialBuildState): this;
  67915. }
  67916. }
  67917. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  67918. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67919. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67920. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67921. /**
  67922. * Block used to lerp between 2 values
  67923. */
  67924. export class LerpBlock extends NodeMaterialBlock {
  67925. /**
  67926. * Creates a new LerpBlock
  67927. * @param name defines the block name
  67928. */
  67929. constructor(name: string);
  67930. /**
  67931. * Gets the current class name
  67932. * @returns the class name
  67933. */
  67934. getClassName(): string;
  67935. /**
  67936. * Gets the left operand input component
  67937. */
  67938. get left(): NodeMaterialConnectionPoint;
  67939. /**
  67940. * Gets the right operand input component
  67941. */
  67942. get right(): NodeMaterialConnectionPoint;
  67943. /**
  67944. * Gets the gradient operand input component
  67945. */
  67946. get gradient(): NodeMaterialConnectionPoint;
  67947. /**
  67948. * Gets the output component
  67949. */
  67950. get output(): NodeMaterialConnectionPoint;
  67951. protected _buildBlock(state: NodeMaterialBuildState): this;
  67952. }
  67953. }
  67954. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  67955. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67956. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67957. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67958. /**
  67959. * Block used to divide 2 vectors
  67960. */
  67961. export class DivideBlock extends NodeMaterialBlock {
  67962. /**
  67963. * Creates a new DivideBlock
  67964. * @param name defines the block name
  67965. */
  67966. constructor(name: string);
  67967. /**
  67968. * Gets the current class name
  67969. * @returns the class name
  67970. */
  67971. getClassName(): string;
  67972. /**
  67973. * Gets the left operand input component
  67974. */
  67975. get left(): NodeMaterialConnectionPoint;
  67976. /**
  67977. * Gets the right operand input component
  67978. */
  67979. get right(): NodeMaterialConnectionPoint;
  67980. /**
  67981. * Gets the output component
  67982. */
  67983. get output(): NodeMaterialConnectionPoint;
  67984. protected _buildBlock(state: NodeMaterialBuildState): this;
  67985. }
  67986. }
  67987. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  67988. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67989. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67990. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67991. /**
  67992. * Block used to subtract 2 vectors
  67993. */
  67994. export class SubtractBlock extends NodeMaterialBlock {
  67995. /**
  67996. * Creates a new SubtractBlock
  67997. * @param name defines the block name
  67998. */
  67999. constructor(name: string);
  68000. /**
  68001. * Gets the current class name
  68002. * @returns the class name
  68003. */
  68004. getClassName(): string;
  68005. /**
  68006. * Gets the left operand input component
  68007. */
  68008. get left(): NodeMaterialConnectionPoint;
  68009. /**
  68010. * Gets the right operand input component
  68011. */
  68012. get right(): NodeMaterialConnectionPoint;
  68013. /**
  68014. * Gets the output component
  68015. */
  68016. get output(): NodeMaterialConnectionPoint;
  68017. protected _buildBlock(state: NodeMaterialBuildState): this;
  68018. }
  68019. }
  68020. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  68021. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68022. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68023. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68024. /**
  68025. * Block used to step a value
  68026. */
  68027. export class StepBlock extends NodeMaterialBlock {
  68028. /**
  68029. * Creates a new StepBlock
  68030. * @param name defines the block name
  68031. */
  68032. constructor(name: string);
  68033. /**
  68034. * Gets the current class name
  68035. * @returns the class name
  68036. */
  68037. getClassName(): string;
  68038. /**
  68039. * Gets the value operand input component
  68040. */
  68041. get value(): NodeMaterialConnectionPoint;
  68042. /**
  68043. * Gets the edge operand input component
  68044. */
  68045. get edge(): NodeMaterialConnectionPoint;
  68046. /**
  68047. * Gets the output component
  68048. */
  68049. get output(): NodeMaterialConnectionPoint;
  68050. protected _buildBlock(state: NodeMaterialBuildState): this;
  68051. }
  68052. }
  68053. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  68054. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68055. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68056. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68057. /**
  68058. * Block used to get the opposite (1 - x) of a value
  68059. */
  68060. export class OneMinusBlock extends NodeMaterialBlock {
  68061. /**
  68062. * Creates a new OneMinusBlock
  68063. * @param name defines the block name
  68064. */
  68065. constructor(name: string);
  68066. /**
  68067. * Gets the current class name
  68068. * @returns the class name
  68069. */
  68070. getClassName(): string;
  68071. /**
  68072. * Gets the input component
  68073. */
  68074. get input(): NodeMaterialConnectionPoint;
  68075. /**
  68076. * Gets the output component
  68077. */
  68078. get output(): NodeMaterialConnectionPoint;
  68079. protected _buildBlock(state: NodeMaterialBuildState): this;
  68080. }
  68081. }
  68082. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  68083. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68084. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68085. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68086. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68087. /**
  68088. * Block used to get the view direction
  68089. */
  68090. export class ViewDirectionBlock extends NodeMaterialBlock {
  68091. /**
  68092. * Creates a new ViewDirectionBlock
  68093. * @param name defines the block name
  68094. */
  68095. constructor(name: string);
  68096. /**
  68097. * Gets the current class name
  68098. * @returns the class name
  68099. */
  68100. getClassName(): string;
  68101. /**
  68102. * Gets the world position component
  68103. */
  68104. get worldPosition(): NodeMaterialConnectionPoint;
  68105. /**
  68106. * Gets the camera position component
  68107. */
  68108. get cameraPosition(): NodeMaterialConnectionPoint;
  68109. /**
  68110. * Gets the output component
  68111. */
  68112. get output(): NodeMaterialConnectionPoint;
  68113. autoConfigure(material: NodeMaterial): void;
  68114. protected _buildBlock(state: NodeMaterialBuildState): this;
  68115. }
  68116. }
  68117. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  68118. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68119. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68120. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68121. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68122. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  68123. /**
  68124. * Block used to compute fresnel value
  68125. */
  68126. export class FresnelBlock extends NodeMaterialBlock {
  68127. /**
  68128. * Create a new FresnelBlock
  68129. * @param name defines the block name
  68130. */
  68131. constructor(name: string);
  68132. /**
  68133. * Gets the current class name
  68134. * @returns the class name
  68135. */
  68136. getClassName(): string;
  68137. /**
  68138. * Gets the world normal input component
  68139. */
  68140. get worldNormal(): NodeMaterialConnectionPoint;
  68141. /**
  68142. * Gets the view direction input component
  68143. */
  68144. get viewDirection(): NodeMaterialConnectionPoint;
  68145. /**
  68146. * Gets the bias input component
  68147. */
  68148. get bias(): NodeMaterialConnectionPoint;
  68149. /**
  68150. * Gets the camera (or eye) position component
  68151. */
  68152. get power(): NodeMaterialConnectionPoint;
  68153. /**
  68154. * Gets the fresnel output component
  68155. */
  68156. get fresnel(): NodeMaterialConnectionPoint;
  68157. autoConfigure(material: NodeMaterial): void;
  68158. protected _buildBlock(state: NodeMaterialBuildState): this;
  68159. }
  68160. }
  68161. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  68162. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68163. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68164. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68165. /**
  68166. * Block used to get the max of 2 values
  68167. */
  68168. export class MaxBlock extends NodeMaterialBlock {
  68169. /**
  68170. * Creates a new MaxBlock
  68171. * @param name defines the block name
  68172. */
  68173. constructor(name: string);
  68174. /**
  68175. * Gets the current class name
  68176. * @returns the class name
  68177. */
  68178. getClassName(): string;
  68179. /**
  68180. * Gets the left operand input component
  68181. */
  68182. get left(): NodeMaterialConnectionPoint;
  68183. /**
  68184. * Gets the right operand input component
  68185. */
  68186. get right(): NodeMaterialConnectionPoint;
  68187. /**
  68188. * Gets the output component
  68189. */
  68190. get output(): NodeMaterialConnectionPoint;
  68191. protected _buildBlock(state: NodeMaterialBuildState): this;
  68192. }
  68193. }
  68194. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  68195. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68196. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68197. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68198. /**
  68199. * Block used to get the min of 2 values
  68200. */
  68201. export class MinBlock extends NodeMaterialBlock {
  68202. /**
  68203. * Creates a new MinBlock
  68204. * @param name defines the block name
  68205. */
  68206. constructor(name: string);
  68207. /**
  68208. * Gets the current class name
  68209. * @returns the class name
  68210. */
  68211. getClassName(): string;
  68212. /**
  68213. * Gets the left operand input component
  68214. */
  68215. get left(): NodeMaterialConnectionPoint;
  68216. /**
  68217. * Gets the right operand input component
  68218. */
  68219. get right(): NodeMaterialConnectionPoint;
  68220. /**
  68221. * Gets the output component
  68222. */
  68223. get output(): NodeMaterialConnectionPoint;
  68224. protected _buildBlock(state: NodeMaterialBuildState): this;
  68225. }
  68226. }
  68227. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  68228. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68229. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68230. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68231. /**
  68232. * Block used to get the distance between 2 values
  68233. */
  68234. export class DistanceBlock extends NodeMaterialBlock {
  68235. /**
  68236. * Creates a new DistanceBlock
  68237. * @param name defines the block name
  68238. */
  68239. constructor(name: string);
  68240. /**
  68241. * Gets the current class name
  68242. * @returns the class name
  68243. */
  68244. getClassName(): string;
  68245. /**
  68246. * Gets the left operand input component
  68247. */
  68248. get left(): NodeMaterialConnectionPoint;
  68249. /**
  68250. * Gets the right operand input component
  68251. */
  68252. get right(): NodeMaterialConnectionPoint;
  68253. /**
  68254. * Gets the output component
  68255. */
  68256. get output(): NodeMaterialConnectionPoint;
  68257. protected _buildBlock(state: NodeMaterialBuildState): this;
  68258. }
  68259. }
  68260. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  68261. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68262. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68263. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68264. /**
  68265. * Block used to get the length of a vector
  68266. */
  68267. export class LengthBlock extends NodeMaterialBlock {
  68268. /**
  68269. * Creates a new LengthBlock
  68270. * @param name defines the block name
  68271. */
  68272. constructor(name: string);
  68273. /**
  68274. * Gets the current class name
  68275. * @returns the class name
  68276. */
  68277. getClassName(): string;
  68278. /**
  68279. * Gets the value input component
  68280. */
  68281. get value(): NodeMaterialConnectionPoint;
  68282. /**
  68283. * Gets the output component
  68284. */
  68285. get output(): NodeMaterialConnectionPoint;
  68286. protected _buildBlock(state: NodeMaterialBuildState): this;
  68287. }
  68288. }
  68289. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  68290. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68291. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68292. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68293. /**
  68294. * Block used to get negative version of a value (i.e. x * -1)
  68295. */
  68296. export class NegateBlock extends NodeMaterialBlock {
  68297. /**
  68298. * Creates a new NegateBlock
  68299. * @param name defines the block name
  68300. */
  68301. constructor(name: string);
  68302. /**
  68303. * Gets the current class name
  68304. * @returns the class name
  68305. */
  68306. getClassName(): string;
  68307. /**
  68308. * Gets the value input component
  68309. */
  68310. get value(): NodeMaterialConnectionPoint;
  68311. /**
  68312. * Gets the output component
  68313. */
  68314. get output(): NodeMaterialConnectionPoint;
  68315. protected _buildBlock(state: NodeMaterialBuildState): this;
  68316. }
  68317. }
  68318. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  68319. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68320. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68321. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68322. /**
  68323. * Block used to get the value of the first parameter raised to the power of the second
  68324. */
  68325. export class PowBlock extends NodeMaterialBlock {
  68326. /**
  68327. * Creates a new PowBlock
  68328. * @param name defines the block name
  68329. */
  68330. constructor(name: string);
  68331. /**
  68332. * Gets the current class name
  68333. * @returns the class name
  68334. */
  68335. getClassName(): string;
  68336. /**
  68337. * Gets the value operand input component
  68338. */
  68339. get value(): NodeMaterialConnectionPoint;
  68340. /**
  68341. * Gets the power operand input component
  68342. */
  68343. get power(): NodeMaterialConnectionPoint;
  68344. /**
  68345. * Gets the output component
  68346. */
  68347. get output(): NodeMaterialConnectionPoint;
  68348. protected _buildBlock(state: NodeMaterialBuildState): this;
  68349. }
  68350. }
  68351. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  68352. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68353. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68354. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68355. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68356. /**
  68357. * Block used to get a random number
  68358. */
  68359. export class RandomNumberBlock extends NodeMaterialBlock {
  68360. /**
  68361. * Creates a new RandomNumberBlock
  68362. * @param name defines the block name
  68363. */
  68364. constructor(name: string);
  68365. /**
  68366. * Gets the current class name
  68367. * @returns the class name
  68368. */
  68369. getClassName(): string;
  68370. /**
  68371. * Gets the seed input component
  68372. */
  68373. get seed(): NodeMaterialConnectionPoint;
  68374. /**
  68375. * Gets the output component
  68376. */
  68377. get output(): NodeMaterialConnectionPoint;
  68378. protected _buildBlock(state: NodeMaterialBuildState): this;
  68379. }
  68380. }
  68381. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  68382. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68383. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68384. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68385. /**
  68386. * Block used to compute arc tangent of 2 values
  68387. */
  68388. export class ArcTan2Block extends NodeMaterialBlock {
  68389. /**
  68390. * Creates a new ArcTan2Block
  68391. * @param name defines the block name
  68392. */
  68393. constructor(name: string);
  68394. /**
  68395. * Gets the current class name
  68396. * @returns the class name
  68397. */
  68398. getClassName(): string;
  68399. /**
  68400. * Gets the x operand input component
  68401. */
  68402. get x(): NodeMaterialConnectionPoint;
  68403. /**
  68404. * Gets the y operand input component
  68405. */
  68406. get y(): NodeMaterialConnectionPoint;
  68407. /**
  68408. * Gets the output component
  68409. */
  68410. get output(): NodeMaterialConnectionPoint;
  68411. protected _buildBlock(state: NodeMaterialBuildState): this;
  68412. }
  68413. }
  68414. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  68415. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68416. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68417. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68418. /**
  68419. * Block used to smooth step a value
  68420. */
  68421. export class SmoothStepBlock extends NodeMaterialBlock {
  68422. /**
  68423. * Creates a new SmoothStepBlock
  68424. * @param name defines the block name
  68425. */
  68426. constructor(name: string);
  68427. /**
  68428. * Gets the current class name
  68429. * @returns the class name
  68430. */
  68431. getClassName(): string;
  68432. /**
  68433. * Gets the value operand input component
  68434. */
  68435. get value(): NodeMaterialConnectionPoint;
  68436. /**
  68437. * Gets the first edge operand input component
  68438. */
  68439. get edge0(): NodeMaterialConnectionPoint;
  68440. /**
  68441. * Gets the second edge operand input component
  68442. */
  68443. get edge1(): NodeMaterialConnectionPoint;
  68444. /**
  68445. * Gets the output component
  68446. */
  68447. get output(): NodeMaterialConnectionPoint;
  68448. protected _buildBlock(state: NodeMaterialBuildState): this;
  68449. }
  68450. }
  68451. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  68452. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68453. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68454. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68455. /**
  68456. * Block used to get the reciprocal (1 / x) of a value
  68457. */
  68458. export class ReciprocalBlock extends NodeMaterialBlock {
  68459. /**
  68460. * Creates a new ReciprocalBlock
  68461. * @param name defines the block name
  68462. */
  68463. constructor(name: string);
  68464. /**
  68465. * Gets the current class name
  68466. * @returns the class name
  68467. */
  68468. getClassName(): string;
  68469. /**
  68470. * Gets the input component
  68471. */
  68472. get input(): NodeMaterialConnectionPoint;
  68473. /**
  68474. * Gets the output component
  68475. */
  68476. get output(): NodeMaterialConnectionPoint;
  68477. protected _buildBlock(state: NodeMaterialBuildState): this;
  68478. }
  68479. }
  68480. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  68481. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68482. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68483. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68484. /**
  68485. * Block used to replace a color by another one
  68486. */
  68487. export class ReplaceColorBlock extends NodeMaterialBlock {
  68488. /**
  68489. * Creates a new ReplaceColorBlock
  68490. * @param name defines the block name
  68491. */
  68492. constructor(name: string);
  68493. /**
  68494. * Gets the current class name
  68495. * @returns the class name
  68496. */
  68497. getClassName(): string;
  68498. /**
  68499. * Gets the value input component
  68500. */
  68501. get value(): NodeMaterialConnectionPoint;
  68502. /**
  68503. * Gets the reference input component
  68504. */
  68505. get reference(): NodeMaterialConnectionPoint;
  68506. /**
  68507. * Gets the distance input component
  68508. */
  68509. get distance(): NodeMaterialConnectionPoint;
  68510. /**
  68511. * Gets the replacement input component
  68512. */
  68513. get replacement(): NodeMaterialConnectionPoint;
  68514. /**
  68515. * Gets the output component
  68516. */
  68517. get output(): NodeMaterialConnectionPoint;
  68518. protected _buildBlock(state: NodeMaterialBuildState): this;
  68519. }
  68520. }
  68521. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  68522. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68523. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68524. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68525. /**
  68526. * Block used to posterize a value
  68527. * @see https://en.wikipedia.org/wiki/Posterization
  68528. */
  68529. export class PosterizeBlock extends NodeMaterialBlock {
  68530. /**
  68531. * Creates a new PosterizeBlock
  68532. * @param name defines the block name
  68533. */
  68534. constructor(name: string);
  68535. /**
  68536. * Gets the current class name
  68537. * @returns the class name
  68538. */
  68539. getClassName(): string;
  68540. /**
  68541. * Gets the value input component
  68542. */
  68543. get value(): NodeMaterialConnectionPoint;
  68544. /**
  68545. * Gets the steps input component
  68546. */
  68547. get steps(): NodeMaterialConnectionPoint;
  68548. /**
  68549. * Gets the output component
  68550. */
  68551. get output(): NodeMaterialConnectionPoint;
  68552. protected _buildBlock(state: NodeMaterialBuildState): this;
  68553. }
  68554. }
  68555. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  68556. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68557. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68558. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68559. import { Scene } from "babylonjs/scene";
  68560. /**
  68561. * Operations supported by the Wave block
  68562. */
  68563. export enum WaveBlockKind {
  68564. /** SawTooth */
  68565. SawTooth = 0,
  68566. /** Square */
  68567. Square = 1,
  68568. /** Triangle */
  68569. Triangle = 2
  68570. }
  68571. /**
  68572. * Block used to apply wave operation to floats
  68573. */
  68574. export class WaveBlock extends NodeMaterialBlock {
  68575. /**
  68576. * Gets or sets the kibnd of wave to be applied by the block
  68577. */
  68578. kind: WaveBlockKind;
  68579. /**
  68580. * Creates a new WaveBlock
  68581. * @param name defines the block name
  68582. */
  68583. constructor(name: string);
  68584. /**
  68585. * Gets the current class name
  68586. * @returns the class name
  68587. */
  68588. getClassName(): string;
  68589. /**
  68590. * Gets the input component
  68591. */
  68592. get input(): NodeMaterialConnectionPoint;
  68593. /**
  68594. * Gets the output component
  68595. */
  68596. get output(): NodeMaterialConnectionPoint;
  68597. protected _buildBlock(state: NodeMaterialBuildState): this;
  68598. serialize(): any;
  68599. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68600. }
  68601. }
  68602. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  68603. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68604. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68605. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68606. import { Color3 } from "babylonjs/Maths/math.color";
  68607. import { Scene } from "babylonjs/scene";
  68608. import { Observable } from "babylonjs/Misc/observable";
  68609. /**
  68610. * Class used to store a color step for the GradientBlock
  68611. */
  68612. export class GradientBlockColorStep {
  68613. private _step;
  68614. /**
  68615. * Gets value indicating which step this color is associated with (between 0 and 1)
  68616. */
  68617. get step(): number;
  68618. /**
  68619. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68620. */
  68621. set step(val: number);
  68622. private _color;
  68623. /**
  68624. * Gets the color associated with this step
  68625. */
  68626. get color(): Color3;
  68627. /**
  68628. * Sets the color associated with this step
  68629. */
  68630. set color(val: Color3);
  68631. /**
  68632. * Creates a new GradientBlockColorStep
  68633. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68634. * @param color defines the color associated with this step
  68635. */
  68636. constructor(step: number, color: Color3);
  68637. }
  68638. /**
  68639. * Block used to return a color from a gradient based on an input value between 0 and 1
  68640. */
  68641. export class GradientBlock extends NodeMaterialBlock {
  68642. /**
  68643. * Gets or sets the list of color steps
  68644. */
  68645. colorSteps: GradientBlockColorStep[];
  68646. /** Gets an observable raised when the value is changed */
  68647. onValueChangedObservable: Observable<GradientBlock>;
  68648. /** calls observable when the value is changed*/
  68649. colorStepsUpdated(): void;
  68650. /**
  68651. * Creates a new GradientBlock
  68652. * @param name defines the block name
  68653. */
  68654. constructor(name: string);
  68655. /**
  68656. * Gets the current class name
  68657. * @returns the class name
  68658. */
  68659. getClassName(): string;
  68660. /**
  68661. * Gets the gradient input component
  68662. */
  68663. get gradient(): NodeMaterialConnectionPoint;
  68664. /**
  68665. * Gets the output component
  68666. */
  68667. get output(): NodeMaterialConnectionPoint;
  68668. private _writeColorConstant;
  68669. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68670. serialize(): any;
  68671. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68672. protected _dumpPropertiesCode(): string;
  68673. }
  68674. }
  68675. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  68676. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68677. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68678. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68679. /**
  68680. * Block used to normalize lerp between 2 values
  68681. */
  68682. export class NLerpBlock extends NodeMaterialBlock {
  68683. /**
  68684. * Creates a new NLerpBlock
  68685. * @param name defines the block name
  68686. */
  68687. constructor(name: string);
  68688. /**
  68689. * Gets the current class name
  68690. * @returns the class name
  68691. */
  68692. getClassName(): string;
  68693. /**
  68694. * Gets the left operand input component
  68695. */
  68696. get left(): NodeMaterialConnectionPoint;
  68697. /**
  68698. * Gets the right operand input component
  68699. */
  68700. get right(): NodeMaterialConnectionPoint;
  68701. /**
  68702. * Gets the gradient operand input component
  68703. */
  68704. get gradient(): NodeMaterialConnectionPoint;
  68705. /**
  68706. * Gets the output component
  68707. */
  68708. get output(): NodeMaterialConnectionPoint;
  68709. protected _buildBlock(state: NodeMaterialBuildState): this;
  68710. }
  68711. }
  68712. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  68713. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68714. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68715. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68716. import { Scene } from "babylonjs/scene";
  68717. /**
  68718. * block used to Generate a Worley Noise 3D Noise Pattern
  68719. */
  68720. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68721. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68722. manhattanDistance: boolean;
  68723. /**
  68724. * Creates a new WorleyNoise3DBlock
  68725. * @param name defines the block name
  68726. */
  68727. constructor(name: string);
  68728. /**
  68729. * Gets the current class name
  68730. * @returns the class name
  68731. */
  68732. getClassName(): string;
  68733. /**
  68734. * Gets the seed input component
  68735. */
  68736. get seed(): NodeMaterialConnectionPoint;
  68737. /**
  68738. * Gets the jitter input component
  68739. */
  68740. get jitter(): NodeMaterialConnectionPoint;
  68741. /**
  68742. * Gets the output component
  68743. */
  68744. get output(): NodeMaterialConnectionPoint;
  68745. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68746. /**
  68747. * Exposes the properties to the UI?
  68748. */
  68749. protected _dumpPropertiesCode(): string;
  68750. /**
  68751. * Exposes the properties to the Seralize?
  68752. */
  68753. serialize(): any;
  68754. /**
  68755. * Exposes the properties to the deseralize?
  68756. */
  68757. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68758. }
  68759. }
  68760. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  68761. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68762. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68763. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68764. /**
  68765. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68766. */
  68767. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68768. /**
  68769. * Creates a new SimplexPerlin3DBlock
  68770. * @param name defines the block name
  68771. */
  68772. constructor(name: string);
  68773. /**
  68774. * Gets the current class name
  68775. * @returns the class name
  68776. */
  68777. getClassName(): string;
  68778. /**
  68779. * Gets the seed operand input component
  68780. */
  68781. get seed(): NodeMaterialConnectionPoint;
  68782. /**
  68783. * Gets the output component
  68784. */
  68785. get output(): NodeMaterialConnectionPoint;
  68786. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68787. }
  68788. }
  68789. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  68790. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68791. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68792. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68793. /**
  68794. * Block used to blend normals
  68795. */
  68796. export class NormalBlendBlock extends NodeMaterialBlock {
  68797. /**
  68798. * Creates a new NormalBlendBlock
  68799. * @param name defines the block name
  68800. */
  68801. constructor(name: string);
  68802. /**
  68803. * Gets the current class name
  68804. * @returns the class name
  68805. */
  68806. getClassName(): string;
  68807. /**
  68808. * Gets the first input component
  68809. */
  68810. get normalMap0(): NodeMaterialConnectionPoint;
  68811. /**
  68812. * Gets the second input component
  68813. */
  68814. get normalMap1(): NodeMaterialConnectionPoint;
  68815. /**
  68816. * Gets the output component
  68817. */
  68818. get output(): NodeMaterialConnectionPoint;
  68819. protected _buildBlock(state: NodeMaterialBuildState): this;
  68820. }
  68821. }
  68822. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  68823. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68824. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68825. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68826. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68827. /**
  68828. * Block used to rotate a 2d vector by a given angle
  68829. */
  68830. export class Rotate2dBlock extends NodeMaterialBlock {
  68831. /**
  68832. * Creates a new Rotate2dBlock
  68833. * @param name defines the block name
  68834. */
  68835. constructor(name: string);
  68836. /**
  68837. * Gets the current class name
  68838. * @returns the class name
  68839. */
  68840. getClassName(): string;
  68841. /**
  68842. * Gets the input vector
  68843. */
  68844. get input(): NodeMaterialConnectionPoint;
  68845. /**
  68846. * Gets the input angle
  68847. */
  68848. get angle(): NodeMaterialConnectionPoint;
  68849. /**
  68850. * Gets the output component
  68851. */
  68852. get output(): NodeMaterialConnectionPoint;
  68853. autoConfigure(material: NodeMaterial): void;
  68854. protected _buildBlock(state: NodeMaterialBuildState): this;
  68855. }
  68856. }
  68857. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  68858. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68859. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68860. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68861. /**
  68862. * Block used to get the reflected vector from a direction and a normal
  68863. */
  68864. export class ReflectBlock extends NodeMaterialBlock {
  68865. /**
  68866. * Creates a new ReflectBlock
  68867. * @param name defines the block name
  68868. */
  68869. constructor(name: string);
  68870. /**
  68871. * Gets the current class name
  68872. * @returns the class name
  68873. */
  68874. getClassName(): string;
  68875. /**
  68876. * Gets the incident component
  68877. */
  68878. get incident(): NodeMaterialConnectionPoint;
  68879. /**
  68880. * Gets the normal component
  68881. */
  68882. get normal(): NodeMaterialConnectionPoint;
  68883. /**
  68884. * Gets the output component
  68885. */
  68886. get output(): NodeMaterialConnectionPoint;
  68887. protected _buildBlock(state: NodeMaterialBuildState): this;
  68888. }
  68889. }
  68890. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  68891. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68892. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68893. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68894. /**
  68895. * Block used to get the refracted vector from a direction and a normal
  68896. */
  68897. export class RefractBlock extends NodeMaterialBlock {
  68898. /**
  68899. * Creates a new RefractBlock
  68900. * @param name defines the block name
  68901. */
  68902. constructor(name: string);
  68903. /**
  68904. * Gets the current class name
  68905. * @returns the class name
  68906. */
  68907. getClassName(): string;
  68908. /**
  68909. * Gets the incident component
  68910. */
  68911. get incident(): NodeMaterialConnectionPoint;
  68912. /**
  68913. * Gets the normal component
  68914. */
  68915. get normal(): NodeMaterialConnectionPoint;
  68916. /**
  68917. * Gets the index of refraction component
  68918. */
  68919. get ior(): NodeMaterialConnectionPoint;
  68920. /**
  68921. * Gets the output component
  68922. */
  68923. get output(): NodeMaterialConnectionPoint;
  68924. protected _buildBlock(state: NodeMaterialBuildState): this;
  68925. }
  68926. }
  68927. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  68928. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68929. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68930. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68931. /**
  68932. * Block used to desaturate a color
  68933. */
  68934. export class DesaturateBlock extends NodeMaterialBlock {
  68935. /**
  68936. * Creates a new DesaturateBlock
  68937. * @param name defines the block name
  68938. */
  68939. constructor(name: string);
  68940. /**
  68941. * Gets the current class name
  68942. * @returns the class name
  68943. */
  68944. getClassName(): string;
  68945. /**
  68946. * Gets the color operand input component
  68947. */
  68948. get color(): NodeMaterialConnectionPoint;
  68949. /**
  68950. * Gets the level operand input component
  68951. */
  68952. get level(): NodeMaterialConnectionPoint;
  68953. /**
  68954. * Gets the output component
  68955. */
  68956. get output(): NodeMaterialConnectionPoint;
  68957. protected _buildBlock(state: NodeMaterialBuildState): this;
  68958. }
  68959. }
  68960. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  68961. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68962. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68963. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68964. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  68965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68966. import { Nullable } from "babylonjs/types";
  68967. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68968. import { Mesh } from "babylonjs/Meshes/mesh";
  68969. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68970. import { Effect } from "babylonjs/Materials/effect";
  68971. import { Scene } from "babylonjs/scene";
  68972. /**
  68973. * Block used to implement the reflection module of the PBR material
  68974. */
  68975. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  68976. /** @hidden */
  68977. _defineLODReflectionAlpha: string;
  68978. /** @hidden */
  68979. _defineLinearSpecularReflection: string;
  68980. private _vEnvironmentIrradianceName;
  68981. /** @hidden */
  68982. _vReflectionMicrosurfaceInfosName: string;
  68983. /** @hidden */
  68984. _vReflectionInfosName: string;
  68985. /** @hidden */
  68986. _vReflectionFilteringInfoName: string;
  68987. private _scene;
  68988. /**
  68989. * The properties below are set by the main PBR block prior to calling methods of this class.
  68990. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68991. * It's less burden on the user side in the editor part.
  68992. */
  68993. /** @hidden */
  68994. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68995. /** @hidden */
  68996. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68997. /** @hidden */
  68998. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  68999. /** @hidden */
  69000. viewConnectionPoint: NodeMaterialConnectionPoint;
  69001. /**
  69002. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  69003. * diffuse part of the IBL.
  69004. */
  69005. useSphericalHarmonics: boolean;
  69006. /**
  69007. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  69008. */
  69009. forceIrradianceInFragment: boolean;
  69010. /**
  69011. * Create a new ReflectionBlock
  69012. * @param name defines the block name
  69013. */
  69014. constructor(name: string);
  69015. /**
  69016. * Gets the current class name
  69017. * @returns the class name
  69018. */
  69019. getClassName(): string;
  69020. /**
  69021. * Gets the position input component
  69022. */
  69023. get position(): NodeMaterialConnectionPoint;
  69024. /**
  69025. * Gets the world position input component
  69026. */
  69027. get worldPosition(): NodeMaterialConnectionPoint;
  69028. /**
  69029. * Gets the world normal input component
  69030. */
  69031. get worldNormal(): NodeMaterialConnectionPoint;
  69032. /**
  69033. * Gets the world input component
  69034. */
  69035. get world(): NodeMaterialConnectionPoint;
  69036. /**
  69037. * Gets the camera (or eye) position component
  69038. */
  69039. get cameraPosition(): NodeMaterialConnectionPoint;
  69040. /**
  69041. * Gets the view input component
  69042. */
  69043. get view(): NodeMaterialConnectionPoint;
  69044. /**
  69045. * Gets the color input component
  69046. */
  69047. get color(): NodeMaterialConnectionPoint;
  69048. /**
  69049. * Gets the reflection object output component
  69050. */
  69051. get reflection(): NodeMaterialConnectionPoint;
  69052. /**
  69053. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  69054. */
  69055. get hasTexture(): boolean;
  69056. /**
  69057. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  69058. */
  69059. get reflectionColor(): string;
  69060. protected _getTexture(): Nullable<BaseTexture>;
  69061. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69062. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69063. /**
  69064. * Gets the code to inject in the vertex shader
  69065. * @param state current state of the node material building
  69066. * @returns the shader code
  69067. */
  69068. handleVertexSide(state: NodeMaterialBuildState): string;
  69069. /**
  69070. * Gets the main code of the block (fragment side)
  69071. * @param state current state of the node material building
  69072. * @param normalVarName name of the existing variable corresponding to the normal
  69073. * @returns the shader code
  69074. */
  69075. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  69076. protected _buildBlock(state: NodeMaterialBuildState): this;
  69077. protected _dumpPropertiesCode(): string;
  69078. serialize(): any;
  69079. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69080. }
  69081. }
  69082. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  69083. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69084. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69085. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69086. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69088. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69089. import { Scene } from "babylonjs/scene";
  69090. import { Nullable } from "babylonjs/types";
  69091. /**
  69092. * Block used to implement the sheen module of the PBR material
  69093. */
  69094. export class SheenBlock extends NodeMaterialBlock {
  69095. /**
  69096. * Create a new SheenBlock
  69097. * @param name defines the block name
  69098. */
  69099. constructor(name: string);
  69100. /**
  69101. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  69102. * It allows the strength of the sheen effect to not depend on the base color of the material,
  69103. * making it easier to setup and tweak the effect
  69104. */
  69105. albedoScaling: boolean;
  69106. /**
  69107. * Defines if the sheen is linked to the sheen color.
  69108. */
  69109. linkSheenWithAlbedo: boolean;
  69110. /**
  69111. * Initialize the block and prepare the context for build
  69112. * @param state defines the state that will be used for the build
  69113. */
  69114. initialize(state: NodeMaterialBuildState): void;
  69115. /**
  69116. * Gets the current class name
  69117. * @returns the class name
  69118. */
  69119. getClassName(): string;
  69120. /**
  69121. * Gets the intensity input component
  69122. */
  69123. get intensity(): NodeMaterialConnectionPoint;
  69124. /**
  69125. * Gets the color input component
  69126. */
  69127. get color(): NodeMaterialConnectionPoint;
  69128. /**
  69129. * Gets the roughness input component
  69130. */
  69131. get roughness(): NodeMaterialConnectionPoint;
  69132. /**
  69133. * Gets the sheen object output component
  69134. */
  69135. get sheen(): NodeMaterialConnectionPoint;
  69136. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69137. /**
  69138. * Gets the main code of the block (fragment side)
  69139. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69140. * @returns the shader code
  69141. */
  69142. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  69143. protected _buildBlock(state: NodeMaterialBuildState): this;
  69144. protected _dumpPropertiesCode(): string;
  69145. serialize(): any;
  69146. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69147. }
  69148. }
  69149. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  69150. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69151. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69152. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69153. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69155. /**
  69156. * Block used to implement the anisotropy module of the PBR material
  69157. */
  69158. export class AnisotropyBlock extends NodeMaterialBlock {
  69159. /**
  69160. * The two properties below are set by the main PBR block prior to calling methods of this class.
  69161. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69162. * It's less burden on the user side in the editor part.
  69163. */
  69164. /** @hidden */
  69165. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69166. /** @hidden */
  69167. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69168. /**
  69169. * Create a new AnisotropyBlock
  69170. * @param name defines the block name
  69171. */
  69172. constructor(name: string);
  69173. /**
  69174. * Initialize the block and prepare the context for build
  69175. * @param state defines the state that will be used for the build
  69176. */
  69177. initialize(state: NodeMaterialBuildState): void;
  69178. /**
  69179. * Gets the current class name
  69180. * @returns the class name
  69181. */
  69182. getClassName(): string;
  69183. /**
  69184. * Gets the intensity input component
  69185. */
  69186. get intensity(): NodeMaterialConnectionPoint;
  69187. /**
  69188. * Gets the direction input component
  69189. */
  69190. get direction(): NodeMaterialConnectionPoint;
  69191. /**
  69192. * Gets the uv input component
  69193. */
  69194. get uv(): NodeMaterialConnectionPoint;
  69195. /**
  69196. * Gets the worldTangent input component
  69197. */
  69198. get worldTangent(): NodeMaterialConnectionPoint;
  69199. /**
  69200. * Gets the anisotropy object output component
  69201. */
  69202. get anisotropy(): NodeMaterialConnectionPoint;
  69203. private _generateTBNSpace;
  69204. /**
  69205. * Gets the main code of the block (fragment side)
  69206. * @param state current state of the node material building
  69207. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69208. * @returns the shader code
  69209. */
  69210. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  69211. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69212. protected _buildBlock(state: NodeMaterialBuildState): this;
  69213. }
  69214. }
  69215. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  69216. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69217. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69218. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69219. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69221. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69222. import { Scene } from "babylonjs/scene";
  69223. import { Nullable } from "babylonjs/types";
  69224. import { Mesh } from "babylonjs/Meshes/mesh";
  69225. import { SubMesh } from "babylonjs/Meshes/subMesh";
  69226. import { Effect } from "babylonjs/Materials/effect";
  69227. /**
  69228. * Block used to implement the clear coat module of the PBR material
  69229. */
  69230. export class ClearCoatBlock extends NodeMaterialBlock {
  69231. private _scene;
  69232. /**
  69233. * Create a new ClearCoatBlock
  69234. * @param name defines the block name
  69235. */
  69236. constructor(name: string);
  69237. /**
  69238. * Defines if the F0 value should be remapped to account for the interface change in the material.
  69239. */
  69240. remapF0OnInterfaceChange: boolean;
  69241. /**
  69242. * Initialize the block and prepare the context for build
  69243. * @param state defines the state that will be used for the build
  69244. */
  69245. initialize(state: NodeMaterialBuildState): void;
  69246. /**
  69247. * Gets the current class name
  69248. * @returns the class name
  69249. */
  69250. getClassName(): string;
  69251. /**
  69252. * Gets the intensity input component
  69253. */
  69254. get intensity(): NodeMaterialConnectionPoint;
  69255. /**
  69256. * Gets the roughness input component
  69257. */
  69258. get roughness(): NodeMaterialConnectionPoint;
  69259. /**
  69260. * Gets the ior input component
  69261. */
  69262. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69263. /**
  69264. * Gets the bump texture input component
  69265. */
  69266. get normalMapColor(): NodeMaterialConnectionPoint;
  69267. /**
  69268. * Gets the uv input component
  69269. */
  69270. get uv(): NodeMaterialConnectionPoint;
  69271. /**
  69272. * Gets the tint color input component
  69273. */
  69274. get tintColor(): NodeMaterialConnectionPoint;
  69275. /**
  69276. * Gets the tint "at distance" input component
  69277. */
  69278. get tintAtDistance(): NodeMaterialConnectionPoint;
  69279. /**
  69280. * Gets the tint thickness input component
  69281. */
  69282. get tintThickness(): NodeMaterialConnectionPoint;
  69283. /**
  69284. * Gets the world tangent input component
  69285. */
  69286. get worldTangent(): NodeMaterialConnectionPoint;
  69287. /**
  69288. * Gets the clear coat object output component
  69289. */
  69290. get clearcoat(): NodeMaterialConnectionPoint;
  69291. autoConfigure(material: NodeMaterial): void;
  69292. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69293. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69294. private _generateTBNSpace;
  69295. /**
  69296. * Gets the main code of the block (fragment side)
  69297. * @param state current state of the node material building
  69298. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  69299. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69300. * @param worldPosVarName name of the variable holding the world position
  69301. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69302. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  69303. * @param worldNormalVarName name of the variable holding the world normal
  69304. * @returns the shader code
  69305. */
  69306. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  69307. protected _buildBlock(state: NodeMaterialBuildState): this;
  69308. protected _dumpPropertiesCode(): string;
  69309. serialize(): any;
  69310. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69311. }
  69312. }
  69313. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  69314. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69315. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69316. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69317. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69319. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69320. import { Nullable } from "babylonjs/types";
  69321. /**
  69322. * Block used to implement the sub surface module of the PBR material
  69323. */
  69324. export class SubSurfaceBlock extends NodeMaterialBlock {
  69325. /**
  69326. * Create a new SubSurfaceBlock
  69327. * @param name defines the block name
  69328. */
  69329. constructor(name: string);
  69330. /**
  69331. * Initialize the block and prepare the context for build
  69332. * @param state defines the state that will be used for the build
  69333. */
  69334. initialize(state: NodeMaterialBuildState): void;
  69335. /**
  69336. * Gets the current class name
  69337. * @returns the class name
  69338. */
  69339. getClassName(): string;
  69340. /**
  69341. * Gets the thickness component
  69342. */
  69343. get thickness(): NodeMaterialConnectionPoint;
  69344. /**
  69345. * Gets the tint color input component
  69346. */
  69347. get tintColor(): NodeMaterialConnectionPoint;
  69348. /**
  69349. * Gets the translucency intensity input component
  69350. */
  69351. get translucencyIntensity(): NodeMaterialConnectionPoint;
  69352. /**
  69353. * Gets the translucency diffusion distance input component
  69354. */
  69355. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  69356. /**
  69357. * Gets the refraction object parameters
  69358. */
  69359. get refraction(): NodeMaterialConnectionPoint;
  69360. /**
  69361. * Gets the sub surface object output component
  69362. */
  69363. get subsurface(): NodeMaterialConnectionPoint;
  69364. autoConfigure(material: NodeMaterial): void;
  69365. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69366. /**
  69367. * Gets the main code of the block (fragment side)
  69368. * @param state current state of the node material building
  69369. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  69370. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69371. * @param worldPosVarName name of the variable holding the world position
  69372. * @returns the shader code
  69373. */
  69374. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  69375. protected _buildBlock(state: NodeMaterialBuildState): this;
  69376. }
  69377. }
  69378. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  69379. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69380. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69381. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69382. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69383. import { Light } from "babylonjs/Lights/light";
  69384. import { Nullable } from "babylonjs/types";
  69385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69386. import { Effect } from "babylonjs/Materials/effect";
  69387. import { Mesh } from "babylonjs/Meshes/mesh";
  69388. import { Scene } from "babylonjs/scene";
  69389. /**
  69390. * Block used to implement the PBR metallic/roughness model
  69391. */
  69392. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  69393. /**
  69394. * Gets or sets the light associated with this block
  69395. */
  69396. light: Nullable<Light>;
  69397. private _lightId;
  69398. private _scene;
  69399. private _environmentBRDFTexture;
  69400. private _environmentBrdfSamplerName;
  69401. private _vNormalWName;
  69402. private _invertNormalName;
  69403. private _metallicReflectanceColor;
  69404. private _metallicF0Factor;
  69405. private _vMetallicReflectanceFactorsName;
  69406. /**
  69407. * Create a new ReflectionBlock
  69408. * @param name defines the block name
  69409. */
  69410. constructor(name: string);
  69411. /**
  69412. * Intensity of the direct lights e.g. the four lights available in your scene.
  69413. * This impacts both the direct diffuse and specular highlights.
  69414. */
  69415. directIntensity: number;
  69416. /**
  69417. * Intensity of the environment e.g. how much the environment will light the object
  69418. * either through harmonics for rough material or through the refelction for shiny ones.
  69419. */
  69420. environmentIntensity: number;
  69421. /**
  69422. * This is a special control allowing the reduction of the specular highlights coming from the
  69423. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  69424. */
  69425. specularIntensity: number;
  69426. /**
  69427. * Defines the falloff type used in this material.
  69428. * It by default is Physical.
  69429. */
  69430. lightFalloff: number;
  69431. /**
  69432. * Specifies that alpha test should be used
  69433. */
  69434. useAlphaTest: boolean;
  69435. /**
  69436. * Defines the alpha limits in alpha test mode.
  69437. */
  69438. alphaTestCutoff: number;
  69439. /**
  69440. * Specifies that alpha blending should be used
  69441. */
  69442. useAlphaBlending: boolean;
  69443. /**
  69444. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  69445. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  69446. */
  69447. useRadianceOverAlpha: boolean;
  69448. /**
  69449. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  69450. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  69451. */
  69452. useSpecularOverAlpha: boolean;
  69453. /**
  69454. * Enables specular anti aliasing in the PBR shader.
  69455. * It will both interacts on the Geometry for analytical and IBL lighting.
  69456. * It also prefilter the roughness map based on the bump values.
  69457. */
  69458. enableSpecularAntiAliasing: boolean;
  69459. /**
  69460. * Enables realtime filtering on the texture.
  69461. */
  69462. realTimeFiltering: boolean;
  69463. /**
  69464. * Quality switch for realtime filtering
  69465. */
  69466. realTimeFilteringQuality: number;
  69467. /**
  69468. * Defines if the material uses energy conservation.
  69469. */
  69470. useEnergyConservation: boolean;
  69471. /**
  69472. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  69473. * too much the area relying on ambient texture to define their ambient occlusion.
  69474. */
  69475. useRadianceOcclusion: boolean;
  69476. /**
  69477. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  69478. * makes the reflect vector face the model (under horizon).
  69479. */
  69480. useHorizonOcclusion: boolean;
  69481. /**
  69482. * If set to true, no lighting calculations will be applied.
  69483. */
  69484. unlit: boolean;
  69485. /**
  69486. * Force normal to face away from face.
  69487. */
  69488. forceNormalForward: boolean;
  69489. /**
  69490. * Defines the material debug mode.
  69491. * It helps seeing only some components of the material while troubleshooting.
  69492. */
  69493. debugMode: number;
  69494. /**
  69495. * Specify from where on screen the debug mode should start.
  69496. * The value goes from -1 (full screen) to 1 (not visible)
  69497. * It helps with side by side comparison against the final render
  69498. * This defaults to 0
  69499. */
  69500. debugLimit: number;
  69501. /**
  69502. * As the default viewing range might not be enough (if the ambient is really small for instance)
  69503. * You can use the factor to better multiply the final value.
  69504. */
  69505. debugFactor: number;
  69506. /**
  69507. * Initialize the block and prepare the context for build
  69508. * @param state defines the state that will be used for the build
  69509. */
  69510. initialize(state: NodeMaterialBuildState): void;
  69511. /**
  69512. * Gets the current class name
  69513. * @returns the class name
  69514. */
  69515. getClassName(): string;
  69516. /**
  69517. * Gets the world position input component
  69518. */
  69519. get worldPosition(): NodeMaterialConnectionPoint;
  69520. /**
  69521. * Gets the world normal input component
  69522. */
  69523. get worldNormal(): NodeMaterialConnectionPoint;
  69524. /**
  69525. * Gets the view matrix parameter
  69526. */
  69527. get view(): NodeMaterialConnectionPoint;
  69528. /**
  69529. * Gets the camera position input component
  69530. */
  69531. get cameraPosition(): NodeMaterialConnectionPoint;
  69532. /**
  69533. * Gets the perturbed normal input component
  69534. */
  69535. get perturbedNormal(): NodeMaterialConnectionPoint;
  69536. /**
  69537. * Gets the base color input component
  69538. */
  69539. get baseColor(): NodeMaterialConnectionPoint;
  69540. /**
  69541. * Gets the metallic input component
  69542. */
  69543. get metallic(): NodeMaterialConnectionPoint;
  69544. /**
  69545. * Gets the roughness input component
  69546. */
  69547. get roughness(): NodeMaterialConnectionPoint;
  69548. /**
  69549. * Gets the ambient occlusion input component
  69550. */
  69551. get ambientOcc(): NodeMaterialConnectionPoint;
  69552. /**
  69553. * Gets the opacity input component
  69554. */
  69555. get opacity(): NodeMaterialConnectionPoint;
  69556. /**
  69557. * Gets the index of refraction input component
  69558. */
  69559. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69560. /**
  69561. * Gets the ambient color input component
  69562. */
  69563. get ambientColor(): NodeMaterialConnectionPoint;
  69564. /**
  69565. * Gets the reflection object parameters
  69566. */
  69567. get reflection(): NodeMaterialConnectionPoint;
  69568. /**
  69569. * Gets the clear coat object parameters
  69570. */
  69571. get clearcoat(): NodeMaterialConnectionPoint;
  69572. /**
  69573. * Gets the sheen object parameters
  69574. */
  69575. get sheen(): NodeMaterialConnectionPoint;
  69576. /**
  69577. * Gets the sub surface object parameters
  69578. */
  69579. get subsurface(): NodeMaterialConnectionPoint;
  69580. /**
  69581. * Gets the anisotropy object parameters
  69582. */
  69583. get anisotropy(): NodeMaterialConnectionPoint;
  69584. /**
  69585. * Gets the ambient output component
  69586. */
  69587. get ambientClr(): NodeMaterialConnectionPoint;
  69588. /**
  69589. * Gets the diffuse output component
  69590. */
  69591. get diffuseDir(): NodeMaterialConnectionPoint;
  69592. /**
  69593. * Gets the specular output component
  69594. */
  69595. get specularDir(): NodeMaterialConnectionPoint;
  69596. /**
  69597. * Gets the clear coat output component
  69598. */
  69599. get clearcoatDir(): NodeMaterialConnectionPoint;
  69600. /**
  69601. * Gets the sheen output component
  69602. */
  69603. get sheenDir(): NodeMaterialConnectionPoint;
  69604. /**
  69605. * Gets the indirect diffuse output component
  69606. */
  69607. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69608. /**
  69609. * Gets the indirect specular output component
  69610. */
  69611. get specularIndirect(): NodeMaterialConnectionPoint;
  69612. /**
  69613. * Gets the indirect clear coat output component
  69614. */
  69615. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69616. /**
  69617. * Gets the indirect sheen output component
  69618. */
  69619. get sheenIndirect(): NodeMaterialConnectionPoint;
  69620. /**
  69621. * Gets the refraction output component
  69622. */
  69623. get refraction(): NodeMaterialConnectionPoint;
  69624. /**
  69625. * Gets the global lighting output component
  69626. */
  69627. get lighting(): NodeMaterialConnectionPoint;
  69628. /**
  69629. * Gets the shadow output component
  69630. */
  69631. get shadow(): NodeMaterialConnectionPoint;
  69632. /**
  69633. * Gets the alpha output component
  69634. */
  69635. get alpha(): NodeMaterialConnectionPoint;
  69636. autoConfigure(material: NodeMaterial): void;
  69637. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69638. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69639. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69640. private _injectVertexCode;
  69641. private _getAlbedoOpacityCode;
  69642. private _getAmbientOcclusionCode;
  69643. private _getReflectivityCode;
  69644. protected _buildBlock(state: NodeMaterialBuildState): this;
  69645. protected _dumpPropertiesCode(): string;
  69646. serialize(): any;
  69647. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69648. }
  69649. }
  69650. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  69651. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  69652. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  69653. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  69654. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69655. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  69656. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  69657. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  69658. }
  69659. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  69660. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  69661. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  69662. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  69663. }
  69664. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  69665. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69666. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69667. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69668. /**
  69669. * Block used to compute value of one parameter modulo another
  69670. */
  69671. export class ModBlock extends NodeMaterialBlock {
  69672. /**
  69673. * Creates a new ModBlock
  69674. * @param name defines the block name
  69675. */
  69676. constructor(name: string);
  69677. /**
  69678. * Gets the current class name
  69679. * @returns the class name
  69680. */
  69681. getClassName(): string;
  69682. /**
  69683. * Gets the left operand input component
  69684. */
  69685. get left(): NodeMaterialConnectionPoint;
  69686. /**
  69687. * Gets the right operand input component
  69688. */
  69689. get right(): NodeMaterialConnectionPoint;
  69690. /**
  69691. * Gets the output component
  69692. */
  69693. get output(): NodeMaterialConnectionPoint;
  69694. protected _buildBlock(state: NodeMaterialBuildState): this;
  69695. }
  69696. }
  69697. declare module "babylonjs/Materials/Node/Blocks/index" {
  69698. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  69699. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  69700. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  69701. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  69702. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  69703. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  69704. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  69705. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  69706. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  69707. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  69708. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  69709. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  69710. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  69711. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  69712. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  69713. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  69714. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  69715. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  69716. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  69717. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  69718. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  69719. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  69720. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  69721. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  69722. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  69723. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  69724. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  69725. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  69726. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  69727. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  69728. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  69729. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  69730. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  69731. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  69732. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  69733. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  69734. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  69735. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  69736. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  69737. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  69738. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  69739. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  69740. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  69741. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  69742. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  69743. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  69744. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  69745. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  69746. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  69747. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  69748. }
  69749. declare module "babylonjs/Materials/Node/Optimizers/index" {
  69750. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  69751. }
  69752. declare module "babylonjs/Materials/Node/index" {
  69753. export * from "babylonjs/Materials/Node/Enums/index";
  69754. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69755. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  69756. export * from "babylonjs/Materials/Node/nodeMaterial";
  69757. export * from "babylonjs/Materials/Node/Blocks/index";
  69758. export * from "babylonjs/Materials/Node/Optimizers/index";
  69759. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  69760. }
  69761. declare module "babylonjs/Materials/index" {
  69762. export * from "babylonjs/Materials/Background/index";
  69763. export * from "babylonjs/Materials/colorCurves";
  69764. export * from "babylonjs/Materials/iEffectFallbacks";
  69765. export * from "babylonjs/Materials/effectFallbacks";
  69766. export * from "babylonjs/Materials/effect";
  69767. export * from "babylonjs/Materials/fresnelParameters";
  69768. export * from "babylonjs/Materials/imageProcessingConfiguration";
  69769. export * from "babylonjs/Materials/material";
  69770. export * from "babylonjs/Materials/materialDefines";
  69771. export * from "babylonjs/Materials/thinMaterialHelper";
  69772. export * from "babylonjs/Materials/materialHelper";
  69773. export * from "babylonjs/Materials/multiMaterial";
  69774. export * from "babylonjs/Materials/PBR/index";
  69775. export * from "babylonjs/Materials/pushMaterial";
  69776. export * from "babylonjs/Materials/shaderMaterial";
  69777. export * from "babylonjs/Materials/standardMaterial";
  69778. export * from "babylonjs/Materials/Textures/index";
  69779. export * from "babylonjs/Materials/uniformBuffer";
  69780. export * from "babylonjs/Materials/materialFlags";
  69781. export * from "babylonjs/Materials/Node/index";
  69782. export * from "babylonjs/Materials/effectRenderer";
  69783. export * from "babylonjs/Materials/shadowDepthWrapper";
  69784. }
  69785. declare module "babylonjs/Maths/index" {
  69786. export * from "babylonjs/Maths/math.scalar";
  69787. export * from "babylonjs/Maths/math";
  69788. export * from "babylonjs/Maths/sphericalPolynomial";
  69789. }
  69790. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  69791. import { IDisposable } from "babylonjs/scene";
  69792. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69793. /**
  69794. * Configuration for Draco compression
  69795. */
  69796. export interface IDracoCompressionConfiguration {
  69797. /**
  69798. * Configuration for the decoder.
  69799. */
  69800. decoder: {
  69801. /**
  69802. * The url to the WebAssembly module.
  69803. */
  69804. wasmUrl?: string;
  69805. /**
  69806. * The url to the WebAssembly binary.
  69807. */
  69808. wasmBinaryUrl?: string;
  69809. /**
  69810. * The url to the fallback JavaScript module.
  69811. */
  69812. fallbackUrl?: string;
  69813. };
  69814. }
  69815. /**
  69816. * Draco compression (https://google.github.io/draco/)
  69817. *
  69818. * This class wraps the Draco module.
  69819. *
  69820. * **Encoder**
  69821. *
  69822. * The encoder is not currently implemented.
  69823. *
  69824. * **Decoder**
  69825. *
  69826. * 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.
  69827. *
  69828. * To update the configuration, use the following code:
  69829. * ```javascript
  69830. * DracoCompression.Configuration = {
  69831. * decoder: {
  69832. * wasmUrl: "<url to the WebAssembly library>",
  69833. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69834. * fallbackUrl: "<url to the fallback JavaScript library>",
  69835. * }
  69836. * };
  69837. * ```
  69838. *
  69839. * 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.
  69840. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69841. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69842. *
  69843. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69844. * ```javascript
  69845. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69846. * ```
  69847. *
  69848. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69849. */
  69850. export class DracoCompression implements IDisposable {
  69851. private _workerPoolPromise?;
  69852. private _decoderModulePromise?;
  69853. /**
  69854. * The configuration. Defaults to the following urls:
  69855. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69856. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69857. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69858. */
  69859. static Configuration: IDracoCompressionConfiguration;
  69860. /**
  69861. * Returns true if the decoder configuration is available.
  69862. */
  69863. static get DecoderAvailable(): boolean;
  69864. /**
  69865. * Default number of workers to create when creating the draco compression object.
  69866. */
  69867. static DefaultNumWorkers: number;
  69868. private static GetDefaultNumWorkers;
  69869. private static _Default;
  69870. /**
  69871. * Default instance for the draco compression object.
  69872. */
  69873. static get Default(): DracoCompression;
  69874. /**
  69875. * Constructor
  69876. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69877. */
  69878. constructor(numWorkers?: number);
  69879. /**
  69880. * Stop all async operations and release resources.
  69881. */
  69882. dispose(): void;
  69883. /**
  69884. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69885. * @returns a promise that resolves when ready
  69886. */
  69887. whenReadyAsync(): Promise<void>;
  69888. /**
  69889. * Decode Draco compressed mesh data to vertex data.
  69890. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69891. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69892. * @returns A promise that resolves with the decoded vertex data
  69893. */
  69894. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69895. [kind: string]: number;
  69896. }): Promise<VertexData>;
  69897. }
  69898. }
  69899. declare module "babylonjs/Meshes/Compression/index" {
  69900. export * from "babylonjs/Meshes/Compression/dracoCompression";
  69901. }
  69902. declare module "babylonjs/Meshes/csg" {
  69903. import { Nullable } from "babylonjs/types";
  69904. import { Scene } from "babylonjs/scene";
  69905. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  69906. import { Mesh } from "babylonjs/Meshes/mesh";
  69907. import { Material } from "babylonjs/Materials/material";
  69908. /**
  69909. * Class for building Constructive Solid Geometry
  69910. */
  69911. export class CSG {
  69912. private polygons;
  69913. /**
  69914. * The world matrix
  69915. */
  69916. matrix: Matrix;
  69917. /**
  69918. * Stores the position
  69919. */
  69920. position: Vector3;
  69921. /**
  69922. * Stores the rotation
  69923. */
  69924. rotation: Vector3;
  69925. /**
  69926. * Stores the rotation quaternion
  69927. */
  69928. rotationQuaternion: Nullable<Quaternion>;
  69929. /**
  69930. * Stores the scaling vector
  69931. */
  69932. scaling: Vector3;
  69933. /**
  69934. * Convert the Mesh to CSG
  69935. * @param mesh The Mesh to convert to CSG
  69936. * @returns A new CSG from the Mesh
  69937. */
  69938. static FromMesh(mesh: Mesh): CSG;
  69939. /**
  69940. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69941. * @param polygons Polygons used to construct a CSG solid
  69942. */
  69943. private static FromPolygons;
  69944. /**
  69945. * Clones, or makes a deep copy, of the CSG
  69946. * @returns A new CSG
  69947. */
  69948. clone(): CSG;
  69949. /**
  69950. * Unions this CSG with another CSG
  69951. * @param csg The CSG to union against this CSG
  69952. * @returns The unioned CSG
  69953. */
  69954. union(csg: CSG): CSG;
  69955. /**
  69956. * Unions this CSG with another CSG in place
  69957. * @param csg The CSG to union against this CSG
  69958. */
  69959. unionInPlace(csg: CSG): void;
  69960. /**
  69961. * Subtracts this CSG with another CSG
  69962. * @param csg The CSG to subtract against this CSG
  69963. * @returns A new CSG
  69964. */
  69965. subtract(csg: CSG): CSG;
  69966. /**
  69967. * Subtracts this CSG with another CSG in place
  69968. * @param csg The CSG to subtact against this CSG
  69969. */
  69970. subtractInPlace(csg: CSG): void;
  69971. /**
  69972. * Intersect this CSG with another CSG
  69973. * @param csg The CSG to intersect against this CSG
  69974. * @returns A new CSG
  69975. */
  69976. intersect(csg: CSG): CSG;
  69977. /**
  69978. * Intersects this CSG with another CSG in place
  69979. * @param csg The CSG to intersect against this CSG
  69980. */
  69981. intersectInPlace(csg: CSG): void;
  69982. /**
  69983. * Return a new CSG solid with solid and empty space switched. This solid is
  69984. * not modified.
  69985. * @returns A new CSG solid with solid and empty space switched
  69986. */
  69987. inverse(): CSG;
  69988. /**
  69989. * Inverses the CSG in place
  69990. */
  69991. inverseInPlace(): void;
  69992. /**
  69993. * This is used to keep meshes transformations so they can be restored
  69994. * when we build back a Babylon Mesh
  69995. * NB : All CSG operations are performed in world coordinates
  69996. * @param csg The CSG to copy the transform attributes from
  69997. * @returns This CSG
  69998. */
  69999. copyTransformAttributes(csg: CSG): CSG;
  70000. /**
  70001. * Build Raw mesh from CSG
  70002. * Coordinates here are in world space
  70003. * @param name The name of the mesh geometry
  70004. * @param scene The Scene
  70005. * @param keepSubMeshes Specifies if the submeshes should be kept
  70006. * @returns A new Mesh
  70007. */
  70008. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  70009. /**
  70010. * Build Mesh from CSG taking material and transforms into account
  70011. * @param name The name of the Mesh
  70012. * @param material The material of the Mesh
  70013. * @param scene The Scene
  70014. * @param keepSubMeshes Specifies if submeshes should be kept
  70015. * @returns The new Mesh
  70016. */
  70017. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  70018. }
  70019. }
  70020. declare module "babylonjs/Meshes/trailMesh" {
  70021. import { Mesh } from "babylonjs/Meshes/mesh";
  70022. import { Scene } from "babylonjs/scene";
  70023. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70024. /**
  70025. * Class used to create a trail following a mesh
  70026. */
  70027. export class TrailMesh extends Mesh {
  70028. private _generator;
  70029. private _autoStart;
  70030. private _running;
  70031. private _diameter;
  70032. private _length;
  70033. private _sectionPolygonPointsCount;
  70034. private _sectionVectors;
  70035. private _sectionNormalVectors;
  70036. private _beforeRenderObserver;
  70037. /**
  70038. * @constructor
  70039. * @param name The value used by scene.getMeshByName() to do a lookup.
  70040. * @param generator The mesh or transform node to generate a trail.
  70041. * @param scene The scene to add this mesh to.
  70042. * @param diameter Diameter of trailing mesh. Default is 1.
  70043. * @param length Length of trailing mesh. Default is 60.
  70044. * @param autoStart Automatically start trailing mesh. Default true.
  70045. */
  70046. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  70047. /**
  70048. * "TrailMesh"
  70049. * @returns "TrailMesh"
  70050. */
  70051. getClassName(): string;
  70052. private _createMesh;
  70053. /**
  70054. * Start trailing mesh.
  70055. */
  70056. start(): void;
  70057. /**
  70058. * Stop trailing mesh.
  70059. */
  70060. stop(): void;
  70061. /**
  70062. * Update trailing mesh geometry.
  70063. */
  70064. update(): void;
  70065. /**
  70066. * Returns a new TrailMesh object.
  70067. * @param name is a string, the name given to the new mesh
  70068. * @param newGenerator use new generator object for cloned trail mesh
  70069. * @returns a new mesh
  70070. */
  70071. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  70072. /**
  70073. * Serializes this trail mesh
  70074. * @param serializationObject object to write serialization to
  70075. */
  70076. serialize(serializationObject: any): void;
  70077. /**
  70078. * Parses a serialized trail mesh
  70079. * @param parsedMesh the serialized mesh
  70080. * @param scene the scene to create the trail mesh in
  70081. * @returns the created trail mesh
  70082. */
  70083. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  70084. }
  70085. }
  70086. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  70087. import { Nullable } from "babylonjs/types";
  70088. import { Scene } from "babylonjs/scene";
  70089. import { Vector4 } from "babylonjs/Maths/math.vector";
  70090. import { Color4 } from "babylonjs/Maths/math.color";
  70091. import { Mesh } from "babylonjs/Meshes/mesh";
  70092. /**
  70093. * Class containing static functions to help procedurally build meshes
  70094. */
  70095. export class TiledBoxBuilder {
  70096. /**
  70097. * Creates a box mesh
  70098. * 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)
  70099. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70100. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70101. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70103. * @param name defines the name of the mesh
  70104. * @param options defines the options used to create the mesh
  70105. * @param scene defines the hosting scene
  70106. * @returns the box mesh
  70107. */
  70108. static CreateTiledBox(name: string, options: {
  70109. pattern?: number;
  70110. width?: number;
  70111. height?: number;
  70112. depth?: number;
  70113. tileSize?: number;
  70114. tileWidth?: number;
  70115. tileHeight?: number;
  70116. alignHorizontal?: number;
  70117. alignVertical?: number;
  70118. faceUV?: Vector4[];
  70119. faceColors?: Color4[];
  70120. sideOrientation?: number;
  70121. updatable?: boolean;
  70122. }, scene?: Nullable<Scene>): Mesh;
  70123. }
  70124. }
  70125. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  70126. import { Vector4 } from "babylonjs/Maths/math.vector";
  70127. import { Mesh } from "babylonjs/Meshes/mesh";
  70128. /**
  70129. * Class containing static functions to help procedurally build meshes
  70130. */
  70131. export class TorusKnotBuilder {
  70132. /**
  70133. * Creates a torus knot mesh
  70134. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70135. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70136. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70137. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70139. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70141. * @param name defines the name of the mesh
  70142. * @param options defines the options used to create the mesh
  70143. * @param scene defines the hosting scene
  70144. * @returns the torus knot mesh
  70145. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70146. */
  70147. static CreateTorusKnot(name: string, options: {
  70148. radius?: number;
  70149. tube?: number;
  70150. radialSegments?: number;
  70151. tubularSegments?: number;
  70152. p?: number;
  70153. q?: number;
  70154. updatable?: boolean;
  70155. sideOrientation?: number;
  70156. frontUVs?: Vector4;
  70157. backUVs?: Vector4;
  70158. }, scene: any): Mesh;
  70159. }
  70160. }
  70161. declare module "babylonjs/Meshes/polygonMesh" {
  70162. import { Scene } from "babylonjs/scene";
  70163. import { Vector2 } from "babylonjs/Maths/math.vector";
  70164. import { Mesh } from "babylonjs/Meshes/mesh";
  70165. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  70166. import { Path2 } from "babylonjs/Maths/math.path";
  70167. /**
  70168. * Polygon
  70169. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  70170. */
  70171. export class Polygon {
  70172. /**
  70173. * Creates a rectangle
  70174. * @param xmin bottom X coord
  70175. * @param ymin bottom Y coord
  70176. * @param xmax top X coord
  70177. * @param ymax top Y coord
  70178. * @returns points that make the resulting rectation
  70179. */
  70180. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  70181. /**
  70182. * Creates a circle
  70183. * @param radius radius of circle
  70184. * @param cx scale in x
  70185. * @param cy scale in y
  70186. * @param numberOfSides number of sides that make up the circle
  70187. * @returns points that make the resulting circle
  70188. */
  70189. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  70190. /**
  70191. * Creates a polygon from input string
  70192. * @param input Input polygon data
  70193. * @returns the parsed points
  70194. */
  70195. static Parse(input: string): Vector2[];
  70196. /**
  70197. * Starts building a polygon from x and y coordinates
  70198. * @param x x coordinate
  70199. * @param y y coordinate
  70200. * @returns the started path2
  70201. */
  70202. static StartingAt(x: number, y: number): Path2;
  70203. }
  70204. /**
  70205. * Builds a polygon
  70206. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  70207. */
  70208. export class PolygonMeshBuilder {
  70209. private _points;
  70210. private _outlinepoints;
  70211. private _holes;
  70212. private _name;
  70213. private _scene;
  70214. private _epoints;
  70215. private _eholes;
  70216. private _addToepoint;
  70217. /**
  70218. * Babylon reference to the earcut plugin.
  70219. */
  70220. bjsEarcut: any;
  70221. /**
  70222. * Creates a PolygonMeshBuilder
  70223. * @param name name of the builder
  70224. * @param contours Path of the polygon
  70225. * @param scene scene to add to when creating the mesh
  70226. * @param earcutInjection can be used to inject your own earcut reference
  70227. */
  70228. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  70229. /**
  70230. * Adds a whole within the polygon
  70231. * @param hole Array of points defining the hole
  70232. * @returns this
  70233. */
  70234. addHole(hole: Vector2[]): PolygonMeshBuilder;
  70235. /**
  70236. * Creates the polygon
  70237. * @param updatable If the mesh should be updatable
  70238. * @param depth The depth of the mesh created
  70239. * @returns the created mesh
  70240. */
  70241. build(updatable?: boolean, depth?: number): Mesh;
  70242. /**
  70243. * Creates the polygon
  70244. * @param depth The depth of the mesh created
  70245. * @returns the created VertexData
  70246. */
  70247. buildVertexData(depth?: number): VertexData;
  70248. /**
  70249. * Adds a side to the polygon
  70250. * @param positions points that make the polygon
  70251. * @param normals normals of the polygon
  70252. * @param uvs uvs of the polygon
  70253. * @param indices indices of the polygon
  70254. * @param bounds bounds of the polygon
  70255. * @param points points of the polygon
  70256. * @param depth depth of the polygon
  70257. * @param flip flip of the polygon
  70258. */
  70259. private addSide;
  70260. }
  70261. }
  70262. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  70263. import { Scene } from "babylonjs/scene";
  70264. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70265. import { Color4 } from "babylonjs/Maths/math.color";
  70266. import { Mesh } from "babylonjs/Meshes/mesh";
  70267. import { Nullable } from "babylonjs/types";
  70268. /**
  70269. * Class containing static functions to help procedurally build meshes
  70270. */
  70271. export class PolygonBuilder {
  70272. /**
  70273. * Creates a polygon mesh
  70274. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70275. * * 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
  70276. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70278. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  70279. * * Remember you can only change the shape positions, not their number when updating a polygon
  70280. * @param name defines the name of the mesh
  70281. * @param options defines the options used to create the mesh
  70282. * @param scene defines the hosting scene
  70283. * @param earcutInjection can be used to inject your own earcut reference
  70284. * @returns the polygon mesh
  70285. */
  70286. static CreatePolygon(name: string, options: {
  70287. shape: Vector3[];
  70288. holes?: Vector3[][];
  70289. depth?: number;
  70290. faceUV?: Vector4[];
  70291. faceColors?: Color4[];
  70292. updatable?: boolean;
  70293. sideOrientation?: number;
  70294. frontUVs?: Vector4;
  70295. backUVs?: Vector4;
  70296. wrap?: boolean;
  70297. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70298. /**
  70299. * Creates an extruded polygon mesh, with depth in the Y direction.
  70300. * * 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)
  70301. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70302. * @param name defines the name of the mesh
  70303. * @param options defines the options used to create the mesh
  70304. * @param scene defines the hosting scene
  70305. * @param earcutInjection can be used to inject your own earcut reference
  70306. * @returns the polygon mesh
  70307. */
  70308. static ExtrudePolygon(name: string, options: {
  70309. shape: Vector3[];
  70310. holes?: Vector3[][];
  70311. depth?: number;
  70312. faceUV?: Vector4[];
  70313. faceColors?: Color4[];
  70314. updatable?: boolean;
  70315. sideOrientation?: number;
  70316. frontUVs?: Vector4;
  70317. backUVs?: Vector4;
  70318. wrap?: boolean;
  70319. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70320. }
  70321. }
  70322. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  70323. import { Scene } from "babylonjs/scene";
  70324. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70325. import { Mesh } from "babylonjs/Meshes/mesh";
  70326. import { Nullable } from "babylonjs/types";
  70327. /**
  70328. * Class containing static functions to help procedurally build meshes
  70329. */
  70330. export class LatheBuilder {
  70331. /**
  70332. * Creates lathe mesh.
  70333. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70334. * * 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
  70335. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70336. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70337. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70338. * * 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
  70339. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70340. * * 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
  70341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70342. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70343. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70345. * @param name defines the name of the mesh
  70346. * @param options defines the options used to create the mesh
  70347. * @param scene defines the hosting scene
  70348. * @returns the lathe mesh
  70349. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70350. */
  70351. static CreateLathe(name: string, options: {
  70352. shape: Vector3[];
  70353. radius?: number;
  70354. tessellation?: number;
  70355. clip?: number;
  70356. arc?: number;
  70357. closed?: boolean;
  70358. updatable?: boolean;
  70359. sideOrientation?: number;
  70360. frontUVs?: Vector4;
  70361. backUVs?: Vector4;
  70362. cap?: number;
  70363. invertUV?: boolean;
  70364. }, scene?: Nullable<Scene>): Mesh;
  70365. }
  70366. }
  70367. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  70368. import { Nullable } from "babylonjs/types";
  70369. import { Scene } from "babylonjs/scene";
  70370. import { Vector4 } from "babylonjs/Maths/math.vector";
  70371. import { Mesh } from "babylonjs/Meshes/mesh";
  70372. /**
  70373. * Class containing static functions to help procedurally build meshes
  70374. */
  70375. export class TiledPlaneBuilder {
  70376. /**
  70377. * Creates a tiled plane mesh
  70378. * * The parameter `pattern` will, depending on value, do nothing or
  70379. * * * flip (reflect about central vertical) alternate tiles across and up
  70380. * * * flip every tile on alternate rows
  70381. * * * rotate (180 degs) alternate tiles across and up
  70382. * * * rotate every tile on alternate rows
  70383. * * * flip and rotate alternate tiles across and up
  70384. * * * flip and rotate every tile on alternate rows
  70385. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  70386. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  70387. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70388. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70389. * * 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)
  70390. * * 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)
  70391. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70392. * @param name defines the name of the mesh
  70393. * @param options defines the options used to create the mesh
  70394. * @param scene defines the hosting scene
  70395. * @returns the box mesh
  70396. */
  70397. static CreateTiledPlane(name: string, options: {
  70398. pattern?: number;
  70399. tileSize?: number;
  70400. tileWidth?: number;
  70401. tileHeight?: number;
  70402. size?: number;
  70403. width?: number;
  70404. height?: number;
  70405. alignHorizontal?: number;
  70406. alignVertical?: number;
  70407. sideOrientation?: number;
  70408. frontUVs?: Vector4;
  70409. backUVs?: Vector4;
  70410. updatable?: boolean;
  70411. }, scene?: Nullable<Scene>): Mesh;
  70412. }
  70413. }
  70414. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  70415. import { Nullable } from "babylonjs/types";
  70416. import { Scene } from "babylonjs/scene";
  70417. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70418. import { Mesh } from "babylonjs/Meshes/mesh";
  70419. /**
  70420. * Class containing static functions to help procedurally build meshes
  70421. */
  70422. export class TubeBuilder {
  70423. /**
  70424. * Creates a tube mesh.
  70425. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70426. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70427. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70428. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70429. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70430. * * 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)
  70431. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70432. * * 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
  70433. * * 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
  70434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70435. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70436. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70438. * @param name defines the name of the mesh
  70439. * @param options defines the options used to create the mesh
  70440. * @param scene defines the hosting scene
  70441. * @returns the tube mesh
  70442. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70443. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70444. */
  70445. static CreateTube(name: string, options: {
  70446. path: Vector3[];
  70447. radius?: number;
  70448. tessellation?: number;
  70449. radiusFunction?: {
  70450. (i: number, distance: number): number;
  70451. };
  70452. cap?: number;
  70453. arc?: number;
  70454. updatable?: boolean;
  70455. sideOrientation?: number;
  70456. frontUVs?: Vector4;
  70457. backUVs?: Vector4;
  70458. instance?: Mesh;
  70459. invertUV?: boolean;
  70460. }, scene?: Nullable<Scene>): Mesh;
  70461. }
  70462. }
  70463. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  70464. import { Scene } from "babylonjs/scene";
  70465. import { Vector4 } from "babylonjs/Maths/math.vector";
  70466. import { Mesh } from "babylonjs/Meshes/mesh";
  70467. import { Nullable } from "babylonjs/types";
  70468. /**
  70469. * Class containing static functions to help procedurally build meshes
  70470. */
  70471. export class IcoSphereBuilder {
  70472. /**
  70473. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70474. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70475. * * 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`)
  70476. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70477. * * 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
  70478. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70479. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70481. * @param name defines the name of the mesh
  70482. * @param options defines the options used to create the mesh
  70483. * @param scene defines the hosting scene
  70484. * @returns the icosahedron mesh
  70485. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70486. */
  70487. static CreateIcoSphere(name: string, options: {
  70488. radius?: number;
  70489. radiusX?: number;
  70490. radiusY?: number;
  70491. radiusZ?: number;
  70492. flat?: boolean;
  70493. subdivisions?: number;
  70494. sideOrientation?: number;
  70495. frontUVs?: Vector4;
  70496. backUVs?: Vector4;
  70497. updatable?: boolean;
  70498. }, scene?: Nullable<Scene>): Mesh;
  70499. }
  70500. }
  70501. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  70502. import { Vector3 } from "babylonjs/Maths/math.vector";
  70503. import { Mesh } from "babylonjs/Meshes/mesh";
  70504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70505. /**
  70506. * Class containing static functions to help procedurally build meshes
  70507. */
  70508. export class DecalBuilder {
  70509. /**
  70510. * Creates a decal mesh.
  70511. * 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
  70512. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70513. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70514. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70515. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70516. * @param name defines the name of the mesh
  70517. * @param sourceMesh defines the mesh where the decal must be applied
  70518. * @param options defines the options used to create the mesh
  70519. * @param scene defines the hosting scene
  70520. * @returns the decal mesh
  70521. * @see https://doc.babylonjs.com/how_to/decals
  70522. */
  70523. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70524. position?: Vector3;
  70525. normal?: Vector3;
  70526. size?: Vector3;
  70527. angle?: number;
  70528. }): Mesh;
  70529. }
  70530. }
  70531. declare module "babylonjs/Meshes/meshBuilder" {
  70532. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  70533. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  70534. import { Nullable } from "babylonjs/types";
  70535. import { Scene } from "babylonjs/scene";
  70536. import { Mesh } from "babylonjs/Meshes/mesh";
  70537. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  70538. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  70539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70540. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70541. import { Plane } from "babylonjs/Maths/math.plane";
  70542. /**
  70543. * Class containing static functions to help procedurally build meshes
  70544. */
  70545. export class MeshBuilder {
  70546. /**
  70547. * Creates a box mesh
  70548. * * The parameter `size` sets the size (float) of each box side (default 1)
  70549. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70550. * * 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)
  70551. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70555. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70556. * @param name defines the name of the mesh
  70557. * @param options defines the options used to create the mesh
  70558. * @param scene defines the hosting scene
  70559. * @returns the box mesh
  70560. */
  70561. static CreateBox(name: string, options: {
  70562. size?: number;
  70563. width?: number;
  70564. height?: number;
  70565. depth?: number;
  70566. faceUV?: Vector4[];
  70567. faceColors?: Color4[];
  70568. sideOrientation?: number;
  70569. frontUVs?: Vector4;
  70570. backUVs?: Vector4;
  70571. wrap?: boolean;
  70572. topBaseAt?: number;
  70573. bottomBaseAt?: number;
  70574. updatable?: boolean;
  70575. }, scene?: Nullable<Scene>): Mesh;
  70576. /**
  70577. * Creates a tiled box mesh
  70578. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70580. * @param name defines the name of the mesh
  70581. * @param options defines the options used to create the mesh
  70582. * @param scene defines the hosting scene
  70583. * @returns the tiled box mesh
  70584. */
  70585. static CreateTiledBox(name: string, options: {
  70586. pattern?: number;
  70587. size?: number;
  70588. width?: number;
  70589. height?: number;
  70590. depth: number;
  70591. tileSize?: number;
  70592. tileWidth?: number;
  70593. tileHeight?: number;
  70594. faceUV?: Vector4[];
  70595. faceColors?: Color4[];
  70596. alignHorizontal?: number;
  70597. alignVertical?: number;
  70598. sideOrientation?: number;
  70599. updatable?: boolean;
  70600. }, scene?: Nullable<Scene>): Mesh;
  70601. /**
  70602. * Creates a sphere mesh
  70603. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70604. * * 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`)
  70605. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70606. * * 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
  70607. * * 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)
  70608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70609. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70611. * @param name defines the name of the mesh
  70612. * @param options defines the options used to create the mesh
  70613. * @param scene defines the hosting scene
  70614. * @returns the sphere mesh
  70615. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70616. */
  70617. static CreateSphere(name: string, options: {
  70618. segments?: number;
  70619. diameter?: number;
  70620. diameterX?: number;
  70621. diameterY?: number;
  70622. diameterZ?: number;
  70623. arc?: number;
  70624. slice?: number;
  70625. sideOrientation?: number;
  70626. frontUVs?: Vector4;
  70627. backUVs?: Vector4;
  70628. updatable?: boolean;
  70629. }, scene?: Nullable<Scene>): Mesh;
  70630. /**
  70631. * Creates a plane polygonal mesh. By default, this is a disc
  70632. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70633. * * 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
  70634. * * 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
  70635. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70636. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70638. * @param name defines the name of the mesh
  70639. * @param options defines the options used to create the mesh
  70640. * @param scene defines the hosting scene
  70641. * @returns the plane polygonal mesh
  70642. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70643. */
  70644. static CreateDisc(name: string, options: {
  70645. radius?: number;
  70646. tessellation?: number;
  70647. arc?: number;
  70648. updatable?: boolean;
  70649. sideOrientation?: number;
  70650. frontUVs?: Vector4;
  70651. backUVs?: Vector4;
  70652. }, scene?: Nullable<Scene>): Mesh;
  70653. /**
  70654. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70655. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70656. * * 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`)
  70657. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70658. * * 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
  70659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70660. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70662. * @param name defines the name of the mesh
  70663. * @param options defines the options used to create the mesh
  70664. * @param scene defines the hosting scene
  70665. * @returns the icosahedron mesh
  70666. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70667. */
  70668. static CreateIcoSphere(name: string, options: {
  70669. radius?: number;
  70670. radiusX?: number;
  70671. radiusY?: number;
  70672. radiusZ?: number;
  70673. flat?: boolean;
  70674. subdivisions?: number;
  70675. sideOrientation?: number;
  70676. frontUVs?: Vector4;
  70677. backUVs?: Vector4;
  70678. updatable?: boolean;
  70679. }, scene?: Nullable<Scene>): Mesh;
  70680. /**
  70681. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70682. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70683. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70684. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70685. * * 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
  70686. * * 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
  70687. * * 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
  70688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70689. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70690. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70691. * * 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
  70692. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70693. * * 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
  70694. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70696. * @param name defines the name of the mesh
  70697. * @param options defines the options used to create the mesh
  70698. * @param scene defines the hosting scene
  70699. * @returns the ribbon mesh
  70700. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70701. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70702. */
  70703. static CreateRibbon(name: string, options: {
  70704. pathArray: Vector3[][];
  70705. closeArray?: boolean;
  70706. closePath?: boolean;
  70707. offset?: number;
  70708. updatable?: boolean;
  70709. sideOrientation?: number;
  70710. frontUVs?: Vector4;
  70711. backUVs?: Vector4;
  70712. instance?: Mesh;
  70713. invertUV?: boolean;
  70714. uvs?: Vector2[];
  70715. colors?: Color4[];
  70716. }, scene?: Nullable<Scene>): Mesh;
  70717. /**
  70718. * Creates a cylinder or a cone mesh
  70719. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70720. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70721. * * 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.
  70722. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70723. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70724. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70725. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70726. * * 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).
  70727. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70728. * * 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).
  70729. * * 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
  70730. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70731. * * 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
  70732. * * 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.
  70733. * * If `enclose` is false, a ring surface is one element.
  70734. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70735. * * 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
  70736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70737. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70739. * @param name defines the name of the mesh
  70740. * @param options defines the options used to create the mesh
  70741. * @param scene defines the hosting scene
  70742. * @returns the cylinder mesh
  70743. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70744. */
  70745. static CreateCylinder(name: string, options: {
  70746. height?: number;
  70747. diameterTop?: number;
  70748. diameterBottom?: number;
  70749. diameter?: number;
  70750. tessellation?: number;
  70751. subdivisions?: number;
  70752. arc?: number;
  70753. faceColors?: Color4[];
  70754. faceUV?: Vector4[];
  70755. updatable?: boolean;
  70756. hasRings?: boolean;
  70757. enclose?: boolean;
  70758. cap?: number;
  70759. sideOrientation?: number;
  70760. frontUVs?: Vector4;
  70761. backUVs?: Vector4;
  70762. }, scene?: Nullable<Scene>): Mesh;
  70763. /**
  70764. * Creates a torus mesh
  70765. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70766. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70767. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70768. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70769. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70771. * @param name defines the name of the mesh
  70772. * @param options defines the options used to create the mesh
  70773. * @param scene defines the hosting scene
  70774. * @returns the torus mesh
  70775. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70776. */
  70777. static CreateTorus(name: string, options: {
  70778. diameter?: number;
  70779. thickness?: number;
  70780. tessellation?: number;
  70781. updatable?: boolean;
  70782. sideOrientation?: number;
  70783. frontUVs?: Vector4;
  70784. backUVs?: Vector4;
  70785. }, scene?: Nullable<Scene>): Mesh;
  70786. /**
  70787. * Creates a torus knot mesh
  70788. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70789. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70790. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70791. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70792. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70793. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70795. * @param name defines the name of the mesh
  70796. * @param options defines the options used to create the mesh
  70797. * @param scene defines the hosting scene
  70798. * @returns the torus knot mesh
  70799. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70800. */
  70801. static CreateTorusKnot(name: string, options: {
  70802. radius?: number;
  70803. tube?: number;
  70804. radialSegments?: number;
  70805. tubularSegments?: number;
  70806. p?: number;
  70807. q?: number;
  70808. updatable?: boolean;
  70809. sideOrientation?: number;
  70810. frontUVs?: Vector4;
  70811. backUVs?: Vector4;
  70812. }, scene?: Nullable<Scene>): Mesh;
  70813. /**
  70814. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70815. * * 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
  70816. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70817. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70818. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70819. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70820. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70821. * * 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
  70822. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70824. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70825. * @param name defines the name of the new line system
  70826. * @param options defines the options used to create the line system
  70827. * @param scene defines the hosting scene
  70828. * @returns a new line system mesh
  70829. */
  70830. static CreateLineSystem(name: string, options: {
  70831. lines: Vector3[][];
  70832. updatable?: boolean;
  70833. instance?: Nullable<LinesMesh>;
  70834. colors?: Nullable<Color4[][]>;
  70835. useVertexAlpha?: boolean;
  70836. }, scene: Nullable<Scene>): LinesMesh;
  70837. /**
  70838. * Creates a line mesh
  70839. * 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
  70840. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70841. * * The parameter `points` is an array successive Vector3
  70842. * * 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
  70843. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70844. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70845. * * When updating an instance, remember that only point positions can change, not the number of points
  70846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70847. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70848. * @param name defines the name of the new line system
  70849. * @param options defines the options used to create the line system
  70850. * @param scene defines the hosting scene
  70851. * @returns a new line mesh
  70852. */
  70853. static CreateLines(name: string, options: {
  70854. points: Vector3[];
  70855. updatable?: boolean;
  70856. instance?: Nullable<LinesMesh>;
  70857. colors?: Color4[];
  70858. useVertexAlpha?: boolean;
  70859. }, scene?: Nullable<Scene>): LinesMesh;
  70860. /**
  70861. * Creates a dashed line mesh
  70862. * * 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
  70863. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70864. * * The parameter `points` is an array successive Vector3
  70865. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70866. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70867. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70868. * * 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
  70869. * * When updating an instance, remember that only point positions can change, not the number of points
  70870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70871. * @param name defines the name of the mesh
  70872. * @param options defines the options used to create the mesh
  70873. * @param scene defines the hosting scene
  70874. * @returns the dashed line mesh
  70875. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70876. */
  70877. static CreateDashedLines(name: string, options: {
  70878. points: Vector3[];
  70879. dashSize?: number;
  70880. gapSize?: number;
  70881. dashNb?: number;
  70882. updatable?: boolean;
  70883. instance?: LinesMesh;
  70884. }, scene?: Nullable<Scene>): LinesMesh;
  70885. /**
  70886. * 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.
  70887. * * 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.
  70888. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70889. * * 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.
  70890. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70891. * * 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
  70892. * * 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
  70893. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70894. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70895. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70896. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70898. * @param name defines the name of the mesh
  70899. * @param options defines the options used to create the mesh
  70900. * @param scene defines the hosting scene
  70901. * @returns the extruded shape mesh
  70902. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70903. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70904. */
  70905. static ExtrudeShape(name: string, options: {
  70906. shape: Vector3[];
  70907. path: Vector3[];
  70908. scale?: number;
  70909. rotation?: number;
  70910. cap?: number;
  70911. updatable?: boolean;
  70912. sideOrientation?: number;
  70913. frontUVs?: Vector4;
  70914. backUVs?: Vector4;
  70915. instance?: Mesh;
  70916. invertUV?: boolean;
  70917. }, scene?: Nullable<Scene>): Mesh;
  70918. /**
  70919. * Creates an custom extruded shape mesh.
  70920. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70921. * * 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.
  70922. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70923. * * 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
  70924. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70925. * * 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
  70926. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70927. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70928. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70929. * * 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
  70930. * * 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
  70931. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70933. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70934. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70936. * @param name defines the name of the mesh
  70937. * @param options defines the options used to create the mesh
  70938. * @param scene defines the hosting scene
  70939. * @returns the custom extruded shape mesh
  70940. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70941. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70942. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70943. */
  70944. static ExtrudeShapeCustom(name: string, options: {
  70945. shape: Vector3[];
  70946. path: Vector3[];
  70947. scaleFunction?: any;
  70948. rotationFunction?: any;
  70949. ribbonCloseArray?: boolean;
  70950. ribbonClosePath?: boolean;
  70951. cap?: number;
  70952. updatable?: boolean;
  70953. sideOrientation?: number;
  70954. frontUVs?: Vector4;
  70955. backUVs?: Vector4;
  70956. instance?: Mesh;
  70957. invertUV?: boolean;
  70958. }, scene?: Nullable<Scene>): Mesh;
  70959. /**
  70960. * Creates lathe mesh.
  70961. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70962. * * 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
  70963. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70964. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70965. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70966. * * 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
  70967. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70968. * * 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
  70969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70970. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70971. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70973. * @param name defines the name of the mesh
  70974. * @param options defines the options used to create the mesh
  70975. * @param scene defines the hosting scene
  70976. * @returns the lathe mesh
  70977. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70978. */
  70979. static CreateLathe(name: string, options: {
  70980. shape: Vector3[];
  70981. radius?: number;
  70982. tessellation?: number;
  70983. clip?: number;
  70984. arc?: number;
  70985. closed?: boolean;
  70986. updatable?: boolean;
  70987. sideOrientation?: number;
  70988. frontUVs?: Vector4;
  70989. backUVs?: Vector4;
  70990. cap?: number;
  70991. invertUV?: boolean;
  70992. }, scene?: Nullable<Scene>): Mesh;
  70993. /**
  70994. * Creates a tiled plane mesh
  70995. * * You can set a limited pattern arrangement with the tiles
  70996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70997. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70999. * @param name defines the name of the mesh
  71000. * @param options defines the options used to create the mesh
  71001. * @param scene defines the hosting scene
  71002. * @returns the plane mesh
  71003. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  71004. */
  71005. static CreateTiledPlane(name: string, options: {
  71006. pattern?: number;
  71007. tileSize?: number;
  71008. tileWidth?: number;
  71009. tileHeight?: number;
  71010. size?: number;
  71011. width?: number;
  71012. height?: number;
  71013. alignHorizontal?: number;
  71014. alignVertical?: number;
  71015. sideOrientation?: number;
  71016. frontUVs?: Vector4;
  71017. backUVs?: Vector4;
  71018. updatable?: boolean;
  71019. }, scene?: Nullable<Scene>): Mesh;
  71020. /**
  71021. * Creates a plane mesh
  71022. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  71023. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  71024. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  71025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71026. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71028. * @param name defines the name of the mesh
  71029. * @param options defines the options used to create the mesh
  71030. * @param scene defines the hosting scene
  71031. * @returns the plane mesh
  71032. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  71033. */
  71034. static CreatePlane(name: string, options: {
  71035. size?: number;
  71036. width?: number;
  71037. height?: number;
  71038. sideOrientation?: number;
  71039. frontUVs?: Vector4;
  71040. backUVs?: Vector4;
  71041. updatable?: boolean;
  71042. sourcePlane?: Plane;
  71043. }, scene?: Nullable<Scene>): Mesh;
  71044. /**
  71045. * Creates a ground mesh
  71046. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  71047. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  71048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71049. * @param name defines the name of the mesh
  71050. * @param options defines the options used to create the mesh
  71051. * @param scene defines the hosting scene
  71052. * @returns the ground mesh
  71053. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  71054. */
  71055. static CreateGround(name: string, options: {
  71056. width?: number;
  71057. height?: number;
  71058. subdivisions?: number;
  71059. subdivisionsX?: number;
  71060. subdivisionsY?: number;
  71061. updatable?: boolean;
  71062. }, scene?: Nullable<Scene>): Mesh;
  71063. /**
  71064. * Creates a tiled ground mesh
  71065. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  71066. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  71067. * * 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
  71068. * * 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
  71069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71070. * @param name defines the name of the mesh
  71071. * @param options defines the options used to create the mesh
  71072. * @param scene defines the hosting scene
  71073. * @returns the tiled ground mesh
  71074. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  71075. */
  71076. static CreateTiledGround(name: string, options: {
  71077. xmin: number;
  71078. zmin: number;
  71079. xmax: number;
  71080. zmax: number;
  71081. subdivisions?: {
  71082. w: number;
  71083. h: number;
  71084. };
  71085. precision?: {
  71086. w: number;
  71087. h: number;
  71088. };
  71089. updatable?: boolean;
  71090. }, scene?: Nullable<Scene>): Mesh;
  71091. /**
  71092. * Creates a ground mesh from a height map
  71093. * * The parameter `url` sets the URL of the height map image resource.
  71094. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  71095. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  71096. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  71097. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  71098. * * 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.
  71099. * * 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).
  71100. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  71101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71102. * @param name defines the name of the mesh
  71103. * @param url defines the url to the height map
  71104. * @param options defines the options used to create the mesh
  71105. * @param scene defines the hosting scene
  71106. * @returns the ground mesh
  71107. * @see https://doc.babylonjs.com/babylon101/height_map
  71108. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  71109. */
  71110. static CreateGroundFromHeightMap(name: string, url: string, options: {
  71111. width?: number;
  71112. height?: number;
  71113. subdivisions?: number;
  71114. minHeight?: number;
  71115. maxHeight?: number;
  71116. colorFilter?: Color3;
  71117. alphaFilter?: number;
  71118. updatable?: boolean;
  71119. onReady?: (mesh: GroundMesh) => void;
  71120. }, scene?: Nullable<Scene>): GroundMesh;
  71121. /**
  71122. * Creates a polygon mesh
  71123. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  71124. * * 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
  71125. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  71126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71127. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  71128. * * Remember you can only change the shape positions, not their number when updating a polygon
  71129. * @param name defines the name of the mesh
  71130. * @param options defines the options used to create the mesh
  71131. * @param scene defines the hosting scene
  71132. * @param earcutInjection can be used to inject your own earcut reference
  71133. * @returns the polygon mesh
  71134. */
  71135. static CreatePolygon(name: string, options: {
  71136. shape: Vector3[];
  71137. holes?: Vector3[][];
  71138. depth?: number;
  71139. faceUV?: Vector4[];
  71140. faceColors?: Color4[];
  71141. updatable?: boolean;
  71142. sideOrientation?: number;
  71143. frontUVs?: Vector4;
  71144. backUVs?: Vector4;
  71145. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71146. /**
  71147. * Creates an extruded polygon mesh, with depth in the Y direction.
  71148. * * 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)
  71149. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  71150. * @param name defines the name of the mesh
  71151. * @param options defines the options used to create the mesh
  71152. * @param scene defines the hosting scene
  71153. * @param earcutInjection can be used to inject your own earcut reference
  71154. * @returns the polygon mesh
  71155. */
  71156. static ExtrudePolygon(name: string, options: {
  71157. shape: Vector3[];
  71158. holes?: Vector3[][];
  71159. depth?: number;
  71160. faceUV?: Vector4[];
  71161. faceColors?: Color4[];
  71162. updatable?: boolean;
  71163. sideOrientation?: number;
  71164. frontUVs?: Vector4;
  71165. backUVs?: Vector4;
  71166. wrap?: boolean;
  71167. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71168. /**
  71169. * Creates a tube mesh.
  71170. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  71171. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  71172. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  71173. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  71174. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  71175. * * 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)
  71176. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  71177. * * 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
  71178. * * 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
  71179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71180. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71181. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71183. * @param name defines the name of the mesh
  71184. * @param options defines the options used to create the mesh
  71185. * @param scene defines the hosting scene
  71186. * @returns the tube mesh
  71187. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71188. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  71189. */
  71190. static CreateTube(name: string, options: {
  71191. path: Vector3[];
  71192. radius?: number;
  71193. tessellation?: number;
  71194. radiusFunction?: {
  71195. (i: number, distance: number): number;
  71196. };
  71197. cap?: number;
  71198. arc?: number;
  71199. updatable?: boolean;
  71200. sideOrientation?: number;
  71201. frontUVs?: Vector4;
  71202. backUVs?: Vector4;
  71203. instance?: Mesh;
  71204. invertUV?: boolean;
  71205. }, scene?: Nullable<Scene>): Mesh;
  71206. /**
  71207. * Creates a polyhedron mesh
  71208. * * 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
  71209. * * The parameter `size` (positive float, default 1) sets the polygon size
  71210. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  71211. * * 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`
  71212. * * 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
  71213. * * 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)`)
  71214. * * 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
  71215. * * 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
  71216. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71217. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71219. * @param name defines the name of the mesh
  71220. * @param options defines the options used to create the mesh
  71221. * @param scene defines the hosting scene
  71222. * @returns the polyhedron mesh
  71223. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  71224. */
  71225. static CreatePolyhedron(name: string, options: {
  71226. type?: number;
  71227. size?: number;
  71228. sizeX?: number;
  71229. sizeY?: number;
  71230. sizeZ?: number;
  71231. custom?: any;
  71232. faceUV?: Vector4[];
  71233. faceColors?: Color4[];
  71234. flat?: boolean;
  71235. updatable?: boolean;
  71236. sideOrientation?: number;
  71237. frontUVs?: Vector4;
  71238. backUVs?: Vector4;
  71239. }, scene?: Nullable<Scene>): Mesh;
  71240. /**
  71241. * Creates a decal mesh.
  71242. * 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
  71243. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  71244. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  71245. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  71246. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  71247. * @param name defines the name of the mesh
  71248. * @param sourceMesh defines the mesh where the decal must be applied
  71249. * @param options defines the options used to create the mesh
  71250. * @param scene defines the hosting scene
  71251. * @returns the decal mesh
  71252. * @see https://doc.babylonjs.com/how_to/decals
  71253. */
  71254. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  71255. position?: Vector3;
  71256. normal?: Vector3;
  71257. size?: Vector3;
  71258. angle?: number;
  71259. }): Mesh;
  71260. /**
  71261. * Creates a Capsule Mesh
  71262. * @param name defines the name of the mesh.
  71263. * @param options the constructors options used to shape the mesh.
  71264. * @param scene defines the scene the mesh is scoped to.
  71265. * @returns the capsule mesh
  71266. * @see https://doc.babylonjs.com/how_to/capsule_shape
  71267. */
  71268. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  71269. }
  71270. }
  71271. declare module "babylonjs/Meshes/meshSimplification" {
  71272. import { Mesh } from "babylonjs/Meshes/mesh";
  71273. /**
  71274. * A simplifier interface for future simplification implementations
  71275. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71276. */
  71277. export interface ISimplifier {
  71278. /**
  71279. * Simplification of a given mesh according to the given settings.
  71280. * Since this requires computation, it is assumed that the function runs async.
  71281. * @param settings The settings of the simplification, including quality and distance
  71282. * @param successCallback A callback that will be called after the mesh was simplified.
  71283. * @param errorCallback in case of an error, this callback will be called. optional.
  71284. */
  71285. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  71286. }
  71287. /**
  71288. * Expected simplification settings.
  71289. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  71290. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71291. */
  71292. export interface ISimplificationSettings {
  71293. /**
  71294. * Gets or sets the expected quality
  71295. */
  71296. quality: number;
  71297. /**
  71298. * Gets or sets the distance when this optimized version should be used
  71299. */
  71300. distance: number;
  71301. /**
  71302. * Gets an already optimized mesh
  71303. */
  71304. optimizeMesh?: boolean;
  71305. }
  71306. /**
  71307. * Class used to specify simplification options
  71308. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71309. */
  71310. export class SimplificationSettings implements ISimplificationSettings {
  71311. /** expected quality */
  71312. quality: number;
  71313. /** distance when this optimized version should be used */
  71314. distance: number;
  71315. /** already optimized mesh */
  71316. optimizeMesh?: boolean | undefined;
  71317. /**
  71318. * Creates a SimplificationSettings
  71319. * @param quality expected quality
  71320. * @param distance distance when this optimized version should be used
  71321. * @param optimizeMesh already optimized mesh
  71322. */
  71323. constructor(
  71324. /** expected quality */
  71325. quality: number,
  71326. /** distance when this optimized version should be used */
  71327. distance: number,
  71328. /** already optimized mesh */
  71329. optimizeMesh?: boolean | undefined);
  71330. }
  71331. /**
  71332. * Interface used to define a simplification task
  71333. */
  71334. export interface ISimplificationTask {
  71335. /**
  71336. * Array of settings
  71337. */
  71338. settings: Array<ISimplificationSettings>;
  71339. /**
  71340. * Simplification type
  71341. */
  71342. simplificationType: SimplificationType;
  71343. /**
  71344. * Mesh to simplify
  71345. */
  71346. mesh: Mesh;
  71347. /**
  71348. * Callback called on success
  71349. */
  71350. successCallback?: () => void;
  71351. /**
  71352. * Defines if parallel processing can be used
  71353. */
  71354. parallelProcessing: boolean;
  71355. }
  71356. /**
  71357. * Queue used to order the simplification tasks
  71358. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71359. */
  71360. export class SimplificationQueue {
  71361. private _simplificationArray;
  71362. /**
  71363. * Gets a boolean indicating that the process is still running
  71364. */
  71365. running: boolean;
  71366. /**
  71367. * Creates a new queue
  71368. */
  71369. constructor();
  71370. /**
  71371. * Adds a new simplification task
  71372. * @param task defines a task to add
  71373. */
  71374. addTask(task: ISimplificationTask): void;
  71375. /**
  71376. * Execute next task
  71377. */
  71378. executeNext(): void;
  71379. /**
  71380. * Execute a simplification task
  71381. * @param task defines the task to run
  71382. */
  71383. runSimplification(task: ISimplificationTask): void;
  71384. private getSimplifier;
  71385. }
  71386. /**
  71387. * The implemented types of simplification
  71388. * At the moment only Quadratic Error Decimation is implemented
  71389. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71390. */
  71391. export enum SimplificationType {
  71392. /** Quadratic error decimation */
  71393. QUADRATIC = 0
  71394. }
  71395. /**
  71396. * An implementation of the Quadratic Error simplification algorithm.
  71397. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  71398. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  71399. * @author RaananW
  71400. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71401. */
  71402. export class QuadraticErrorSimplification implements ISimplifier {
  71403. private _mesh;
  71404. private triangles;
  71405. private vertices;
  71406. private references;
  71407. private _reconstructedMesh;
  71408. /** Gets or sets the number pf sync interations */
  71409. syncIterations: number;
  71410. /** Gets or sets the aggressiveness of the simplifier */
  71411. aggressiveness: number;
  71412. /** Gets or sets the number of allowed iterations for decimation */
  71413. decimationIterations: number;
  71414. /** Gets or sets the espilon to use for bounding box computation */
  71415. boundingBoxEpsilon: number;
  71416. /**
  71417. * Creates a new QuadraticErrorSimplification
  71418. * @param _mesh defines the target mesh
  71419. */
  71420. constructor(_mesh: Mesh);
  71421. /**
  71422. * Simplification of a given mesh according to the given settings.
  71423. * Since this requires computation, it is assumed that the function runs async.
  71424. * @param settings The settings of the simplification, including quality and distance
  71425. * @param successCallback A callback that will be called after the mesh was simplified.
  71426. */
  71427. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  71428. private runDecimation;
  71429. private initWithMesh;
  71430. private init;
  71431. private reconstructMesh;
  71432. private initDecimatedMesh;
  71433. private isFlipped;
  71434. private updateTriangles;
  71435. private identifyBorder;
  71436. private updateMesh;
  71437. private vertexError;
  71438. private calculateError;
  71439. }
  71440. }
  71441. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  71442. import { Scene } from "babylonjs/scene";
  71443. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  71444. import { ISceneComponent } from "babylonjs/sceneComponent";
  71445. module "babylonjs/scene" {
  71446. interface Scene {
  71447. /** @hidden (Backing field) */
  71448. _simplificationQueue: SimplificationQueue;
  71449. /**
  71450. * Gets or sets the simplification queue attached to the scene
  71451. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71452. */
  71453. simplificationQueue: SimplificationQueue;
  71454. }
  71455. }
  71456. module "babylonjs/Meshes/mesh" {
  71457. interface Mesh {
  71458. /**
  71459. * Simplify the mesh according to the given array of settings.
  71460. * Function will return immediately and will simplify async
  71461. * @param settings a collection of simplification settings
  71462. * @param parallelProcessing should all levels calculate parallel or one after the other
  71463. * @param simplificationType the type of simplification to run
  71464. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  71465. * @returns the current mesh
  71466. */
  71467. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  71468. }
  71469. }
  71470. /**
  71471. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  71472. * created in a scene
  71473. */
  71474. export class SimplicationQueueSceneComponent implements ISceneComponent {
  71475. /**
  71476. * The component name helpfull to identify the component in the list of scene components.
  71477. */
  71478. readonly name: string;
  71479. /**
  71480. * The scene the component belongs to.
  71481. */
  71482. scene: Scene;
  71483. /**
  71484. * Creates a new instance of the component for the given scene
  71485. * @param scene Defines the scene to register the component in
  71486. */
  71487. constructor(scene: Scene);
  71488. /**
  71489. * Registers the component in a given scene
  71490. */
  71491. register(): void;
  71492. /**
  71493. * Rebuilds the elements related to this component in case of
  71494. * context lost for instance.
  71495. */
  71496. rebuild(): void;
  71497. /**
  71498. * Disposes the component and the associated ressources
  71499. */
  71500. dispose(): void;
  71501. private _beforeCameraUpdate;
  71502. }
  71503. }
  71504. declare module "babylonjs/Meshes/Builders/index" {
  71505. export * from "babylonjs/Meshes/Builders/boxBuilder";
  71506. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  71507. export * from "babylonjs/Meshes/Builders/discBuilder";
  71508. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  71509. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  71510. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  71511. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  71512. export * from "babylonjs/Meshes/Builders/torusBuilder";
  71513. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  71514. export * from "babylonjs/Meshes/Builders/linesBuilder";
  71515. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  71516. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  71517. export * from "babylonjs/Meshes/Builders/latheBuilder";
  71518. export * from "babylonjs/Meshes/Builders/planeBuilder";
  71519. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  71520. export * from "babylonjs/Meshes/Builders/groundBuilder";
  71521. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  71522. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  71523. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  71524. export * from "babylonjs/Meshes/Builders/decalBuilder";
  71525. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  71526. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  71527. }
  71528. declare module "babylonjs/Meshes/thinInstanceMesh" {
  71529. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  71530. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  71531. import { Matrix } from "babylonjs/Maths/math.vector";
  71532. module "babylonjs/Meshes/mesh" {
  71533. interface Mesh {
  71534. /**
  71535. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71536. */
  71537. thinInstanceEnablePicking: boolean;
  71538. /**
  71539. * Creates a new thin instance
  71540. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71541. * @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
  71542. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71543. */
  71544. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  71545. /**
  71546. * Adds the transformation (matrix) of the current mesh as a thin instance
  71547. * @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
  71548. * @returns the thin instance index number
  71549. */
  71550. thinInstanceAddSelf(refresh: boolean): number;
  71551. /**
  71552. * Registers a custom attribute to be used with thin instances
  71553. * @param kind name of the attribute
  71554. * @param stride size in floats of the attribute
  71555. */
  71556. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71557. /**
  71558. * Sets the matrix of a thin instance
  71559. * @param index index of the thin instance
  71560. * @param matrix matrix to set
  71561. * @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
  71562. */
  71563. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  71564. /**
  71565. * Sets the value of a custom attribute for a thin instance
  71566. * @param kind name of the attribute
  71567. * @param index index of the thin instance
  71568. * @param value value to set
  71569. * @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
  71570. */
  71571. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71572. /**
  71573. * 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.
  71574. */
  71575. thinInstanceCount: number;
  71576. /**
  71577. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71578. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71579. * @param buffer buffer to set
  71580. * @param stride size in floats of each value of the buffer
  71581. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71582. */
  71583. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71584. /**
  71585. * Gets the list of world matrices
  71586. * @return an array containing all the world matrices from the thin instances
  71587. */
  71588. thinInstanceGetWorldMatrices(): Matrix[];
  71589. /**
  71590. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71591. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71592. */
  71593. thinInstanceBufferUpdated(kind: string): void;
  71594. /**
  71595. * Applies a partial update to a buffer directly on the GPU
  71596. * 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
  71597. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71598. * @param data the data to set in the GPU buffer
  71599. * @param offset the offset in the GPU buffer where to update the data
  71600. */
  71601. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71602. /**
  71603. * Refreshes the bounding info, taking into account all the thin instances defined
  71604. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71605. */
  71606. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71607. /** @hidden */
  71608. _thinInstanceInitializeUserStorage(): void;
  71609. /** @hidden */
  71610. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71611. /** @hidden */
  71612. _userThinInstanceBuffersStorage: {
  71613. data: {
  71614. [key: string]: Float32Array;
  71615. };
  71616. sizes: {
  71617. [key: string]: number;
  71618. };
  71619. vertexBuffers: {
  71620. [key: string]: Nullable<VertexBuffer>;
  71621. };
  71622. strides: {
  71623. [key: string]: number;
  71624. };
  71625. };
  71626. }
  71627. }
  71628. }
  71629. declare module "babylonjs/Meshes/index" {
  71630. export * from "babylonjs/Meshes/abstractMesh";
  71631. export * from "babylonjs/Meshes/buffer";
  71632. export * from "babylonjs/Meshes/Compression/index";
  71633. export * from "babylonjs/Meshes/csg";
  71634. export * from "babylonjs/Meshes/geometry";
  71635. export * from "babylonjs/Meshes/groundMesh";
  71636. export * from "babylonjs/Meshes/trailMesh";
  71637. export * from "babylonjs/Meshes/instancedMesh";
  71638. export * from "babylonjs/Meshes/linesMesh";
  71639. export * from "babylonjs/Meshes/mesh";
  71640. export * from "babylonjs/Meshes/mesh.vertexData";
  71641. export * from "babylonjs/Meshes/meshBuilder";
  71642. export * from "babylonjs/Meshes/meshSimplification";
  71643. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  71644. export * from "babylonjs/Meshes/polygonMesh";
  71645. export * from "babylonjs/Meshes/subMesh";
  71646. export * from "babylonjs/Meshes/meshLODLevel";
  71647. export * from "babylonjs/Meshes/transformNode";
  71648. export * from "babylonjs/Meshes/Builders/index";
  71649. export * from "babylonjs/Meshes/dataBuffer";
  71650. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  71651. import "babylonjs/Meshes/thinInstanceMesh";
  71652. export * from "babylonjs/Meshes/thinInstanceMesh";
  71653. }
  71654. declare module "babylonjs/Morph/index" {
  71655. export * from "babylonjs/Morph/morphTarget";
  71656. export * from "babylonjs/Morph/morphTargetManager";
  71657. }
  71658. declare module "babylonjs/Navigation/INavigationEngine" {
  71659. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71660. import { Vector3 } from "babylonjs/Maths/math";
  71661. import { Mesh } from "babylonjs/Meshes/mesh";
  71662. import { Scene } from "babylonjs/scene";
  71663. /**
  71664. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71665. */
  71666. export interface INavigationEnginePlugin {
  71667. /**
  71668. * plugin name
  71669. */
  71670. name: string;
  71671. /**
  71672. * Creates a navigation mesh
  71673. * @param meshes array of all the geometry used to compute the navigatio mesh
  71674. * @param parameters bunch of parameters used to filter geometry
  71675. */
  71676. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71677. /**
  71678. * Create a navigation mesh debug mesh
  71679. * @param scene is where the mesh will be added
  71680. * @returns debug display mesh
  71681. */
  71682. createDebugNavMesh(scene: Scene): Mesh;
  71683. /**
  71684. * Get a navigation mesh constrained position, closest to the parameter position
  71685. * @param position world position
  71686. * @returns the closest point to position constrained by the navigation mesh
  71687. */
  71688. getClosestPoint(position: Vector3): Vector3;
  71689. /**
  71690. * Get a navigation mesh constrained position, closest to the parameter position
  71691. * @param position world position
  71692. * @param result output the closest point to position constrained by the navigation mesh
  71693. */
  71694. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71695. /**
  71696. * Get a navigation mesh constrained position, within a particular radius
  71697. * @param position world position
  71698. * @param maxRadius the maximum distance to the constrained world position
  71699. * @returns the closest point to position constrained by the navigation mesh
  71700. */
  71701. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71702. /**
  71703. * Get a navigation mesh constrained position, within a particular radius
  71704. * @param position world position
  71705. * @param maxRadius the maximum distance to the constrained world position
  71706. * @param result output the closest point to position constrained by the navigation mesh
  71707. */
  71708. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71709. /**
  71710. * Compute the final position from a segment made of destination-position
  71711. * @param position world position
  71712. * @param destination world position
  71713. * @returns the resulting point along the navmesh
  71714. */
  71715. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71716. /**
  71717. * Compute the final position from a segment made of destination-position
  71718. * @param position world position
  71719. * @param destination world position
  71720. * @param result output the resulting point along the navmesh
  71721. */
  71722. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71723. /**
  71724. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71725. * @param start world position
  71726. * @param end world position
  71727. * @returns array containing world position composing the path
  71728. */
  71729. computePath(start: Vector3, end: Vector3): Vector3[];
  71730. /**
  71731. * If this plugin is supported
  71732. * @returns true if plugin is supported
  71733. */
  71734. isSupported(): boolean;
  71735. /**
  71736. * Create a new Crowd so you can add agents
  71737. * @param maxAgents the maximum agent count in the crowd
  71738. * @param maxAgentRadius the maximum radius an agent can have
  71739. * @param scene to attach the crowd to
  71740. * @returns the crowd you can add agents to
  71741. */
  71742. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71743. /**
  71744. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71745. * The queries will try to find a solution within those bounds
  71746. * default is (1,1,1)
  71747. * @param extent x,y,z value that define the extent around the queries point of reference
  71748. */
  71749. setDefaultQueryExtent(extent: Vector3): void;
  71750. /**
  71751. * Get the Bounding box extent specified by setDefaultQueryExtent
  71752. * @returns the box extent values
  71753. */
  71754. getDefaultQueryExtent(): Vector3;
  71755. /**
  71756. * build the navmesh from a previously saved state using getNavmeshData
  71757. * @param data the Uint8Array returned by getNavmeshData
  71758. */
  71759. buildFromNavmeshData(data: Uint8Array): void;
  71760. /**
  71761. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71762. * @returns data the Uint8Array that can be saved and reused
  71763. */
  71764. getNavmeshData(): Uint8Array;
  71765. /**
  71766. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71767. * @param result output the box extent values
  71768. */
  71769. getDefaultQueryExtentToRef(result: Vector3): void;
  71770. /**
  71771. * Release all resources
  71772. */
  71773. dispose(): void;
  71774. }
  71775. /**
  71776. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71777. */
  71778. export interface ICrowd {
  71779. /**
  71780. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71781. * You can attach anything to that node. The node position is updated in the scene update tick.
  71782. * @param pos world position that will be constrained by the navigation mesh
  71783. * @param parameters agent parameters
  71784. * @param transform hooked to the agent that will be update by the scene
  71785. * @returns agent index
  71786. */
  71787. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71788. /**
  71789. * Returns the agent position in world space
  71790. * @param index agent index returned by addAgent
  71791. * @returns world space position
  71792. */
  71793. getAgentPosition(index: number): Vector3;
  71794. /**
  71795. * Gets the agent position result in world space
  71796. * @param index agent index returned by addAgent
  71797. * @param result output world space position
  71798. */
  71799. getAgentPositionToRef(index: number, result: Vector3): void;
  71800. /**
  71801. * Gets the agent velocity in world space
  71802. * @param index agent index returned by addAgent
  71803. * @returns world space velocity
  71804. */
  71805. getAgentVelocity(index: number): Vector3;
  71806. /**
  71807. * Gets the agent velocity result in world space
  71808. * @param index agent index returned by addAgent
  71809. * @param result output world space velocity
  71810. */
  71811. getAgentVelocityToRef(index: number, result: Vector3): void;
  71812. /**
  71813. * Gets the agent next target point on the path
  71814. * @param index agent index returned by addAgent
  71815. * @returns world space position
  71816. */
  71817. getAgentNextTargetPath(index: number): Vector3;
  71818. /**
  71819. * Gets the agent state
  71820. * @param index agent index returned by addAgent
  71821. * @returns agent state
  71822. */
  71823. getAgentState(index: number): number;
  71824. /**
  71825. * returns true if the agent in over an off mesh link connection
  71826. * @param index agent index returned by addAgent
  71827. * @returns true if over an off mesh link connection
  71828. */
  71829. overOffmeshConnection(index: number): boolean;
  71830. /**
  71831. * Gets the agent next target point on the path
  71832. * @param index agent index returned by addAgent
  71833. * @param result output world space position
  71834. */
  71835. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71836. /**
  71837. * remove a particular agent previously created
  71838. * @param index agent index returned by addAgent
  71839. */
  71840. removeAgent(index: number): void;
  71841. /**
  71842. * get the list of all agents attached to this crowd
  71843. * @returns list of agent indices
  71844. */
  71845. getAgents(): number[];
  71846. /**
  71847. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71848. * @param deltaTime in seconds
  71849. */
  71850. update(deltaTime: number): void;
  71851. /**
  71852. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71853. * @param index agent index returned by addAgent
  71854. * @param destination targeted world position
  71855. */
  71856. agentGoto(index: number, destination: Vector3): void;
  71857. /**
  71858. * Teleport the agent to a new position
  71859. * @param index agent index returned by addAgent
  71860. * @param destination targeted world position
  71861. */
  71862. agentTeleport(index: number, destination: Vector3): void;
  71863. /**
  71864. * Update agent parameters
  71865. * @param index agent index returned by addAgent
  71866. * @param parameters agent parameters
  71867. */
  71868. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71869. /**
  71870. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71871. * The queries will try to find a solution within those bounds
  71872. * default is (1,1,1)
  71873. * @param extent x,y,z value that define the extent around the queries point of reference
  71874. */
  71875. setDefaultQueryExtent(extent: Vector3): void;
  71876. /**
  71877. * Get the Bounding box extent specified by setDefaultQueryExtent
  71878. * @returns the box extent values
  71879. */
  71880. getDefaultQueryExtent(): Vector3;
  71881. /**
  71882. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71883. * @param result output the box extent values
  71884. */
  71885. getDefaultQueryExtentToRef(result: Vector3): void;
  71886. /**
  71887. * Release all resources
  71888. */
  71889. dispose(): void;
  71890. }
  71891. /**
  71892. * Configures an agent
  71893. */
  71894. export interface IAgentParameters {
  71895. /**
  71896. * Agent radius. [Limit: >= 0]
  71897. */
  71898. radius: number;
  71899. /**
  71900. * Agent height. [Limit: > 0]
  71901. */
  71902. height: number;
  71903. /**
  71904. * Maximum allowed acceleration. [Limit: >= 0]
  71905. */
  71906. maxAcceleration: number;
  71907. /**
  71908. * Maximum allowed speed. [Limit: >= 0]
  71909. */
  71910. maxSpeed: number;
  71911. /**
  71912. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71913. */
  71914. collisionQueryRange: number;
  71915. /**
  71916. * The path visibility optimization range. [Limit: > 0]
  71917. */
  71918. pathOptimizationRange: number;
  71919. /**
  71920. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71921. */
  71922. separationWeight: number;
  71923. }
  71924. /**
  71925. * Configures the navigation mesh creation
  71926. */
  71927. export interface INavMeshParameters {
  71928. /**
  71929. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71930. */
  71931. cs: number;
  71932. /**
  71933. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71934. */
  71935. ch: number;
  71936. /**
  71937. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71938. */
  71939. walkableSlopeAngle: number;
  71940. /**
  71941. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71942. * be considered walkable. [Limit: >= 3] [Units: vx]
  71943. */
  71944. walkableHeight: number;
  71945. /**
  71946. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71947. */
  71948. walkableClimb: number;
  71949. /**
  71950. * The distance to erode/shrink the walkable area of the heightfield away from
  71951. * obstructions. [Limit: >=0] [Units: vx]
  71952. */
  71953. walkableRadius: number;
  71954. /**
  71955. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71956. */
  71957. maxEdgeLen: number;
  71958. /**
  71959. * The maximum distance a simplfied contour's border edges should deviate
  71960. * the original raw contour. [Limit: >=0] [Units: vx]
  71961. */
  71962. maxSimplificationError: number;
  71963. /**
  71964. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71965. */
  71966. minRegionArea: number;
  71967. /**
  71968. * Any regions with a span count smaller than this value will, if possible,
  71969. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71970. */
  71971. mergeRegionArea: number;
  71972. /**
  71973. * The maximum number of vertices allowed for polygons generated during the
  71974. * contour to polygon conversion process. [Limit: >= 3]
  71975. */
  71976. maxVertsPerPoly: number;
  71977. /**
  71978. * Sets the sampling distance to use when generating the detail mesh.
  71979. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71980. */
  71981. detailSampleDist: number;
  71982. /**
  71983. * The maximum distance the detail mesh surface should deviate from heightfield
  71984. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71985. */
  71986. detailSampleMaxError: number;
  71987. }
  71988. }
  71989. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  71990. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  71991. import { Mesh } from "babylonjs/Meshes/mesh";
  71992. import { Scene } from "babylonjs/scene";
  71993. import { Vector3 } from "babylonjs/Maths/math";
  71994. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71995. /**
  71996. * RecastJS navigation plugin
  71997. */
  71998. export class RecastJSPlugin implements INavigationEnginePlugin {
  71999. /**
  72000. * Reference to the Recast library
  72001. */
  72002. bjsRECAST: any;
  72003. /**
  72004. * plugin name
  72005. */
  72006. name: string;
  72007. /**
  72008. * the first navmesh created. We might extend this to support multiple navmeshes
  72009. */
  72010. navMesh: any;
  72011. /**
  72012. * Initializes the recastJS plugin
  72013. * @param recastInjection can be used to inject your own recast reference
  72014. */
  72015. constructor(recastInjection?: any);
  72016. /**
  72017. * Creates a navigation mesh
  72018. * @param meshes array of all the geometry used to compute the navigatio mesh
  72019. * @param parameters bunch of parameters used to filter geometry
  72020. */
  72021. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  72022. /**
  72023. * Create a navigation mesh debug mesh
  72024. * @param scene is where the mesh will be added
  72025. * @returns debug display mesh
  72026. */
  72027. createDebugNavMesh(scene: Scene): Mesh;
  72028. /**
  72029. * Get a navigation mesh constrained position, closest to the parameter position
  72030. * @param position world position
  72031. * @returns the closest point to position constrained by the navigation mesh
  72032. */
  72033. getClosestPoint(position: Vector3): Vector3;
  72034. /**
  72035. * Get a navigation mesh constrained position, closest to the parameter position
  72036. * @param position world position
  72037. * @param result output the closest point to position constrained by the navigation mesh
  72038. */
  72039. getClosestPointToRef(position: Vector3, result: Vector3): void;
  72040. /**
  72041. * Get a navigation mesh constrained position, within a particular radius
  72042. * @param position world position
  72043. * @param maxRadius the maximum distance to the constrained world position
  72044. * @returns the closest point to position constrained by the navigation mesh
  72045. */
  72046. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  72047. /**
  72048. * Get a navigation mesh constrained position, within a particular radius
  72049. * @param position world position
  72050. * @param maxRadius the maximum distance to the constrained world position
  72051. * @param result output the closest point to position constrained by the navigation mesh
  72052. */
  72053. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  72054. /**
  72055. * Compute the final position from a segment made of destination-position
  72056. * @param position world position
  72057. * @param destination world position
  72058. * @returns the resulting point along the navmesh
  72059. */
  72060. moveAlong(position: Vector3, destination: Vector3): Vector3;
  72061. /**
  72062. * Compute the final position from a segment made of destination-position
  72063. * @param position world position
  72064. * @param destination world position
  72065. * @param result output the resulting point along the navmesh
  72066. */
  72067. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  72068. /**
  72069. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  72070. * @param start world position
  72071. * @param end world position
  72072. * @returns array containing world position composing the path
  72073. */
  72074. computePath(start: Vector3, end: Vector3): Vector3[];
  72075. /**
  72076. * Create a new Crowd so you can add agents
  72077. * @param maxAgents the maximum agent count in the crowd
  72078. * @param maxAgentRadius the maximum radius an agent can have
  72079. * @param scene to attach the crowd to
  72080. * @returns the crowd you can add agents to
  72081. */
  72082. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  72083. /**
  72084. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72085. * The queries will try to find a solution within those bounds
  72086. * default is (1,1,1)
  72087. * @param extent x,y,z value that define the extent around the queries point of reference
  72088. */
  72089. setDefaultQueryExtent(extent: Vector3): void;
  72090. /**
  72091. * Get the Bounding box extent specified by setDefaultQueryExtent
  72092. * @returns the box extent values
  72093. */
  72094. getDefaultQueryExtent(): Vector3;
  72095. /**
  72096. * build the navmesh from a previously saved state using getNavmeshData
  72097. * @param data the Uint8Array returned by getNavmeshData
  72098. */
  72099. buildFromNavmeshData(data: Uint8Array): void;
  72100. /**
  72101. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  72102. * @returns data the Uint8Array that can be saved and reused
  72103. */
  72104. getNavmeshData(): Uint8Array;
  72105. /**
  72106. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72107. * @param result output the box extent values
  72108. */
  72109. getDefaultQueryExtentToRef(result: Vector3): void;
  72110. /**
  72111. * Disposes
  72112. */
  72113. dispose(): void;
  72114. /**
  72115. * If this plugin is supported
  72116. * @returns true if plugin is supported
  72117. */
  72118. isSupported(): boolean;
  72119. }
  72120. /**
  72121. * Recast detour crowd implementation
  72122. */
  72123. export class RecastJSCrowd implements ICrowd {
  72124. /**
  72125. * Recast/detour plugin
  72126. */
  72127. bjsRECASTPlugin: RecastJSPlugin;
  72128. /**
  72129. * Link to the detour crowd
  72130. */
  72131. recastCrowd: any;
  72132. /**
  72133. * One transform per agent
  72134. */
  72135. transforms: TransformNode[];
  72136. /**
  72137. * All agents created
  72138. */
  72139. agents: number[];
  72140. /**
  72141. * Link to the scene is kept to unregister the crowd from the scene
  72142. */
  72143. private _scene;
  72144. /**
  72145. * Observer for crowd updates
  72146. */
  72147. private _onBeforeAnimationsObserver;
  72148. /**
  72149. * Constructor
  72150. * @param plugin recastJS plugin
  72151. * @param maxAgents the maximum agent count in the crowd
  72152. * @param maxAgentRadius the maximum radius an agent can have
  72153. * @param scene to attach the crowd to
  72154. * @returns the crowd you can add agents to
  72155. */
  72156. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  72157. /**
  72158. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  72159. * You can attach anything to that node. The node position is updated in the scene update tick.
  72160. * @param pos world position that will be constrained by the navigation mesh
  72161. * @param parameters agent parameters
  72162. * @param transform hooked to the agent that will be update by the scene
  72163. * @returns agent index
  72164. */
  72165. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  72166. /**
  72167. * Returns the agent position in world space
  72168. * @param index agent index returned by addAgent
  72169. * @returns world space position
  72170. */
  72171. getAgentPosition(index: number): Vector3;
  72172. /**
  72173. * Returns the agent position result in world space
  72174. * @param index agent index returned by addAgent
  72175. * @param result output world space position
  72176. */
  72177. getAgentPositionToRef(index: number, result: Vector3): void;
  72178. /**
  72179. * Returns the agent velocity in world space
  72180. * @param index agent index returned by addAgent
  72181. * @returns world space velocity
  72182. */
  72183. getAgentVelocity(index: number): Vector3;
  72184. /**
  72185. * Returns the agent velocity result in world space
  72186. * @param index agent index returned by addAgent
  72187. * @param result output world space velocity
  72188. */
  72189. getAgentVelocityToRef(index: number, result: Vector3): void;
  72190. /**
  72191. * Returns the agent next target point on the path
  72192. * @param index agent index returned by addAgent
  72193. * @returns world space position
  72194. */
  72195. getAgentNextTargetPath(index: number): Vector3;
  72196. /**
  72197. * Returns the agent next target point on the path
  72198. * @param index agent index returned by addAgent
  72199. * @param result output world space position
  72200. */
  72201. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  72202. /**
  72203. * Gets the agent state
  72204. * @param index agent index returned by addAgent
  72205. * @returns agent state
  72206. */
  72207. getAgentState(index: number): number;
  72208. /**
  72209. * returns true if the agent in over an off mesh link connection
  72210. * @param index agent index returned by addAgent
  72211. * @returns true if over an off mesh link connection
  72212. */
  72213. overOffmeshConnection(index: number): boolean;
  72214. /**
  72215. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  72216. * @param index agent index returned by addAgent
  72217. * @param destination targeted world position
  72218. */
  72219. agentGoto(index: number, destination: Vector3): void;
  72220. /**
  72221. * Teleport the agent to a new position
  72222. * @param index agent index returned by addAgent
  72223. * @param destination targeted world position
  72224. */
  72225. agentTeleport(index: number, destination: Vector3): void;
  72226. /**
  72227. * Update agent parameters
  72228. * @param index agent index returned by addAgent
  72229. * @param parameters agent parameters
  72230. */
  72231. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  72232. /**
  72233. * remove a particular agent previously created
  72234. * @param index agent index returned by addAgent
  72235. */
  72236. removeAgent(index: number): void;
  72237. /**
  72238. * get the list of all agents attached to this crowd
  72239. * @returns list of agent indices
  72240. */
  72241. getAgents(): number[];
  72242. /**
  72243. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  72244. * @param deltaTime in seconds
  72245. */
  72246. update(deltaTime: number): void;
  72247. /**
  72248. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72249. * The queries will try to find a solution within those bounds
  72250. * default is (1,1,1)
  72251. * @param extent x,y,z value that define the extent around the queries point of reference
  72252. */
  72253. setDefaultQueryExtent(extent: Vector3): void;
  72254. /**
  72255. * Get the Bounding box extent specified by setDefaultQueryExtent
  72256. * @returns the box extent values
  72257. */
  72258. getDefaultQueryExtent(): Vector3;
  72259. /**
  72260. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72261. * @param result output the box extent values
  72262. */
  72263. getDefaultQueryExtentToRef(result: Vector3): void;
  72264. /**
  72265. * Release all resources
  72266. */
  72267. dispose(): void;
  72268. }
  72269. }
  72270. declare module "babylonjs/Navigation/Plugins/index" {
  72271. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  72272. }
  72273. declare module "babylonjs/Navigation/index" {
  72274. export * from "babylonjs/Navigation/INavigationEngine";
  72275. export * from "babylonjs/Navigation/Plugins/index";
  72276. }
  72277. declare module "babylonjs/Offline/database" {
  72278. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  72279. /**
  72280. * Class used to enable access to IndexedDB
  72281. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  72282. */
  72283. export class Database implements IOfflineProvider {
  72284. private _callbackManifestChecked;
  72285. private _currentSceneUrl;
  72286. private _db;
  72287. private _enableSceneOffline;
  72288. private _enableTexturesOffline;
  72289. private _manifestVersionFound;
  72290. private _mustUpdateRessources;
  72291. private _hasReachedQuota;
  72292. private _isSupported;
  72293. private _idbFactory;
  72294. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  72295. private static IsUASupportingBlobStorage;
  72296. /**
  72297. * Gets a boolean indicating if Database storate is enabled (off by default)
  72298. */
  72299. static IDBStorageEnabled: boolean;
  72300. /**
  72301. * Gets a boolean indicating if scene must be saved in the database
  72302. */
  72303. get enableSceneOffline(): boolean;
  72304. /**
  72305. * Gets a boolean indicating if textures must be saved in the database
  72306. */
  72307. get enableTexturesOffline(): boolean;
  72308. /**
  72309. * Creates a new Database
  72310. * @param urlToScene defines the url to load the scene
  72311. * @param callbackManifestChecked defines the callback to use when manifest is checked
  72312. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  72313. */
  72314. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  72315. private static _ParseURL;
  72316. private static _ReturnFullUrlLocation;
  72317. private _checkManifestFile;
  72318. /**
  72319. * Open the database and make it available
  72320. * @param successCallback defines the callback to call on success
  72321. * @param errorCallback defines the callback to call on error
  72322. */
  72323. open(successCallback: () => void, errorCallback: () => void): void;
  72324. /**
  72325. * Loads an image from the database
  72326. * @param url defines the url to load from
  72327. * @param image defines the target DOM image
  72328. */
  72329. loadImage(url: string, image: HTMLImageElement): void;
  72330. private _loadImageFromDBAsync;
  72331. private _saveImageIntoDBAsync;
  72332. private _checkVersionFromDB;
  72333. private _loadVersionFromDBAsync;
  72334. private _saveVersionIntoDBAsync;
  72335. /**
  72336. * Loads a file from database
  72337. * @param url defines the URL to load from
  72338. * @param sceneLoaded defines a callback to call on success
  72339. * @param progressCallBack defines a callback to call when progress changed
  72340. * @param errorCallback defines a callback to call on error
  72341. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  72342. */
  72343. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  72344. private _loadFileAsync;
  72345. private _saveFileAsync;
  72346. /**
  72347. * Validates if xhr data is correct
  72348. * @param xhr defines the request to validate
  72349. * @param dataType defines the expected data type
  72350. * @returns true if data is correct
  72351. */
  72352. private static _ValidateXHRData;
  72353. }
  72354. }
  72355. declare module "babylonjs/Offline/index" {
  72356. export * from "babylonjs/Offline/database";
  72357. export * from "babylonjs/Offline/IOfflineProvider";
  72358. }
  72359. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  72360. /** @hidden */
  72361. export var gpuUpdateParticlesPixelShader: {
  72362. name: string;
  72363. shader: string;
  72364. };
  72365. }
  72366. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  72367. /** @hidden */
  72368. export var gpuUpdateParticlesVertexShader: {
  72369. name: string;
  72370. shader: string;
  72371. };
  72372. }
  72373. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  72374. /** @hidden */
  72375. export var clipPlaneFragmentDeclaration2: {
  72376. name: string;
  72377. shader: string;
  72378. };
  72379. }
  72380. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  72381. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  72382. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  72383. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72384. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  72385. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  72386. /** @hidden */
  72387. export var gpuRenderParticlesPixelShader: {
  72388. name: string;
  72389. shader: string;
  72390. };
  72391. }
  72392. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  72393. /** @hidden */
  72394. export var clipPlaneVertexDeclaration2: {
  72395. name: string;
  72396. shader: string;
  72397. };
  72398. }
  72399. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  72400. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  72401. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  72402. /** @hidden */
  72403. export var gpuRenderParticlesVertexShader: {
  72404. name: string;
  72405. shader: string;
  72406. };
  72407. }
  72408. declare module "babylonjs/Particles/gpuParticleSystem" {
  72409. import { Nullable } from "babylonjs/types";
  72410. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  72411. import { Observable } from "babylonjs/Misc/observable";
  72412. import { Matrix } from "babylonjs/Maths/math.vector";
  72413. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  72414. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72415. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  72416. import { IDisposable } from "babylonjs/scene";
  72417. import { Effect } from "babylonjs/Materials/effect";
  72418. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  72419. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72420. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  72421. import { Scene } from "babylonjs/scene";
  72422. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  72423. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  72424. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  72425. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  72426. /**
  72427. * This represents a GPU particle system in Babylon
  72428. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  72429. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  72430. */
  72431. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  72432. /**
  72433. * The layer mask we are rendering the particles through.
  72434. */
  72435. layerMask: number;
  72436. private _capacity;
  72437. private _activeCount;
  72438. private _currentActiveCount;
  72439. private _accumulatedCount;
  72440. private _renderEffect;
  72441. private _updateEffect;
  72442. private _buffer0;
  72443. private _buffer1;
  72444. private _spriteBuffer;
  72445. private _updateVAO;
  72446. private _renderVAO;
  72447. private _targetIndex;
  72448. private _sourceBuffer;
  72449. private _targetBuffer;
  72450. private _currentRenderId;
  72451. private _started;
  72452. private _stopped;
  72453. private _timeDelta;
  72454. private _randomTexture;
  72455. private _randomTexture2;
  72456. private _attributesStrideSize;
  72457. private _updateEffectOptions;
  72458. private _randomTextureSize;
  72459. private _actualFrame;
  72460. private _customEffect;
  72461. private readonly _rawTextureWidth;
  72462. /**
  72463. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  72464. */
  72465. static get IsSupported(): boolean;
  72466. /**
  72467. * An event triggered when the system is disposed.
  72468. */
  72469. onDisposeObservable: Observable<IParticleSystem>;
  72470. /**
  72471. * An event triggered when the system is stopped
  72472. */
  72473. onStoppedObservable: Observable<IParticleSystem>;
  72474. /**
  72475. * Gets the maximum number of particles active at the same time.
  72476. * @returns The max number of active particles.
  72477. */
  72478. getCapacity(): number;
  72479. /**
  72480. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72481. * to override the particles.
  72482. */
  72483. forceDepthWrite: boolean;
  72484. /**
  72485. * Gets or set the number of active particles
  72486. */
  72487. get activeParticleCount(): number;
  72488. set activeParticleCount(value: number);
  72489. private _preWarmDone;
  72490. /**
  72491. * Specifies if the particles are updated in emitter local space or world space.
  72492. */
  72493. isLocal: boolean;
  72494. /** Gets or sets a matrix to use to compute projection */
  72495. defaultProjectionMatrix: Matrix;
  72496. /**
  72497. * Is this system ready to be used/rendered
  72498. * @return true if the system is ready
  72499. */
  72500. isReady(): boolean;
  72501. /**
  72502. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72503. * @returns True if it has been started, otherwise false.
  72504. */
  72505. isStarted(): boolean;
  72506. /**
  72507. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  72508. * @returns True if it has been stopped, otherwise false.
  72509. */
  72510. isStopped(): boolean;
  72511. /**
  72512. * Gets a boolean indicating that the system is stopping
  72513. * @returns true if the system is currently stopping
  72514. */
  72515. isStopping(): boolean;
  72516. /**
  72517. * Gets the number of particles active at the same time.
  72518. * @returns The number of active particles.
  72519. */
  72520. getActiveCount(): number;
  72521. /**
  72522. * Starts the particle system and begins to emit
  72523. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72524. */
  72525. start(delay?: number): void;
  72526. /**
  72527. * Stops the particle system.
  72528. */
  72529. stop(): void;
  72530. /**
  72531. * Remove all active particles
  72532. */
  72533. reset(): void;
  72534. /**
  72535. * Returns the string "GPUParticleSystem"
  72536. * @returns a string containing the class name
  72537. */
  72538. getClassName(): string;
  72539. /**
  72540. * Gets the custom effect used to render the particles
  72541. * @param blendMode Blend mode for which the effect should be retrieved
  72542. * @returns The effect
  72543. */
  72544. getCustomEffect(blendMode?: number): Nullable<Effect>;
  72545. /**
  72546. * Sets the custom effect used to render the particles
  72547. * @param effect The effect to set
  72548. * @param blendMode Blend mode for which the effect should be set
  72549. */
  72550. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  72551. /** @hidden */
  72552. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  72553. /**
  72554. * Observable that will be called just before the particles are drawn
  72555. */
  72556. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  72557. /**
  72558. * Gets the name of the particle vertex shader
  72559. */
  72560. get vertexShaderName(): string;
  72561. private _colorGradientsTexture;
  72562. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  72563. /**
  72564. * Adds a new color gradient
  72565. * @param gradient defines the gradient to use (between 0 and 1)
  72566. * @param color1 defines the color to affect to the specified gradient
  72567. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72568. * @returns the current particle system
  72569. */
  72570. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  72571. private _refreshColorGradient;
  72572. /** Force the system to rebuild all gradients that need to be resync */
  72573. forceRefreshGradients(): void;
  72574. /**
  72575. * Remove a specific color gradient
  72576. * @param gradient defines the gradient to remove
  72577. * @returns the current particle system
  72578. */
  72579. removeColorGradient(gradient: number): GPUParticleSystem;
  72580. private _angularSpeedGradientsTexture;
  72581. private _sizeGradientsTexture;
  72582. private _velocityGradientsTexture;
  72583. private _limitVelocityGradientsTexture;
  72584. private _dragGradientsTexture;
  72585. private _addFactorGradient;
  72586. /**
  72587. * Adds a new size gradient
  72588. * @param gradient defines the gradient to use (between 0 and 1)
  72589. * @param factor defines the size factor to affect to the specified gradient
  72590. * @returns the current particle system
  72591. */
  72592. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  72593. /**
  72594. * Remove a specific size gradient
  72595. * @param gradient defines the gradient to remove
  72596. * @returns the current particle system
  72597. */
  72598. removeSizeGradient(gradient: number): GPUParticleSystem;
  72599. private _refreshFactorGradient;
  72600. /**
  72601. * Adds a new angular speed gradient
  72602. * @param gradient defines the gradient to use (between 0 and 1)
  72603. * @param factor defines the angular speed to affect to the specified gradient
  72604. * @returns the current particle system
  72605. */
  72606. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  72607. /**
  72608. * Remove a specific angular speed gradient
  72609. * @param gradient defines the gradient to remove
  72610. * @returns the current particle system
  72611. */
  72612. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72613. /**
  72614. * Adds a new velocity gradient
  72615. * @param gradient defines the gradient to use (between 0 and 1)
  72616. * @param factor defines the velocity to affect to the specified gradient
  72617. * @returns the current particle system
  72618. */
  72619. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72620. /**
  72621. * Remove a specific velocity gradient
  72622. * @param gradient defines the gradient to remove
  72623. * @returns the current particle system
  72624. */
  72625. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72626. /**
  72627. * Adds a new limit velocity gradient
  72628. * @param gradient defines the gradient to use (between 0 and 1)
  72629. * @param factor defines the limit velocity value to affect to the specified gradient
  72630. * @returns the current particle system
  72631. */
  72632. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72633. /**
  72634. * Remove a specific limit velocity gradient
  72635. * @param gradient defines the gradient to remove
  72636. * @returns the current particle system
  72637. */
  72638. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72639. /**
  72640. * Adds a new drag gradient
  72641. * @param gradient defines the gradient to use (between 0 and 1)
  72642. * @param factor defines the drag value to affect to the specified gradient
  72643. * @returns the current particle system
  72644. */
  72645. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72646. /**
  72647. * Remove a specific drag gradient
  72648. * @param gradient defines the gradient to remove
  72649. * @returns the current particle system
  72650. */
  72651. removeDragGradient(gradient: number): GPUParticleSystem;
  72652. /**
  72653. * Not supported by GPUParticleSystem
  72654. * @param gradient defines the gradient to use (between 0 and 1)
  72655. * @param factor defines the emit rate value to affect to the specified gradient
  72656. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72657. * @returns the current particle system
  72658. */
  72659. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72660. /**
  72661. * Not supported by GPUParticleSystem
  72662. * @param gradient defines the gradient to remove
  72663. * @returns the current particle system
  72664. */
  72665. removeEmitRateGradient(gradient: number): IParticleSystem;
  72666. /**
  72667. * Not supported by GPUParticleSystem
  72668. * @param gradient defines the gradient to use (between 0 and 1)
  72669. * @param factor defines the start size value to affect to the specified gradient
  72670. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72671. * @returns the current particle system
  72672. */
  72673. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72674. /**
  72675. * Not supported by GPUParticleSystem
  72676. * @param gradient defines the gradient to remove
  72677. * @returns the current particle system
  72678. */
  72679. removeStartSizeGradient(gradient: number): IParticleSystem;
  72680. /**
  72681. * Not supported by GPUParticleSystem
  72682. * @param gradient defines the gradient to use (between 0 and 1)
  72683. * @param min defines the color remap minimal range
  72684. * @param max defines the color remap maximal range
  72685. * @returns the current particle system
  72686. */
  72687. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72688. /**
  72689. * Not supported by GPUParticleSystem
  72690. * @param gradient defines the gradient to remove
  72691. * @returns the current particle system
  72692. */
  72693. removeColorRemapGradient(): IParticleSystem;
  72694. /**
  72695. * Not supported by GPUParticleSystem
  72696. * @param gradient defines the gradient to use (between 0 and 1)
  72697. * @param min defines the alpha remap minimal range
  72698. * @param max defines the alpha remap maximal range
  72699. * @returns the current particle system
  72700. */
  72701. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72702. /**
  72703. * Not supported by GPUParticleSystem
  72704. * @param gradient defines the gradient to remove
  72705. * @returns the current particle system
  72706. */
  72707. removeAlphaRemapGradient(): IParticleSystem;
  72708. /**
  72709. * Not supported by GPUParticleSystem
  72710. * @param gradient defines the gradient to use (between 0 and 1)
  72711. * @param color defines the color to affect to the specified gradient
  72712. * @returns the current particle system
  72713. */
  72714. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72715. /**
  72716. * Not supported by GPUParticleSystem
  72717. * @param gradient defines the gradient to remove
  72718. * @returns the current particle system
  72719. */
  72720. removeRampGradient(): IParticleSystem;
  72721. /**
  72722. * Not supported by GPUParticleSystem
  72723. * @returns the list of ramp gradients
  72724. */
  72725. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72726. /**
  72727. * Not supported by GPUParticleSystem
  72728. * Gets or sets a boolean indicating that ramp gradients must be used
  72729. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72730. */
  72731. get useRampGradients(): boolean;
  72732. set useRampGradients(value: boolean);
  72733. /**
  72734. * Not supported by GPUParticleSystem
  72735. * @param gradient defines the gradient to use (between 0 and 1)
  72736. * @param factor defines the life time factor to affect to the specified gradient
  72737. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72738. * @returns the current particle system
  72739. */
  72740. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72741. /**
  72742. * Not supported by GPUParticleSystem
  72743. * @param gradient defines the gradient to remove
  72744. * @returns the current particle system
  72745. */
  72746. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72747. /**
  72748. * Instantiates a GPU particle system.
  72749. * 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.
  72750. * @param name The name of the particle system
  72751. * @param options The options used to create the system
  72752. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72753. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72754. * @param customEffect a custom effect used to change the way particles are rendered by default
  72755. */
  72756. constructor(name: string, options: Partial<{
  72757. capacity: number;
  72758. randomTextureSize: number;
  72759. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72760. protected _reset(): void;
  72761. private _createUpdateVAO;
  72762. private _createRenderVAO;
  72763. private _initialize;
  72764. /** @hidden */
  72765. _recreateUpdateEffect(): void;
  72766. private _getEffect;
  72767. /**
  72768. * Fill the defines array according to the current settings of the particle system
  72769. * @param defines Array to be updated
  72770. * @param blendMode blend mode to take into account when updating the array
  72771. */
  72772. fillDefines(defines: Array<string>, blendMode?: number): void;
  72773. /**
  72774. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72775. * @param uniforms Uniforms array to fill
  72776. * @param attributes Attributes array to fill
  72777. * @param samplers Samplers array to fill
  72778. */
  72779. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72780. /** @hidden */
  72781. _recreateRenderEffect(): Effect;
  72782. /**
  72783. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72784. * @param preWarm defines if we are in the pre-warmimg phase
  72785. */
  72786. animate(preWarm?: boolean): void;
  72787. private _createFactorGradientTexture;
  72788. private _createSizeGradientTexture;
  72789. private _createAngularSpeedGradientTexture;
  72790. private _createVelocityGradientTexture;
  72791. private _createLimitVelocityGradientTexture;
  72792. private _createDragGradientTexture;
  72793. private _createColorGradientTexture;
  72794. /**
  72795. * Renders the particle system in its current state
  72796. * @param preWarm defines if the system should only update the particles but not render them
  72797. * @returns the current number of particles
  72798. */
  72799. render(preWarm?: boolean): number;
  72800. /**
  72801. * Rebuilds the particle system
  72802. */
  72803. rebuild(): void;
  72804. private _releaseBuffers;
  72805. private _releaseVAOs;
  72806. /**
  72807. * Disposes the particle system and free the associated resources
  72808. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72809. */
  72810. dispose(disposeTexture?: boolean): void;
  72811. /**
  72812. * Clones the particle system.
  72813. * @param name The name of the cloned object
  72814. * @param newEmitter The new emitter to use
  72815. * @returns the cloned particle system
  72816. */
  72817. clone(name: string, newEmitter: any): GPUParticleSystem;
  72818. /**
  72819. * Serializes the particle system to a JSON object
  72820. * @param serializeTexture defines if the texture must be serialized as well
  72821. * @returns the JSON object
  72822. */
  72823. serialize(serializeTexture?: boolean): any;
  72824. /**
  72825. * Parses a JSON object to create a GPU particle system.
  72826. * @param parsedParticleSystem The JSON object to parse
  72827. * @param sceneOrEngine The scene or the engine to create the particle system in
  72828. * @param rootUrl The root url to use to load external dependencies like texture
  72829. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72830. * @returns the parsed GPU particle system
  72831. */
  72832. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72833. }
  72834. }
  72835. declare module "babylonjs/Particles/particleSystemSet" {
  72836. import { Nullable } from "babylonjs/types";
  72837. import { Color3 } from "babylonjs/Maths/math.color";
  72838. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72840. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72841. import { Scene, IDisposable } from "babylonjs/scene";
  72842. /**
  72843. * Represents a set of particle systems working together to create a specific effect
  72844. */
  72845. export class ParticleSystemSet implements IDisposable {
  72846. /**
  72847. * Gets or sets base Assets URL
  72848. */
  72849. static BaseAssetsUrl: string;
  72850. private _emitterCreationOptions;
  72851. private _emitterNode;
  72852. /**
  72853. * Gets the particle system list
  72854. */
  72855. systems: IParticleSystem[];
  72856. /**
  72857. * Gets the emitter node used with this set
  72858. */
  72859. get emitterNode(): Nullable<TransformNode>;
  72860. /**
  72861. * Creates a new emitter mesh as a sphere
  72862. * @param options defines the options used to create the sphere
  72863. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72864. * @param scene defines the hosting scene
  72865. */
  72866. setEmitterAsSphere(options: {
  72867. diameter: number;
  72868. segments: number;
  72869. color: Color3;
  72870. }, renderingGroupId: number, scene: Scene): void;
  72871. /**
  72872. * Starts all particle systems of the set
  72873. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72874. */
  72875. start(emitter?: AbstractMesh): void;
  72876. /**
  72877. * Release all associated resources
  72878. */
  72879. dispose(): void;
  72880. /**
  72881. * Serialize the set into a JSON compatible object
  72882. * @param serializeTexture defines if the texture must be serialized as well
  72883. * @returns a JSON compatible representation of the set
  72884. */
  72885. serialize(serializeTexture?: boolean): any;
  72886. /**
  72887. * Parse a new ParticleSystemSet from a serialized source
  72888. * @param data defines a JSON compatible representation of the set
  72889. * @param scene defines the hosting scene
  72890. * @param gpu defines if we want GPU particles or CPU particles
  72891. * @returns a new ParticleSystemSet
  72892. */
  72893. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72894. }
  72895. }
  72896. declare module "babylonjs/Particles/particleHelper" {
  72897. import { Nullable } from "babylonjs/types";
  72898. import { Scene } from "babylonjs/scene";
  72899. import { Vector3 } from "babylonjs/Maths/math.vector";
  72900. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72901. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72902. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  72903. /**
  72904. * This class is made for on one-liner static method to help creating particle system set.
  72905. */
  72906. export class ParticleHelper {
  72907. /**
  72908. * Gets or sets base Assets URL
  72909. */
  72910. static BaseAssetsUrl: string;
  72911. /** Define the Url to load snippets */
  72912. static SnippetUrl: string;
  72913. /**
  72914. * Create a default particle system that you can tweak
  72915. * @param emitter defines the emitter to use
  72916. * @param capacity defines the system capacity (default is 500 particles)
  72917. * @param scene defines the hosting scene
  72918. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72919. * @returns the new Particle system
  72920. */
  72921. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72922. /**
  72923. * This is the main static method (one-liner) of this helper to create different particle systems
  72924. * @param type This string represents the type to the particle system to create
  72925. * @param scene The scene where the particle system should live
  72926. * @param gpu If the system will use gpu
  72927. * @returns the ParticleSystemSet created
  72928. */
  72929. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72930. /**
  72931. * Static function used to export a particle system to a ParticleSystemSet variable.
  72932. * Please note that the emitter shape is not exported
  72933. * @param systems defines the particle systems to export
  72934. * @returns the created particle system set
  72935. */
  72936. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72937. /**
  72938. * Creates a particle system from a snippet saved in a remote file
  72939. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72940. * @param url defines the url to load from
  72941. * @param scene defines the hosting scene
  72942. * @param gpu If the system will use gpu
  72943. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72944. * @returns a promise that will resolve to the new particle system
  72945. */
  72946. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72947. /**
  72948. * Creates a particle system from a snippet saved by the particle system editor
  72949. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72950. * @param scene defines the hosting scene
  72951. * @param gpu If the system will use gpu
  72952. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72953. * @returns a promise that will resolve to the new particle system
  72954. */
  72955. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72956. }
  72957. }
  72958. declare module "babylonjs/Particles/particleSystemComponent" {
  72959. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72960. import { Effect } from "babylonjs/Materials/effect";
  72961. import "babylonjs/Shaders/particles.vertex";
  72962. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  72963. module "babylonjs/Engines/engine" {
  72964. interface Engine {
  72965. /**
  72966. * Create an effect to use with particle systems.
  72967. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72968. * the particle system for which you want to create a custom effect in the last parameter
  72969. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72970. * @param uniformsNames defines a list of attribute names
  72971. * @param samplers defines an array of string used to represent textures
  72972. * @param defines defines the string containing the defines to use to compile the shaders
  72973. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  72974. * @param onCompiled defines a function to call when the effect creation is successful
  72975. * @param onError defines a function to call when the effect creation has failed
  72976. * @param particleSystem the particle system you want to create the effect for
  72977. * @returns the new Effect
  72978. */
  72979. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72980. }
  72981. }
  72982. module "babylonjs/Meshes/mesh" {
  72983. interface Mesh {
  72984. /**
  72985. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72986. * @returns an array of IParticleSystem
  72987. */
  72988. getEmittedParticleSystems(): IParticleSystem[];
  72989. /**
  72990. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72991. * @returns an array of IParticleSystem
  72992. */
  72993. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72994. }
  72995. }
  72996. }
  72997. declare module "babylonjs/Particles/pointsCloudSystem" {
  72998. import { Color4 } from "babylonjs/Maths/math";
  72999. import { Mesh } from "babylonjs/Meshes/mesh";
  73000. import { Scene, IDisposable } from "babylonjs/scene";
  73001. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  73002. /** Defines the 4 color options */
  73003. export enum PointColor {
  73004. /** color value */
  73005. Color = 2,
  73006. /** uv value */
  73007. UV = 1,
  73008. /** random value */
  73009. Random = 0,
  73010. /** stated value */
  73011. Stated = 3
  73012. }
  73013. /**
  73014. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  73015. * 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.
  73016. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  73017. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  73018. *
  73019. * Full documentation here : TO BE ENTERED
  73020. */
  73021. export class PointsCloudSystem implements IDisposable {
  73022. /**
  73023. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  73024. * Example : var p = SPS.particles[i];
  73025. */
  73026. particles: CloudPoint[];
  73027. /**
  73028. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  73029. */
  73030. nbParticles: number;
  73031. /**
  73032. * This a counter for your own usage. It's not set by any SPS functions.
  73033. */
  73034. counter: number;
  73035. /**
  73036. * The PCS name. This name is also given to the underlying mesh.
  73037. */
  73038. name: string;
  73039. /**
  73040. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  73041. */
  73042. mesh: Mesh;
  73043. /**
  73044. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  73045. * Please read :
  73046. */
  73047. vars: any;
  73048. /**
  73049. * @hidden
  73050. */
  73051. _size: number;
  73052. private _scene;
  73053. private _promises;
  73054. private _positions;
  73055. private _indices;
  73056. private _normals;
  73057. private _colors;
  73058. private _uvs;
  73059. private _indices32;
  73060. private _positions32;
  73061. private _colors32;
  73062. private _uvs32;
  73063. private _updatable;
  73064. private _isVisibilityBoxLocked;
  73065. private _alwaysVisible;
  73066. private _groups;
  73067. private _groupCounter;
  73068. private _computeParticleColor;
  73069. private _computeParticleTexture;
  73070. private _computeParticleRotation;
  73071. private _computeBoundingBox;
  73072. private _isReady;
  73073. /**
  73074. * Creates a PCS (Points Cloud System) object
  73075. * @param name (String) is the PCS name, this will be the underlying mesh name
  73076. * @param pointSize (number) is the size for each point
  73077. * @param scene (Scene) is the scene in which the PCS is added
  73078. * @param options defines the options of the PCS e.g.
  73079. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  73080. */
  73081. constructor(name: string, pointSize: number, scene: Scene, options?: {
  73082. updatable?: boolean;
  73083. });
  73084. /**
  73085. * Builds the PCS underlying mesh. Returns a standard Mesh.
  73086. * If no points were added to the PCS, the returned mesh is just a single point.
  73087. * @returns a promise for the created mesh
  73088. */
  73089. buildMeshAsync(): Promise<Mesh>;
  73090. /**
  73091. * @hidden
  73092. */
  73093. private _buildMesh;
  73094. private _addParticle;
  73095. private _randomUnitVector;
  73096. private _getColorIndicesForCoord;
  73097. private _setPointsColorOrUV;
  73098. private _colorFromTexture;
  73099. private _calculateDensity;
  73100. /**
  73101. * Adds points to the PCS in random positions within a unit sphere
  73102. * @param nb (positive integer) the number of particles to be created from this model
  73103. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  73104. * @returns the number of groups in the system
  73105. */
  73106. addPoints(nb: number, pointFunction?: any): number;
  73107. /**
  73108. * Adds points to the PCS from the surface of the model shape
  73109. * @param mesh is any Mesh object that will be used as a surface model for the points
  73110. * @param nb (positive integer) the number of particles to be created from this model
  73111. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  73112. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  73113. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  73114. * @returns the number of groups in the system
  73115. */
  73116. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  73117. /**
  73118. * Adds points to the PCS inside the model shape
  73119. * @param mesh is any Mesh object that will be used as a surface model for the points
  73120. * @param nb (positive integer) the number of particles to be created from this model
  73121. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  73122. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  73123. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  73124. * @returns the number of groups in the system
  73125. */
  73126. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  73127. /**
  73128. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  73129. * This method calls `updateParticle()` for each particle of the SPS.
  73130. * For an animated SPS, it is usually called within the render loop.
  73131. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  73132. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  73133. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  73134. * @returns the PCS.
  73135. */
  73136. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  73137. /**
  73138. * Disposes the PCS.
  73139. */
  73140. dispose(): void;
  73141. /**
  73142. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  73143. * doc :
  73144. * @returns the PCS.
  73145. */
  73146. refreshVisibleSize(): PointsCloudSystem;
  73147. /**
  73148. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  73149. * @param size the size (float) of the visibility box
  73150. * note : this doesn't lock the PCS mesh bounding box.
  73151. * doc :
  73152. */
  73153. setVisibilityBox(size: number): void;
  73154. /**
  73155. * Gets whether the PCS is always visible or not
  73156. * doc :
  73157. */
  73158. get isAlwaysVisible(): boolean;
  73159. /**
  73160. * Sets the PCS as always visible or not
  73161. * doc :
  73162. */
  73163. set isAlwaysVisible(val: boolean);
  73164. /**
  73165. * Tells to `setParticles()` to compute the particle rotations or not
  73166. * Default value : false. The PCS is faster when it's set to false
  73167. * Note : particle rotations are only applied to parent particles
  73168. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  73169. */
  73170. set computeParticleRotation(val: boolean);
  73171. /**
  73172. * Tells to `setParticles()` to compute the particle colors or not.
  73173. * Default value : true. The PCS is faster when it's set to false.
  73174. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73175. */
  73176. set computeParticleColor(val: boolean);
  73177. set computeParticleTexture(val: boolean);
  73178. /**
  73179. * Gets if `setParticles()` computes the particle colors or not.
  73180. * Default value : false. The PCS is faster when it's set to false.
  73181. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73182. */
  73183. get computeParticleColor(): boolean;
  73184. /**
  73185. * Gets if `setParticles()` computes the particle textures or not.
  73186. * Default value : false. The PCS is faster when it's set to false.
  73187. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  73188. */
  73189. get computeParticleTexture(): boolean;
  73190. /**
  73191. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  73192. */
  73193. set computeBoundingBox(val: boolean);
  73194. /**
  73195. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  73196. */
  73197. get computeBoundingBox(): boolean;
  73198. /**
  73199. * This function does nothing. It may be overwritten to set all the particle first values.
  73200. * The PCS doesn't call this function, you may have to call it by your own.
  73201. * doc :
  73202. */
  73203. initParticles(): void;
  73204. /**
  73205. * This function does nothing. It may be overwritten to recycle a particle
  73206. * The PCS doesn't call this function, you can to call it
  73207. * doc :
  73208. * @param particle The particle to recycle
  73209. * @returns the recycled particle
  73210. */
  73211. recycleParticle(particle: CloudPoint): CloudPoint;
  73212. /**
  73213. * Updates a particle : this function should be overwritten by the user.
  73214. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  73215. * doc :
  73216. * @example : just set a particle position or velocity and recycle conditions
  73217. * @param particle The particle to update
  73218. * @returns the updated particle
  73219. */
  73220. updateParticle(particle: CloudPoint): CloudPoint;
  73221. /**
  73222. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  73223. * This does nothing and may be overwritten by the user.
  73224. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73225. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73226. * @param update the boolean update value actually passed to setParticles()
  73227. */
  73228. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73229. /**
  73230. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  73231. * This will be passed three parameters.
  73232. * This does nothing and may be overwritten by the user.
  73233. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73234. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73235. * @param update the boolean update value actually passed to setParticles()
  73236. */
  73237. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73238. }
  73239. }
  73240. declare module "babylonjs/Particles/cloudPoint" {
  73241. import { Nullable } from "babylonjs/types";
  73242. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  73243. import { Mesh } from "babylonjs/Meshes/mesh";
  73244. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  73245. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  73246. /**
  73247. * Represents one particle of a points cloud system.
  73248. */
  73249. export class CloudPoint {
  73250. /**
  73251. * particle global index
  73252. */
  73253. idx: number;
  73254. /**
  73255. * The color of the particle
  73256. */
  73257. color: Nullable<Color4>;
  73258. /**
  73259. * The world space position of the particle.
  73260. */
  73261. position: Vector3;
  73262. /**
  73263. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  73264. */
  73265. rotation: Vector3;
  73266. /**
  73267. * The world space rotation quaternion of the particle.
  73268. */
  73269. rotationQuaternion: Nullable<Quaternion>;
  73270. /**
  73271. * The uv of the particle.
  73272. */
  73273. uv: Nullable<Vector2>;
  73274. /**
  73275. * The current speed of the particle.
  73276. */
  73277. velocity: Vector3;
  73278. /**
  73279. * The pivot point in the particle local space.
  73280. */
  73281. pivot: Vector3;
  73282. /**
  73283. * Must the particle be translated from its pivot point in its local space ?
  73284. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  73285. * Default : false
  73286. */
  73287. translateFromPivot: boolean;
  73288. /**
  73289. * Index of this particle in the global "positions" array (Internal use)
  73290. * @hidden
  73291. */
  73292. _pos: number;
  73293. /**
  73294. * @hidden Index of this particle in the global "indices" array (Internal use)
  73295. */
  73296. _ind: number;
  73297. /**
  73298. * Group this particle belongs to
  73299. */
  73300. _group: PointsGroup;
  73301. /**
  73302. * Group id of this particle
  73303. */
  73304. groupId: number;
  73305. /**
  73306. * Index of the particle in its group id (Internal use)
  73307. */
  73308. idxInGroup: number;
  73309. /**
  73310. * @hidden Particle BoundingInfo object (Internal use)
  73311. */
  73312. _boundingInfo: BoundingInfo;
  73313. /**
  73314. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  73315. */
  73316. _pcs: PointsCloudSystem;
  73317. /**
  73318. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  73319. */
  73320. _stillInvisible: boolean;
  73321. /**
  73322. * @hidden Last computed particle rotation matrix
  73323. */
  73324. _rotationMatrix: number[];
  73325. /**
  73326. * Parent particle Id, if any.
  73327. * Default null.
  73328. */
  73329. parentId: Nullable<number>;
  73330. /**
  73331. * @hidden Internal global position in the PCS.
  73332. */
  73333. _globalPosition: Vector3;
  73334. /**
  73335. * Creates a Point Cloud object.
  73336. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  73337. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  73338. * @param group (PointsGroup) is the group the particle belongs to
  73339. * @param groupId (integer) is the group identifier in the PCS.
  73340. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  73341. * @param pcs defines the PCS it is associated to
  73342. */
  73343. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  73344. /**
  73345. * get point size
  73346. */
  73347. get size(): Vector3;
  73348. /**
  73349. * Set point size
  73350. */
  73351. set size(scale: Vector3);
  73352. /**
  73353. * Legacy support, changed quaternion to rotationQuaternion
  73354. */
  73355. get quaternion(): Nullable<Quaternion>;
  73356. /**
  73357. * Legacy support, changed quaternion to rotationQuaternion
  73358. */
  73359. set quaternion(q: Nullable<Quaternion>);
  73360. /**
  73361. * Returns a boolean. True if the particle intersects a mesh, else false
  73362. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  73363. * @param target is the object (point or mesh) what the intersection is computed against
  73364. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  73365. * @returns true if it intersects
  73366. */
  73367. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  73368. /**
  73369. * get the rotation matrix of the particle
  73370. * @hidden
  73371. */
  73372. getRotationMatrix(m: Matrix): void;
  73373. }
  73374. /**
  73375. * Represents a group of points in a points cloud system
  73376. * * PCS internal tool, don't use it manually.
  73377. */
  73378. export class PointsGroup {
  73379. /**
  73380. * The group id
  73381. * @hidden
  73382. */
  73383. groupID: number;
  73384. /**
  73385. * image data for group (internal use)
  73386. * @hidden
  73387. */
  73388. _groupImageData: Nullable<ArrayBufferView>;
  73389. /**
  73390. * Image Width (internal use)
  73391. * @hidden
  73392. */
  73393. _groupImgWidth: number;
  73394. /**
  73395. * Image Height (internal use)
  73396. * @hidden
  73397. */
  73398. _groupImgHeight: number;
  73399. /**
  73400. * Custom position function (internal use)
  73401. * @hidden
  73402. */
  73403. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  73404. /**
  73405. * density per facet for surface points
  73406. * @hidden
  73407. */
  73408. _groupDensity: number[];
  73409. /**
  73410. * Only when points are colored by texture carries pointer to texture list array
  73411. * @hidden
  73412. */
  73413. _textureNb: number;
  73414. /**
  73415. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  73416. * PCS internal tool, don't use it manually.
  73417. * @hidden
  73418. */
  73419. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  73420. }
  73421. }
  73422. declare module "babylonjs/Particles/index" {
  73423. export * from "babylonjs/Particles/baseParticleSystem";
  73424. export * from "babylonjs/Particles/EmitterTypes/index";
  73425. export * from "babylonjs/Particles/gpuParticleSystem";
  73426. export * from "babylonjs/Particles/IParticleSystem";
  73427. export * from "babylonjs/Particles/particle";
  73428. export * from "babylonjs/Particles/particleHelper";
  73429. export * from "babylonjs/Particles/particleSystem";
  73430. import "babylonjs/Particles/particleSystemComponent";
  73431. export * from "babylonjs/Particles/particleSystemComponent";
  73432. export * from "babylonjs/Particles/particleSystemSet";
  73433. export * from "babylonjs/Particles/solidParticle";
  73434. export * from "babylonjs/Particles/solidParticleSystem";
  73435. export * from "babylonjs/Particles/cloudPoint";
  73436. export * from "babylonjs/Particles/pointsCloudSystem";
  73437. export * from "babylonjs/Particles/subEmitter";
  73438. }
  73439. declare module "babylonjs/Physics/physicsEngineComponent" {
  73440. import { Nullable } from "babylonjs/types";
  73441. import { Observable, Observer } from "babylonjs/Misc/observable";
  73442. import { Vector3 } from "babylonjs/Maths/math.vector";
  73443. import { Mesh } from "babylonjs/Meshes/mesh";
  73444. import { ISceneComponent } from "babylonjs/sceneComponent";
  73445. import { Scene } from "babylonjs/scene";
  73446. import { Node } from "babylonjs/node";
  73447. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  73448. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73449. module "babylonjs/scene" {
  73450. interface Scene {
  73451. /** @hidden (Backing field) */
  73452. _physicsEngine: Nullable<IPhysicsEngine>;
  73453. /** @hidden */
  73454. _physicsTimeAccumulator: number;
  73455. /**
  73456. * Gets the current physics engine
  73457. * @returns a IPhysicsEngine or null if none attached
  73458. */
  73459. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  73460. /**
  73461. * Enables physics to the current scene
  73462. * @param gravity defines the scene's gravity for the physics engine
  73463. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  73464. * @return a boolean indicating if the physics engine was initialized
  73465. */
  73466. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  73467. /**
  73468. * Disables and disposes the physics engine associated with the scene
  73469. */
  73470. disablePhysicsEngine(): void;
  73471. /**
  73472. * Gets a boolean indicating if there is an active physics engine
  73473. * @returns a boolean indicating if there is an active physics engine
  73474. */
  73475. isPhysicsEnabled(): boolean;
  73476. /**
  73477. * Deletes a physics compound impostor
  73478. * @param compound defines the compound to delete
  73479. */
  73480. deleteCompoundImpostor(compound: any): void;
  73481. /**
  73482. * An event triggered when physic simulation is about to be run
  73483. */
  73484. onBeforePhysicsObservable: Observable<Scene>;
  73485. /**
  73486. * An event triggered when physic simulation has been done
  73487. */
  73488. onAfterPhysicsObservable: Observable<Scene>;
  73489. }
  73490. }
  73491. module "babylonjs/Meshes/abstractMesh" {
  73492. interface AbstractMesh {
  73493. /** @hidden */
  73494. _physicsImpostor: Nullable<PhysicsImpostor>;
  73495. /**
  73496. * Gets or sets impostor used for physic simulation
  73497. * @see https://doc.babylonjs.com/features/physics_engine
  73498. */
  73499. physicsImpostor: Nullable<PhysicsImpostor>;
  73500. /**
  73501. * Gets the current physics impostor
  73502. * @see https://doc.babylonjs.com/features/physics_engine
  73503. * @returns a physics impostor or null
  73504. */
  73505. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  73506. /** Apply a physic impulse to the mesh
  73507. * @param force defines the force to apply
  73508. * @param contactPoint defines where to apply the force
  73509. * @returns the current mesh
  73510. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73511. */
  73512. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  73513. /**
  73514. * Creates a physic joint between two meshes
  73515. * @param otherMesh defines the other mesh to use
  73516. * @param pivot1 defines the pivot to use on this mesh
  73517. * @param pivot2 defines the pivot to use on the other mesh
  73518. * @param options defines additional options (can be plugin dependent)
  73519. * @returns the current mesh
  73520. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  73521. */
  73522. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  73523. /** @hidden */
  73524. _disposePhysicsObserver: Nullable<Observer<Node>>;
  73525. }
  73526. }
  73527. /**
  73528. * Defines the physics engine scene component responsible to manage a physics engine
  73529. */
  73530. export class PhysicsEngineSceneComponent implements ISceneComponent {
  73531. /**
  73532. * The component name helpful to identify the component in the list of scene components.
  73533. */
  73534. readonly name: string;
  73535. /**
  73536. * The scene the component belongs to.
  73537. */
  73538. scene: Scene;
  73539. /**
  73540. * Creates a new instance of the component for the given scene
  73541. * @param scene Defines the scene to register the component in
  73542. */
  73543. constructor(scene: Scene);
  73544. /**
  73545. * Registers the component in a given scene
  73546. */
  73547. register(): void;
  73548. /**
  73549. * Rebuilds the elements related to this component in case of
  73550. * context lost for instance.
  73551. */
  73552. rebuild(): void;
  73553. /**
  73554. * Disposes the component and the associated ressources
  73555. */
  73556. dispose(): void;
  73557. }
  73558. }
  73559. declare module "babylonjs/Physics/physicsHelper" {
  73560. import { Nullable } from "babylonjs/types";
  73561. import { Vector3 } from "babylonjs/Maths/math.vector";
  73562. import { Mesh } from "babylonjs/Meshes/mesh";
  73563. import { Scene } from "babylonjs/scene";
  73564. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73565. /**
  73566. * A helper for physics simulations
  73567. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73568. */
  73569. export class PhysicsHelper {
  73570. private _scene;
  73571. private _physicsEngine;
  73572. /**
  73573. * Initializes the Physics helper
  73574. * @param scene Babylon.js scene
  73575. */
  73576. constructor(scene: Scene);
  73577. /**
  73578. * Applies a radial explosion impulse
  73579. * @param origin the origin of the explosion
  73580. * @param radiusOrEventOptions the radius or the options of radial explosion
  73581. * @param strength the explosion strength
  73582. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73583. * @returns A physics radial explosion event, or null
  73584. */
  73585. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73586. /**
  73587. * Applies a radial explosion force
  73588. * @param origin the origin of the explosion
  73589. * @param radiusOrEventOptions the radius or the options of radial explosion
  73590. * @param strength the explosion strength
  73591. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73592. * @returns A physics radial explosion event, or null
  73593. */
  73594. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73595. /**
  73596. * Creates a gravitational field
  73597. * @param origin the origin of the explosion
  73598. * @param radiusOrEventOptions the radius or the options of radial explosion
  73599. * @param strength the explosion strength
  73600. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73601. * @returns A physics gravitational field event, or null
  73602. */
  73603. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73604. /**
  73605. * Creates a physics updraft event
  73606. * @param origin the origin of the updraft
  73607. * @param radiusOrEventOptions the radius or the options of the updraft
  73608. * @param strength the strength of the updraft
  73609. * @param height the height of the updraft
  73610. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73611. * @returns A physics updraft event, or null
  73612. */
  73613. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73614. /**
  73615. * Creates a physics vortex event
  73616. * @param origin the of the vortex
  73617. * @param radiusOrEventOptions the radius or the options of the vortex
  73618. * @param strength the strength of the vortex
  73619. * @param height the height of the vortex
  73620. * @returns a Physics vortex event, or null
  73621. * A physics vortex event or null
  73622. */
  73623. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73624. }
  73625. /**
  73626. * Represents a physics radial explosion event
  73627. */
  73628. class PhysicsRadialExplosionEvent {
  73629. private _scene;
  73630. private _options;
  73631. private _sphere;
  73632. private _dataFetched;
  73633. /**
  73634. * Initializes a radial explosioin event
  73635. * @param _scene BabylonJS scene
  73636. * @param _options The options for the vortex event
  73637. */
  73638. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73639. /**
  73640. * Returns the data related to the radial explosion event (sphere).
  73641. * @returns The radial explosion event data
  73642. */
  73643. getData(): PhysicsRadialExplosionEventData;
  73644. /**
  73645. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73646. * @param impostor A physics imposter
  73647. * @param origin the origin of the explosion
  73648. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73649. */
  73650. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73651. /**
  73652. * Triggers affecterd impostors callbacks
  73653. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73654. */
  73655. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73656. /**
  73657. * Disposes the sphere.
  73658. * @param force Specifies if the sphere should be disposed by force
  73659. */
  73660. dispose(force?: boolean): void;
  73661. /*** Helpers ***/
  73662. private _prepareSphere;
  73663. private _intersectsWithSphere;
  73664. }
  73665. /**
  73666. * Represents a gravitational field event
  73667. */
  73668. class PhysicsGravitationalFieldEvent {
  73669. private _physicsHelper;
  73670. private _scene;
  73671. private _origin;
  73672. private _options;
  73673. private _tickCallback;
  73674. private _sphere;
  73675. private _dataFetched;
  73676. /**
  73677. * Initializes the physics gravitational field event
  73678. * @param _physicsHelper A physics helper
  73679. * @param _scene BabylonJS scene
  73680. * @param _origin The origin position of the gravitational field event
  73681. * @param _options The options for the vortex event
  73682. */
  73683. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73684. /**
  73685. * Returns the data related to the gravitational field event (sphere).
  73686. * @returns A gravitational field event
  73687. */
  73688. getData(): PhysicsGravitationalFieldEventData;
  73689. /**
  73690. * Enables the gravitational field.
  73691. */
  73692. enable(): void;
  73693. /**
  73694. * Disables the gravitational field.
  73695. */
  73696. disable(): void;
  73697. /**
  73698. * Disposes the sphere.
  73699. * @param force The force to dispose from the gravitational field event
  73700. */
  73701. dispose(force?: boolean): void;
  73702. private _tick;
  73703. }
  73704. /**
  73705. * Represents a physics updraft event
  73706. */
  73707. class PhysicsUpdraftEvent {
  73708. private _scene;
  73709. private _origin;
  73710. private _options;
  73711. private _physicsEngine;
  73712. private _originTop;
  73713. private _originDirection;
  73714. private _tickCallback;
  73715. private _cylinder;
  73716. private _cylinderPosition;
  73717. private _dataFetched;
  73718. /**
  73719. * Initializes the physics updraft event
  73720. * @param _scene BabylonJS scene
  73721. * @param _origin The origin position of the updraft
  73722. * @param _options The options for the updraft event
  73723. */
  73724. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73725. /**
  73726. * Returns the data related to the updraft event (cylinder).
  73727. * @returns A physics updraft event
  73728. */
  73729. getData(): PhysicsUpdraftEventData;
  73730. /**
  73731. * Enables the updraft.
  73732. */
  73733. enable(): void;
  73734. /**
  73735. * Disables the updraft.
  73736. */
  73737. disable(): void;
  73738. /**
  73739. * Disposes the cylinder.
  73740. * @param force Specifies if the updraft should be disposed by force
  73741. */
  73742. dispose(force?: boolean): void;
  73743. private getImpostorHitData;
  73744. private _tick;
  73745. /*** Helpers ***/
  73746. private _prepareCylinder;
  73747. private _intersectsWithCylinder;
  73748. }
  73749. /**
  73750. * Represents a physics vortex event
  73751. */
  73752. class PhysicsVortexEvent {
  73753. private _scene;
  73754. private _origin;
  73755. private _options;
  73756. private _physicsEngine;
  73757. private _originTop;
  73758. private _tickCallback;
  73759. private _cylinder;
  73760. private _cylinderPosition;
  73761. private _dataFetched;
  73762. /**
  73763. * Initializes the physics vortex event
  73764. * @param _scene The BabylonJS scene
  73765. * @param _origin The origin position of the vortex
  73766. * @param _options The options for the vortex event
  73767. */
  73768. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73769. /**
  73770. * Returns the data related to the vortex event (cylinder).
  73771. * @returns The physics vortex event data
  73772. */
  73773. getData(): PhysicsVortexEventData;
  73774. /**
  73775. * Enables the vortex.
  73776. */
  73777. enable(): void;
  73778. /**
  73779. * Disables the cortex.
  73780. */
  73781. disable(): void;
  73782. /**
  73783. * Disposes the sphere.
  73784. * @param force
  73785. */
  73786. dispose(force?: boolean): void;
  73787. private getImpostorHitData;
  73788. private _tick;
  73789. /*** Helpers ***/
  73790. private _prepareCylinder;
  73791. private _intersectsWithCylinder;
  73792. }
  73793. /**
  73794. * Options fot the radial explosion event
  73795. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73796. */
  73797. export class PhysicsRadialExplosionEventOptions {
  73798. /**
  73799. * The radius of the sphere for the radial explosion.
  73800. */
  73801. radius: number;
  73802. /**
  73803. * The strenth of the explosion.
  73804. */
  73805. strength: number;
  73806. /**
  73807. * The strenght of the force in correspondence to the distance of the affected object
  73808. */
  73809. falloff: PhysicsRadialImpulseFalloff;
  73810. /**
  73811. * Sphere options for the radial explosion.
  73812. */
  73813. sphere: {
  73814. segments: number;
  73815. diameter: number;
  73816. };
  73817. /**
  73818. * Sphere options for the radial explosion.
  73819. */
  73820. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73821. }
  73822. /**
  73823. * Options fot the updraft event
  73824. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73825. */
  73826. export class PhysicsUpdraftEventOptions {
  73827. /**
  73828. * The radius of the cylinder for the vortex
  73829. */
  73830. radius: number;
  73831. /**
  73832. * The strenth of the updraft.
  73833. */
  73834. strength: number;
  73835. /**
  73836. * The height of the cylinder for the updraft.
  73837. */
  73838. height: number;
  73839. /**
  73840. * The mode for the the updraft.
  73841. */
  73842. updraftMode: PhysicsUpdraftMode;
  73843. }
  73844. /**
  73845. * Options fot the vortex event
  73846. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73847. */
  73848. export class PhysicsVortexEventOptions {
  73849. /**
  73850. * The radius of the cylinder for the vortex
  73851. */
  73852. radius: number;
  73853. /**
  73854. * The strenth of the vortex.
  73855. */
  73856. strength: number;
  73857. /**
  73858. * The height of the cylinder for the vortex.
  73859. */
  73860. height: number;
  73861. /**
  73862. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73863. */
  73864. centripetalForceThreshold: number;
  73865. /**
  73866. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  73867. */
  73868. centripetalForceMultiplier: number;
  73869. /**
  73870. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  73871. */
  73872. centrifugalForceMultiplier: number;
  73873. /**
  73874. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73875. */
  73876. updraftForceMultiplier: number;
  73877. }
  73878. /**
  73879. * The strenght of the force in correspondence to the distance of the affected object
  73880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73881. */
  73882. export enum PhysicsRadialImpulseFalloff {
  73883. /** Defines that impulse is constant in strength across it's whole radius */
  73884. Constant = 0,
  73885. /** Defines that impulse gets weaker if it's further from the origin */
  73886. Linear = 1
  73887. }
  73888. /**
  73889. * The strength of the force in correspondence to the distance of the affected object
  73890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73891. */
  73892. export enum PhysicsUpdraftMode {
  73893. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73894. Center = 0,
  73895. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73896. Perpendicular = 1
  73897. }
  73898. /**
  73899. * Interface for a physics hit data
  73900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73901. */
  73902. export interface PhysicsHitData {
  73903. /**
  73904. * The force applied at the contact point
  73905. */
  73906. force: Vector3;
  73907. /**
  73908. * The contact point
  73909. */
  73910. contactPoint: Vector3;
  73911. /**
  73912. * The distance from the origin to the contact point
  73913. */
  73914. distanceFromOrigin: number;
  73915. }
  73916. /**
  73917. * Interface for radial explosion event data
  73918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73919. */
  73920. export interface PhysicsRadialExplosionEventData {
  73921. /**
  73922. * A sphere used for the radial explosion event
  73923. */
  73924. sphere: Mesh;
  73925. }
  73926. /**
  73927. * Interface for gravitational field event data
  73928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73929. */
  73930. export interface PhysicsGravitationalFieldEventData {
  73931. /**
  73932. * A sphere mesh used for the gravitational field event
  73933. */
  73934. sphere: Mesh;
  73935. }
  73936. /**
  73937. * Interface for updraft event data
  73938. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73939. */
  73940. export interface PhysicsUpdraftEventData {
  73941. /**
  73942. * A cylinder used for the updraft event
  73943. */
  73944. cylinder: Mesh;
  73945. }
  73946. /**
  73947. * Interface for vortex event data
  73948. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73949. */
  73950. export interface PhysicsVortexEventData {
  73951. /**
  73952. * A cylinder used for the vortex event
  73953. */
  73954. cylinder: Mesh;
  73955. }
  73956. /**
  73957. * Interface for an affected physics impostor
  73958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73959. */
  73960. export interface PhysicsAffectedImpostorWithData {
  73961. /**
  73962. * The impostor affected by the effect
  73963. */
  73964. impostor: PhysicsImpostor;
  73965. /**
  73966. * The data about the hit/horce from the explosion
  73967. */
  73968. hitData: PhysicsHitData;
  73969. }
  73970. }
  73971. declare module "babylonjs/Physics/Plugins/index" {
  73972. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  73973. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  73974. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  73975. }
  73976. declare module "babylonjs/Physics/index" {
  73977. export * from "babylonjs/Physics/IPhysicsEngine";
  73978. export * from "babylonjs/Physics/physicsEngine";
  73979. export * from "babylonjs/Physics/physicsEngineComponent";
  73980. export * from "babylonjs/Physics/physicsHelper";
  73981. export * from "babylonjs/Physics/physicsImpostor";
  73982. export * from "babylonjs/Physics/physicsJoint";
  73983. export * from "babylonjs/Physics/Plugins/index";
  73984. }
  73985. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  73986. /** @hidden */
  73987. export var blackAndWhitePixelShader: {
  73988. name: string;
  73989. shader: string;
  73990. };
  73991. }
  73992. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  73993. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73994. import { Camera } from "babylonjs/Cameras/camera";
  73995. import { Engine } from "babylonjs/Engines/engine";
  73996. import "babylonjs/Shaders/blackAndWhite.fragment";
  73997. import { Nullable } from "babylonjs/types";
  73998. import { Scene } from "babylonjs/scene";
  73999. /**
  74000. * Post process used to render in black and white
  74001. */
  74002. export class BlackAndWhitePostProcess extends PostProcess {
  74003. /**
  74004. * Linear about to convert he result to black and white (default: 1)
  74005. */
  74006. degree: number;
  74007. /**
  74008. * Gets a string identifying the name of the class
  74009. * @returns "BlackAndWhitePostProcess" string
  74010. */
  74011. getClassName(): string;
  74012. /**
  74013. * Creates a black and white post process
  74014. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  74015. * @param name The name of the effect.
  74016. * @param options The required width/height ratio to downsize to before computing the render pass.
  74017. * @param camera The camera to apply the render pass to.
  74018. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74019. * @param engine The engine which the post process will be applied. (default: current engine)
  74020. * @param reusable If the post process can be reused on the same frame. (default: false)
  74021. */
  74022. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74023. /** @hidden */
  74024. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  74025. }
  74026. }
  74027. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  74028. import { Nullable } from "babylonjs/types";
  74029. import { Camera } from "babylonjs/Cameras/camera";
  74030. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74031. import { Engine } from "babylonjs/Engines/engine";
  74032. /**
  74033. * This represents a set of one or more post processes in Babylon.
  74034. * A post process can be used to apply a shader to a texture after it is rendered.
  74035. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74036. */
  74037. export class PostProcessRenderEffect {
  74038. private _postProcesses;
  74039. private _getPostProcesses;
  74040. private _singleInstance;
  74041. private _cameras;
  74042. private _indicesForCamera;
  74043. /**
  74044. * Name of the effect
  74045. * @hidden
  74046. */
  74047. _name: string;
  74048. /**
  74049. * Instantiates a post process render effect.
  74050. * A post process can be used to apply a shader to a texture after it is rendered.
  74051. * @param engine The engine the effect is tied to
  74052. * @param name The name of the effect
  74053. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  74054. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  74055. */
  74056. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  74057. /**
  74058. * Checks if all the post processes in the effect are supported.
  74059. */
  74060. get isSupported(): boolean;
  74061. /**
  74062. * Updates the current state of the effect
  74063. * @hidden
  74064. */
  74065. _update(): void;
  74066. /**
  74067. * Attaches the effect on cameras
  74068. * @param cameras The camera to attach to.
  74069. * @hidden
  74070. */
  74071. _attachCameras(cameras: Camera): void;
  74072. /**
  74073. * Attaches the effect on cameras
  74074. * @param cameras The camera to attach to.
  74075. * @hidden
  74076. */
  74077. _attachCameras(cameras: Camera[]): void;
  74078. /**
  74079. * Detaches the effect on cameras
  74080. * @param cameras The camera to detatch from.
  74081. * @hidden
  74082. */
  74083. _detachCameras(cameras: Camera): void;
  74084. /**
  74085. * Detatches the effect on cameras
  74086. * @param cameras The camera to detatch from.
  74087. * @hidden
  74088. */
  74089. _detachCameras(cameras: Camera[]): void;
  74090. /**
  74091. * Enables the effect on given cameras
  74092. * @param cameras The camera to enable.
  74093. * @hidden
  74094. */
  74095. _enable(cameras: Camera): void;
  74096. /**
  74097. * Enables the effect on given cameras
  74098. * @param cameras The camera to enable.
  74099. * @hidden
  74100. */
  74101. _enable(cameras: Nullable<Camera[]>): void;
  74102. /**
  74103. * Disables the effect on the given cameras
  74104. * @param cameras The camera to disable.
  74105. * @hidden
  74106. */
  74107. _disable(cameras: Camera): void;
  74108. /**
  74109. * Disables the effect on the given cameras
  74110. * @param cameras The camera to disable.
  74111. * @hidden
  74112. */
  74113. _disable(cameras: Nullable<Camera[]>): void;
  74114. /**
  74115. * Gets a list of the post processes contained in the effect.
  74116. * @param camera The camera to get the post processes on.
  74117. * @returns The list of the post processes in the effect.
  74118. */
  74119. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  74120. }
  74121. }
  74122. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  74123. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74124. /** @hidden */
  74125. export var extractHighlightsPixelShader: {
  74126. name: string;
  74127. shader: string;
  74128. };
  74129. }
  74130. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  74131. import { Nullable } from "babylonjs/types";
  74132. import { Camera } from "babylonjs/Cameras/camera";
  74133. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74134. import { Engine } from "babylonjs/Engines/engine";
  74135. import "babylonjs/Shaders/extractHighlights.fragment";
  74136. /**
  74137. * 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.
  74138. */
  74139. export class ExtractHighlightsPostProcess extends PostProcess {
  74140. /**
  74141. * The luminance threshold, pixels below this value will be set to black.
  74142. */
  74143. threshold: number;
  74144. /** @hidden */
  74145. _exposure: number;
  74146. /**
  74147. * Post process which has the input texture to be used when performing highlight extraction
  74148. * @hidden
  74149. */
  74150. _inputPostProcess: Nullable<PostProcess>;
  74151. /**
  74152. * Gets a string identifying the name of the class
  74153. * @returns "ExtractHighlightsPostProcess" string
  74154. */
  74155. getClassName(): string;
  74156. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74157. }
  74158. }
  74159. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  74160. /** @hidden */
  74161. export var bloomMergePixelShader: {
  74162. name: string;
  74163. shader: string;
  74164. };
  74165. }
  74166. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  74167. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74168. import { Nullable } from "babylonjs/types";
  74169. import { Engine } from "babylonjs/Engines/engine";
  74170. import { Camera } from "babylonjs/Cameras/camera";
  74171. import "babylonjs/Shaders/bloomMerge.fragment";
  74172. /**
  74173. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74174. */
  74175. export class BloomMergePostProcess extends PostProcess {
  74176. /** Weight of the bloom to be added to the original input. */
  74177. weight: number;
  74178. /**
  74179. * Gets a string identifying the name of the class
  74180. * @returns "BloomMergePostProcess" string
  74181. */
  74182. getClassName(): string;
  74183. /**
  74184. * Creates a new instance of @see BloomMergePostProcess
  74185. * @param name The name of the effect.
  74186. * @param originalFromInput Post process which's input will be used for the merge.
  74187. * @param blurred Blurred highlights post process which's output will be used.
  74188. * @param weight Weight of the bloom to be added to the original input.
  74189. * @param options The required width/height ratio to downsize to before computing the render pass.
  74190. * @param camera The camera to apply the render pass to.
  74191. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74192. * @param engine The engine which the post process will be applied. (default: current engine)
  74193. * @param reusable If the post process can be reused on the same frame. (default: false)
  74194. * @param textureType Type of textures used when performing the post process. (default: 0)
  74195. * @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)
  74196. */
  74197. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  74198. /** Weight of the bloom to be added to the original input. */
  74199. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74200. }
  74201. }
  74202. declare module "babylonjs/PostProcesses/bloomEffect" {
  74203. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74204. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74205. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  74206. import { Camera } from "babylonjs/Cameras/camera";
  74207. import { Scene } from "babylonjs/scene";
  74208. /**
  74209. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  74210. */
  74211. export class BloomEffect extends PostProcessRenderEffect {
  74212. private bloomScale;
  74213. /**
  74214. * @hidden Internal
  74215. */
  74216. _effects: Array<PostProcess>;
  74217. /**
  74218. * @hidden Internal
  74219. */
  74220. _downscale: ExtractHighlightsPostProcess;
  74221. private _blurX;
  74222. private _blurY;
  74223. private _merge;
  74224. /**
  74225. * The luminance threshold to find bright areas of the image to bloom.
  74226. */
  74227. get threshold(): number;
  74228. set threshold(value: number);
  74229. /**
  74230. * The strength of the bloom.
  74231. */
  74232. get weight(): number;
  74233. set weight(value: number);
  74234. /**
  74235. * Specifies the size of the bloom blur kernel, relative to the final output size
  74236. */
  74237. get kernel(): number;
  74238. set kernel(value: number);
  74239. /**
  74240. * Creates a new instance of @see BloomEffect
  74241. * @param scene The scene the effect belongs to.
  74242. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  74243. * @param bloomKernel The size of the kernel to be used when applying the blur.
  74244. * @param bloomWeight The the strength of bloom.
  74245. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74246. * @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)
  74247. */
  74248. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  74249. /**
  74250. * Disposes each of the internal effects for a given camera.
  74251. * @param camera The camera to dispose the effect on.
  74252. */
  74253. disposeEffects(camera: Camera): void;
  74254. /**
  74255. * @hidden Internal
  74256. */
  74257. _updateEffects(): void;
  74258. /**
  74259. * Internal
  74260. * @returns if all the contained post processes are ready.
  74261. * @hidden
  74262. */
  74263. _isReady(): boolean;
  74264. }
  74265. }
  74266. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  74267. /** @hidden */
  74268. export var chromaticAberrationPixelShader: {
  74269. name: string;
  74270. shader: string;
  74271. };
  74272. }
  74273. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  74274. import { Vector2 } from "babylonjs/Maths/math.vector";
  74275. import { Nullable } from "babylonjs/types";
  74276. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74277. import { Camera } from "babylonjs/Cameras/camera";
  74278. import { Engine } from "babylonjs/Engines/engine";
  74279. import "babylonjs/Shaders/chromaticAberration.fragment";
  74280. import { Scene } from "babylonjs/scene";
  74281. /**
  74282. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  74283. */
  74284. export class ChromaticAberrationPostProcess extends PostProcess {
  74285. /**
  74286. * The amount of seperation of rgb channels (default: 30)
  74287. */
  74288. aberrationAmount: number;
  74289. /**
  74290. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  74291. */
  74292. radialIntensity: number;
  74293. /**
  74294. * 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))
  74295. */
  74296. direction: Vector2;
  74297. /**
  74298. * 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))
  74299. */
  74300. centerPosition: Vector2;
  74301. /** The width of the screen to apply the effect on */
  74302. screenWidth: number;
  74303. /** The height of the screen to apply the effect on */
  74304. screenHeight: number;
  74305. /**
  74306. * Gets a string identifying the name of the class
  74307. * @returns "ChromaticAberrationPostProcess" string
  74308. */
  74309. getClassName(): string;
  74310. /**
  74311. * Creates a new instance ChromaticAberrationPostProcess
  74312. * @param name The name of the effect.
  74313. * @param screenWidth The width of the screen to apply the effect on.
  74314. * @param screenHeight The height of the screen to apply the effect on.
  74315. * @param options The required width/height ratio to downsize to before computing the render pass.
  74316. * @param camera The camera to apply the render pass to.
  74317. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74318. * @param engine The engine which the post process will be applied. (default: current engine)
  74319. * @param reusable If the post process can be reused on the same frame. (default: false)
  74320. * @param textureType Type of textures used when performing the post process. (default: 0)
  74321. * @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)
  74322. */
  74323. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74324. /** @hidden */
  74325. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  74326. }
  74327. }
  74328. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  74329. /** @hidden */
  74330. export var circleOfConfusionPixelShader: {
  74331. name: string;
  74332. shader: string;
  74333. };
  74334. }
  74335. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  74336. import { Nullable } from "babylonjs/types";
  74337. import { Engine } from "babylonjs/Engines/engine";
  74338. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74339. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74340. import { Camera } from "babylonjs/Cameras/camera";
  74341. import "babylonjs/Shaders/circleOfConfusion.fragment";
  74342. /**
  74343. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  74344. */
  74345. export class CircleOfConfusionPostProcess extends PostProcess {
  74346. /**
  74347. * 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.
  74348. */
  74349. lensSize: number;
  74350. /**
  74351. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74352. */
  74353. fStop: number;
  74354. /**
  74355. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74356. */
  74357. focusDistance: number;
  74358. /**
  74359. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  74360. */
  74361. focalLength: number;
  74362. /**
  74363. * Gets a string identifying the name of the class
  74364. * @returns "CircleOfConfusionPostProcess" string
  74365. */
  74366. getClassName(): string;
  74367. private _depthTexture;
  74368. /**
  74369. * Creates a new instance CircleOfConfusionPostProcess
  74370. * @param name The name of the effect.
  74371. * @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.
  74372. * @param options The required width/height ratio to downsize to before computing the render pass.
  74373. * @param camera The camera to apply the render pass to.
  74374. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74375. * @param engine The engine which the post process will be applied. (default: current engine)
  74376. * @param reusable If the post process can be reused on the same frame. (default: false)
  74377. * @param textureType Type of textures used when performing the post process. (default: 0)
  74378. * @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)
  74379. */
  74380. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74381. /**
  74382. * 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.
  74383. */
  74384. set depthTexture(value: RenderTargetTexture);
  74385. }
  74386. }
  74387. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  74388. /** @hidden */
  74389. export var colorCorrectionPixelShader: {
  74390. name: string;
  74391. shader: string;
  74392. };
  74393. }
  74394. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  74395. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74396. import { Engine } from "babylonjs/Engines/engine";
  74397. import { Camera } from "babylonjs/Cameras/camera";
  74398. import "babylonjs/Shaders/colorCorrection.fragment";
  74399. import { Nullable } from "babylonjs/types";
  74400. import { Scene } from "babylonjs/scene";
  74401. /**
  74402. *
  74403. * This post-process allows the modification of rendered colors by using
  74404. * a 'look-up table' (LUT). This effect is also called Color Grading.
  74405. *
  74406. * The object needs to be provided an url to a texture containing the color
  74407. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  74408. * Use an image editing software to tweak the LUT to match your needs.
  74409. *
  74410. * For an example of a color LUT, see here:
  74411. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  74412. * For explanations on color grading, see here:
  74413. * @see http://udn.epicgames.com/Three/ColorGrading.html
  74414. *
  74415. */
  74416. export class ColorCorrectionPostProcess extends PostProcess {
  74417. private _colorTableTexture;
  74418. /**
  74419. * Gets the color table url used to create the LUT texture
  74420. */
  74421. colorTableUrl: string;
  74422. /**
  74423. * Gets a string identifying the name of the class
  74424. * @returns "ColorCorrectionPostProcess" string
  74425. */
  74426. getClassName(): string;
  74427. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74428. /** @hidden */
  74429. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  74430. }
  74431. }
  74432. declare module "babylonjs/Shaders/convolution.fragment" {
  74433. /** @hidden */
  74434. export var convolutionPixelShader: {
  74435. name: string;
  74436. shader: string;
  74437. };
  74438. }
  74439. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  74440. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74441. import { Nullable } from "babylonjs/types";
  74442. import { Camera } from "babylonjs/Cameras/camera";
  74443. import { Engine } from "babylonjs/Engines/engine";
  74444. import "babylonjs/Shaders/convolution.fragment";
  74445. import { Scene } from "babylonjs/scene";
  74446. /**
  74447. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  74448. * input texture to perform effects such as edge detection or sharpening
  74449. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74450. */
  74451. export class ConvolutionPostProcess extends PostProcess {
  74452. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  74453. kernel: number[];
  74454. /**
  74455. * Gets a string identifying the name of the class
  74456. * @returns "ConvolutionPostProcess" string
  74457. */
  74458. getClassName(): string;
  74459. /**
  74460. * Creates a new instance ConvolutionPostProcess
  74461. * @param name The name of the effect.
  74462. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  74463. * @param options The required width/height ratio to downsize to before computing the render pass.
  74464. * @param camera The camera to apply the render pass to.
  74465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74466. * @param engine The engine which the post process will be applied. (default: current engine)
  74467. * @param reusable If the post process can be reused on the same frame. (default: false)
  74468. * @param textureType Type of textures used when performing the post process. (default: 0)
  74469. */
  74470. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74471. /** @hidden */
  74472. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  74473. /**
  74474. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74475. */
  74476. static EdgeDetect0Kernel: number[];
  74477. /**
  74478. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74479. */
  74480. static EdgeDetect1Kernel: number[];
  74481. /**
  74482. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74483. */
  74484. static EdgeDetect2Kernel: number[];
  74485. /**
  74486. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74487. */
  74488. static SharpenKernel: number[];
  74489. /**
  74490. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74491. */
  74492. static EmbossKernel: number[];
  74493. /**
  74494. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74495. */
  74496. static GaussianKernel: number[];
  74497. }
  74498. }
  74499. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  74500. import { Nullable } from "babylonjs/types";
  74501. import { Vector2 } from "babylonjs/Maths/math.vector";
  74502. import { Camera } from "babylonjs/Cameras/camera";
  74503. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74504. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  74505. import { Engine } from "babylonjs/Engines/engine";
  74506. import { Scene } from "babylonjs/scene";
  74507. /**
  74508. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  74509. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  74510. * based on samples that have a large difference in distance than the center pixel.
  74511. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  74512. */
  74513. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  74514. /**
  74515. * The direction the blur should be applied
  74516. */
  74517. direction: Vector2;
  74518. /**
  74519. * Gets a string identifying the name of the class
  74520. * @returns "DepthOfFieldBlurPostProcess" string
  74521. */
  74522. getClassName(): string;
  74523. /**
  74524. * Creates a new instance CircleOfConfusionPostProcess
  74525. * @param name The name of the effect.
  74526. * @param scene The scene the effect belongs to.
  74527. * @param direction The direction the blur should be applied.
  74528. * @param kernel The size of the kernel used to blur.
  74529. * @param options The required width/height ratio to downsize to before computing the render pass.
  74530. * @param camera The camera to apply the render pass to.
  74531. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  74532. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  74533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74534. * @param engine The engine which the post process will be applied. (default: current engine)
  74535. * @param reusable If the post process can be reused on the same frame. (default: false)
  74536. * @param textureType Type of textures used when performing the post process. (default: 0)
  74537. * @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)
  74538. */
  74539. 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);
  74540. }
  74541. }
  74542. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  74543. /** @hidden */
  74544. export var depthOfFieldMergePixelShader: {
  74545. name: string;
  74546. shader: string;
  74547. };
  74548. }
  74549. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  74550. import { Nullable } from "babylonjs/types";
  74551. import { Camera } from "babylonjs/Cameras/camera";
  74552. import { Effect } from "babylonjs/Materials/effect";
  74553. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74554. import { Engine } from "babylonjs/Engines/engine";
  74555. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  74556. /**
  74557. * Options to be set when merging outputs from the default pipeline.
  74558. */
  74559. export class DepthOfFieldMergePostProcessOptions {
  74560. /**
  74561. * The original image to merge on top of
  74562. */
  74563. originalFromInput: PostProcess;
  74564. /**
  74565. * Parameters to perform the merge of the depth of field effect
  74566. */
  74567. depthOfField?: {
  74568. circleOfConfusion: PostProcess;
  74569. blurSteps: Array<PostProcess>;
  74570. };
  74571. /**
  74572. * Parameters to perform the merge of bloom effect
  74573. */
  74574. bloom?: {
  74575. blurred: PostProcess;
  74576. weight: number;
  74577. };
  74578. }
  74579. /**
  74580. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74581. */
  74582. export class DepthOfFieldMergePostProcess extends PostProcess {
  74583. private blurSteps;
  74584. /**
  74585. * Gets a string identifying the name of the class
  74586. * @returns "DepthOfFieldMergePostProcess" string
  74587. */
  74588. getClassName(): string;
  74589. /**
  74590. * Creates a new instance of DepthOfFieldMergePostProcess
  74591. * @param name The name of the effect.
  74592. * @param originalFromInput Post process which's input will be used for the merge.
  74593. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  74594. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  74595. * @param options The required width/height ratio to downsize to before computing the render pass.
  74596. * @param camera The camera to apply the render pass to.
  74597. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74598. * @param engine The engine which the post process will be applied. (default: current engine)
  74599. * @param reusable If the post process can be reused on the same frame. (default: false)
  74600. * @param textureType Type of textures used when performing the post process. (default: 0)
  74601. * @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)
  74602. */
  74603. 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);
  74604. /**
  74605. * Updates the effect with the current post process compile time values and recompiles the shader.
  74606. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  74607. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  74608. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  74609. * @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
  74610. * @param onCompiled Called when the shader has been compiled.
  74611. * @param onError Called if there is an error when compiling a shader.
  74612. */
  74613. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  74614. }
  74615. }
  74616. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  74617. import { Nullable } from "babylonjs/types";
  74618. import { Camera } from "babylonjs/Cameras/camera";
  74619. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74620. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74621. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74622. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74623. import { Scene } from "babylonjs/scene";
  74624. /**
  74625. * Specifies the level of max blur that should be applied when using the depth of field effect
  74626. */
  74627. export enum DepthOfFieldEffectBlurLevel {
  74628. /**
  74629. * Subtle blur
  74630. */
  74631. Low = 0,
  74632. /**
  74633. * Medium blur
  74634. */
  74635. Medium = 1,
  74636. /**
  74637. * Large blur
  74638. */
  74639. High = 2
  74640. }
  74641. /**
  74642. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74643. */
  74644. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74645. private _circleOfConfusion;
  74646. /**
  74647. * @hidden Internal, blurs from high to low
  74648. */
  74649. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74650. private _depthOfFieldBlurY;
  74651. private _dofMerge;
  74652. /**
  74653. * @hidden Internal post processes in depth of field effect
  74654. */
  74655. _effects: Array<PostProcess>;
  74656. /**
  74657. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74658. */
  74659. set focalLength(value: number);
  74660. get focalLength(): number;
  74661. /**
  74662. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74663. */
  74664. set fStop(value: number);
  74665. get fStop(): number;
  74666. /**
  74667. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74668. */
  74669. set focusDistance(value: number);
  74670. get focusDistance(): number;
  74671. /**
  74672. * 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.
  74673. */
  74674. set lensSize(value: number);
  74675. get lensSize(): number;
  74676. /**
  74677. * Creates a new instance DepthOfFieldEffect
  74678. * @param scene The scene the effect belongs to.
  74679. * @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.
  74680. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74681. * @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)
  74682. */
  74683. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74684. /**
  74685. * Get the current class name of the current effet
  74686. * @returns "DepthOfFieldEffect"
  74687. */
  74688. getClassName(): string;
  74689. /**
  74690. * 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.
  74691. */
  74692. set depthTexture(value: RenderTargetTexture);
  74693. /**
  74694. * Disposes each of the internal effects for a given camera.
  74695. * @param camera The camera to dispose the effect on.
  74696. */
  74697. disposeEffects(camera: Camera): void;
  74698. /**
  74699. * @hidden Internal
  74700. */
  74701. _updateEffects(): void;
  74702. /**
  74703. * Internal
  74704. * @returns if all the contained post processes are ready.
  74705. * @hidden
  74706. */
  74707. _isReady(): boolean;
  74708. }
  74709. }
  74710. declare module "babylonjs/Shaders/displayPass.fragment" {
  74711. /** @hidden */
  74712. export var displayPassPixelShader: {
  74713. name: string;
  74714. shader: string;
  74715. };
  74716. }
  74717. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  74718. import { Nullable } from "babylonjs/types";
  74719. import { Camera } from "babylonjs/Cameras/camera";
  74720. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74721. import { Engine } from "babylonjs/Engines/engine";
  74722. import "babylonjs/Shaders/displayPass.fragment";
  74723. import { Scene } from "babylonjs/scene";
  74724. /**
  74725. * DisplayPassPostProcess which produces an output the same as it's input
  74726. */
  74727. export class DisplayPassPostProcess extends PostProcess {
  74728. /**
  74729. * Gets a string identifying the name of the class
  74730. * @returns "DisplayPassPostProcess" string
  74731. */
  74732. getClassName(): string;
  74733. /**
  74734. * Creates the DisplayPassPostProcess
  74735. * @param name The name of the effect.
  74736. * @param options The required width/height ratio to downsize to before computing the render pass.
  74737. * @param camera The camera to apply the render pass to.
  74738. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74739. * @param engine The engine which the post process will be applied. (default: current engine)
  74740. * @param reusable If the post process can be reused on the same frame. (default: false)
  74741. */
  74742. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74743. /** @hidden */
  74744. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74745. }
  74746. }
  74747. declare module "babylonjs/Shaders/filter.fragment" {
  74748. /** @hidden */
  74749. export var filterPixelShader: {
  74750. name: string;
  74751. shader: string;
  74752. };
  74753. }
  74754. declare module "babylonjs/PostProcesses/filterPostProcess" {
  74755. import { Nullable } from "babylonjs/types";
  74756. import { Matrix } from "babylonjs/Maths/math.vector";
  74757. import { Camera } from "babylonjs/Cameras/camera";
  74758. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74759. import { Engine } from "babylonjs/Engines/engine";
  74760. import "babylonjs/Shaders/filter.fragment";
  74761. import { Scene } from "babylonjs/scene";
  74762. /**
  74763. * Applies a kernel filter to the image
  74764. */
  74765. export class FilterPostProcess extends PostProcess {
  74766. /** The matrix to be applied to the image */
  74767. kernelMatrix: Matrix;
  74768. /**
  74769. * Gets a string identifying the name of the class
  74770. * @returns "FilterPostProcess" string
  74771. */
  74772. getClassName(): string;
  74773. /**
  74774. *
  74775. * @param name The name of the effect.
  74776. * @param kernelMatrix The matrix to be applied to the image
  74777. * @param options The required width/height ratio to downsize to before computing the render pass.
  74778. * @param camera The camera to apply the render pass to.
  74779. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74780. * @param engine The engine which the post process will be applied. (default: current engine)
  74781. * @param reusable If the post process can be reused on the same frame. (default: false)
  74782. */
  74783. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74784. /** @hidden */
  74785. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74786. }
  74787. }
  74788. declare module "babylonjs/Shaders/fxaa.fragment" {
  74789. /** @hidden */
  74790. export var fxaaPixelShader: {
  74791. name: string;
  74792. shader: string;
  74793. };
  74794. }
  74795. declare module "babylonjs/Shaders/fxaa.vertex" {
  74796. /** @hidden */
  74797. export var fxaaVertexShader: {
  74798. name: string;
  74799. shader: string;
  74800. };
  74801. }
  74802. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  74803. import { Nullable } from "babylonjs/types";
  74804. import { Camera } from "babylonjs/Cameras/camera";
  74805. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74806. import { Engine } from "babylonjs/Engines/engine";
  74807. import "babylonjs/Shaders/fxaa.fragment";
  74808. import "babylonjs/Shaders/fxaa.vertex";
  74809. import { Scene } from "babylonjs/scene";
  74810. /**
  74811. * Fxaa post process
  74812. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74813. */
  74814. export class FxaaPostProcess extends PostProcess {
  74815. /**
  74816. * Gets a string identifying the name of the class
  74817. * @returns "FxaaPostProcess" string
  74818. */
  74819. getClassName(): string;
  74820. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74821. private _getDefines;
  74822. /** @hidden */
  74823. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74824. }
  74825. }
  74826. declare module "babylonjs/Shaders/grain.fragment" {
  74827. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74828. /** @hidden */
  74829. export var grainPixelShader: {
  74830. name: string;
  74831. shader: string;
  74832. };
  74833. }
  74834. declare module "babylonjs/PostProcesses/grainPostProcess" {
  74835. import { Nullable } from "babylonjs/types";
  74836. import { Camera } from "babylonjs/Cameras/camera";
  74837. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74838. import { Engine } from "babylonjs/Engines/engine";
  74839. import "babylonjs/Shaders/grain.fragment";
  74840. import { Scene } from "babylonjs/scene";
  74841. /**
  74842. * The GrainPostProcess adds noise to the image at mid luminance levels
  74843. */
  74844. export class GrainPostProcess extends PostProcess {
  74845. /**
  74846. * The intensity of the grain added (default: 30)
  74847. */
  74848. intensity: number;
  74849. /**
  74850. * If the grain should be randomized on every frame
  74851. */
  74852. animated: boolean;
  74853. /**
  74854. * Gets a string identifying the name of the class
  74855. * @returns "GrainPostProcess" string
  74856. */
  74857. getClassName(): string;
  74858. /**
  74859. * Creates a new instance of @see GrainPostProcess
  74860. * @param name The name of the effect.
  74861. * @param options The required width/height ratio to downsize to before computing the render pass.
  74862. * @param camera The camera to apply the render pass to.
  74863. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74864. * @param engine The engine which the post process will be applied. (default: current engine)
  74865. * @param reusable If the post process can be reused on the same frame. (default: false)
  74866. * @param textureType Type of textures used when performing the post process. (default: 0)
  74867. * @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)
  74868. */
  74869. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74870. /** @hidden */
  74871. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74872. }
  74873. }
  74874. declare module "babylonjs/Shaders/highlights.fragment" {
  74875. /** @hidden */
  74876. export var highlightsPixelShader: {
  74877. name: string;
  74878. shader: string;
  74879. };
  74880. }
  74881. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  74882. import { Nullable } from "babylonjs/types";
  74883. import { Camera } from "babylonjs/Cameras/camera";
  74884. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74885. import { Engine } from "babylonjs/Engines/engine";
  74886. import "babylonjs/Shaders/highlights.fragment";
  74887. /**
  74888. * Extracts highlights from the image
  74889. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74890. */
  74891. export class HighlightsPostProcess extends PostProcess {
  74892. /**
  74893. * Gets a string identifying the name of the class
  74894. * @returns "HighlightsPostProcess" string
  74895. */
  74896. getClassName(): string;
  74897. /**
  74898. * Extracts highlights from the image
  74899. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74900. * @param name The name of the effect.
  74901. * @param options The required width/height ratio to downsize to before computing the render pass.
  74902. * @param camera The camera to apply the render pass to.
  74903. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74904. * @param engine The engine which the post process will be applied. (default: current engine)
  74905. * @param reusable If the post process can be reused on the same frame. (default: false)
  74906. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74907. */
  74908. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74909. }
  74910. }
  74911. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  74912. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74913. /**
  74914. * Contains all parameters needed for the prepass to perform
  74915. * motion blur
  74916. */
  74917. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74918. /**
  74919. * Is motion blur enabled
  74920. */
  74921. enabled: boolean;
  74922. /**
  74923. * Name of the configuration
  74924. */
  74925. name: string;
  74926. /**
  74927. * Textures that should be present in the MRT for this effect to work
  74928. */
  74929. readonly texturesRequired: number[];
  74930. }
  74931. }
  74932. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  74933. import { Nullable } from "babylonjs/types";
  74934. import { Scene } from "babylonjs/scene";
  74935. import { ISceneComponent } from "babylonjs/sceneComponent";
  74936. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  74937. module "babylonjs/scene" {
  74938. interface Scene {
  74939. /** @hidden (Backing field) */
  74940. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74941. /**
  74942. * Gets or Sets the current geometry buffer associated to the scene.
  74943. */
  74944. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74945. /**
  74946. * Enables a GeometryBufferRender and associates it with the scene
  74947. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74948. * @returns the GeometryBufferRenderer
  74949. */
  74950. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74951. /**
  74952. * Disables the GeometryBufferRender associated with the scene
  74953. */
  74954. disableGeometryBufferRenderer(): void;
  74955. }
  74956. }
  74957. /**
  74958. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74959. * in several rendering techniques.
  74960. */
  74961. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74962. /**
  74963. * The component name helpful to identify the component in the list of scene components.
  74964. */
  74965. readonly name: string;
  74966. /**
  74967. * The scene the component belongs to.
  74968. */
  74969. scene: Scene;
  74970. /**
  74971. * Creates a new instance of the component for the given scene
  74972. * @param scene Defines the scene to register the component in
  74973. */
  74974. constructor(scene: Scene);
  74975. /**
  74976. * Registers the component in a given scene
  74977. */
  74978. register(): void;
  74979. /**
  74980. * Rebuilds the elements related to this component in case of
  74981. * context lost for instance.
  74982. */
  74983. rebuild(): void;
  74984. /**
  74985. * Disposes the component and the associated ressources
  74986. */
  74987. dispose(): void;
  74988. private _gatherRenderTargets;
  74989. }
  74990. }
  74991. declare module "babylonjs/Shaders/motionBlur.fragment" {
  74992. /** @hidden */
  74993. export var motionBlurPixelShader: {
  74994. name: string;
  74995. shader: string;
  74996. };
  74997. }
  74998. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  74999. import { Nullable } from "babylonjs/types";
  75000. import { Camera } from "babylonjs/Cameras/camera";
  75001. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75003. import "babylonjs/Animations/animatable";
  75004. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75005. import "babylonjs/Shaders/motionBlur.fragment";
  75006. import { Engine } from "babylonjs/Engines/engine";
  75007. import { Scene } from "babylonjs/scene";
  75008. /**
  75009. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  75010. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  75011. * As an example, all you have to do is to create the post-process:
  75012. * var mb = new BABYLON.MotionBlurPostProcess(
  75013. * 'mb', // The name of the effect.
  75014. * scene, // The scene containing the objects to blur according to their velocity.
  75015. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  75016. * camera // The camera to apply the render pass to.
  75017. * );
  75018. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  75019. */
  75020. export class MotionBlurPostProcess extends PostProcess {
  75021. /**
  75022. * Defines how much the image is blurred by the movement. Default value is equal to 1
  75023. */
  75024. motionStrength: number;
  75025. /**
  75026. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  75027. */
  75028. get motionBlurSamples(): number;
  75029. /**
  75030. * Sets the number of iterations to be used for motion blur quality
  75031. */
  75032. set motionBlurSamples(samples: number);
  75033. private _motionBlurSamples;
  75034. private _forceGeometryBuffer;
  75035. private _geometryBufferRenderer;
  75036. private _prePassRenderer;
  75037. /**
  75038. * Gets a string identifying the name of the class
  75039. * @returns "MotionBlurPostProcess" string
  75040. */
  75041. getClassName(): string;
  75042. /**
  75043. * Creates a new instance MotionBlurPostProcess
  75044. * @param name The name of the effect.
  75045. * @param scene The scene containing the objects to blur according to their velocity.
  75046. * @param options The required width/height ratio to downsize to before computing the render pass.
  75047. * @param camera The camera to apply the render pass to.
  75048. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75049. * @param engine The engine which the post process will be applied. (default: current engine)
  75050. * @param reusable If the post process can be reused on the same frame. (default: false)
  75051. * @param textureType Type of textures used when performing the post process. (default: 0)
  75052. * @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)
  75053. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75054. */
  75055. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75056. /**
  75057. * Excludes the given skinned mesh from computing bones velocities.
  75058. * 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.
  75059. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  75060. */
  75061. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  75062. /**
  75063. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  75064. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  75065. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  75066. */
  75067. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  75068. /**
  75069. * Disposes the post process.
  75070. * @param camera The camera to dispose the post process on.
  75071. */
  75072. dispose(camera?: Camera): void;
  75073. /** @hidden */
  75074. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  75075. }
  75076. }
  75077. declare module "babylonjs/Shaders/refraction.fragment" {
  75078. /** @hidden */
  75079. export var refractionPixelShader: {
  75080. name: string;
  75081. shader: string;
  75082. };
  75083. }
  75084. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  75085. import { Color3 } from "babylonjs/Maths/math.color";
  75086. import { Camera } from "babylonjs/Cameras/camera";
  75087. import { Texture } from "babylonjs/Materials/Textures/texture";
  75088. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75089. import { Engine } from "babylonjs/Engines/engine";
  75090. import "babylonjs/Shaders/refraction.fragment";
  75091. import { Scene } from "babylonjs/scene";
  75092. /**
  75093. * Post process which applies a refractin texture
  75094. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  75095. */
  75096. export class RefractionPostProcess extends PostProcess {
  75097. private _refTexture;
  75098. private _ownRefractionTexture;
  75099. /** the base color of the refraction (used to taint the rendering) */
  75100. color: Color3;
  75101. /** simulated refraction depth */
  75102. depth: number;
  75103. /** the coefficient of the base color (0 to remove base color tainting) */
  75104. colorLevel: number;
  75105. /** Gets the url used to load the refraction texture */
  75106. refractionTextureUrl: string;
  75107. /**
  75108. * Gets or sets the refraction texture
  75109. * Please note that you are responsible for disposing the texture if you set it manually
  75110. */
  75111. get refractionTexture(): Texture;
  75112. set refractionTexture(value: Texture);
  75113. /**
  75114. * Gets a string identifying the name of the class
  75115. * @returns "RefractionPostProcess" string
  75116. */
  75117. getClassName(): string;
  75118. /**
  75119. * Initializes the RefractionPostProcess
  75120. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  75121. * @param name The name of the effect.
  75122. * @param refractionTextureUrl Url of the refraction texture to use
  75123. * @param color the base color of the refraction (used to taint the rendering)
  75124. * @param depth simulated refraction depth
  75125. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  75126. * @param camera The camera to apply the render pass to.
  75127. * @param options The required width/height ratio to downsize to before computing the render pass.
  75128. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75129. * @param engine The engine which the post process will be applied. (default: current engine)
  75130. * @param reusable If the post process can be reused on the same frame. (default: false)
  75131. */
  75132. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75133. /**
  75134. * Disposes of the post process
  75135. * @param camera Camera to dispose post process on
  75136. */
  75137. dispose(camera: Camera): void;
  75138. /** @hidden */
  75139. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  75140. }
  75141. }
  75142. declare module "babylonjs/Shaders/sharpen.fragment" {
  75143. /** @hidden */
  75144. export var sharpenPixelShader: {
  75145. name: string;
  75146. shader: string;
  75147. };
  75148. }
  75149. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  75150. import { Nullable } from "babylonjs/types";
  75151. import { Camera } from "babylonjs/Cameras/camera";
  75152. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75153. import "babylonjs/Shaders/sharpen.fragment";
  75154. import { Engine } from "babylonjs/Engines/engine";
  75155. import { Scene } from "babylonjs/scene";
  75156. /**
  75157. * The SharpenPostProcess applies a sharpen kernel to every pixel
  75158. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  75159. */
  75160. export class SharpenPostProcess extends PostProcess {
  75161. /**
  75162. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  75163. */
  75164. colorAmount: number;
  75165. /**
  75166. * How much sharpness should be applied (default: 0.3)
  75167. */
  75168. edgeAmount: number;
  75169. /**
  75170. * Gets a string identifying the name of the class
  75171. * @returns "SharpenPostProcess" string
  75172. */
  75173. getClassName(): string;
  75174. /**
  75175. * Creates a new instance ConvolutionPostProcess
  75176. * @param name The name of the effect.
  75177. * @param options The required width/height ratio to downsize to before computing the render pass.
  75178. * @param camera The camera to apply the render pass to.
  75179. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75180. * @param engine The engine which the post process will be applied. (default: current engine)
  75181. * @param reusable If the post process can be reused on the same frame. (default: false)
  75182. * @param textureType Type of textures used when performing the post process. (default: 0)
  75183. * @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)
  75184. */
  75185. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75186. /** @hidden */
  75187. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  75188. }
  75189. }
  75190. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  75191. import { Nullable } from "babylonjs/types";
  75192. import { Camera } from "babylonjs/Cameras/camera";
  75193. import { Engine } from "babylonjs/Engines/engine";
  75194. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75195. import { IInspectable } from "babylonjs/Misc/iInspectable";
  75196. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  75197. /**
  75198. * PostProcessRenderPipeline
  75199. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75200. */
  75201. export class PostProcessRenderPipeline {
  75202. private engine;
  75203. private _renderEffects;
  75204. private _renderEffectsForIsolatedPass;
  75205. /**
  75206. * List of inspectable custom properties (used by the Inspector)
  75207. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75208. */
  75209. inspectableCustomProperties: IInspectable[];
  75210. /**
  75211. * @hidden
  75212. */
  75213. protected _cameras: Camera[];
  75214. /** @hidden */
  75215. _name: string;
  75216. /**
  75217. * Gets pipeline name
  75218. */
  75219. get name(): string;
  75220. /** Gets the list of attached cameras */
  75221. get cameras(): Camera[];
  75222. /**
  75223. * Initializes a PostProcessRenderPipeline
  75224. * @param engine engine to add the pipeline to
  75225. * @param name name of the pipeline
  75226. */
  75227. constructor(engine: Engine, name: string);
  75228. /**
  75229. * Gets the class name
  75230. * @returns "PostProcessRenderPipeline"
  75231. */
  75232. getClassName(): string;
  75233. /**
  75234. * If all the render effects in the pipeline are supported
  75235. */
  75236. get isSupported(): boolean;
  75237. /**
  75238. * Adds an effect to the pipeline
  75239. * @param renderEffect the effect to add
  75240. */
  75241. addEffect(renderEffect: PostProcessRenderEffect): void;
  75242. /** @hidden */
  75243. _rebuild(): void;
  75244. /** @hidden */
  75245. _enableEffect(renderEffectName: string, cameras: Camera): void;
  75246. /** @hidden */
  75247. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  75248. /** @hidden */
  75249. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75250. /** @hidden */
  75251. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75252. /** @hidden */
  75253. _attachCameras(cameras: Camera, unique: boolean): void;
  75254. /** @hidden */
  75255. _attachCameras(cameras: Camera[], unique: boolean): void;
  75256. /** @hidden */
  75257. _detachCameras(cameras: Camera): void;
  75258. /** @hidden */
  75259. _detachCameras(cameras: Nullable<Camera[]>): void;
  75260. /** @hidden */
  75261. _update(): void;
  75262. /** @hidden */
  75263. _reset(): void;
  75264. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  75265. /**
  75266. * Sets the required values to the prepass renderer.
  75267. * @param prePassRenderer defines the prepass renderer to setup.
  75268. * @returns true if the pre pass is needed.
  75269. */
  75270. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  75271. /**
  75272. * Disposes of the pipeline
  75273. */
  75274. dispose(): void;
  75275. }
  75276. }
  75277. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  75278. import { Camera } from "babylonjs/Cameras/camera";
  75279. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75280. /**
  75281. * PostProcessRenderPipelineManager class
  75282. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75283. */
  75284. export class PostProcessRenderPipelineManager {
  75285. private _renderPipelines;
  75286. /**
  75287. * Initializes a PostProcessRenderPipelineManager
  75288. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75289. */
  75290. constructor();
  75291. /**
  75292. * Gets the list of supported render pipelines
  75293. */
  75294. get supportedPipelines(): PostProcessRenderPipeline[];
  75295. /**
  75296. * Adds a pipeline to the manager
  75297. * @param renderPipeline The pipeline to add
  75298. */
  75299. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  75300. /**
  75301. * Attaches a camera to the pipeline
  75302. * @param renderPipelineName The name of the pipeline to attach to
  75303. * @param cameras the camera to attach
  75304. * @param unique if the camera can be attached multiple times to the pipeline
  75305. */
  75306. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  75307. /**
  75308. * Detaches a camera from the pipeline
  75309. * @param renderPipelineName The name of the pipeline to detach from
  75310. * @param cameras the camera to detach
  75311. */
  75312. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  75313. /**
  75314. * Enables an effect by name on a pipeline
  75315. * @param renderPipelineName the name of the pipeline to enable the effect in
  75316. * @param renderEffectName the name of the effect to enable
  75317. * @param cameras the cameras that the effect should be enabled on
  75318. */
  75319. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75320. /**
  75321. * Disables an effect by name on a pipeline
  75322. * @param renderPipelineName the name of the pipeline to disable the effect in
  75323. * @param renderEffectName the name of the effect to disable
  75324. * @param cameras the cameras that the effect should be disabled on
  75325. */
  75326. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75327. /**
  75328. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  75329. */
  75330. update(): void;
  75331. /** @hidden */
  75332. _rebuild(): void;
  75333. /**
  75334. * Disposes of the manager and pipelines
  75335. */
  75336. dispose(): void;
  75337. }
  75338. }
  75339. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  75340. import { ISceneComponent } from "babylonjs/sceneComponent";
  75341. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75342. import { Scene } from "babylonjs/scene";
  75343. module "babylonjs/scene" {
  75344. interface Scene {
  75345. /** @hidden (Backing field) */
  75346. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75347. /**
  75348. * Gets the postprocess render pipeline manager
  75349. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75350. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75351. */
  75352. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75353. }
  75354. }
  75355. /**
  75356. * Defines the Render Pipeline scene component responsible to rendering pipelines
  75357. */
  75358. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  75359. /**
  75360. * The component name helpfull to identify the component in the list of scene components.
  75361. */
  75362. readonly name: string;
  75363. /**
  75364. * The scene the component belongs to.
  75365. */
  75366. scene: Scene;
  75367. /**
  75368. * Creates a new instance of the component for the given scene
  75369. * @param scene Defines the scene to register the component in
  75370. */
  75371. constructor(scene: Scene);
  75372. /**
  75373. * Registers the component in a given scene
  75374. */
  75375. register(): void;
  75376. /**
  75377. * Rebuilds the elements related to this component in case of
  75378. * context lost for instance.
  75379. */
  75380. rebuild(): void;
  75381. /**
  75382. * Disposes the component and the associated ressources
  75383. */
  75384. dispose(): void;
  75385. private _gatherRenderTargets;
  75386. }
  75387. }
  75388. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  75389. import { Nullable } from "babylonjs/types";
  75390. import { Observable } from "babylonjs/Misc/observable";
  75391. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75392. import { Camera } from "babylonjs/Cameras/camera";
  75393. import { IDisposable } from "babylonjs/scene";
  75394. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  75395. import { Scene } from "babylonjs/scene";
  75396. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  75397. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75398. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75399. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  75400. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75401. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75402. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  75403. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75404. import { Animation } from "babylonjs/Animations/animation";
  75405. /**
  75406. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  75407. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75408. */
  75409. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75410. private _scene;
  75411. private _camerasToBeAttached;
  75412. /**
  75413. * ID of the sharpen post process,
  75414. */
  75415. private readonly SharpenPostProcessId;
  75416. /**
  75417. * @ignore
  75418. * ID of the image processing post process;
  75419. */
  75420. readonly ImageProcessingPostProcessId: string;
  75421. /**
  75422. * @ignore
  75423. * ID of the Fast Approximate Anti-Aliasing post process;
  75424. */
  75425. readonly FxaaPostProcessId: string;
  75426. /**
  75427. * ID of the chromatic aberration post process,
  75428. */
  75429. private readonly ChromaticAberrationPostProcessId;
  75430. /**
  75431. * ID of the grain post process
  75432. */
  75433. private readonly GrainPostProcessId;
  75434. /**
  75435. * Sharpen post process which will apply a sharpen convolution to enhance edges
  75436. */
  75437. sharpen: SharpenPostProcess;
  75438. private _sharpenEffect;
  75439. private bloom;
  75440. /**
  75441. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  75442. */
  75443. depthOfField: DepthOfFieldEffect;
  75444. /**
  75445. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75446. */
  75447. fxaa: FxaaPostProcess;
  75448. /**
  75449. * Image post processing pass used to perform operations such as tone mapping or color grading.
  75450. */
  75451. imageProcessing: ImageProcessingPostProcess;
  75452. /**
  75453. * Chromatic aberration post process which will shift rgb colors in the image
  75454. */
  75455. chromaticAberration: ChromaticAberrationPostProcess;
  75456. private _chromaticAberrationEffect;
  75457. /**
  75458. * Grain post process which add noise to the image
  75459. */
  75460. grain: GrainPostProcess;
  75461. private _grainEffect;
  75462. /**
  75463. * Glow post process which adds a glow to emissive areas of the image
  75464. */
  75465. private _glowLayer;
  75466. /**
  75467. * Animations which can be used to tweak settings over a period of time
  75468. */
  75469. animations: Animation[];
  75470. private _imageProcessingConfigurationObserver;
  75471. private _sharpenEnabled;
  75472. private _bloomEnabled;
  75473. private _depthOfFieldEnabled;
  75474. private _depthOfFieldBlurLevel;
  75475. private _fxaaEnabled;
  75476. private _imageProcessingEnabled;
  75477. private _defaultPipelineTextureType;
  75478. private _bloomScale;
  75479. private _chromaticAberrationEnabled;
  75480. private _grainEnabled;
  75481. private _buildAllowed;
  75482. /**
  75483. * This is triggered each time the pipeline has been built.
  75484. */
  75485. onBuildObservable: Observable<DefaultRenderingPipeline>;
  75486. /**
  75487. * Gets active scene
  75488. */
  75489. get scene(): Scene;
  75490. /**
  75491. * Enable or disable the sharpen process from the pipeline
  75492. */
  75493. set sharpenEnabled(enabled: boolean);
  75494. get sharpenEnabled(): boolean;
  75495. private _resizeObserver;
  75496. private _hardwareScaleLevel;
  75497. private _bloomKernel;
  75498. /**
  75499. * Specifies the size of the bloom blur kernel, relative to the final output size
  75500. */
  75501. get bloomKernel(): number;
  75502. set bloomKernel(value: number);
  75503. /**
  75504. * Specifies the weight of the bloom in the final rendering
  75505. */
  75506. private _bloomWeight;
  75507. /**
  75508. * Specifies the luma threshold for the area that will be blurred by the bloom
  75509. */
  75510. private _bloomThreshold;
  75511. private _hdr;
  75512. /**
  75513. * The strength of the bloom.
  75514. */
  75515. set bloomWeight(value: number);
  75516. get bloomWeight(): number;
  75517. /**
  75518. * The strength of the bloom.
  75519. */
  75520. set bloomThreshold(value: number);
  75521. get bloomThreshold(): number;
  75522. /**
  75523. * The scale of the bloom, lower value will provide better performance.
  75524. */
  75525. set bloomScale(value: number);
  75526. get bloomScale(): number;
  75527. /**
  75528. * Enable or disable the bloom from the pipeline
  75529. */
  75530. set bloomEnabled(enabled: boolean);
  75531. get bloomEnabled(): boolean;
  75532. private _rebuildBloom;
  75533. /**
  75534. * If the depth of field is enabled.
  75535. */
  75536. get depthOfFieldEnabled(): boolean;
  75537. set depthOfFieldEnabled(enabled: boolean);
  75538. /**
  75539. * Blur level of the depth of field effect. (Higher blur will effect performance)
  75540. */
  75541. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  75542. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  75543. /**
  75544. * If the anti aliasing is enabled.
  75545. */
  75546. set fxaaEnabled(enabled: boolean);
  75547. get fxaaEnabled(): boolean;
  75548. private _samples;
  75549. /**
  75550. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75551. */
  75552. set samples(sampleCount: number);
  75553. get samples(): number;
  75554. /**
  75555. * If image processing is enabled.
  75556. */
  75557. set imageProcessingEnabled(enabled: boolean);
  75558. get imageProcessingEnabled(): boolean;
  75559. /**
  75560. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  75561. */
  75562. set glowLayerEnabled(enabled: boolean);
  75563. get glowLayerEnabled(): boolean;
  75564. /**
  75565. * Gets the glow layer (or null if not defined)
  75566. */
  75567. get glowLayer(): Nullable<GlowLayer>;
  75568. /**
  75569. * Enable or disable the chromaticAberration process from the pipeline
  75570. */
  75571. set chromaticAberrationEnabled(enabled: boolean);
  75572. get chromaticAberrationEnabled(): boolean;
  75573. /**
  75574. * Enable or disable the grain process from the pipeline
  75575. */
  75576. set grainEnabled(enabled: boolean);
  75577. get grainEnabled(): boolean;
  75578. /**
  75579. * @constructor
  75580. * @param name - The rendering pipeline name (default: "")
  75581. * @param hdr - If high dynamic range textures should be used (default: true)
  75582. * @param scene - The scene linked to this pipeline (default: the last created scene)
  75583. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  75584. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  75585. */
  75586. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  75587. /**
  75588. * Get the class name
  75589. * @returns "DefaultRenderingPipeline"
  75590. */
  75591. getClassName(): string;
  75592. /**
  75593. * Force the compilation of the entire pipeline.
  75594. */
  75595. prepare(): void;
  75596. private _hasCleared;
  75597. private _prevPostProcess;
  75598. private _prevPrevPostProcess;
  75599. private _setAutoClearAndTextureSharing;
  75600. private _depthOfFieldSceneObserver;
  75601. private _buildPipeline;
  75602. private _disposePostProcesses;
  75603. /**
  75604. * Adds a camera to the pipeline
  75605. * @param camera the camera to be added
  75606. */
  75607. addCamera(camera: Camera): void;
  75608. /**
  75609. * Removes a camera from the pipeline
  75610. * @param camera the camera to remove
  75611. */
  75612. removeCamera(camera: Camera): void;
  75613. /**
  75614. * Dispose of the pipeline and stop all post processes
  75615. */
  75616. dispose(): void;
  75617. /**
  75618. * Serialize the rendering pipeline (Used when exporting)
  75619. * @returns the serialized object
  75620. */
  75621. serialize(): any;
  75622. /**
  75623. * Parse the serialized pipeline
  75624. * @param source Source pipeline.
  75625. * @param scene The scene to load the pipeline to.
  75626. * @param rootUrl The URL of the serialized pipeline.
  75627. * @returns An instantiated pipeline from the serialized object.
  75628. */
  75629. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  75630. }
  75631. }
  75632. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  75633. /** @hidden */
  75634. export var lensHighlightsPixelShader: {
  75635. name: string;
  75636. shader: string;
  75637. };
  75638. }
  75639. declare module "babylonjs/Shaders/depthOfField.fragment" {
  75640. /** @hidden */
  75641. export var depthOfFieldPixelShader: {
  75642. name: string;
  75643. shader: string;
  75644. };
  75645. }
  75646. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  75647. import { Camera } from "babylonjs/Cameras/camera";
  75648. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75649. import { Scene } from "babylonjs/scene";
  75650. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75651. import "babylonjs/Shaders/chromaticAberration.fragment";
  75652. import "babylonjs/Shaders/lensHighlights.fragment";
  75653. import "babylonjs/Shaders/depthOfField.fragment";
  75654. /**
  75655. * BABYLON.JS Chromatic Aberration GLSL Shader
  75656. * Author: Olivier Guyot
  75657. * Separates very slightly R, G and B colors on the edges of the screen
  75658. * Inspired by Francois Tarlier & Martins Upitis
  75659. */
  75660. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  75661. /**
  75662. * @ignore
  75663. * The chromatic aberration PostProcess id in the pipeline
  75664. */
  75665. LensChromaticAberrationEffect: string;
  75666. /**
  75667. * @ignore
  75668. * The highlights enhancing PostProcess id in the pipeline
  75669. */
  75670. HighlightsEnhancingEffect: string;
  75671. /**
  75672. * @ignore
  75673. * The depth-of-field PostProcess id in the pipeline
  75674. */
  75675. LensDepthOfFieldEffect: string;
  75676. private _scene;
  75677. private _depthTexture;
  75678. private _grainTexture;
  75679. private _chromaticAberrationPostProcess;
  75680. private _highlightsPostProcess;
  75681. private _depthOfFieldPostProcess;
  75682. private _edgeBlur;
  75683. private _grainAmount;
  75684. private _chromaticAberration;
  75685. private _distortion;
  75686. private _highlightsGain;
  75687. private _highlightsThreshold;
  75688. private _dofDistance;
  75689. private _dofAperture;
  75690. private _dofDarken;
  75691. private _dofPentagon;
  75692. private _blurNoise;
  75693. /**
  75694. * @constructor
  75695. *
  75696. * Effect parameters are as follow:
  75697. * {
  75698. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75699. * edge_blur: number; // from 0 to x (1 for realism)
  75700. * distortion: number; // from 0 to x (1 for realism)
  75701. * grain_amount: number; // from 0 to 1
  75702. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75703. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75704. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75705. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75706. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75707. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75708. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75709. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75710. * }
  75711. * Note: if an effect parameter is unset, effect is disabled
  75712. *
  75713. * @param name The rendering pipeline name
  75714. * @param parameters - An object containing all parameters (see above)
  75715. * @param scene The scene linked to this pipeline
  75716. * @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)
  75717. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75718. */
  75719. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75720. /**
  75721. * Get the class name
  75722. * @returns "LensRenderingPipeline"
  75723. */
  75724. getClassName(): string;
  75725. /**
  75726. * Gets associated scene
  75727. */
  75728. get scene(): Scene;
  75729. /**
  75730. * Gets or sets the edge blur
  75731. */
  75732. get edgeBlur(): number;
  75733. set edgeBlur(value: number);
  75734. /**
  75735. * Gets or sets the grain amount
  75736. */
  75737. get grainAmount(): number;
  75738. set grainAmount(value: number);
  75739. /**
  75740. * Gets or sets the chromatic aberration amount
  75741. */
  75742. get chromaticAberration(): number;
  75743. set chromaticAberration(value: number);
  75744. /**
  75745. * Gets or sets the depth of field aperture
  75746. */
  75747. get dofAperture(): number;
  75748. set dofAperture(value: number);
  75749. /**
  75750. * Gets or sets the edge distortion
  75751. */
  75752. get edgeDistortion(): number;
  75753. set edgeDistortion(value: number);
  75754. /**
  75755. * Gets or sets the depth of field distortion
  75756. */
  75757. get dofDistortion(): number;
  75758. set dofDistortion(value: number);
  75759. /**
  75760. * Gets or sets the darken out of focus amount
  75761. */
  75762. get darkenOutOfFocus(): number;
  75763. set darkenOutOfFocus(value: number);
  75764. /**
  75765. * Gets or sets a boolean indicating if blur noise is enabled
  75766. */
  75767. get blurNoise(): boolean;
  75768. set blurNoise(value: boolean);
  75769. /**
  75770. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75771. */
  75772. get pentagonBokeh(): boolean;
  75773. set pentagonBokeh(value: boolean);
  75774. /**
  75775. * Gets or sets the highlight grain amount
  75776. */
  75777. get highlightsGain(): number;
  75778. set highlightsGain(value: number);
  75779. /**
  75780. * Gets or sets the highlight threshold
  75781. */
  75782. get highlightsThreshold(): number;
  75783. set highlightsThreshold(value: number);
  75784. /**
  75785. * Sets the amount of blur at the edges
  75786. * @param amount blur amount
  75787. */
  75788. setEdgeBlur(amount: number): void;
  75789. /**
  75790. * Sets edge blur to 0
  75791. */
  75792. disableEdgeBlur(): void;
  75793. /**
  75794. * Sets the amout of grain
  75795. * @param amount Amount of grain
  75796. */
  75797. setGrainAmount(amount: number): void;
  75798. /**
  75799. * Set grain amount to 0
  75800. */
  75801. disableGrain(): void;
  75802. /**
  75803. * Sets the chromatic aberration amount
  75804. * @param amount amount of chromatic aberration
  75805. */
  75806. setChromaticAberration(amount: number): void;
  75807. /**
  75808. * Sets chromatic aberration amount to 0
  75809. */
  75810. disableChromaticAberration(): void;
  75811. /**
  75812. * Sets the EdgeDistortion amount
  75813. * @param amount amount of EdgeDistortion
  75814. */
  75815. setEdgeDistortion(amount: number): void;
  75816. /**
  75817. * Sets edge distortion to 0
  75818. */
  75819. disableEdgeDistortion(): void;
  75820. /**
  75821. * Sets the FocusDistance amount
  75822. * @param amount amount of FocusDistance
  75823. */
  75824. setFocusDistance(amount: number): void;
  75825. /**
  75826. * Disables depth of field
  75827. */
  75828. disableDepthOfField(): void;
  75829. /**
  75830. * Sets the Aperture amount
  75831. * @param amount amount of Aperture
  75832. */
  75833. setAperture(amount: number): void;
  75834. /**
  75835. * Sets the DarkenOutOfFocus amount
  75836. * @param amount amount of DarkenOutOfFocus
  75837. */
  75838. setDarkenOutOfFocus(amount: number): void;
  75839. private _pentagonBokehIsEnabled;
  75840. /**
  75841. * Creates a pentagon bokeh effect
  75842. */
  75843. enablePentagonBokeh(): void;
  75844. /**
  75845. * Disables the pentagon bokeh effect
  75846. */
  75847. disablePentagonBokeh(): void;
  75848. /**
  75849. * Enables noise blur
  75850. */
  75851. enableNoiseBlur(): void;
  75852. /**
  75853. * Disables noise blur
  75854. */
  75855. disableNoiseBlur(): void;
  75856. /**
  75857. * Sets the HighlightsGain amount
  75858. * @param amount amount of HighlightsGain
  75859. */
  75860. setHighlightsGain(amount: number): void;
  75861. /**
  75862. * Sets the HighlightsThreshold amount
  75863. * @param amount amount of HighlightsThreshold
  75864. */
  75865. setHighlightsThreshold(amount: number): void;
  75866. /**
  75867. * Disables highlights
  75868. */
  75869. disableHighlights(): void;
  75870. /**
  75871. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75872. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  75873. */
  75874. dispose(disableDepthRender?: boolean): void;
  75875. private _createChromaticAberrationPostProcess;
  75876. private _createHighlightsPostProcess;
  75877. private _createDepthOfFieldPostProcess;
  75878. private _createGrainTexture;
  75879. }
  75880. }
  75881. declare module "babylonjs/Rendering/ssao2Configuration" {
  75882. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75883. /**
  75884. * Contains all parameters needed for the prepass to perform
  75885. * screen space subsurface scattering
  75886. */
  75887. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75888. /**
  75889. * Is subsurface enabled
  75890. */
  75891. enabled: boolean;
  75892. /**
  75893. * Name of the configuration
  75894. */
  75895. name: string;
  75896. /**
  75897. * Textures that should be present in the MRT for this effect to work
  75898. */
  75899. readonly texturesRequired: number[];
  75900. }
  75901. }
  75902. declare module "babylonjs/Shaders/ssao2.fragment" {
  75903. /** @hidden */
  75904. export var ssao2PixelShader: {
  75905. name: string;
  75906. shader: string;
  75907. };
  75908. }
  75909. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  75910. /** @hidden */
  75911. export var ssaoCombinePixelShader: {
  75912. name: string;
  75913. shader: string;
  75914. };
  75915. }
  75916. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  75917. import { Camera } from "babylonjs/Cameras/camera";
  75918. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75919. import { Scene } from "babylonjs/scene";
  75920. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75921. import "babylonjs/Shaders/ssao2.fragment";
  75922. import "babylonjs/Shaders/ssaoCombine.fragment";
  75923. /**
  75924. * Render pipeline to produce ssao effect
  75925. */
  75926. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75927. /**
  75928. * @ignore
  75929. * The PassPostProcess id in the pipeline that contains the original scene color
  75930. */
  75931. SSAOOriginalSceneColorEffect: string;
  75932. /**
  75933. * @ignore
  75934. * The SSAO PostProcess id in the pipeline
  75935. */
  75936. SSAORenderEffect: string;
  75937. /**
  75938. * @ignore
  75939. * The horizontal blur PostProcess id in the pipeline
  75940. */
  75941. SSAOBlurHRenderEffect: string;
  75942. /**
  75943. * @ignore
  75944. * The vertical blur PostProcess id in the pipeline
  75945. */
  75946. SSAOBlurVRenderEffect: string;
  75947. /**
  75948. * @ignore
  75949. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75950. */
  75951. SSAOCombineRenderEffect: string;
  75952. /**
  75953. * The output strength of the SSAO post-process. Default value is 1.0.
  75954. */
  75955. totalStrength: number;
  75956. /**
  75957. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75958. */
  75959. maxZ: number;
  75960. /**
  75961. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75962. */
  75963. minZAspect: number;
  75964. private _samples;
  75965. /**
  75966. * Number of samples used for the SSAO calculations. Default value is 8
  75967. */
  75968. set samples(n: number);
  75969. get samples(): number;
  75970. private _textureSamples;
  75971. /**
  75972. * Number of samples to use for antialiasing
  75973. */
  75974. set textureSamples(n: number);
  75975. get textureSamples(): number;
  75976. /**
  75977. * Force rendering the geometry through geometry buffer
  75978. */
  75979. private _forceGeometryBuffer;
  75980. /**
  75981. * Ratio object used for SSAO ratio and blur ratio
  75982. */
  75983. private _ratio;
  75984. /**
  75985. * Dynamically generated sphere sampler.
  75986. */
  75987. private _sampleSphere;
  75988. /**
  75989. * Blur filter offsets
  75990. */
  75991. private _samplerOffsets;
  75992. private _expensiveBlur;
  75993. /**
  75994. * If bilateral blur should be used
  75995. */
  75996. set expensiveBlur(b: boolean);
  75997. get expensiveBlur(): boolean;
  75998. /**
  75999. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  76000. */
  76001. radius: number;
  76002. /**
  76003. * The base color of the SSAO post-process
  76004. * The final result is "base + ssao" between [0, 1]
  76005. */
  76006. base: number;
  76007. /**
  76008. * Support test.
  76009. */
  76010. static get IsSupported(): boolean;
  76011. private _scene;
  76012. private _randomTexture;
  76013. private _originalColorPostProcess;
  76014. private _ssaoPostProcess;
  76015. private _blurHPostProcess;
  76016. private _blurVPostProcess;
  76017. private _ssaoCombinePostProcess;
  76018. private _prePassRenderer;
  76019. /**
  76020. * Gets active scene
  76021. */
  76022. get scene(): Scene;
  76023. /**
  76024. * @constructor
  76025. * @param name The rendering pipeline name
  76026. * @param scene The scene linked to this pipeline
  76027. * @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 }
  76028. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76029. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  76030. */
  76031. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  76032. /**
  76033. * Get the class name
  76034. * @returns "SSAO2RenderingPipeline"
  76035. */
  76036. getClassName(): string;
  76037. /**
  76038. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  76039. */
  76040. dispose(disableGeometryBufferRenderer?: boolean): void;
  76041. private _createBlurPostProcess;
  76042. /** @hidden */
  76043. _rebuild(): void;
  76044. private _bits;
  76045. private _radicalInverse_VdC;
  76046. private _hammersley;
  76047. private _hemisphereSample_uniform;
  76048. private _generateHemisphere;
  76049. private _getDefinesForSSAO;
  76050. private _createSSAOPostProcess;
  76051. private _createSSAOCombinePostProcess;
  76052. private _createRandomTexture;
  76053. /**
  76054. * Serialize the rendering pipeline (Used when exporting)
  76055. * @returns the serialized object
  76056. */
  76057. serialize(): any;
  76058. /**
  76059. * Parse the serialized pipeline
  76060. * @param source Source pipeline.
  76061. * @param scene The scene to load the pipeline to.
  76062. * @param rootUrl The URL of the serialized pipeline.
  76063. * @returns An instantiated pipeline from the serialized object.
  76064. */
  76065. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  76066. }
  76067. }
  76068. declare module "babylonjs/Shaders/ssao.fragment" {
  76069. /** @hidden */
  76070. export var ssaoPixelShader: {
  76071. name: string;
  76072. shader: string;
  76073. };
  76074. }
  76075. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  76076. import { Camera } from "babylonjs/Cameras/camera";
  76077. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76078. import { Scene } from "babylonjs/scene";
  76079. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76080. import "babylonjs/Shaders/ssao.fragment";
  76081. import "babylonjs/Shaders/ssaoCombine.fragment";
  76082. /**
  76083. * Render pipeline to produce ssao effect
  76084. */
  76085. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  76086. /**
  76087. * @ignore
  76088. * The PassPostProcess id in the pipeline that contains the original scene color
  76089. */
  76090. SSAOOriginalSceneColorEffect: string;
  76091. /**
  76092. * @ignore
  76093. * The SSAO PostProcess id in the pipeline
  76094. */
  76095. SSAORenderEffect: string;
  76096. /**
  76097. * @ignore
  76098. * The horizontal blur PostProcess id in the pipeline
  76099. */
  76100. SSAOBlurHRenderEffect: string;
  76101. /**
  76102. * @ignore
  76103. * The vertical blur PostProcess id in the pipeline
  76104. */
  76105. SSAOBlurVRenderEffect: string;
  76106. /**
  76107. * @ignore
  76108. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  76109. */
  76110. SSAOCombineRenderEffect: string;
  76111. /**
  76112. * The output strength of the SSAO post-process. Default value is 1.0.
  76113. */
  76114. totalStrength: number;
  76115. /**
  76116. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  76117. */
  76118. radius: number;
  76119. /**
  76120. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  76121. * Must not be equal to fallOff and superior to fallOff.
  76122. * Default value is 0.0075
  76123. */
  76124. area: number;
  76125. /**
  76126. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  76127. * Must not be equal to area and inferior to area.
  76128. * Default value is 0.000001
  76129. */
  76130. fallOff: number;
  76131. /**
  76132. * The base color of the SSAO post-process
  76133. * The final result is "base + ssao" between [0, 1]
  76134. */
  76135. base: number;
  76136. private _scene;
  76137. private _depthTexture;
  76138. private _randomTexture;
  76139. private _originalColorPostProcess;
  76140. private _ssaoPostProcess;
  76141. private _blurHPostProcess;
  76142. private _blurVPostProcess;
  76143. private _ssaoCombinePostProcess;
  76144. private _firstUpdate;
  76145. /**
  76146. * Gets active scene
  76147. */
  76148. get scene(): Scene;
  76149. /**
  76150. * @constructor
  76151. * @param name - The rendering pipeline name
  76152. * @param scene - The scene linked to this pipeline
  76153. * @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 }
  76154. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  76155. */
  76156. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  76157. /**
  76158. * Get the class name
  76159. * @returns "SSAORenderingPipeline"
  76160. */
  76161. getClassName(): string;
  76162. /**
  76163. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  76164. */
  76165. dispose(disableDepthRender?: boolean): void;
  76166. private _createBlurPostProcess;
  76167. /** @hidden */
  76168. _rebuild(): void;
  76169. private _createSSAOPostProcess;
  76170. private _createSSAOCombinePostProcess;
  76171. private _createRandomTexture;
  76172. }
  76173. }
  76174. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  76175. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76176. /**
  76177. * Contains all parameters needed for the prepass to perform
  76178. * screen space reflections
  76179. */
  76180. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  76181. /**
  76182. * Is ssr enabled
  76183. */
  76184. enabled: boolean;
  76185. /**
  76186. * Name of the configuration
  76187. */
  76188. name: string;
  76189. /**
  76190. * Textures that should be present in the MRT for this effect to work
  76191. */
  76192. readonly texturesRequired: number[];
  76193. }
  76194. }
  76195. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  76196. /** @hidden */
  76197. export var screenSpaceReflectionPixelShader: {
  76198. name: string;
  76199. shader: string;
  76200. };
  76201. }
  76202. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  76203. import { Nullable } from "babylonjs/types";
  76204. import { Camera } from "babylonjs/Cameras/camera";
  76205. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76206. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  76207. import { Engine } from "babylonjs/Engines/engine";
  76208. import { Scene } from "babylonjs/scene";
  76209. /**
  76210. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  76211. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  76212. */
  76213. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  76214. /**
  76215. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  76216. */
  76217. threshold: number;
  76218. /**
  76219. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  76220. */
  76221. strength: number;
  76222. /**
  76223. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  76224. */
  76225. reflectionSpecularFalloffExponent: number;
  76226. /**
  76227. * 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]
  76228. */
  76229. step: number;
  76230. /**
  76231. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  76232. */
  76233. roughnessFactor: number;
  76234. private _forceGeometryBuffer;
  76235. private _geometryBufferRenderer;
  76236. private _prePassRenderer;
  76237. private _enableSmoothReflections;
  76238. private _reflectionSamples;
  76239. private _smoothSteps;
  76240. /**
  76241. * Gets a string identifying the name of the class
  76242. * @returns "ScreenSpaceReflectionPostProcess" string
  76243. */
  76244. getClassName(): string;
  76245. /**
  76246. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  76247. * @param name The name of the effect.
  76248. * @param scene The scene containing the objects to calculate reflections.
  76249. * @param options The required width/height ratio to downsize to before computing the render pass.
  76250. * @param camera The camera to apply the render pass to.
  76251. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76252. * @param engine The engine which the post process will be applied. (default: current engine)
  76253. * @param reusable If the post process can be reused on the same frame. (default: false)
  76254. * @param textureType Type of textures used when performing the post process. (default: 0)
  76255. * @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)
  76256. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  76257. */
  76258. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  76259. /**
  76260. * Gets wether or not smoothing reflections is enabled.
  76261. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76262. */
  76263. get enableSmoothReflections(): boolean;
  76264. /**
  76265. * Sets wether or not smoothing reflections is enabled.
  76266. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76267. */
  76268. set enableSmoothReflections(enabled: boolean);
  76269. /**
  76270. * Gets the number of samples taken while computing reflections. More samples count is high,
  76271. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76272. */
  76273. get reflectionSamples(): number;
  76274. /**
  76275. * Sets the number of samples taken while computing reflections. More samples count is high,
  76276. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76277. */
  76278. set reflectionSamples(samples: number);
  76279. /**
  76280. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  76281. * more the post-process will require GPU power and can generate a drop in FPS.
  76282. * Default value (5.0) work pretty well in all cases but can be adjusted.
  76283. */
  76284. get smoothSteps(): number;
  76285. set smoothSteps(steps: number);
  76286. private _updateEffectDefines;
  76287. /** @hidden */
  76288. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  76289. }
  76290. }
  76291. declare module "babylonjs/Shaders/standard.fragment" {
  76292. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  76293. /** @hidden */
  76294. export var standardPixelShader: {
  76295. name: string;
  76296. shader: string;
  76297. };
  76298. }
  76299. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  76300. import { Nullable } from "babylonjs/types";
  76301. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  76302. import { Camera } from "babylonjs/Cameras/camera";
  76303. import { Texture } from "babylonjs/Materials/Textures/texture";
  76304. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76305. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76306. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  76307. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  76308. import { IDisposable } from "babylonjs/scene";
  76309. import { SpotLight } from "babylonjs/Lights/spotLight";
  76310. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  76311. import { Scene } from "babylonjs/scene";
  76312. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76313. import { Animation } from "babylonjs/Animations/animation";
  76314. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76315. import "babylonjs/Shaders/standard.fragment";
  76316. /**
  76317. * Standard rendering pipeline
  76318. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76319. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  76320. */
  76321. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  76322. /**
  76323. * Public members
  76324. */
  76325. /**
  76326. * Post-process which contains the original scene color before the pipeline applies all the effects
  76327. */
  76328. originalPostProcess: Nullable<PostProcess>;
  76329. /**
  76330. * Post-process used to down scale an image x4
  76331. */
  76332. downSampleX4PostProcess: Nullable<PostProcess>;
  76333. /**
  76334. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  76335. */
  76336. brightPassPostProcess: Nullable<PostProcess>;
  76337. /**
  76338. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  76339. */
  76340. blurHPostProcesses: PostProcess[];
  76341. /**
  76342. * Post-process array storing all the vertical blur post-processes used by the pipeline
  76343. */
  76344. blurVPostProcesses: PostProcess[];
  76345. /**
  76346. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  76347. */
  76348. textureAdderPostProcess: Nullable<PostProcess>;
  76349. /**
  76350. * Post-process used to create volumetric lighting effect
  76351. */
  76352. volumetricLightPostProcess: Nullable<PostProcess>;
  76353. /**
  76354. * Post-process used to smooth the previous volumetric light post-process on the X axis
  76355. */
  76356. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  76357. /**
  76358. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  76359. */
  76360. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  76361. /**
  76362. * Post-process used to merge the volumetric light effect and the real scene color
  76363. */
  76364. volumetricLightMergePostProces: Nullable<PostProcess>;
  76365. /**
  76366. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  76367. */
  76368. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  76369. /**
  76370. * Base post-process used to calculate the average luminance of the final image for HDR
  76371. */
  76372. luminancePostProcess: Nullable<PostProcess>;
  76373. /**
  76374. * Post-processes used to create down sample post-processes in order to get
  76375. * the average luminance of the final image for HDR
  76376. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  76377. */
  76378. luminanceDownSamplePostProcesses: PostProcess[];
  76379. /**
  76380. * Post-process used to create a HDR effect (light adaptation)
  76381. */
  76382. hdrPostProcess: Nullable<PostProcess>;
  76383. /**
  76384. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  76385. */
  76386. textureAdderFinalPostProcess: Nullable<PostProcess>;
  76387. /**
  76388. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  76389. */
  76390. lensFlareFinalPostProcess: Nullable<PostProcess>;
  76391. /**
  76392. * Post-process used to merge the final HDR post-process and the real scene color
  76393. */
  76394. hdrFinalPostProcess: Nullable<PostProcess>;
  76395. /**
  76396. * Post-process used to create a lens flare effect
  76397. */
  76398. lensFlarePostProcess: Nullable<PostProcess>;
  76399. /**
  76400. * Post-process that merges the result of the lens flare post-process and the real scene color
  76401. */
  76402. lensFlareComposePostProcess: Nullable<PostProcess>;
  76403. /**
  76404. * Post-process used to create a motion blur effect
  76405. */
  76406. motionBlurPostProcess: Nullable<PostProcess>;
  76407. /**
  76408. * Post-process used to create a depth of field effect
  76409. */
  76410. depthOfFieldPostProcess: Nullable<PostProcess>;
  76411. /**
  76412. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  76413. */
  76414. fxaaPostProcess: Nullable<FxaaPostProcess>;
  76415. /**
  76416. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  76417. */
  76418. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  76419. /**
  76420. * Represents the brightness threshold in order to configure the illuminated surfaces
  76421. */
  76422. brightThreshold: number;
  76423. /**
  76424. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  76425. */
  76426. blurWidth: number;
  76427. /**
  76428. * Sets if the blur for highlighted surfaces must be only horizontal
  76429. */
  76430. horizontalBlur: boolean;
  76431. /**
  76432. * Gets the overall exposure used by the pipeline
  76433. */
  76434. get exposure(): number;
  76435. /**
  76436. * Sets the overall exposure used by the pipeline
  76437. */
  76438. set exposure(value: number);
  76439. /**
  76440. * Texture used typically to simulate "dirty" on camera lens
  76441. */
  76442. lensTexture: Nullable<Texture>;
  76443. /**
  76444. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  76445. */
  76446. volumetricLightCoefficient: number;
  76447. /**
  76448. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  76449. */
  76450. volumetricLightPower: number;
  76451. /**
  76452. * Used the set the blur intensity to smooth the volumetric lights
  76453. */
  76454. volumetricLightBlurScale: number;
  76455. /**
  76456. * Light (spot or directional) used to generate the volumetric lights rays
  76457. * The source light must have a shadow generate so the pipeline can get its
  76458. * depth map
  76459. */
  76460. sourceLight: Nullable<SpotLight | DirectionalLight>;
  76461. /**
  76462. * For eye adaptation, represents the minimum luminance the eye can see
  76463. */
  76464. hdrMinimumLuminance: number;
  76465. /**
  76466. * For eye adaptation, represents the decrease luminance speed
  76467. */
  76468. hdrDecreaseRate: number;
  76469. /**
  76470. * For eye adaptation, represents the increase luminance speed
  76471. */
  76472. hdrIncreaseRate: number;
  76473. /**
  76474. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76475. */
  76476. get hdrAutoExposure(): boolean;
  76477. /**
  76478. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76479. */
  76480. set hdrAutoExposure(value: boolean);
  76481. /**
  76482. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  76483. */
  76484. lensColorTexture: Nullable<Texture>;
  76485. /**
  76486. * The overall strengh for the lens flare effect
  76487. */
  76488. lensFlareStrength: number;
  76489. /**
  76490. * Dispersion coefficient for lens flare ghosts
  76491. */
  76492. lensFlareGhostDispersal: number;
  76493. /**
  76494. * Main lens flare halo width
  76495. */
  76496. lensFlareHaloWidth: number;
  76497. /**
  76498. * Based on the lens distortion effect, defines how much the lens flare result
  76499. * is distorted
  76500. */
  76501. lensFlareDistortionStrength: number;
  76502. /**
  76503. * Configures the blur intensity used for for lens flare (halo)
  76504. */
  76505. lensFlareBlurWidth: number;
  76506. /**
  76507. * Lens star texture must be used to simulate rays on the flares and is available
  76508. * in the documentation
  76509. */
  76510. lensStarTexture: Nullable<Texture>;
  76511. /**
  76512. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  76513. * flare effect by taking account of the dirt texture
  76514. */
  76515. lensFlareDirtTexture: Nullable<Texture>;
  76516. /**
  76517. * Represents the focal length for the depth of field effect
  76518. */
  76519. depthOfFieldDistance: number;
  76520. /**
  76521. * Represents the blur intensity for the blurred part of the depth of field effect
  76522. */
  76523. depthOfFieldBlurWidth: number;
  76524. /**
  76525. * Gets how much the image is blurred by the movement while using the motion blur post-process
  76526. */
  76527. get motionStrength(): number;
  76528. /**
  76529. * Sets how much the image is blurred by the movement while using the motion blur post-process
  76530. */
  76531. set motionStrength(strength: number);
  76532. /**
  76533. * Gets wether or not the motion blur post-process is object based or screen based.
  76534. */
  76535. get objectBasedMotionBlur(): boolean;
  76536. /**
  76537. * Sets wether or not the motion blur post-process should be object based or screen based
  76538. */
  76539. set objectBasedMotionBlur(value: boolean);
  76540. /**
  76541. * List of animations for the pipeline (IAnimatable implementation)
  76542. */
  76543. animations: Animation[];
  76544. /**
  76545. * Private members
  76546. */
  76547. private _scene;
  76548. private _currentDepthOfFieldSource;
  76549. private _basePostProcess;
  76550. private _fixedExposure;
  76551. private _currentExposure;
  76552. private _hdrAutoExposure;
  76553. private _hdrCurrentLuminance;
  76554. private _motionStrength;
  76555. private _isObjectBasedMotionBlur;
  76556. private _floatTextureType;
  76557. private _camerasToBeAttached;
  76558. private _ratio;
  76559. private _bloomEnabled;
  76560. private _depthOfFieldEnabled;
  76561. private _vlsEnabled;
  76562. private _lensFlareEnabled;
  76563. private _hdrEnabled;
  76564. private _motionBlurEnabled;
  76565. private _fxaaEnabled;
  76566. private _screenSpaceReflectionsEnabled;
  76567. private _motionBlurSamples;
  76568. private _volumetricLightStepsCount;
  76569. private _samples;
  76570. /**
  76571. * @ignore
  76572. * Specifies if the bloom pipeline is enabled
  76573. */
  76574. get BloomEnabled(): boolean;
  76575. set BloomEnabled(enabled: boolean);
  76576. /**
  76577. * @ignore
  76578. * Specifies if the depth of field pipeline is enabed
  76579. */
  76580. get DepthOfFieldEnabled(): boolean;
  76581. set DepthOfFieldEnabled(enabled: boolean);
  76582. /**
  76583. * @ignore
  76584. * Specifies if the lens flare pipeline is enabed
  76585. */
  76586. get LensFlareEnabled(): boolean;
  76587. set LensFlareEnabled(enabled: boolean);
  76588. /**
  76589. * @ignore
  76590. * Specifies if the HDR pipeline is enabled
  76591. */
  76592. get HDREnabled(): boolean;
  76593. set HDREnabled(enabled: boolean);
  76594. /**
  76595. * @ignore
  76596. * Specifies if the volumetric lights scattering effect is enabled
  76597. */
  76598. get VLSEnabled(): boolean;
  76599. set VLSEnabled(enabled: boolean);
  76600. /**
  76601. * @ignore
  76602. * Specifies if the motion blur effect is enabled
  76603. */
  76604. get MotionBlurEnabled(): boolean;
  76605. set MotionBlurEnabled(enabled: boolean);
  76606. /**
  76607. * Specifies if anti-aliasing is enabled
  76608. */
  76609. get fxaaEnabled(): boolean;
  76610. set fxaaEnabled(enabled: boolean);
  76611. /**
  76612. * Specifies if screen space reflections are enabled.
  76613. */
  76614. get screenSpaceReflectionsEnabled(): boolean;
  76615. set screenSpaceReflectionsEnabled(enabled: boolean);
  76616. /**
  76617. * Specifies the number of steps used to calculate the volumetric lights
  76618. * Typically in interval [50, 200]
  76619. */
  76620. get volumetricLightStepsCount(): number;
  76621. set volumetricLightStepsCount(count: number);
  76622. /**
  76623. * Specifies the number of samples used for the motion blur effect
  76624. * Typically in interval [16, 64]
  76625. */
  76626. get motionBlurSamples(): number;
  76627. set motionBlurSamples(samples: number);
  76628. /**
  76629. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  76630. */
  76631. get samples(): number;
  76632. set samples(sampleCount: number);
  76633. /**
  76634. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76635. * @constructor
  76636. * @param name The rendering pipeline name
  76637. * @param scene The scene linked to this pipeline
  76638. * @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)
  76639. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  76640. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76641. */
  76642. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  76643. private _buildPipeline;
  76644. private _createDownSampleX4PostProcess;
  76645. private _createBrightPassPostProcess;
  76646. private _createBlurPostProcesses;
  76647. private _createTextureAdderPostProcess;
  76648. private _createVolumetricLightPostProcess;
  76649. private _createLuminancePostProcesses;
  76650. private _createHdrPostProcess;
  76651. private _createLensFlarePostProcess;
  76652. private _createDepthOfFieldPostProcess;
  76653. private _createMotionBlurPostProcess;
  76654. private _getDepthTexture;
  76655. private _disposePostProcesses;
  76656. /**
  76657. * Dispose of the pipeline and stop all post processes
  76658. */
  76659. dispose(): void;
  76660. /**
  76661. * Serialize the rendering pipeline (Used when exporting)
  76662. * @returns the serialized object
  76663. */
  76664. serialize(): any;
  76665. /**
  76666. * Parse the serialized pipeline
  76667. * @param source Source pipeline.
  76668. * @param scene The scene to load the pipeline to.
  76669. * @param rootUrl The URL of the serialized pipeline.
  76670. * @returns An instantiated pipeline from the serialized object.
  76671. */
  76672. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  76673. /**
  76674. * Luminance steps
  76675. */
  76676. static LuminanceSteps: number;
  76677. }
  76678. }
  76679. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  76680. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  76681. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  76682. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  76683. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  76684. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  76685. }
  76686. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  76687. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  76688. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  76689. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76690. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  76691. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76692. }
  76693. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  76694. /** @hidden */
  76695. export var stereoscopicInterlacePixelShader: {
  76696. name: string;
  76697. shader: string;
  76698. };
  76699. }
  76700. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  76701. import { Camera } from "babylonjs/Cameras/camera";
  76702. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76703. import { Engine } from "babylonjs/Engines/engine";
  76704. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  76705. /**
  76706. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  76707. */
  76708. export class StereoscopicInterlacePostProcessI extends PostProcess {
  76709. private _stepSize;
  76710. private _passedProcess;
  76711. /**
  76712. * Gets a string identifying the name of the class
  76713. * @returns "StereoscopicInterlacePostProcessI" string
  76714. */
  76715. getClassName(): string;
  76716. /**
  76717. * Initializes a StereoscopicInterlacePostProcessI
  76718. * @param name The name of the effect.
  76719. * @param rigCameras The rig cameras to be appled to the post process
  76720. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  76721. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  76722. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76723. * @param engine The engine which the post process will be applied. (default: current engine)
  76724. * @param reusable If the post process can be reused on the same frame. (default: false)
  76725. */
  76726. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76727. }
  76728. /**
  76729. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  76730. */
  76731. export class StereoscopicInterlacePostProcess extends PostProcess {
  76732. private _stepSize;
  76733. private _passedProcess;
  76734. /**
  76735. * Gets a string identifying the name of the class
  76736. * @returns "StereoscopicInterlacePostProcess" string
  76737. */
  76738. getClassName(): string;
  76739. /**
  76740. * Initializes a StereoscopicInterlacePostProcess
  76741. * @param name The name of the effect.
  76742. * @param rigCameras The rig cameras to be appled to the post process
  76743. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  76744. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76745. * @param engine The engine which the post process will be applied. (default: current engine)
  76746. * @param reusable If the post process can be reused on the same frame. (default: false)
  76747. */
  76748. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76749. }
  76750. }
  76751. declare module "babylonjs/Shaders/tonemap.fragment" {
  76752. /** @hidden */
  76753. export var tonemapPixelShader: {
  76754. name: string;
  76755. shader: string;
  76756. };
  76757. }
  76758. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  76759. import { Camera } from "babylonjs/Cameras/camera";
  76760. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76761. import "babylonjs/Shaders/tonemap.fragment";
  76762. import { Engine } from "babylonjs/Engines/engine";
  76763. /** Defines operator used for tonemapping */
  76764. export enum TonemappingOperator {
  76765. /** Hable */
  76766. Hable = 0,
  76767. /** Reinhard */
  76768. Reinhard = 1,
  76769. /** HejiDawson */
  76770. HejiDawson = 2,
  76771. /** Photographic */
  76772. Photographic = 3
  76773. }
  76774. /**
  76775. * Defines a post process to apply tone mapping
  76776. */
  76777. export class TonemapPostProcess extends PostProcess {
  76778. private _operator;
  76779. /** Defines the required exposure adjustement */
  76780. exposureAdjustment: number;
  76781. /**
  76782. * Gets a string identifying the name of the class
  76783. * @returns "TonemapPostProcess" string
  76784. */
  76785. getClassName(): string;
  76786. /**
  76787. * Creates a new TonemapPostProcess
  76788. * @param name defines the name of the postprocess
  76789. * @param _operator defines the operator to use
  76790. * @param exposureAdjustment defines the required exposure adjustement
  76791. * @param camera defines the camera to use (can be null)
  76792. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76793. * @param engine defines the hosting engine (can be ignore if camera is set)
  76794. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76795. */
  76796. constructor(name: string, _operator: TonemappingOperator,
  76797. /** Defines the required exposure adjustement */
  76798. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76799. }
  76800. }
  76801. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  76802. /** @hidden */
  76803. export var volumetricLightScatteringPixelShader: {
  76804. name: string;
  76805. shader: string;
  76806. };
  76807. }
  76808. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  76809. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76810. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76811. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76812. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76813. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76814. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76815. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76816. /** @hidden */
  76817. export var volumetricLightScatteringPassVertexShader: {
  76818. name: string;
  76819. shader: string;
  76820. };
  76821. }
  76822. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  76823. /** @hidden */
  76824. export var volumetricLightScatteringPassPixelShader: {
  76825. name: string;
  76826. shader: string;
  76827. };
  76828. }
  76829. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  76830. import { Vector3 } from "babylonjs/Maths/math.vector";
  76831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76832. import { Mesh } from "babylonjs/Meshes/mesh";
  76833. import { Camera } from "babylonjs/Cameras/camera";
  76834. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  76835. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76836. import { Scene } from "babylonjs/scene";
  76837. import "babylonjs/Meshes/Builders/planeBuilder";
  76838. import "babylonjs/Shaders/depth.vertex";
  76839. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  76840. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  76841. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  76842. import { Engine } from "babylonjs/Engines/engine";
  76843. /**
  76844. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76845. */
  76846. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76847. private _volumetricLightScatteringPass;
  76848. private _volumetricLightScatteringRTT;
  76849. private _viewPort;
  76850. private _screenCoordinates;
  76851. private _cachedDefines;
  76852. /**
  76853. * If not undefined, the mesh position is computed from the attached node position
  76854. */
  76855. attachedNode: {
  76856. position: Vector3;
  76857. };
  76858. /**
  76859. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76860. */
  76861. customMeshPosition: Vector3;
  76862. /**
  76863. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76864. */
  76865. useCustomMeshPosition: boolean;
  76866. /**
  76867. * If the post-process should inverse the light scattering direction
  76868. */
  76869. invert: boolean;
  76870. /**
  76871. * The internal mesh used by the post-process
  76872. */
  76873. mesh: Mesh;
  76874. /**
  76875. * @hidden
  76876. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76877. */
  76878. get useDiffuseColor(): boolean;
  76879. set useDiffuseColor(useDiffuseColor: boolean);
  76880. /**
  76881. * Array containing the excluded meshes not rendered in the internal pass
  76882. */
  76883. excludedMeshes: AbstractMesh[];
  76884. /**
  76885. * Controls the overall intensity of the post-process
  76886. */
  76887. exposure: number;
  76888. /**
  76889. * Dissipates each sample's contribution in range [0, 1]
  76890. */
  76891. decay: number;
  76892. /**
  76893. * Controls the overall intensity of each sample
  76894. */
  76895. weight: number;
  76896. /**
  76897. * Controls the density of each sample
  76898. */
  76899. density: number;
  76900. /**
  76901. * @constructor
  76902. * @param name The post-process name
  76903. * @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)
  76904. * @param camera The camera that the post-process will be attached to
  76905. * @param mesh The mesh used to create the light scattering
  76906. * @param samples The post-process quality, default 100
  76907. * @param samplingModeThe post-process filtering mode
  76908. * @param engine The babylon engine
  76909. * @param reusable If the post-process is reusable
  76910. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76911. */
  76912. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76913. /**
  76914. * Returns the string "VolumetricLightScatteringPostProcess"
  76915. * @returns "VolumetricLightScatteringPostProcess"
  76916. */
  76917. getClassName(): string;
  76918. private _isReady;
  76919. /**
  76920. * Sets the new light position for light scattering effect
  76921. * @param position The new custom light position
  76922. */
  76923. setCustomMeshPosition(position: Vector3): void;
  76924. /**
  76925. * Returns the light position for light scattering effect
  76926. * @return Vector3 The custom light position
  76927. */
  76928. getCustomMeshPosition(): Vector3;
  76929. /**
  76930. * Disposes the internal assets and detaches the post-process from the camera
  76931. */
  76932. dispose(camera: Camera): void;
  76933. /**
  76934. * Returns the render target texture used by the post-process
  76935. * @return the render target texture used by the post-process
  76936. */
  76937. getPass(): RenderTargetTexture;
  76938. private _meshExcluded;
  76939. private _createPass;
  76940. private _updateMeshScreenCoordinates;
  76941. /**
  76942. * Creates a default mesh for the Volumeric Light Scattering post-process
  76943. * @param name The mesh name
  76944. * @param scene The scene where to create the mesh
  76945. * @return the default mesh
  76946. */
  76947. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76948. }
  76949. }
  76950. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  76951. /** @hidden */
  76952. export var screenSpaceCurvaturePixelShader: {
  76953. name: string;
  76954. shader: string;
  76955. };
  76956. }
  76957. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  76958. import { Nullable } from "babylonjs/types";
  76959. import { Camera } from "babylonjs/Cameras/camera";
  76960. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76961. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76962. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  76963. import { Engine } from "babylonjs/Engines/engine";
  76964. import { Scene } from "babylonjs/scene";
  76965. /**
  76966. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76967. */
  76968. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76969. /**
  76970. * Defines how much ridge the curvature effect displays.
  76971. */
  76972. ridge: number;
  76973. /**
  76974. * Defines how much valley the curvature effect displays.
  76975. */
  76976. valley: number;
  76977. private _geometryBufferRenderer;
  76978. /**
  76979. * Gets a string identifying the name of the class
  76980. * @returns "ScreenSpaceCurvaturePostProcess" string
  76981. */
  76982. getClassName(): string;
  76983. /**
  76984. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76985. * @param name The name of the effect.
  76986. * @param scene The scene containing the objects to blur according to their velocity.
  76987. * @param options The required width/height ratio to downsize to before computing the render pass.
  76988. * @param camera The camera to apply the render pass to.
  76989. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76990. * @param engine The engine which the post process will be applied. (default: current engine)
  76991. * @param reusable If the post process can be reused on the same frame. (default: false)
  76992. * @param textureType Type of textures used when performing the post process. (default: 0)
  76993. * @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)
  76994. */
  76995. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76996. /**
  76997. * Support test.
  76998. */
  76999. static get IsSupported(): boolean;
  77000. /** @hidden */
  77001. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  77002. }
  77003. }
  77004. declare module "babylonjs/PostProcesses/index" {
  77005. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  77006. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  77007. export * from "babylonjs/PostProcesses/bloomEffect";
  77008. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  77009. export * from "babylonjs/PostProcesses/blurPostProcess";
  77010. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  77011. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  77012. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  77013. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  77014. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  77015. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  77016. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  77017. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  77018. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  77019. export * from "babylonjs/PostProcesses/filterPostProcess";
  77020. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  77021. export * from "babylonjs/PostProcesses/grainPostProcess";
  77022. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  77023. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  77024. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  77025. export * from "babylonjs/PostProcesses/passPostProcess";
  77026. export * from "babylonjs/PostProcesses/postProcess";
  77027. export * from "babylonjs/PostProcesses/postProcessManager";
  77028. export * from "babylonjs/PostProcesses/refractionPostProcess";
  77029. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  77030. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  77031. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  77032. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  77033. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  77034. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  77035. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  77036. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  77037. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  77038. }
  77039. declare module "babylonjs/Probes/index" {
  77040. export * from "babylonjs/Probes/reflectionProbe";
  77041. }
  77042. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  77043. import { Scene } from "babylonjs/scene";
  77044. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77045. import { SmartArray } from "babylonjs/Misc/smartArray";
  77046. import { ISceneComponent } from "babylonjs/sceneComponent";
  77047. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  77048. import "babylonjs/Meshes/Builders/boxBuilder";
  77049. import "babylonjs/Shaders/color.fragment";
  77050. import "babylonjs/Shaders/color.vertex";
  77051. import { Color3 } from "babylonjs/Maths/math.color";
  77052. import { Observable } from "babylonjs/Misc/observable";
  77053. module "babylonjs/scene" {
  77054. interface Scene {
  77055. /** @hidden (Backing field) */
  77056. _boundingBoxRenderer: BoundingBoxRenderer;
  77057. /** @hidden (Backing field) */
  77058. _forceShowBoundingBoxes: boolean;
  77059. /**
  77060. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  77061. */
  77062. forceShowBoundingBoxes: boolean;
  77063. /**
  77064. * Gets the bounding box renderer associated with the scene
  77065. * @returns a BoundingBoxRenderer
  77066. */
  77067. getBoundingBoxRenderer(): BoundingBoxRenderer;
  77068. }
  77069. }
  77070. module "babylonjs/Meshes/abstractMesh" {
  77071. interface AbstractMesh {
  77072. /** @hidden (Backing field) */
  77073. _showBoundingBox: boolean;
  77074. /**
  77075. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  77076. */
  77077. showBoundingBox: boolean;
  77078. }
  77079. }
  77080. /**
  77081. * Component responsible of rendering the bounding box of the meshes in a scene.
  77082. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  77083. */
  77084. export class BoundingBoxRenderer implements ISceneComponent {
  77085. /**
  77086. * The component name helpfull to identify the component in the list of scene components.
  77087. */
  77088. readonly name: string;
  77089. /**
  77090. * The scene the component belongs to.
  77091. */
  77092. scene: Scene;
  77093. /**
  77094. * Color of the bounding box lines placed in front of an object
  77095. */
  77096. frontColor: Color3;
  77097. /**
  77098. * Color of the bounding box lines placed behind an object
  77099. */
  77100. backColor: Color3;
  77101. /**
  77102. * Defines if the renderer should show the back lines or not
  77103. */
  77104. showBackLines: boolean;
  77105. /**
  77106. * Observable raised before rendering a bounding box
  77107. */
  77108. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  77109. /**
  77110. * Observable raised after rendering a bounding box
  77111. */
  77112. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  77113. /**
  77114. * Observable raised after resources are created
  77115. */
  77116. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  77117. /**
  77118. * When false, no bounding boxes will be rendered
  77119. */
  77120. enabled: boolean;
  77121. /**
  77122. * @hidden
  77123. */
  77124. renderList: SmartArray<BoundingBox>;
  77125. private _colorShader;
  77126. private _vertexBuffers;
  77127. private _indexBuffer;
  77128. private _fillIndexBuffer;
  77129. private _fillIndexData;
  77130. /**
  77131. * Instantiates a new bounding box renderer in a scene.
  77132. * @param scene the scene the renderer renders in
  77133. */
  77134. constructor(scene: Scene);
  77135. /**
  77136. * Registers the component in a given scene
  77137. */
  77138. register(): void;
  77139. private _evaluateSubMesh;
  77140. private _preActiveMesh;
  77141. private _prepareResources;
  77142. private _createIndexBuffer;
  77143. /**
  77144. * Rebuilds the elements related to this component in case of
  77145. * context lost for instance.
  77146. */
  77147. rebuild(): void;
  77148. /**
  77149. * @hidden
  77150. */
  77151. reset(): void;
  77152. /**
  77153. * Render the bounding boxes of a specific rendering group
  77154. * @param renderingGroupId defines the rendering group to render
  77155. */
  77156. render(renderingGroupId: number): void;
  77157. /**
  77158. * In case of occlusion queries, we can render the occlusion bounding box through this method
  77159. * @param mesh Define the mesh to render the occlusion bounding box for
  77160. */
  77161. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  77162. /**
  77163. * Dispose and release the resources attached to this renderer.
  77164. */
  77165. dispose(): void;
  77166. }
  77167. }
  77168. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  77169. import { Nullable } from "babylonjs/types";
  77170. import { Scene } from "babylonjs/scene";
  77171. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  77172. import { Camera } from "babylonjs/Cameras/camera";
  77173. import { ISceneComponent } from "babylonjs/sceneComponent";
  77174. module "babylonjs/scene" {
  77175. interface Scene {
  77176. /** @hidden (Backing field) */
  77177. _depthRenderer: {
  77178. [id: string]: DepthRenderer;
  77179. };
  77180. /**
  77181. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  77182. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  77183. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  77184. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  77185. * @returns the created depth renderer
  77186. */
  77187. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  77188. /**
  77189. * Disables a depth renderer for a given camera
  77190. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  77191. */
  77192. disableDepthRenderer(camera?: Nullable<Camera>): void;
  77193. }
  77194. }
  77195. /**
  77196. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  77197. * in several rendering techniques.
  77198. */
  77199. export class DepthRendererSceneComponent implements ISceneComponent {
  77200. /**
  77201. * The component name helpfull to identify the component in the list of scene components.
  77202. */
  77203. readonly name: string;
  77204. /**
  77205. * The scene the component belongs to.
  77206. */
  77207. scene: Scene;
  77208. /**
  77209. * Creates a new instance of the component for the given scene
  77210. * @param scene Defines the scene to register the component in
  77211. */
  77212. constructor(scene: Scene);
  77213. /**
  77214. * Registers the component in a given scene
  77215. */
  77216. register(): void;
  77217. /**
  77218. * Rebuilds the elements related to this component in case of
  77219. * context lost for instance.
  77220. */
  77221. rebuild(): void;
  77222. /**
  77223. * Disposes the component and the associated ressources
  77224. */
  77225. dispose(): void;
  77226. private _gatherRenderTargets;
  77227. private _gatherActiveCameraRenderTargets;
  77228. }
  77229. }
  77230. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  77231. import { Nullable } from "babylonjs/types";
  77232. import { Scene } from "babylonjs/scene";
  77233. import { ISceneComponent } from "babylonjs/sceneComponent";
  77234. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  77235. module "babylonjs/abstractScene" {
  77236. interface AbstractScene {
  77237. /** @hidden (Backing field) */
  77238. _prePassRenderer: Nullable<PrePassRenderer>;
  77239. /**
  77240. * Gets or Sets the current prepass renderer associated to the scene.
  77241. */
  77242. prePassRenderer: Nullable<PrePassRenderer>;
  77243. /**
  77244. * Enables the prepass and associates it with the scene
  77245. * @returns the PrePassRenderer
  77246. */
  77247. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  77248. /**
  77249. * Disables the prepass associated with the scene
  77250. */
  77251. disablePrePassRenderer(): void;
  77252. }
  77253. }
  77254. /**
  77255. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77256. * in several rendering techniques.
  77257. */
  77258. export class PrePassRendererSceneComponent implements ISceneComponent {
  77259. /**
  77260. * The component name helpful to identify the component in the list of scene components.
  77261. */
  77262. readonly name: string;
  77263. /**
  77264. * The scene the component belongs to.
  77265. */
  77266. scene: Scene;
  77267. /**
  77268. * Creates a new instance of the component for the given scene
  77269. * @param scene Defines the scene to register the component in
  77270. */
  77271. constructor(scene: Scene);
  77272. /**
  77273. * Registers the component in a given scene
  77274. */
  77275. register(): void;
  77276. private _beforeCameraDraw;
  77277. private _afterCameraDraw;
  77278. private _beforeClearStage;
  77279. /**
  77280. * Rebuilds the elements related to this component in case of
  77281. * context lost for instance.
  77282. */
  77283. rebuild(): void;
  77284. /**
  77285. * Disposes the component and the associated ressources
  77286. */
  77287. dispose(): void;
  77288. }
  77289. }
  77290. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  77291. /** @hidden */
  77292. export var fibonacci: {
  77293. name: string;
  77294. shader: string;
  77295. };
  77296. }
  77297. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  77298. /** @hidden */
  77299. export var diffusionProfile: {
  77300. name: string;
  77301. shader: string;
  77302. };
  77303. }
  77304. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  77305. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  77306. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  77307. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  77308. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  77309. /** @hidden */
  77310. export var subSurfaceScatteringPixelShader: {
  77311. name: string;
  77312. shader: string;
  77313. };
  77314. }
  77315. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  77316. import { Nullable } from "babylonjs/types";
  77317. import { Camera } from "babylonjs/Cameras/camera";
  77318. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77319. import { Engine } from "babylonjs/Engines/engine";
  77320. import { Scene } from "babylonjs/scene";
  77321. import "babylonjs/Shaders/imageProcessing.fragment";
  77322. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  77323. import "babylonjs/Shaders/postprocess.vertex";
  77324. /**
  77325. * Sub surface scattering post process
  77326. */
  77327. export class SubSurfaceScatteringPostProcess extends PostProcess {
  77328. /**
  77329. * Gets a string identifying the name of the class
  77330. * @returns "SubSurfaceScatteringPostProcess" string
  77331. */
  77332. getClassName(): string;
  77333. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  77334. }
  77335. }
  77336. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  77337. import { Scene } from "babylonjs/scene";
  77338. import { Color3 } from "babylonjs/Maths/math.color";
  77339. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  77340. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  77341. /**
  77342. * Contains all parameters needed for the prepass to perform
  77343. * screen space subsurface scattering
  77344. */
  77345. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  77346. /** @hidden */
  77347. static _SceneComponentInitialization: (scene: Scene) => void;
  77348. private _ssDiffusionS;
  77349. private _ssFilterRadii;
  77350. private _ssDiffusionD;
  77351. /**
  77352. * Post process to attach for screen space subsurface scattering
  77353. */
  77354. postProcess: SubSurfaceScatteringPostProcess;
  77355. /**
  77356. * Diffusion profile color for subsurface scattering
  77357. */
  77358. get ssDiffusionS(): number[];
  77359. /**
  77360. * Diffusion profile max color channel value for subsurface scattering
  77361. */
  77362. get ssDiffusionD(): number[];
  77363. /**
  77364. * Diffusion profile filter radius for subsurface scattering
  77365. */
  77366. get ssFilterRadii(): number[];
  77367. /**
  77368. * Is subsurface enabled
  77369. */
  77370. enabled: boolean;
  77371. /**
  77372. * Name of the configuration
  77373. */
  77374. name: string;
  77375. /**
  77376. * Diffusion profile colors for subsurface scattering
  77377. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  77378. * See ...
  77379. * Note that you can only store up to 5 of them
  77380. */
  77381. ssDiffusionProfileColors: Color3[];
  77382. /**
  77383. * Defines the ratio real world => scene units.
  77384. * Used for subsurface scattering
  77385. */
  77386. metersPerUnit: number;
  77387. /**
  77388. * Textures that should be present in the MRT for this effect to work
  77389. */
  77390. readonly texturesRequired: number[];
  77391. private _scene;
  77392. /**
  77393. * Builds a subsurface configuration object
  77394. * @param scene The scene
  77395. */
  77396. constructor(scene: Scene);
  77397. /**
  77398. * Adds a new diffusion profile.
  77399. * Useful for more realistic subsurface scattering on diverse materials.
  77400. * @param color The color of the diffusion profile. Should be the average color of the material.
  77401. * @return The index of the diffusion profile for the material subsurface configuration
  77402. */
  77403. addDiffusionProfile(color: Color3): number;
  77404. /**
  77405. * Creates the sss post process
  77406. * @return The created post process
  77407. */
  77408. createPostProcess(): SubSurfaceScatteringPostProcess;
  77409. /**
  77410. * Deletes all diffusion profiles.
  77411. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  77412. */
  77413. clearAllDiffusionProfiles(): void;
  77414. /**
  77415. * Disposes this object
  77416. */
  77417. dispose(): void;
  77418. /**
  77419. * @hidden
  77420. * https://zero-radiance.github.io/post/sampling-diffusion/
  77421. *
  77422. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  77423. * ------------------------------------------------------------------------------------
  77424. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  77425. * PDF[r, phi, s] = r * R[r, phi, s]
  77426. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  77427. * ------------------------------------------------------------------------------------
  77428. * We importance sample the color channel with the widest scattering distance.
  77429. */
  77430. getDiffusionProfileParameters(color: Color3): number;
  77431. /**
  77432. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  77433. * 'u' is the random number (the value of the CDF): [0, 1).
  77434. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  77435. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  77436. */
  77437. private _sampleBurleyDiffusionProfile;
  77438. }
  77439. }
  77440. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  77441. import { Nullable } from "babylonjs/types";
  77442. import { Scene } from "babylonjs/scene";
  77443. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  77444. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  77445. import { AbstractScene } from "babylonjs/abstractScene";
  77446. module "babylonjs/abstractScene" {
  77447. interface AbstractScene {
  77448. /** @hidden (Backing field) */
  77449. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77450. /**
  77451. * Gets or Sets the current prepass renderer associated to the scene.
  77452. */
  77453. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77454. /**
  77455. * Enables the subsurface effect for prepass
  77456. * @returns the SubSurfaceConfiguration
  77457. */
  77458. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  77459. /**
  77460. * Disables the subsurface effect for prepass
  77461. */
  77462. disableSubSurfaceForPrePass(): void;
  77463. }
  77464. }
  77465. /**
  77466. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77467. * in several rendering techniques.
  77468. */
  77469. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  77470. /**
  77471. * The component name helpful to identify the component in the list of scene components.
  77472. */
  77473. readonly name: string;
  77474. /**
  77475. * The scene the component belongs to.
  77476. */
  77477. scene: Scene;
  77478. /**
  77479. * Creates a new instance of the component for the given scene
  77480. * @param scene Defines the scene to register the component in
  77481. */
  77482. constructor(scene: Scene);
  77483. /**
  77484. * Registers the component in a given scene
  77485. */
  77486. register(): void;
  77487. /**
  77488. * Serializes the component data to the specified json object
  77489. * @param serializationObject The object to serialize to
  77490. */
  77491. serialize(serializationObject: any): void;
  77492. /**
  77493. * Adds all the elements from the container to the scene
  77494. * @param container the container holding the elements
  77495. */
  77496. addFromContainer(container: AbstractScene): void;
  77497. /**
  77498. * Removes all the elements in the container from the scene
  77499. * @param container contains the elements to remove
  77500. * @param dispose if the removed element should be disposed (default: false)
  77501. */
  77502. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77503. /**
  77504. * Rebuilds the elements related to this component in case of
  77505. * context lost for instance.
  77506. */
  77507. rebuild(): void;
  77508. /**
  77509. * Disposes the component and the associated ressources
  77510. */
  77511. dispose(): void;
  77512. }
  77513. }
  77514. declare module "babylonjs/Shaders/outline.fragment" {
  77515. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  77516. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  77517. /** @hidden */
  77518. export var outlinePixelShader: {
  77519. name: string;
  77520. shader: string;
  77521. };
  77522. }
  77523. declare module "babylonjs/Shaders/outline.vertex" {
  77524. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  77525. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  77526. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  77527. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  77528. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  77529. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  77530. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  77531. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  77532. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  77533. /** @hidden */
  77534. export var outlineVertexShader: {
  77535. name: string;
  77536. shader: string;
  77537. };
  77538. }
  77539. declare module "babylonjs/Rendering/outlineRenderer" {
  77540. import { SubMesh } from "babylonjs/Meshes/subMesh";
  77541. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  77542. import { Scene } from "babylonjs/scene";
  77543. import { ISceneComponent } from "babylonjs/sceneComponent";
  77544. import "babylonjs/Shaders/outline.fragment";
  77545. import "babylonjs/Shaders/outline.vertex";
  77546. module "babylonjs/scene" {
  77547. interface Scene {
  77548. /** @hidden */
  77549. _outlineRenderer: OutlineRenderer;
  77550. /**
  77551. * Gets the outline renderer associated with the scene
  77552. * @returns a OutlineRenderer
  77553. */
  77554. getOutlineRenderer(): OutlineRenderer;
  77555. }
  77556. }
  77557. module "babylonjs/Meshes/abstractMesh" {
  77558. interface AbstractMesh {
  77559. /** @hidden (Backing field) */
  77560. _renderOutline: boolean;
  77561. /**
  77562. * Gets or sets a boolean indicating if the outline must be rendered as well
  77563. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  77564. */
  77565. renderOutline: boolean;
  77566. /** @hidden (Backing field) */
  77567. _renderOverlay: boolean;
  77568. /**
  77569. * Gets or sets a boolean indicating if the overlay must be rendered as well
  77570. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  77571. */
  77572. renderOverlay: boolean;
  77573. }
  77574. }
  77575. /**
  77576. * This class is responsible to draw bothe outline/overlay of meshes.
  77577. * It should not be used directly but through the available method on mesh.
  77578. */
  77579. export class OutlineRenderer implements ISceneComponent {
  77580. /**
  77581. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  77582. */
  77583. private static _StencilReference;
  77584. /**
  77585. * The name of the component. Each component must have a unique name.
  77586. */
  77587. name: string;
  77588. /**
  77589. * The scene the component belongs to.
  77590. */
  77591. scene: Scene;
  77592. /**
  77593. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  77594. */
  77595. zOffset: number;
  77596. private _engine;
  77597. private _effect;
  77598. private _cachedDefines;
  77599. private _savedDepthWrite;
  77600. /**
  77601. * Instantiates a new outline renderer. (There could be only one per scene).
  77602. * @param scene Defines the scene it belongs to
  77603. */
  77604. constructor(scene: Scene);
  77605. /**
  77606. * Register the component to one instance of a scene.
  77607. */
  77608. register(): void;
  77609. /**
  77610. * Rebuilds the elements related to this component in case of
  77611. * context lost for instance.
  77612. */
  77613. rebuild(): void;
  77614. /**
  77615. * Disposes the component and the associated ressources.
  77616. */
  77617. dispose(): void;
  77618. /**
  77619. * Renders the outline in the canvas.
  77620. * @param subMesh Defines the sumesh to render
  77621. * @param batch Defines the batch of meshes in case of instances
  77622. * @param useOverlay Defines if the rendering is for the overlay or the outline
  77623. */
  77624. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  77625. /**
  77626. * Returns whether or not the outline renderer is ready for a given submesh.
  77627. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  77628. * @param subMesh Defines the submesh to check readyness for
  77629. * @param useInstances Defines wheter wee are trying to render instances or not
  77630. * @returns true if ready otherwise false
  77631. */
  77632. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77633. private _beforeRenderingMesh;
  77634. private _afterRenderingMesh;
  77635. }
  77636. }
  77637. declare module "babylonjs/Rendering/index" {
  77638. export * from "babylonjs/Rendering/boundingBoxRenderer";
  77639. export * from "babylonjs/Rendering/depthRenderer";
  77640. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  77641. export * from "babylonjs/Rendering/edgesRenderer";
  77642. export * from "babylonjs/Rendering/geometryBufferRenderer";
  77643. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  77644. export * from "babylonjs/Rendering/prePassRenderer";
  77645. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  77646. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  77647. export * from "babylonjs/Rendering/outlineRenderer";
  77648. export * from "babylonjs/Rendering/renderingGroup";
  77649. export * from "babylonjs/Rendering/renderingManager";
  77650. export * from "babylonjs/Rendering/utilityLayerRenderer";
  77651. }
  77652. declare module "babylonjs/Sprites/ISprites" {
  77653. /**
  77654. * Defines the basic options interface of a Sprite Frame Source Size.
  77655. */
  77656. export interface ISpriteJSONSpriteSourceSize {
  77657. /**
  77658. * number of the original width of the Frame
  77659. */
  77660. w: number;
  77661. /**
  77662. * number of the original height of the Frame
  77663. */
  77664. h: number;
  77665. }
  77666. /**
  77667. * Defines the basic options interface of a Sprite Frame Data.
  77668. */
  77669. export interface ISpriteJSONSpriteFrameData {
  77670. /**
  77671. * number of the x offset of the Frame
  77672. */
  77673. x: number;
  77674. /**
  77675. * number of the y offset of the Frame
  77676. */
  77677. y: number;
  77678. /**
  77679. * number of the width of the Frame
  77680. */
  77681. w: number;
  77682. /**
  77683. * number of the height of the Frame
  77684. */
  77685. h: number;
  77686. }
  77687. /**
  77688. * Defines the basic options interface of a JSON Sprite.
  77689. */
  77690. export interface ISpriteJSONSprite {
  77691. /**
  77692. * string name of the Frame
  77693. */
  77694. filename: string;
  77695. /**
  77696. * ISpriteJSONSpriteFrame basic object of the frame data
  77697. */
  77698. frame: ISpriteJSONSpriteFrameData;
  77699. /**
  77700. * boolean to flag is the frame was rotated.
  77701. */
  77702. rotated: boolean;
  77703. /**
  77704. * boolean to flag is the frame was trimmed.
  77705. */
  77706. trimmed: boolean;
  77707. /**
  77708. * ISpriteJSONSpriteFrame basic object of the source data
  77709. */
  77710. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77711. /**
  77712. * ISpriteJSONSpriteFrame basic object of the source data
  77713. */
  77714. sourceSize: ISpriteJSONSpriteSourceSize;
  77715. }
  77716. /**
  77717. * Defines the basic options interface of a JSON atlas.
  77718. */
  77719. export interface ISpriteJSONAtlas {
  77720. /**
  77721. * Array of objects that contain the frame data.
  77722. */
  77723. frames: Array<ISpriteJSONSprite>;
  77724. /**
  77725. * object basic object containing the sprite meta data.
  77726. */
  77727. meta?: object;
  77728. }
  77729. }
  77730. declare module "babylonjs/Shaders/spriteMap.fragment" {
  77731. /** @hidden */
  77732. export var spriteMapPixelShader: {
  77733. name: string;
  77734. shader: string;
  77735. };
  77736. }
  77737. declare module "babylonjs/Shaders/spriteMap.vertex" {
  77738. /** @hidden */
  77739. export var spriteMapVertexShader: {
  77740. name: string;
  77741. shader: string;
  77742. };
  77743. }
  77744. declare module "babylonjs/Sprites/spriteMap" {
  77745. import { IDisposable, Scene } from "babylonjs/scene";
  77746. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  77747. import { Texture } from "babylonjs/Materials/Textures/texture";
  77748. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  77749. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  77750. import "babylonjs/Meshes/Builders/planeBuilder";
  77751. import "babylonjs/Shaders/spriteMap.fragment";
  77752. import "babylonjs/Shaders/spriteMap.vertex";
  77753. /**
  77754. * Defines the basic options interface of a SpriteMap
  77755. */
  77756. export interface ISpriteMapOptions {
  77757. /**
  77758. * Vector2 of the number of cells in the grid.
  77759. */
  77760. stageSize?: Vector2;
  77761. /**
  77762. * Vector2 of the size of the output plane in World Units.
  77763. */
  77764. outputSize?: Vector2;
  77765. /**
  77766. * Vector3 of the position of the output plane in World Units.
  77767. */
  77768. outputPosition?: Vector3;
  77769. /**
  77770. * Vector3 of the rotation of the output plane.
  77771. */
  77772. outputRotation?: Vector3;
  77773. /**
  77774. * number of layers that the system will reserve in resources.
  77775. */
  77776. layerCount?: number;
  77777. /**
  77778. * number of max animation frames a single cell will reserve in resources.
  77779. */
  77780. maxAnimationFrames?: number;
  77781. /**
  77782. * number cell index of the base tile when the system compiles.
  77783. */
  77784. baseTile?: number;
  77785. /**
  77786. * boolean flip the sprite after its been repositioned by the framing data.
  77787. */
  77788. flipU?: boolean;
  77789. /**
  77790. * Vector3 scalar of the global RGB values of the SpriteMap.
  77791. */
  77792. colorMultiply?: Vector3;
  77793. }
  77794. /**
  77795. * Defines the IDisposable interface in order to be cleanable from resources.
  77796. */
  77797. export interface ISpriteMap extends IDisposable {
  77798. /**
  77799. * String name of the SpriteMap.
  77800. */
  77801. name: string;
  77802. /**
  77803. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77804. */
  77805. atlasJSON: ISpriteJSONAtlas;
  77806. /**
  77807. * Texture of the SpriteMap.
  77808. */
  77809. spriteSheet: Texture;
  77810. /**
  77811. * The parameters to initialize the SpriteMap with.
  77812. */
  77813. options: ISpriteMapOptions;
  77814. }
  77815. /**
  77816. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77817. */
  77818. export class SpriteMap implements ISpriteMap {
  77819. /** The Name of the spriteMap */
  77820. name: string;
  77821. /** The JSON file with the frame and meta data */
  77822. atlasJSON: ISpriteJSONAtlas;
  77823. /** The systems Sprite Sheet Texture */
  77824. spriteSheet: Texture;
  77825. /** Arguments passed with the Constructor */
  77826. options: ISpriteMapOptions;
  77827. /** Public Sprite Storage array, parsed from atlasJSON */
  77828. sprites: Array<ISpriteJSONSprite>;
  77829. /** Returns the Number of Sprites in the System */
  77830. get spriteCount(): number;
  77831. /** Returns the Position of Output Plane*/
  77832. get position(): Vector3;
  77833. /** Returns the Position of Output Plane*/
  77834. set position(v: Vector3);
  77835. /** Returns the Rotation of Output Plane*/
  77836. get rotation(): Vector3;
  77837. /** Returns the Rotation of Output Plane*/
  77838. set rotation(v: Vector3);
  77839. /** Sets the AnimationMap*/
  77840. get animationMap(): RawTexture;
  77841. /** Sets the AnimationMap*/
  77842. set animationMap(v: RawTexture);
  77843. /** Scene that the SpriteMap was created in */
  77844. private _scene;
  77845. /** Texture Buffer of Float32 that holds tile frame data*/
  77846. private _frameMap;
  77847. /** Texture Buffers of Float32 that holds tileMap data*/
  77848. private _tileMaps;
  77849. /** Texture Buffer of Float32 that holds Animation Data*/
  77850. private _animationMap;
  77851. /** Custom ShaderMaterial Central to the System*/
  77852. private _material;
  77853. /** Custom ShaderMaterial Central to the System*/
  77854. private _output;
  77855. /** Systems Time Ticker*/
  77856. private _time;
  77857. /**
  77858. * Creates a new SpriteMap
  77859. * @param name defines the SpriteMaps Name
  77860. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77861. * @param spriteSheet is the Texture that the Sprites are on.
  77862. * @param options a basic deployment configuration
  77863. * @param scene The Scene that the map is deployed on
  77864. */
  77865. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77866. /**
  77867. * Returns tileID location
  77868. * @returns Vector2 the cell position ID
  77869. */
  77870. getTileID(): Vector2;
  77871. /**
  77872. * Gets the UV location of the mouse over the SpriteMap.
  77873. * @returns Vector2 the UV position of the mouse interaction
  77874. */
  77875. getMousePosition(): Vector2;
  77876. /**
  77877. * Creates the "frame" texture Buffer
  77878. * -------------------------------------
  77879. * Structure of frames
  77880. * "filename": "Falling-Water-2.png",
  77881. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77882. * "rotated": true,
  77883. * "trimmed": true,
  77884. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77885. * "sourceSize": {"w":32,"h":32}
  77886. * @returns RawTexture of the frameMap
  77887. */
  77888. private _createFrameBuffer;
  77889. /**
  77890. * Creates the tileMap texture Buffer
  77891. * @param buffer normally and array of numbers, or a false to generate from scratch
  77892. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77893. * @returns RawTexture of the tileMap
  77894. */
  77895. private _createTileBuffer;
  77896. /**
  77897. * Modifies the data of the tileMaps
  77898. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77899. * @param pos is the iVector2 Coordinates of the Tile
  77900. * @param tile The SpriteIndex of the new Tile
  77901. */
  77902. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77903. /**
  77904. * Creates the animationMap texture Buffer
  77905. * @param buffer normally and array of numbers, or a false to generate from scratch
  77906. * @returns RawTexture of the animationMap
  77907. */
  77908. private _createTileAnimationBuffer;
  77909. /**
  77910. * Modifies the data of the animationMap
  77911. * @param cellID is the Index of the Sprite
  77912. * @param _frame is the target Animation frame
  77913. * @param toCell is the Target Index of the next frame of the animation
  77914. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77915. * @param speed is a global scalar of the time variable on the map.
  77916. */
  77917. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77918. /**
  77919. * Exports the .tilemaps file
  77920. */
  77921. saveTileMaps(): void;
  77922. /**
  77923. * Imports the .tilemaps file
  77924. * @param url of the .tilemaps file
  77925. */
  77926. loadTileMaps(url: string): void;
  77927. /**
  77928. * Release associated resources
  77929. */
  77930. dispose(): void;
  77931. }
  77932. }
  77933. declare module "babylonjs/Sprites/spritePackedManager" {
  77934. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  77935. import { Scene } from "babylonjs/scene";
  77936. /**
  77937. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77938. * @see https://doc.babylonjs.com/babylon101/sprites
  77939. */
  77940. export class SpritePackedManager extends SpriteManager {
  77941. /** defines the packed manager's name */
  77942. name: string;
  77943. /**
  77944. * Creates a new sprite manager from a packed sprite sheet
  77945. * @param name defines the manager's name
  77946. * @param imgUrl defines the sprite sheet url
  77947. * @param capacity defines the maximum allowed number of sprites
  77948. * @param scene defines the hosting scene
  77949. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77950. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77951. * @param samplingMode defines the smapling mode to use with spritesheet
  77952. * @param fromPacked set to true; do not alter
  77953. */
  77954. constructor(
  77955. /** defines the packed manager's name */
  77956. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77957. }
  77958. }
  77959. declare module "babylonjs/Sprites/index" {
  77960. export * from "babylonjs/Sprites/sprite";
  77961. export * from "babylonjs/Sprites/ISprites";
  77962. export * from "babylonjs/Sprites/spriteManager";
  77963. export * from "babylonjs/Sprites/spriteMap";
  77964. export * from "babylonjs/Sprites/spritePackedManager";
  77965. export * from "babylonjs/Sprites/spriteSceneComponent";
  77966. }
  77967. declare module "babylonjs/States/index" {
  77968. export * from "babylonjs/States/alphaCullingState";
  77969. export * from "babylonjs/States/depthCullingState";
  77970. export * from "babylonjs/States/stencilState";
  77971. }
  77972. declare module "babylonjs/Misc/assetsManager" {
  77973. import { Scene } from "babylonjs/scene";
  77974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77975. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  77976. import { Skeleton } from "babylonjs/Bones/skeleton";
  77977. import { Observable } from "babylonjs/Misc/observable";
  77978. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  77979. import { Texture } from "babylonjs/Materials/Textures/texture";
  77980. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  77981. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  77982. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  77983. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  77984. import { AssetContainer } from "babylonjs/assetContainer";
  77985. /**
  77986. * Defines the list of states available for a task inside a AssetsManager
  77987. */
  77988. export enum AssetTaskState {
  77989. /**
  77990. * Initialization
  77991. */
  77992. INIT = 0,
  77993. /**
  77994. * Running
  77995. */
  77996. RUNNING = 1,
  77997. /**
  77998. * Done
  77999. */
  78000. DONE = 2,
  78001. /**
  78002. * Error
  78003. */
  78004. ERROR = 3
  78005. }
  78006. /**
  78007. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  78008. */
  78009. export abstract class AbstractAssetTask {
  78010. /**
  78011. * Task name
  78012. */ name: string;
  78013. /**
  78014. * Callback called when the task is successful
  78015. */
  78016. onSuccess: (task: any) => void;
  78017. /**
  78018. * Callback called when the task is not successful
  78019. */
  78020. onError: (task: any, message?: string, exception?: any) => void;
  78021. /**
  78022. * Creates a new AssetsManager
  78023. * @param name defines the name of the task
  78024. */
  78025. constructor(
  78026. /**
  78027. * Task name
  78028. */ name: string);
  78029. private _isCompleted;
  78030. private _taskState;
  78031. private _errorObject;
  78032. /**
  78033. * Get if the task is completed
  78034. */
  78035. get isCompleted(): boolean;
  78036. /**
  78037. * Gets the current state of the task
  78038. */
  78039. get taskState(): AssetTaskState;
  78040. /**
  78041. * Gets the current error object (if task is in error)
  78042. */
  78043. get errorObject(): {
  78044. message?: string;
  78045. exception?: any;
  78046. };
  78047. /**
  78048. * Internal only
  78049. * @hidden
  78050. */
  78051. _setErrorObject(message?: string, exception?: any): void;
  78052. /**
  78053. * Execute the current task
  78054. * @param scene defines the scene where you want your assets to be loaded
  78055. * @param onSuccess is a callback called when the task is successfully executed
  78056. * @param onError is a callback called if an error occurs
  78057. */
  78058. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78059. /**
  78060. * Execute the current task
  78061. * @param scene defines the scene where you want your assets to be loaded
  78062. * @param onSuccess is a callback called when the task is successfully executed
  78063. * @param onError is a callback called if an error occurs
  78064. */
  78065. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78066. /**
  78067. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  78068. * This can be used with failed tasks that have the reason for failure fixed.
  78069. */
  78070. reset(): void;
  78071. private onErrorCallback;
  78072. private onDoneCallback;
  78073. }
  78074. /**
  78075. * Define the interface used by progress events raised during assets loading
  78076. */
  78077. export interface IAssetsProgressEvent {
  78078. /**
  78079. * Defines the number of remaining tasks to process
  78080. */
  78081. remainingCount: number;
  78082. /**
  78083. * Defines the total number of tasks
  78084. */
  78085. totalCount: number;
  78086. /**
  78087. * Defines the task that was just processed
  78088. */
  78089. task: AbstractAssetTask;
  78090. }
  78091. /**
  78092. * Class used to share progress information about assets loading
  78093. */
  78094. export class AssetsProgressEvent implements IAssetsProgressEvent {
  78095. /**
  78096. * Defines the number of remaining tasks to process
  78097. */
  78098. remainingCount: number;
  78099. /**
  78100. * Defines the total number of tasks
  78101. */
  78102. totalCount: number;
  78103. /**
  78104. * Defines the task that was just processed
  78105. */
  78106. task: AbstractAssetTask;
  78107. /**
  78108. * Creates a AssetsProgressEvent
  78109. * @param remainingCount defines the number of remaining tasks to process
  78110. * @param totalCount defines the total number of tasks
  78111. * @param task defines the task that was just processed
  78112. */
  78113. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  78114. }
  78115. /**
  78116. * Define a task used by AssetsManager to load assets into a container
  78117. */
  78118. export class ContainerAssetTask extends AbstractAssetTask {
  78119. /**
  78120. * Defines the name of the task
  78121. */
  78122. name: string;
  78123. /**
  78124. * Defines the list of mesh's names you want to load
  78125. */
  78126. meshesNames: any;
  78127. /**
  78128. * Defines the root url to use as a base to load your meshes and associated resources
  78129. */
  78130. rootUrl: string;
  78131. /**
  78132. * Defines the filename or File of the scene to load from
  78133. */
  78134. sceneFilename: string | File;
  78135. /**
  78136. * Get the loaded asset container
  78137. */
  78138. loadedContainer: AssetContainer;
  78139. /**
  78140. * Gets the list of loaded meshes
  78141. */
  78142. loadedMeshes: Array<AbstractMesh>;
  78143. /**
  78144. * Gets the list of loaded particle systems
  78145. */
  78146. loadedParticleSystems: Array<IParticleSystem>;
  78147. /**
  78148. * Gets the list of loaded skeletons
  78149. */
  78150. loadedSkeletons: Array<Skeleton>;
  78151. /**
  78152. * Gets the list of loaded animation groups
  78153. */
  78154. loadedAnimationGroups: Array<AnimationGroup>;
  78155. /**
  78156. * Callback called when the task is successful
  78157. */
  78158. onSuccess: (task: ContainerAssetTask) => void;
  78159. /**
  78160. * Callback called when the task is successful
  78161. */
  78162. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  78163. /**
  78164. * Creates a new ContainerAssetTask
  78165. * @param name defines the name of the task
  78166. * @param meshesNames defines the list of mesh's names you want to load
  78167. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  78168. * @param sceneFilename defines the filename or File of the scene to load from
  78169. */
  78170. constructor(
  78171. /**
  78172. * Defines the name of the task
  78173. */
  78174. name: string,
  78175. /**
  78176. * Defines the list of mesh's names you want to load
  78177. */
  78178. meshesNames: any,
  78179. /**
  78180. * Defines the root url to use as a base to load your meshes and associated resources
  78181. */
  78182. rootUrl: string,
  78183. /**
  78184. * Defines the filename or File of the scene to load from
  78185. */
  78186. sceneFilename: string | File);
  78187. /**
  78188. * Execute the current task
  78189. * @param scene defines the scene where you want your assets to be loaded
  78190. * @param onSuccess is a callback called when the task is successfully executed
  78191. * @param onError is a callback called if an error occurs
  78192. */
  78193. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78194. }
  78195. /**
  78196. * Define a task used by AssetsManager to load meshes
  78197. */
  78198. export class MeshAssetTask extends AbstractAssetTask {
  78199. /**
  78200. * Defines the name of the task
  78201. */
  78202. name: string;
  78203. /**
  78204. * Defines the list of mesh's names you want to load
  78205. */
  78206. meshesNames: any;
  78207. /**
  78208. * Defines the root url to use as a base to load your meshes and associated resources
  78209. */
  78210. rootUrl: string;
  78211. /**
  78212. * Defines the filename or File of the scene to load from
  78213. */
  78214. sceneFilename: string | File;
  78215. /**
  78216. * Gets the list of loaded meshes
  78217. */
  78218. loadedMeshes: Array<AbstractMesh>;
  78219. /**
  78220. * Gets the list of loaded particle systems
  78221. */
  78222. loadedParticleSystems: Array<IParticleSystem>;
  78223. /**
  78224. * Gets the list of loaded skeletons
  78225. */
  78226. loadedSkeletons: Array<Skeleton>;
  78227. /**
  78228. * Gets the list of loaded animation groups
  78229. */
  78230. loadedAnimationGroups: Array<AnimationGroup>;
  78231. /**
  78232. * Callback called when the task is successful
  78233. */
  78234. onSuccess: (task: MeshAssetTask) => void;
  78235. /**
  78236. * Callback called when the task is successful
  78237. */
  78238. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  78239. /**
  78240. * Creates a new MeshAssetTask
  78241. * @param name defines the name of the task
  78242. * @param meshesNames defines the list of mesh's names you want to load
  78243. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  78244. * @param sceneFilename defines the filename or File of the scene to load from
  78245. */
  78246. constructor(
  78247. /**
  78248. * Defines the name of the task
  78249. */
  78250. name: string,
  78251. /**
  78252. * Defines the list of mesh's names you want to load
  78253. */
  78254. meshesNames: any,
  78255. /**
  78256. * Defines the root url to use as a base to load your meshes and associated resources
  78257. */
  78258. rootUrl: string,
  78259. /**
  78260. * Defines the filename or File of the scene to load from
  78261. */
  78262. sceneFilename: string | File);
  78263. /**
  78264. * Execute the current task
  78265. * @param scene defines the scene where you want your assets to be loaded
  78266. * @param onSuccess is a callback called when the task is successfully executed
  78267. * @param onError is a callback called if an error occurs
  78268. */
  78269. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78270. }
  78271. /**
  78272. * Define a task used by AssetsManager to load text content
  78273. */
  78274. export class TextFileAssetTask extends AbstractAssetTask {
  78275. /**
  78276. * Defines the name of the task
  78277. */
  78278. name: string;
  78279. /**
  78280. * Defines the location of the file to load
  78281. */
  78282. url: string;
  78283. /**
  78284. * Gets the loaded text string
  78285. */
  78286. text: string;
  78287. /**
  78288. * Callback called when the task is successful
  78289. */
  78290. onSuccess: (task: TextFileAssetTask) => void;
  78291. /**
  78292. * Callback called when the task is successful
  78293. */
  78294. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  78295. /**
  78296. * Creates a new TextFileAssetTask object
  78297. * @param name defines the name of the task
  78298. * @param url defines the location of the file to load
  78299. */
  78300. constructor(
  78301. /**
  78302. * Defines the name of the task
  78303. */
  78304. name: string,
  78305. /**
  78306. * Defines the location of the file to load
  78307. */
  78308. url: string);
  78309. /**
  78310. * Execute the current task
  78311. * @param scene defines the scene where you want your assets to be loaded
  78312. * @param onSuccess is a callback called when the task is successfully executed
  78313. * @param onError is a callback called if an error occurs
  78314. */
  78315. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78316. }
  78317. /**
  78318. * Define a task used by AssetsManager to load binary data
  78319. */
  78320. export class BinaryFileAssetTask extends AbstractAssetTask {
  78321. /**
  78322. * Defines the name of the task
  78323. */
  78324. name: string;
  78325. /**
  78326. * Defines the location of the file to load
  78327. */
  78328. url: string;
  78329. /**
  78330. * Gets the lodaded data (as an array buffer)
  78331. */
  78332. data: ArrayBuffer;
  78333. /**
  78334. * Callback called when the task is successful
  78335. */
  78336. onSuccess: (task: BinaryFileAssetTask) => void;
  78337. /**
  78338. * Callback called when the task is successful
  78339. */
  78340. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  78341. /**
  78342. * Creates a new BinaryFileAssetTask object
  78343. * @param name defines the name of the new task
  78344. * @param url defines the location of the file to load
  78345. */
  78346. constructor(
  78347. /**
  78348. * Defines the name of the task
  78349. */
  78350. name: string,
  78351. /**
  78352. * Defines the location of the file to load
  78353. */
  78354. url: string);
  78355. /**
  78356. * Execute the current task
  78357. * @param scene defines the scene where you want your assets to be loaded
  78358. * @param onSuccess is a callback called when the task is successfully executed
  78359. * @param onError is a callback called if an error occurs
  78360. */
  78361. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78362. }
  78363. /**
  78364. * Define a task used by AssetsManager to load images
  78365. */
  78366. export class ImageAssetTask extends AbstractAssetTask {
  78367. /**
  78368. * Defines the name of the task
  78369. */
  78370. name: string;
  78371. /**
  78372. * Defines the location of the image to load
  78373. */
  78374. url: string;
  78375. /**
  78376. * Gets the loaded images
  78377. */
  78378. image: HTMLImageElement;
  78379. /**
  78380. * Callback called when the task is successful
  78381. */
  78382. onSuccess: (task: ImageAssetTask) => void;
  78383. /**
  78384. * Callback called when the task is successful
  78385. */
  78386. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  78387. /**
  78388. * Creates a new ImageAssetTask
  78389. * @param name defines the name of the task
  78390. * @param url defines the location of the image to load
  78391. */
  78392. constructor(
  78393. /**
  78394. * Defines the name of the task
  78395. */
  78396. name: string,
  78397. /**
  78398. * Defines the location of the image to load
  78399. */
  78400. url: string);
  78401. /**
  78402. * Execute the current task
  78403. * @param scene defines the scene where you want your assets to be loaded
  78404. * @param onSuccess is a callback called when the task is successfully executed
  78405. * @param onError is a callback called if an error occurs
  78406. */
  78407. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78408. }
  78409. /**
  78410. * Defines the interface used by texture loading tasks
  78411. */
  78412. export interface ITextureAssetTask<TEX extends BaseTexture> {
  78413. /**
  78414. * Gets the loaded texture
  78415. */
  78416. texture: TEX;
  78417. }
  78418. /**
  78419. * Define a task used by AssetsManager to load 2D textures
  78420. */
  78421. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  78422. /**
  78423. * Defines the name of the task
  78424. */
  78425. name: string;
  78426. /**
  78427. * Defines the location of the file to load
  78428. */
  78429. url: string;
  78430. /**
  78431. * Defines if mipmap should not be generated (default is false)
  78432. */
  78433. noMipmap?: boolean | undefined;
  78434. /**
  78435. * Defines if texture must be inverted on Y axis (default is true)
  78436. */
  78437. invertY: boolean;
  78438. /**
  78439. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78440. */
  78441. samplingMode: number;
  78442. /**
  78443. * Gets the loaded texture
  78444. */
  78445. texture: Texture;
  78446. /**
  78447. * Callback called when the task is successful
  78448. */
  78449. onSuccess: (task: TextureAssetTask) => void;
  78450. /**
  78451. * Callback called when the task is successful
  78452. */
  78453. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  78454. /**
  78455. * Creates a new TextureAssetTask object
  78456. * @param name defines the name of the task
  78457. * @param url defines the location of the file to load
  78458. * @param noMipmap defines if mipmap should not be generated (default is false)
  78459. * @param invertY defines if texture must be inverted on Y axis (default is true)
  78460. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78461. */
  78462. constructor(
  78463. /**
  78464. * Defines the name of the task
  78465. */
  78466. name: string,
  78467. /**
  78468. * Defines the location of the file to load
  78469. */
  78470. url: string,
  78471. /**
  78472. * Defines if mipmap should not be generated (default is false)
  78473. */
  78474. noMipmap?: boolean | undefined,
  78475. /**
  78476. * Defines if texture must be inverted on Y axis (default is true)
  78477. */
  78478. invertY?: boolean,
  78479. /**
  78480. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78481. */
  78482. samplingMode?: number);
  78483. /**
  78484. * Execute the current task
  78485. * @param scene defines the scene where you want your assets to be loaded
  78486. * @param onSuccess is a callback called when the task is successfully executed
  78487. * @param onError is a callback called if an error occurs
  78488. */
  78489. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78490. }
  78491. /**
  78492. * Define a task used by AssetsManager to load cube textures
  78493. */
  78494. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  78495. /**
  78496. * Defines the name of the task
  78497. */
  78498. name: string;
  78499. /**
  78500. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78501. */
  78502. url: string;
  78503. /**
  78504. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78505. */
  78506. extensions?: string[] | undefined;
  78507. /**
  78508. * Defines if mipmaps should not be generated (default is false)
  78509. */
  78510. noMipmap?: boolean | undefined;
  78511. /**
  78512. * Defines the explicit list of files (undefined by default)
  78513. */
  78514. files?: string[] | undefined;
  78515. /**
  78516. * Gets the loaded texture
  78517. */
  78518. texture: CubeTexture;
  78519. /**
  78520. * Callback called when the task is successful
  78521. */
  78522. onSuccess: (task: CubeTextureAssetTask) => void;
  78523. /**
  78524. * Callback called when the task is successful
  78525. */
  78526. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  78527. /**
  78528. * Creates a new CubeTextureAssetTask
  78529. * @param name defines the name of the task
  78530. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78531. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78532. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78533. * @param files defines the explicit list of files (undefined by default)
  78534. */
  78535. constructor(
  78536. /**
  78537. * Defines the name of the task
  78538. */
  78539. name: string,
  78540. /**
  78541. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78542. */
  78543. url: string,
  78544. /**
  78545. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78546. */
  78547. extensions?: string[] | undefined,
  78548. /**
  78549. * Defines if mipmaps should not be generated (default is false)
  78550. */
  78551. noMipmap?: boolean | undefined,
  78552. /**
  78553. * Defines the explicit list of files (undefined by default)
  78554. */
  78555. files?: string[] | undefined);
  78556. /**
  78557. * Execute the current task
  78558. * @param scene defines the scene where you want your assets to be loaded
  78559. * @param onSuccess is a callback called when the task is successfully executed
  78560. * @param onError is a callback called if an error occurs
  78561. */
  78562. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78563. }
  78564. /**
  78565. * Define a task used by AssetsManager to load HDR cube textures
  78566. */
  78567. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  78568. /**
  78569. * Defines the name of the task
  78570. */
  78571. name: string;
  78572. /**
  78573. * Defines the location of the file to load
  78574. */
  78575. url: string;
  78576. /**
  78577. * Defines the desired size (the more it increases the longer the generation will be)
  78578. */
  78579. size: number;
  78580. /**
  78581. * Defines if mipmaps should not be generated (default is false)
  78582. */
  78583. noMipmap: boolean;
  78584. /**
  78585. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78586. */
  78587. generateHarmonics: boolean;
  78588. /**
  78589. * 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)
  78590. */
  78591. gammaSpace: boolean;
  78592. /**
  78593. * Internal Use Only
  78594. */
  78595. reserved: boolean;
  78596. /**
  78597. * Gets the loaded texture
  78598. */
  78599. texture: HDRCubeTexture;
  78600. /**
  78601. * Callback called when the task is successful
  78602. */
  78603. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  78604. /**
  78605. * Callback called when the task is successful
  78606. */
  78607. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  78608. /**
  78609. * Creates a new HDRCubeTextureAssetTask object
  78610. * @param name defines the name of the task
  78611. * @param url defines the location of the file to load
  78612. * @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.
  78613. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78614. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78615. * @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)
  78616. * @param reserved Internal use only
  78617. */
  78618. constructor(
  78619. /**
  78620. * Defines the name of the task
  78621. */
  78622. name: string,
  78623. /**
  78624. * Defines the location of the file to load
  78625. */
  78626. url: string,
  78627. /**
  78628. * Defines the desired size (the more it increases the longer the generation will be)
  78629. */
  78630. size: number,
  78631. /**
  78632. * Defines if mipmaps should not be generated (default is false)
  78633. */
  78634. noMipmap?: boolean,
  78635. /**
  78636. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78637. */
  78638. generateHarmonics?: boolean,
  78639. /**
  78640. * 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)
  78641. */
  78642. gammaSpace?: boolean,
  78643. /**
  78644. * Internal Use Only
  78645. */
  78646. reserved?: boolean);
  78647. /**
  78648. * Execute the current task
  78649. * @param scene defines the scene where you want your assets to be loaded
  78650. * @param onSuccess is a callback called when the task is successfully executed
  78651. * @param onError is a callback called if an error occurs
  78652. */
  78653. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78654. }
  78655. /**
  78656. * Define a task used by AssetsManager to load Equirectangular cube textures
  78657. */
  78658. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  78659. /**
  78660. * Defines the name of the task
  78661. */
  78662. name: string;
  78663. /**
  78664. * Defines the location of the file to load
  78665. */
  78666. url: string;
  78667. /**
  78668. * Defines the desired size (the more it increases the longer the generation will be)
  78669. */
  78670. size: number;
  78671. /**
  78672. * Defines if mipmaps should not be generated (default is false)
  78673. */
  78674. noMipmap: boolean;
  78675. /**
  78676. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78677. * but the standard material would require them in Gamma space) (default is true)
  78678. */
  78679. gammaSpace: boolean;
  78680. /**
  78681. * Gets the loaded texture
  78682. */
  78683. texture: EquiRectangularCubeTexture;
  78684. /**
  78685. * Callback called when the task is successful
  78686. */
  78687. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  78688. /**
  78689. * Callback called when the task is successful
  78690. */
  78691. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  78692. /**
  78693. * Creates a new EquiRectangularCubeTextureAssetTask object
  78694. * @param name defines the name of the task
  78695. * @param url defines the location of the file to load
  78696. * @param size defines the desired size (the more it increases the longer the generation will be)
  78697. * If the size is omitted this implies you are using a preprocessed cubemap.
  78698. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78699. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  78700. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  78701. * (default is true)
  78702. */
  78703. constructor(
  78704. /**
  78705. * Defines the name of the task
  78706. */
  78707. name: string,
  78708. /**
  78709. * Defines the location of the file to load
  78710. */
  78711. url: string,
  78712. /**
  78713. * Defines the desired size (the more it increases the longer the generation will be)
  78714. */
  78715. size: number,
  78716. /**
  78717. * Defines if mipmaps should not be generated (default is false)
  78718. */
  78719. noMipmap?: boolean,
  78720. /**
  78721. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78722. * but the standard material would require them in Gamma space) (default is true)
  78723. */
  78724. gammaSpace?: boolean);
  78725. /**
  78726. * Execute the current task
  78727. * @param scene defines the scene where you want your assets to be loaded
  78728. * @param onSuccess is a callback called when the task is successfully executed
  78729. * @param onError is a callback called if an error occurs
  78730. */
  78731. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78732. }
  78733. /**
  78734. * This class can be used to easily import assets into a scene
  78735. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  78736. */
  78737. export class AssetsManager {
  78738. private _scene;
  78739. private _isLoading;
  78740. protected _tasks: AbstractAssetTask[];
  78741. protected _waitingTasksCount: number;
  78742. protected _totalTasksCount: number;
  78743. /**
  78744. * Callback called when all tasks are processed
  78745. */
  78746. onFinish: (tasks: AbstractAssetTask[]) => void;
  78747. /**
  78748. * Callback called when a task is successful
  78749. */
  78750. onTaskSuccess: (task: AbstractAssetTask) => void;
  78751. /**
  78752. * Callback called when a task had an error
  78753. */
  78754. onTaskError: (task: AbstractAssetTask) => void;
  78755. /**
  78756. * Callback called when a task is done (whatever the result is)
  78757. */
  78758. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78759. /**
  78760. * Observable called when all tasks are processed
  78761. */
  78762. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78763. /**
  78764. * Observable called when a task had an error
  78765. */
  78766. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78767. /**
  78768. * Observable called when all tasks were executed
  78769. */
  78770. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78771. /**
  78772. * Observable called when a task is done (whatever the result is)
  78773. */
  78774. onProgressObservable: Observable<IAssetsProgressEvent>;
  78775. /**
  78776. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78777. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78778. */
  78779. useDefaultLoadingScreen: boolean;
  78780. /**
  78781. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78782. * when all assets have been downloaded.
  78783. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78784. */
  78785. autoHideLoadingUI: boolean;
  78786. /**
  78787. * Creates a new AssetsManager
  78788. * @param scene defines the scene to work on
  78789. */
  78790. constructor(scene: Scene);
  78791. /**
  78792. * Add a ContainerAssetTask to the list of active tasks
  78793. * @param taskName defines the name of the new task
  78794. * @param meshesNames defines the name of meshes to load
  78795. * @param rootUrl defines the root url to use to locate files
  78796. * @param sceneFilename defines the filename of the scene file
  78797. * @returns a new ContainerAssetTask object
  78798. */
  78799. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78800. /**
  78801. * Add a MeshAssetTask to the list of active tasks
  78802. * @param taskName defines the name of the new task
  78803. * @param meshesNames defines the name of meshes to load
  78804. * @param rootUrl defines the root url to use to locate files
  78805. * @param sceneFilename defines the filename of the scene file
  78806. * @returns a new MeshAssetTask object
  78807. */
  78808. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78809. /**
  78810. * Add a TextFileAssetTask to the list of active tasks
  78811. * @param taskName defines the name of the new task
  78812. * @param url defines the url of the file to load
  78813. * @returns a new TextFileAssetTask object
  78814. */
  78815. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78816. /**
  78817. * Add a BinaryFileAssetTask to the list of active tasks
  78818. * @param taskName defines the name of the new task
  78819. * @param url defines the url of the file to load
  78820. * @returns a new BinaryFileAssetTask object
  78821. */
  78822. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78823. /**
  78824. * Add a ImageAssetTask to the list of active tasks
  78825. * @param taskName defines the name of the new task
  78826. * @param url defines the url of the file to load
  78827. * @returns a new ImageAssetTask object
  78828. */
  78829. addImageTask(taskName: string, url: string): ImageAssetTask;
  78830. /**
  78831. * Add a TextureAssetTask to the list of active tasks
  78832. * @param taskName defines the name of the new task
  78833. * @param url defines the url of the file to load
  78834. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78835. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78836. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78837. * @returns a new TextureAssetTask object
  78838. */
  78839. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78840. /**
  78841. * Add a CubeTextureAssetTask to the list of active tasks
  78842. * @param taskName defines the name of the new task
  78843. * @param url defines the url of the file to load
  78844. * @param extensions defines the extension to use to load the cube map (can be null)
  78845. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78846. * @param files defines the list of files to load (can be null)
  78847. * @returns a new CubeTextureAssetTask object
  78848. */
  78849. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78850. /**
  78851. *
  78852. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78853. * @param taskName defines the name of the new task
  78854. * @param url defines the url of the file to load
  78855. * @param size defines the size you want for the cubemap (can be null)
  78856. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78857. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78858. * @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)
  78859. * @param reserved Internal use only
  78860. * @returns a new HDRCubeTextureAssetTask object
  78861. */
  78862. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78863. /**
  78864. *
  78865. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78866. * @param taskName defines the name of the new task
  78867. * @param url defines the url of the file to load
  78868. * @param size defines the size you want for the cubemap (can be null)
  78869. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78870. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78871. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78872. * @returns a new EquiRectangularCubeTextureAssetTask object
  78873. */
  78874. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78875. /**
  78876. * Remove a task from the assets manager.
  78877. * @param task the task to remove
  78878. */
  78879. removeTask(task: AbstractAssetTask): void;
  78880. private _decreaseWaitingTasksCount;
  78881. private _runTask;
  78882. /**
  78883. * Reset the AssetsManager and remove all tasks
  78884. * @return the current instance of the AssetsManager
  78885. */
  78886. reset(): AssetsManager;
  78887. /**
  78888. * Start the loading process
  78889. * @return the current instance of the AssetsManager
  78890. */
  78891. load(): AssetsManager;
  78892. /**
  78893. * Start the loading process as an async operation
  78894. * @return a promise returning the list of failed tasks
  78895. */
  78896. loadAsync(): Promise<void>;
  78897. }
  78898. }
  78899. declare module "babylonjs/Misc/deferred" {
  78900. /**
  78901. * Wrapper class for promise with external resolve and reject.
  78902. */
  78903. export class Deferred<T> {
  78904. /**
  78905. * The promise associated with this deferred object.
  78906. */
  78907. readonly promise: Promise<T>;
  78908. private _resolve;
  78909. private _reject;
  78910. /**
  78911. * The resolve method of the promise associated with this deferred object.
  78912. */
  78913. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  78914. /**
  78915. * The reject method of the promise associated with this deferred object.
  78916. */
  78917. get reject(): (reason?: any) => void;
  78918. /**
  78919. * Constructor for this deferred object.
  78920. */
  78921. constructor();
  78922. }
  78923. }
  78924. declare module "babylonjs/Misc/meshExploder" {
  78925. import { Mesh } from "babylonjs/Meshes/mesh";
  78926. /**
  78927. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78928. */
  78929. export class MeshExploder {
  78930. private _centerMesh;
  78931. private _meshes;
  78932. private _meshesOrigins;
  78933. private _toCenterVectors;
  78934. private _scaledDirection;
  78935. private _newPosition;
  78936. private _centerPosition;
  78937. /**
  78938. * Explodes meshes from a center mesh.
  78939. * @param meshes The meshes to explode.
  78940. * @param centerMesh The mesh to be center of explosion.
  78941. */
  78942. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78943. private _setCenterMesh;
  78944. /**
  78945. * Get class name
  78946. * @returns "MeshExploder"
  78947. */
  78948. getClassName(): string;
  78949. /**
  78950. * "Exploded meshes"
  78951. * @returns Array of meshes with the centerMesh at index 0.
  78952. */
  78953. getMeshes(): Array<Mesh>;
  78954. /**
  78955. * Explodes meshes giving a specific direction
  78956. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78957. */
  78958. explode(direction?: number): void;
  78959. }
  78960. }
  78961. declare module "babylonjs/Misc/filesInput" {
  78962. import { Engine } from "babylonjs/Engines/engine";
  78963. import { Scene } from "babylonjs/scene";
  78964. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  78965. import { Nullable } from "babylonjs/types";
  78966. /**
  78967. * Class used to help managing file picking and drag'n'drop
  78968. */
  78969. export class FilesInput {
  78970. /**
  78971. * List of files ready to be loaded
  78972. */
  78973. static get FilesToLoad(): {
  78974. [key: string]: File;
  78975. };
  78976. /**
  78977. * Callback called when a file is processed
  78978. */
  78979. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  78980. private _engine;
  78981. private _currentScene;
  78982. private _sceneLoadedCallback;
  78983. private _progressCallback;
  78984. private _additionalRenderLoopLogicCallback;
  78985. private _textureLoadingCallback;
  78986. private _startingProcessingFilesCallback;
  78987. private _onReloadCallback;
  78988. private _errorCallback;
  78989. private _elementToMonitor;
  78990. private _sceneFileToLoad;
  78991. private _filesToLoad;
  78992. /**
  78993. * Creates a new FilesInput
  78994. * @param engine defines the rendering engine
  78995. * @param scene defines the hosting scene
  78996. * @param sceneLoadedCallback callback called when scene is loaded
  78997. * @param progressCallback callback called to track progress
  78998. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78999. * @param textureLoadingCallback callback called when a texture is loading
  79000. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  79001. * @param onReloadCallback callback called when a reload is requested
  79002. * @param errorCallback callback call if an error occurs
  79003. */
  79004. 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>);
  79005. private _dragEnterHandler;
  79006. private _dragOverHandler;
  79007. private _dropHandler;
  79008. /**
  79009. * Calls this function to listen to drag'n'drop events on a specific DOM element
  79010. * @param elementToMonitor defines the DOM element to track
  79011. */
  79012. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  79013. /** Gets the current list of files to load */
  79014. get filesToLoad(): File[];
  79015. /**
  79016. * Release all associated resources
  79017. */
  79018. dispose(): void;
  79019. private renderFunction;
  79020. private drag;
  79021. private drop;
  79022. private _traverseFolder;
  79023. private _processFiles;
  79024. /**
  79025. * Load files from a drop event
  79026. * @param event defines the drop event to use as source
  79027. */
  79028. loadFiles(event: any): void;
  79029. private _processReload;
  79030. /**
  79031. * Reload the current scene from the loaded files
  79032. */
  79033. reload(): void;
  79034. }
  79035. }
  79036. declare module "babylonjs/Misc/HighDynamicRange/index" {
  79037. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  79038. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  79039. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  79040. }
  79041. declare module "babylonjs/Misc/sceneOptimizer" {
  79042. import { Scene, IDisposable } from "babylonjs/scene";
  79043. import { Observable } from "babylonjs/Misc/observable";
  79044. /**
  79045. * Defines the root class used to create scene optimization to use with SceneOptimizer
  79046. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79047. */
  79048. export class SceneOptimization {
  79049. /**
  79050. * Defines the priority of this optimization (0 by default which means first in the list)
  79051. */
  79052. priority: number;
  79053. /**
  79054. * Gets a string describing the action executed by the current optimization
  79055. * @returns description string
  79056. */
  79057. getDescription(): string;
  79058. /**
  79059. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79060. * @param scene defines the current scene where to apply this optimization
  79061. * @param optimizer defines the current optimizer
  79062. * @returns true if everything that can be done was applied
  79063. */
  79064. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79065. /**
  79066. * Creates the SceneOptimization object
  79067. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79068. * @param desc defines the description associated with the optimization
  79069. */
  79070. constructor(
  79071. /**
  79072. * Defines the priority of this optimization (0 by default which means first in the list)
  79073. */
  79074. priority?: number);
  79075. }
  79076. /**
  79077. * Defines an optimization used to reduce the size of render target textures
  79078. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79079. */
  79080. export class TextureOptimization extends SceneOptimization {
  79081. /**
  79082. * Defines the priority of this optimization (0 by default which means first in the list)
  79083. */
  79084. priority: number;
  79085. /**
  79086. * 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
  79087. */
  79088. maximumSize: number;
  79089. /**
  79090. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  79091. */
  79092. step: number;
  79093. /**
  79094. * Gets a string describing the action executed by the current optimization
  79095. * @returns description string
  79096. */
  79097. getDescription(): string;
  79098. /**
  79099. * Creates the TextureOptimization object
  79100. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79101. * @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
  79102. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  79103. */
  79104. constructor(
  79105. /**
  79106. * Defines the priority of this optimization (0 by default which means first in the list)
  79107. */
  79108. priority?: number,
  79109. /**
  79110. * 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
  79111. */
  79112. maximumSize?: number,
  79113. /**
  79114. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  79115. */
  79116. step?: number);
  79117. /**
  79118. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79119. * @param scene defines the current scene where to apply this optimization
  79120. * @param optimizer defines the current optimizer
  79121. * @returns true if everything that can be done was applied
  79122. */
  79123. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79124. }
  79125. /**
  79126. * Defines an optimization used to increase or decrease the rendering resolution
  79127. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79128. */
  79129. export class HardwareScalingOptimization extends SceneOptimization {
  79130. /**
  79131. * Defines the priority of this optimization (0 by default which means first in the list)
  79132. */
  79133. priority: number;
  79134. /**
  79135. * Defines the maximum scale to use (2 by default)
  79136. */
  79137. maximumScale: number;
  79138. /**
  79139. * Defines the step to use between two passes (0.5 by default)
  79140. */
  79141. step: number;
  79142. private _currentScale;
  79143. private _directionOffset;
  79144. /**
  79145. * Gets a string describing the action executed by the current optimization
  79146. * @return description string
  79147. */
  79148. getDescription(): string;
  79149. /**
  79150. * Creates the HardwareScalingOptimization object
  79151. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79152. * @param maximumScale defines the maximum scale to use (2 by default)
  79153. * @param step defines the step to use between two passes (0.5 by default)
  79154. */
  79155. constructor(
  79156. /**
  79157. * Defines the priority of this optimization (0 by default which means first in the list)
  79158. */
  79159. priority?: number,
  79160. /**
  79161. * Defines the maximum scale to use (2 by default)
  79162. */
  79163. maximumScale?: number,
  79164. /**
  79165. * Defines the step to use between two passes (0.5 by default)
  79166. */
  79167. step?: number);
  79168. /**
  79169. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79170. * @param scene defines the current scene where to apply this optimization
  79171. * @param optimizer defines the current optimizer
  79172. * @returns true if everything that can be done was applied
  79173. */
  79174. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79175. }
  79176. /**
  79177. * Defines an optimization used to remove shadows
  79178. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79179. */
  79180. export class ShadowsOptimization extends SceneOptimization {
  79181. /**
  79182. * Gets a string describing the action executed by the current optimization
  79183. * @return description string
  79184. */
  79185. getDescription(): string;
  79186. /**
  79187. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79188. * @param scene defines the current scene where to apply this optimization
  79189. * @param optimizer defines the current optimizer
  79190. * @returns true if everything that can be done was applied
  79191. */
  79192. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79193. }
  79194. /**
  79195. * Defines an optimization used to turn post-processes off
  79196. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79197. */
  79198. export class PostProcessesOptimization extends SceneOptimization {
  79199. /**
  79200. * Gets a string describing the action executed by the current optimization
  79201. * @return description string
  79202. */
  79203. getDescription(): string;
  79204. /**
  79205. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79206. * @param scene defines the current scene where to apply this optimization
  79207. * @param optimizer defines the current optimizer
  79208. * @returns true if everything that can be done was applied
  79209. */
  79210. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79211. }
  79212. /**
  79213. * Defines an optimization used to turn lens flares off
  79214. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79215. */
  79216. export class LensFlaresOptimization extends SceneOptimization {
  79217. /**
  79218. * Gets a string describing the action executed by the current optimization
  79219. * @return description string
  79220. */
  79221. getDescription(): string;
  79222. /**
  79223. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79224. * @param scene defines the current scene where to apply this optimization
  79225. * @param optimizer defines the current optimizer
  79226. * @returns true if everything that can be done was applied
  79227. */
  79228. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79229. }
  79230. /**
  79231. * Defines an optimization based on user defined callback.
  79232. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79233. */
  79234. export class CustomOptimization extends SceneOptimization {
  79235. /**
  79236. * Callback called to apply the custom optimization.
  79237. */
  79238. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  79239. /**
  79240. * Callback called to get custom description
  79241. */
  79242. onGetDescription: () => string;
  79243. /**
  79244. * Gets a string describing the action executed by the current optimization
  79245. * @returns description string
  79246. */
  79247. getDescription(): string;
  79248. /**
  79249. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79250. * @param scene defines the current scene where to apply this optimization
  79251. * @param optimizer defines the current optimizer
  79252. * @returns true if everything that can be done was applied
  79253. */
  79254. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79255. }
  79256. /**
  79257. * Defines an optimization used to turn particles off
  79258. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79259. */
  79260. export class ParticlesOptimization extends SceneOptimization {
  79261. /**
  79262. * Gets a string describing the action executed by the current optimization
  79263. * @return description string
  79264. */
  79265. getDescription(): string;
  79266. /**
  79267. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79268. * @param scene defines the current scene where to apply this optimization
  79269. * @param optimizer defines the current optimizer
  79270. * @returns true if everything that can be done was applied
  79271. */
  79272. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79273. }
  79274. /**
  79275. * Defines an optimization used to turn render targets off
  79276. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79277. */
  79278. export class RenderTargetsOptimization extends SceneOptimization {
  79279. /**
  79280. * Gets a string describing the action executed by the current optimization
  79281. * @return description string
  79282. */
  79283. getDescription(): string;
  79284. /**
  79285. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79286. * @param scene defines the current scene where to apply this optimization
  79287. * @param optimizer defines the current optimizer
  79288. * @returns true if everything that can be done was applied
  79289. */
  79290. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79291. }
  79292. /**
  79293. * Defines an optimization used to merge meshes with compatible materials
  79294. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79295. */
  79296. export class MergeMeshesOptimization extends SceneOptimization {
  79297. private static _UpdateSelectionTree;
  79298. /**
  79299. * Gets or sets a boolean which defines if optimization octree has to be updated
  79300. */
  79301. static get UpdateSelectionTree(): boolean;
  79302. /**
  79303. * Gets or sets a boolean which defines if optimization octree has to be updated
  79304. */
  79305. static set UpdateSelectionTree(value: boolean);
  79306. /**
  79307. * Gets a string describing the action executed by the current optimization
  79308. * @return description string
  79309. */
  79310. getDescription(): string;
  79311. private _canBeMerged;
  79312. /**
  79313. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79314. * @param scene defines the current scene where to apply this optimization
  79315. * @param optimizer defines the current optimizer
  79316. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  79317. * @returns true if everything that can be done was applied
  79318. */
  79319. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  79320. }
  79321. /**
  79322. * Defines a list of options used by SceneOptimizer
  79323. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79324. */
  79325. export class SceneOptimizerOptions {
  79326. /**
  79327. * Defines the target frame rate to reach (60 by default)
  79328. */
  79329. targetFrameRate: number;
  79330. /**
  79331. * Defines the interval between two checkes (2000ms by default)
  79332. */
  79333. trackerDuration: number;
  79334. /**
  79335. * Gets the list of optimizations to apply
  79336. */
  79337. optimizations: SceneOptimization[];
  79338. /**
  79339. * Creates a new list of options used by SceneOptimizer
  79340. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  79341. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  79342. */
  79343. constructor(
  79344. /**
  79345. * Defines the target frame rate to reach (60 by default)
  79346. */
  79347. targetFrameRate?: number,
  79348. /**
  79349. * Defines the interval between two checkes (2000ms by default)
  79350. */
  79351. trackerDuration?: number);
  79352. /**
  79353. * Add a new optimization
  79354. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  79355. * @returns the current SceneOptimizerOptions
  79356. */
  79357. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  79358. /**
  79359. * Add a new custom optimization
  79360. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  79361. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  79362. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79363. * @returns the current SceneOptimizerOptions
  79364. */
  79365. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  79366. /**
  79367. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  79368. * @param targetFrameRate defines the target frame rate (60 by default)
  79369. * @returns a SceneOptimizerOptions object
  79370. */
  79371. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79372. /**
  79373. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  79374. * @param targetFrameRate defines the target frame rate (60 by default)
  79375. * @returns a SceneOptimizerOptions object
  79376. */
  79377. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79378. /**
  79379. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  79380. * @param targetFrameRate defines the target frame rate (60 by default)
  79381. * @returns a SceneOptimizerOptions object
  79382. */
  79383. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79384. }
  79385. /**
  79386. * Class used to run optimizations in order to reach a target frame rate
  79387. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79388. */
  79389. export class SceneOptimizer implements IDisposable {
  79390. private _isRunning;
  79391. private _options;
  79392. private _scene;
  79393. private _currentPriorityLevel;
  79394. private _targetFrameRate;
  79395. private _trackerDuration;
  79396. private _currentFrameRate;
  79397. private _sceneDisposeObserver;
  79398. private _improvementMode;
  79399. /**
  79400. * Defines an observable called when the optimizer reaches the target frame rate
  79401. */
  79402. onSuccessObservable: Observable<SceneOptimizer>;
  79403. /**
  79404. * Defines an observable called when the optimizer enables an optimization
  79405. */
  79406. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  79407. /**
  79408. * Defines an observable called when the optimizer is not able to reach the target frame rate
  79409. */
  79410. onFailureObservable: Observable<SceneOptimizer>;
  79411. /**
  79412. * Gets a boolean indicating if the optimizer is in improvement mode
  79413. */
  79414. get isInImprovementMode(): boolean;
  79415. /**
  79416. * Gets the current priority level (0 at start)
  79417. */
  79418. get currentPriorityLevel(): number;
  79419. /**
  79420. * Gets the current frame rate checked by the SceneOptimizer
  79421. */
  79422. get currentFrameRate(): number;
  79423. /**
  79424. * Gets or sets the current target frame rate (60 by default)
  79425. */
  79426. get targetFrameRate(): number;
  79427. /**
  79428. * Gets or sets the current target frame rate (60 by default)
  79429. */
  79430. set targetFrameRate(value: number);
  79431. /**
  79432. * Gets or sets the current interval between two checks (every 2000ms by default)
  79433. */
  79434. get trackerDuration(): number;
  79435. /**
  79436. * Gets or sets the current interval between two checks (every 2000ms by default)
  79437. */
  79438. set trackerDuration(value: number);
  79439. /**
  79440. * Gets the list of active optimizations
  79441. */
  79442. get optimizations(): SceneOptimization[];
  79443. /**
  79444. * Creates a new SceneOptimizer
  79445. * @param scene defines the scene to work on
  79446. * @param options defines the options to use with the SceneOptimizer
  79447. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  79448. * @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)
  79449. */
  79450. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  79451. /**
  79452. * Stops the current optimizer
  79453. */
  79454. stop(): void;
  79455. /**
  79456. * Reset the optimizer to initial step (current priority level = 0)
  79457. */
  79458. reset(): void;
  79459. /**
  79460. * Start the optimizer. By default it will try to reach a specific framerate
  79461. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  79462. */
  79463. start(): void;
  79464. private _checkCurrentState;
  79465. /**
  79466. * Release all resources
  79467. */
  79468. dispose(): void;
  79469. /**
  79470. * Helper function to create a SceneOptimizer with one single line of code
  79471. * @param scene defines the scene to work on
  79472. * @param options defines the options to use with the SceneOptimizer
  79473. * @param onSuccess defines a callback to call on success
  79474. * @param onFailure defines a callback to call on failure
  79475. * @returns the new SceneOptimizer object
  79476. */
  79477. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  79478. }
  79479. }
  79480. declare module "babylonjs/Misc/sceneSerializer" {
  79481. import { Scene } from "babylonjs/scene";
  79482. /**
  79483. * Class used to serialize a scene into a string
  79484. */
  79485. export class SceneSerializer {
  79486. /**
  79487. * Clear cache used by a previous serialization
  79488. */
  79489. static ClearCache(): void;
  79490. /**
  79491. * Serialize a scene into a JSON compatible object
  79492. * @param scene defines the scene to serialize
  79493. * @returns a JSON compatible object
  79494. */
  79495. static Serialize(scene: Scene): any;
  79496. /**
  79497. * Serialize a mesh into a JSON compatible object
  79498. * @param toSerialize defines the mesh to serialize
  79499. * @param withParents defines if parents must be serialized as well
  79500. * @param withChildren defines if children must be serialized as well
  79501. * @returns a JSON compatible object
  79502. */
  79503. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  79504. }
  79505. }
  79506. declare module "babylonjs/Misc/textureTools" {
  79507. import { Texture } from "babylonjs/Materials/Textures/texture";
  79508. /**
  79509. * Class used to host texture specific utilities
  79510. */
  79511. export class TextureTools {
  79512. /**
  79513. * Uses the GPU to create a copy texture rescaled at a given size
  79514. * @param texture Texture to copy from
  79515. * @param width defines the desired width
  79516. * @param height defines the desired height
  79517. * @param useBilinearMode defines if bilinear mode has to be used
  79518. * @return the generated texture
  79519. */
  79520. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  79521. }
  79522. }
  79523. declare module "babylonjs/Misc/videoRecorder" {
  79524. import { Nullable } from "babylonjs/types";
  79525. import { Engine } from "babylonjs/Engines/engine";
  79526. /**
  79527. * This represents the different options available for the video capture.
  79528. */
  79529. export interface VideoRecorderOptions {
  79530. /** Defines the mime type of the video. */
  79531. mimeType: string;
  79532. /** Defines the FPS the video should be recorded at. */
  79533. fps: number;
  79534. /** Defines the chunk size for the recording data. */
  79535. recordChunckSize: number;
  79536. /** The audio tracks to attach to the recording. */
  79537. audioTracks?: MediaStreamTrack[];
  79538. }
  79539. /**
  79540. * This can help with recording videos from BabylonJS.
  79541. * This is based on the available WebRTC functionalities of the browser.
  79542. *
  79543. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  79544. */
  79545. export class VideoRecorder {
  79546. private static readonly _defaultOptions;
  79547. /**
  79548. * Returns whether or not the VideoRecorder is available in your browser.
  79549. * @param engine Defines the Babylon Engine.
  79550. * @returns true if supported otherwise false.
  79551. */
  79552. static IsSupported(engine: Engine): boolean;
  79553. private readonly _options;
  79554. private _canvas;
  79555. private _mediaRecorder;
  79556. private _recordedChunks;
  79557. private _fileName;
  79558. private _resolve;
  79559. private _reject;
  79560. /**
  79561. * True when a recording is already in progress.
  79562. */
  79563. get isRecording(): boolean;
  79564. /**
  79565. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  79566. * @param engine Defines the BabylonJS Engine you wish to record.
  79567. * @param options Defines options that can be used to customize the capture.
  79568. */
  79569. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  79570. /**
  79571. * Stops the current recording before the default capture timeout passed in the startRecording function.
  79572. */
  79573. stopRecording(): void;
  79574. /**
  79575. * Starts recording the canvas for a max duration specified in parameters.
  79576. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  79577. * If null no automatic download will start and you can rely on the promise to get the data back.
  79578. * @param maxDuration Defines the maximum recording time in seconds.
  79579. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  79580. * @return A promise callback at the end of the recording with the video data in Blob.
  79581. */
  79582. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  79583. /**
  79584. * Releases internal resources used during the recording.
  79585. */
  79586. dispose(): void;
  79587. private _handleDataAvailable;
  79588. private _handleError;
  79589. private _handleStop;
  79590. }
  79591. }
  79592. declare module "babylonjs/Misc/screenshotTools" {
  79593. import { Camera } from "babylonjs/Cameras/camera";
  79594. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  79595. import { Engine } from "babylonjs/Engines/engine";
  79596. /**
  79597. * Class containing a set of static utilities functions for screenshots
  79598. */
  79599. export class ScreenshotTools {
  79600. /**
  79601. * Captures a screenshot of the current rendering
  79602. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79603. * @param engine defines the rendering engine
  79604. * @param camera defines the source camera
  79605. * @param size This parameter can be set to a single number or to an object with the
  79606. * following (optional) properties: precision, width, height. If a single number is passed,
  79607. * it will be used for both width and height. If an object is passed, the screenshot size
  79608. * will be derived from the parameters. The precision property is a multiplier allowing
  79609. * rendering at a higher or lower resolution
  79610. * @param successCallback defines the callback receives a single parameter which contains the
  79611. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79612. * src parameter of an <img> to display it
  79613. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79614. * Check your browser for supported MIME types
  79615. */
  79616. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  79617. /**
  79618. * Captures a screenshot of the current rendering
  79619. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79620. * @param engine defines the rendering engine
  79621. * @param camera defines the source camera
  79622. * @param size This parameter can be set to a single number or to an object with the
  79623. * following (optional) properties: precision, width, height. If a single number is passed,
  79624. * it will be used for both width and height. If an object is passed, the screenshot size
  79625. * will be derived from the parameters. The precision property is a multiplier allowing
  79626. * rendering at a higher or lower resolution
  79627. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79628. * Check your browser for supported MIME types
  79629. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79630. * to the src parameter of an <img> to display it
  79631. */
  79632. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  79633. /**
  79634. * Generates an image screenshot from the specified camera.
  79635. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79636. * @param engine The engine to use for rendering
  79637. * @param camera The camera to use for rendering
  79638. * @param size This parameter can be set to a single number or to an object with the
  79639. * following (optional) properties: precision, width, height. If a single number is passed,
  79640. * it will be used for both width and height. If an object is passed, the screenshot size
  79641. * will be derived from the parameters. The precision property is a multiplier allowing
  79642. * rendering at a higher or lower resolution
  79643. * @param successCallback The callback receives a single parameter which contains the
  79644. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79645. * src parameter of an <img> to display it
  79646. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79647. * Check your browser for supported MIME types
  79648. * @param samples Texture samples (default: 1)
  79649. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79650. * @param fileName A name for for the downloaded file.
  79651. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79652. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  79653. */
  79654. 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;
  79655. /**
  79656. * Generates an image screenshot from the specified camera.
  79657. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79658. * @param engine The engine to use for rendering
  79659. * @param camera The camera to use for rendering
  79660. * @param size This parameter can be set to a single number or to an object with the
  79661. * following (optional) properties: precision, width, height. If a single number is passed,
  79662. * it will be used for both width and height. If an object is passed, the screenshot size
  79663. * will be derived from the parameters. The precision property is a multiplier allowing
  79664. * rendering at a higher or lower resolution
  79665. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79666. * Check your browser for supported MIME types
  79667. * @param samples Texture samples (default: 1)
  79668. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79669. * @param fileName A name for for the downloaded file.
  79670. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79671. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79672. * to the src parameter of an <img> to display it
  79673. */
  79674. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  79675. /**
  79676. * Gets height and width for screenshot size
  79677. * @private
  79678. */
  79679. private static _getScreenshotSize;
  79680. }
  79681. }
  79682. declare module "babylonjs/Misc/dataReader" {
  79683. /**
  79684. * Interface for a data buffer
  79685. */
  79686. export interface IDataBuffer {
  79687. /**
  79688. * Reads bytes from the data buffer.
  79689. * @param byteOffset The byte offset to read
  79690. * @param byteLength The byte length to read
  79691. * @returns A promise that resolves when the bytes are read
  79692. */
  79693. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  79694. /**
  79695. * The byte length of the buffer.
  79696. */
  79697. readonly byteLength: number;
  79698. }
  79699. /**
  79700. * Utility class for reading from a data buffer
  79701. */
  79702. export class DataReader {
  79703. /**
  79704. * The data buffer associated with this data reader.
  79705. */
  79706. readonly buffer: IDataBuffer;
  79707. /**
  79708. * The current byte offset from the beginning of the data buffer.
  79709. */
  79710. byteOffset: number;
  79711. private _dataView;
  79712. private _dataByteOffset;
  79713. /**
  79714. * Constructor
  79715. * @param buffer The buffer to read
  79716. */
  79717. constructor(buffer: IDataBuffer);
  79718. /**
  79719. * Loads the given byte length.
  79720. * @param byteLength The byte length to load
  79721. * @returns A promise that resolves when the load is complete
  79722. */
  79723. loadAsync(byteLength: number): Promise<void>;
  79724. /**
  79725. * Read a unsigned 32-bit integer from the currently loaded data range.
  79726. * @returns The 32-bit integer read
  79727. */
  79728. readUint32(): number;
  79729. /**
  79730. * Read a byte array from the currently loaded data range.
  79731. * @param byteLength The byte length to read
  79732. * @returns The byte array read
  79733. */
  79734. readUint8Array(byteLength: number): Uint8Array;
  79735. /**
  79736. * Read a string from the currently loaded data range.
  79737. * @param byteLength The byte length to read
  79738. * @returns The string read
  79739. */
  79740. readString(byteLength: number): string;
  79741. /**
  79742. * Skips the given byte length the currently loaded data range.
  79743. * @param byteLength The byte length to skip
  79744. */
  79745. skipBytes(byteLength: number): void;
  79746. }
  79747. }
  79748. declare module "babylonjs/Misc/dataStorage" {
  79749. /**
  79750. * Class for storing data to local storage if available or in-memory storage otherwise
  79751. */
  79752. export class DataStorage {
  79753. private static _Storage;
  79754. private static _GetStorage;
  79755. /**
  79756. * Reads a string from the data storage
  79757. * @param key The key to read
  79758. * @param defaultValue The value if the key doesn't exist
  79759. * @returns The string value
  79760. */
  79761. static ReadString(key: string, defaultValue: string): string;
  79762. /**
  79763. * Writes a string to the data storage
  79764. * @param key The key to write
  79765. * @param value The value to write
  79766. */
  79767. static WriteString(key: string, value: string): void;
  79768. /**
  79769. * Reads a boolean from the data storage
  79770. * @param key The key to read
  79771. * @param defaultValue The value if the key doesn't exist
  79772. * @returns The boolean value
  79773. */
  79774. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79775. /**
  79776. * Writes a boolean to the data storage
  79777. * @param key The key to write
  79778. * @param value The value to write
  79779. */
  79780. static WriteBoolean(key: string, value: boolean): void;
  79781. /**
  79782. * Reads a number from the data storage
  79783. * @param key The key to read
  79784. * @param defaultValue The value if the key doesn't exist
  79785. * @returns The number value
  79786. */
  79787. static ReadNumber(key: string, defaultValue: number): number;
  79788. /**
  79789. * Writes a number to the data storage
  79790. * @param key The key to write
  79791. * @param value The value to write
  79792. */
  79793. static WriteNumber(key: string, value: number): void;
  79794. }
  79795. }
  79796. declare module "babylonjs/Misc/sceneRecorder" {
  79797. import { Scene } from "babylonjs/scene";
  79798. /**
  79799. * Class used to record delta files between 2 scene states
  79800. */
  79801. export class SceneRecorder {
  79802. private _trackedScene;
  79803. private _savedJSON;
  79804. /**
  79805. * Track a given scene. This means the current scene state will be considered the original state
  79806. * @param scene defines the scene to track
  79807. */
  79808. track(scene: Scene): void;
  79809. /**
  79810. * Get the delta between current state and original state
  79811. * @returns a string containing the delta
  79812. */
  79813. getDelta(): any;
  79814. private _compareArray;
  79815. private _compareObjects;
  79816. private _compareCollections;
  79817. private static GetShadowGeneratorById;
  79818. /**
  79819. * Apply a given delta to a given scene
  79820. * @param deltaJSON defines the JSON containing the delta
  79821. * @param scene defines the scene to apply the delta to
  79822. */
  79823. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79824. private static _ApplyPropertiesToEntity;
  79825. private static _ApplyDeltaForEntity;
  79826. }
  79827. }
  79828. declare module "babylonjs/Misc/trajectoryClassifier" {
  79829. import { DeepImmutable, Nullable } from "babylonjs/types";
  79830. import { Vector3 } from "babylonjs/Maths/math.vector";
  79831. /**
  79832. * A 3D trajectory consisting of an order list of vectors describing a
  79833. * path of motion through 3D space.
  79834. */
  79835. export class Trajectory {
  79836. private _points;
  79837. private readonly _segmentLength;
  79838. /**
  79839. * Serialize to JSON.
  79840. * @returns serialized JSON string
  79841. */
  79842. serialize(): string;
  79843. /**
  79844. * Deserialize from JSON.
  79845. * @param json serialized JSON string
  79846. * @returns deserialized Trajectory
  79847. */
  79848. static Deserialize(json: string): Trajectory;
  79849. /**
  79850. * Create a new empty Trajectory.
  79851. * @param segmentLength radius of discretization for Trajectory points
  79852. */
  79853. constructor(segmentLength?: number);
  79854. /**
  79855. * Get the length of the Trajectory.
  79856. * @returns length of the Trajectory
  79857. */
  79858. getLength(): number;
  79859. /**
  79860. * Append a new point to the Trajectory.
  79861. * NOTE: This implementation has many allocations.
  79862. * @param point point to append to the Trajectory
  79863. */
  79864. add(point: DeepImmutable<Vector3>): void;
  79865. /**
  79866. * Create a new Trajectory with a segment length chosen to make it
  79867. * probable that the new Trajectory will have a specified number of
  79868. * segments. This operation is imprecise.
  79869. * @param targetResolution number of segments desired
  79870. * @returns new Trajectory with approximately the requested number of segments
  79871. */
  79872. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79873. /**
  79874. * Convert Trajectory segments into tokenized representation. This
  79875. * representation is an array of numbers where each nth number is the
  79876. * index of the token which is most similar to the nth segment of the
  79877. * Trajectory.
  79878. * @param tokens list of vectors which serve as discrete tokens
  79879. * @returns list of indices of most similar token per segment
  79880. */
  79881. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79882. private static _forwardDir;
  79883. private static _inverseFromVec;
  79884. private static _upDir;
  79885. private static _fromToVec;
  79886. private static _lookMatrix;
  79887. /**
  79888. * Transform the rotation (i.e., direction) of a segment to isolate
  79889. * the relative transformation represented by the segment. This operation
  79890. * may or may not succeed due to singularities in the equations that define
  79891. * motion relativity in this context.
  79892. * @param priorVec the origin of the prior segment
  79893. * @param fromVec the origin of the current segment
  79894. * @param toVec the destination of the current segment
  79895. * @param result reference to output variable
  79896. * @returns whether or not transformation was successful
  79897. */
  79898. private static _transformSegmentDirToRef;
  79899. private static _bestMatch;
  79900. private static _score;
  79901. private static _bestScore;
  79902. /**
  79903. * Determine which token vector is most similar to the
  79904. * segment vector.
  79905. * @param segment segment vector
  79906. * @param tokens token vector list
  79907. * @returns index of the most similar token to the segment
  79908. */
  79909. private static _tokenizeSegment;
  79910. }
  79911. /**
  79912. * Class representing a set of known, named trajectories to which Trajectories can be
  79913. * added and using which Trajectories can be recognized.
  79914. */
  79915. export class TrajectoryClassifier {
  79916. private _maximumAllowableMatchCost;
  79917. private _vector3Alphabet;
  79918. private _levenshteinAlphabet;
  79919. private _nameToDescribedTrajectory;
  79920. /**
  79921. * Serialize to JSON.
  79922. * @returns JSON serialization
  79923. */
  79924. serialize(): string;
  79925. /**
  79926. * Deserialize from JSON.
  79927. * @param json JSON serialization
  79928. * @returns deserialized TrajectorySet
  79929. */
  79930. static Deserialize(json: string): TrajectoryClassifier;
  79931. /**
  79932. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79933. * VERY naive, need to be generating these things from known
  79934. * sets. Better version later, probably eliminating this one.
  79935. * @returns auto-generated TrajectorySet
  79936. */
  79937. static Generate(): TrajectoryClassifier;
  79938. private constructor();
  79939. /**
  79940. * Add a new Trajectory to the set with a given name.
  79941. * @param trajectory new Trajectory to be added
  79942. * @param classification name to which to add the Trajectory
  79943. */
  79944. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79945. /**
  79946. * Remove a known named trajectory and all Trajectories associated with it.
  79947. * @param classification name to remove
  79948. * @returns whether anything was removed
  79949. */
  79950. deleteClassification(classification: string): boolean;
  79951. /**
  79952. * Attempt to recognize a Trajectory from among all the classifications
  79953. * already known to the classifier.
  79954. * @param trajectory Trajectory to be recognized
  79955. * @returns classification of Trajectory if recognized, null otherwise
  79956. */
  79957. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79958. }
  79959. }
  79960. declare module "babylonjs/Misc/index" {
  79961. export * from "babylonjs/Misc/andOrNotEvaluator";
  79962. export * from "babylonjs/Misc/assetsManager";
  79963. export * from "babylonjs/Misc/basis";
  79964. export * from "babylonjs/Misc/dds";
  79965. export * from "babylonjs/Misc/decorators";
  79966. export * from "babylonjs/Misc/deferred";
  79967. export * from "babylonjs/Misc/environmentTextureTools";
  79968. export * from "babylonjs/Misc/meshExploder";
  79969. export * from "babylonjs/Misc/filesInput";
  79970. export * from "babylonjs/Misc/HighDynamicRange/index";
  79971. export * from "babylonjs/Misc/khronosTextureContainer";
  79972. export * from "babylonjs/Misc/observable";
  79973. export * from "babylonjs/Misc/performanceMonitor";
  79974. export * from "babylonjs/Misc/promise";
  79975. export * from "babylonjs/Misc/sceneOptimizer";
  79976. export * from "babylonjs/Misc/sceneSerializer";
  79977. export * from "babylonjs/Misc/smartArray";
  79978. export * from "babylonjs/Misc/stringDictionary";
  79979. export * from "babylonjs/Misc/tags";
  79980. export * from "babylonjs/Misc/textureTools";
  79981. export * from "babylonjs/Misc/tga";
  79982. export * from "babylonjs/Misc/tools";
  79983. export * from "babylonjs/Misc/videoRecorder";
  79984. export * from "babylonjs/Misc/virtualJoystick";
  79985. export * from "babylonjs/Misc/workerPool";
  79986. export * from "babylonjs/Misc/logger";
  79987. export * from "babylonjs/Misc/typeStore";
  79988. export * from "babylonjs/Misc/filesInputStore";
  79989. export * from "babylonjs/Misc/deepCopier";
  79990. export * from "babylonjs/Misc/pivotTools";
  79991. export * from "babylonjs/Misc/precisionDate";
  79992. export * from "babylonjs/Misc/screenshotTools";
  79993. export * from "babylonjs/Misc/typeStore";
  79994. export * from "babylonjs/Misc/webRequest";
  79995. export * from "babylonjs/Misc/iInspectable";
  79996. export * from "babylonjs/Misc/brdfTextureTools";
  79997. export * from "babylonjs/Misc/rgbdTextureTools";
  79998. export * from "babylonjs/Misc/gradients";
  79999. export * from "babylonjs/Misc/perfCounter";
  80000. export * from "babylonjs/Misc/fileRequest";
  80001. export * from "babylonjs/Misc/customAnimationFrameRequester";
  80002. export * from "babylonjs/Misc/retryStrategy";
  80003. export * from "babylonjs/Misc/interfaces/screenshotSize";
  80004. export * from "babylonjs/Misc/canvasGenerator";
  80005. export * from "babylonjs/Misc/fileTools";
  80006. export * from "babylonjs/Misc/stringTools";
  80007. export * from "babylonjs/Misc/dataReader";
  80008. export * from "babylonjs/Misc/minMaxReducer";
  80009. export * from "babylonjs/Misc/depthReducer";
  80010. export * from "babylonjs/Misc/dataStorage";
  80011. export * from "babylonjs/Misc/sceneRecorder";
  80012. export * from "babylonjs/Misc/khronosTextureContainer2";
  80013. export * from "babylonjs/Misc/trajectoryClassifier";
  80014. export * from "babylonjs/Misc/timer";
  80015. export * from "babylonjs/Misc/copyTools";
  80016. }
  80017. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  80018. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  80019. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80020. import { Observable } from "babylonjs/Misc/observable";
  80021. import { Matrix } from "babylonjs/Maths/math.vector";
  80022. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80023. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80024. /**
  80025. * An interface for all Hit test features
  80026. */
  80027. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  80028. /**
  80029. * Triggered when new babylon (transformed) hit test results are available
  80030. */
  80031. onHitTestResultObservable: Observable<T[]>;
  80032. }
  80033. /**
  80034. * Options used for hit testing
  80035. */
  80036. export interface IWebXRLegacyHitTestOptions {
  80037. /**
  80038. * Only test when user interacted with the scene. Default - hit test every frame
  80039. */
  80040. testOnPointerDownOnly?: boolean;
  80041. /**
  80042. * The node to use to transform the local results to world coordinates
  80043. */
  80044. worldParentNode?: TransformNode;
  80045. }
  80046. /**
  80047. * Interface defining the babylon result of raycasting/hit-test
  80048. */
  80049. export interface IWebXRLegacyHitResult {
  80050. /**
  80051. * Transformation matrix that can be applied to a node that will put it in the hit point location
  80052. */
  80053. transformationMatrix: Matrix;
  80054. /**
  80055. * The native hit test result
  80056. */
  80057. xrHitResult: XRHitResult | XRHitTestResult;
  80058. }
  80059. /**
  80060. * The currently-working hit-test module.
  80061. * Hit test (or Ray-casting) is used to interact with the real world.
  80062. * For further information read here - https://github.com/immersive-web/hit-test
  80063. */
  80064. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  80065. /**
  80066. * options to use when constructing this feature
  80067. */
  80068. readonly options: IWebXRLegacyHitTestOptions;
  80069. private _direction;
  80070. private _mat;
  80071. private _onSelectEnabled;
  80072. private _origin;
  80073. /**
  80074. * The module's name
  80075. */
  80076. static readonly Name: string;
  80077. /**
  80078. * The (Babylon) version of this module.
  80079. * This is an integer representing the implementation version.
  80080. * This number does not correspond to the WebXR specs version
  80081. */
  80082. static readonly Version: number;
  80083. /**
  80084. * Populated with the last native XR Hit Results
  80085. */
  80086. lastNativeXRHitResults: XRHitResult[];
  80087. /**
  80088. * Triggered when new babylon (transformed) hit test results are available
  80089. */
  80090. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  80091. /**
  80092. * Creates a new instance of the (legacy version) hit test feature
  80093. * @param _xrSessionManager an instance of WebXRSessionManager
  80094. * @param options options to use when constructing this feature
  80095. */
  80096. constructor(_xrSessionManager: WebXRSessionManager,
  80097. /**
  80098. * options to use when constructing this feature
  80099. */
  80100. options?: IWebXRLegacyHitTestOptions);
  80101. /**
  80102. * execute a hit test with an XR Ray
  80103. *
  80104. * @param xrSession a native xrSession that will execute this hit test
  80105. * @param xrRay the ray (position and direction) to use for ray-casting
  80106. * @param referenceSpace native XR reference space to use for the hit-test
  80107. * @param filter filter function that will filter the results
  80108. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  80109. */
  80110. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  80111. /**
  80112. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  80113. * @param event the (select) event to use to select with
  80114. * @param referenceSpace the reference space to use for this hit test
  80115. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  80116. */
  80117. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  80118. /**
  80119. * attach this feature
  80120. * Will usually be called by the features manager
  80121. *
  80122. * @returns true if successful.
  80123. */
  80124. attach(): boolean;
  80125. /**
  80126. * detach this feature.
  80127. * Will usually be called by the features manager
  80128. *
  80129. * @returns true if successful.
  80130. */
  80131. detach(): boolean;
  80132. /**
  80133. * Dispose this feature and all of the resources attached
  80134. */
  80135. dispose(): void;
  80136. protected _onXRFrame(frame: XRFrame): void;
  80137. private _onHitTestResults;
  80138. private _onSelect;
  80139. }
  80140. }
  80141. declare module "babylonjs/XR/features/WebXRHitTest" {
  80142. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80143. import { Observable } from "babylonjs/Misc/observable";
  80144. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  80145. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80146. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  80147. /**
  80148. * Options used for hit testing (version 2)
  80149. */
  80150. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  80151. /**
  80152. * Do not create a permanent hit test. Will usually be used when only
  80153. * transient inputs are needed.
  80154. */
  80155. disablePermanentHitTest?: boolean;
  80156. /**
  80157. * Enable transient (for example touch-based) hit test inspections
  80158. */
  80159. enableTransientHitTest?: boolean;
  80160. /**
  80161. * Offset ray for the permanent hit test
  80162. */
  80163. offsetRay?: Vector3;
  80164. /**
  80165. * Offset ray for the transient hit test
  80166. */
  80167. transientOffsetRay?: Vector3;
  80168. /**
  80169. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  80170. */
  80171. useReferenceSpace?: boolean;
  80172. /**
  80173. * Override the default entity type(s) of the hit-test result
  80174. */
  80175. entityTypes?: XRHitTestTrackableType[];
  80176. }
  80177. /**
  80178. * Interface defining the babylon result of hit-test
  80179. */
  80180. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  80181. /**
  80182. * The input source that generated this hit test (if transient)
  80183. */
  80184. inputSource?: XRInputSource;
  80185. /**
  80186. * Is this a transient hit test
  80187. */
  80188. isTransient?: boolean;
  80189. /**
  80190. * Position of the hit test result
  80191. */
  80192. position: Vector3;
  80193. /**
  80194. * Rotation of the hit test result
  80195. */
  80196. rotationQuaternion: Quaternion;
  80197. /**
  80198. * The native hit test result
  80199. */
  80200. xrHitResult: XRHitTestResult;
  80201. }
  80202. /**
  80203. * The currently-working hit-test module.
  80204. * Hit test (or Ray-casting) is used to interact with the real world.
  80205. * For further information read here - https://github.com/immersive-web/hit-test
  80206. *
  80207. * Tested on chrome (mobile) 80.
  80208. */
  80209. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  80210. /**
  80211. * options to use when constructing this feature
  80212. */
  80213. readonly options: IWebXRHitTestOptions;
  80214. private _tmpMat;
  80215. private _tmpPos;
  80216. private _tmpQuat;
  80217. private _transientXrHitTestSource;
  80218. private _xrHitTestSource;
  80219. private initHitTestSource;
  80220. /**
  80221. * The module's name
  80222. */
  80223. static readonly Name: string;
  80224. /**
  80225. * The (Babylon) version of this module.
  80226. * This is an integer representing the implementation version.
  80227. * This number does not correspond to the WebXR specs version
  80228. */
  80229. static readonly Version: number;
  80230. /**
  80231. * When set to true, each hit test will have its own position/rotation objects
  80232. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  80233. * the developers will clone them or copy them as they see fit.
  80234. */
  80235. autoCloneTransformation: boolean;
  80236. /**
  80237. * Triggered when new babylon (transformed) hit test results are available
  80238. * Note - this will be called when results come back from the device. It can be an empty array!!
  80239. */
  80240. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  80241. /**
  80242. * Use this to temporarily pause hit test checks.
  80243. */
  80244. paused: boolean;
  80245. /**
  80246. * Creates a new instance of the hit test feature
  80247. * @param _xrSessionManager an instance of WebXRSessionManager
  80248. * @param options options to use when constructing this feature
  80249. */
  80250. constructor(_xrSessionManager: WebXRSessionManager,
  80251. /**
  80252. * options to use when constructing this feature
  80253. */
  80254. options?: IWebXRHitTestOptions);
  80255. /**
  80256. * attach this feature
  80257. * Will usually be called by the features manager
  80258. *
  80259. * @returns true if successful.
  80260. */
  80261. attach(): boolean;
  80262. /**
  80263. * detach this feature.
  80264. * Will usually be called by the features manager
  80265. *
  80266. * @returns true if successful.
  80267. */
  80268. detach(): boolean;
  80269. /**
  80270. * Dispose this feature and all of the resources attached
  80271. */
  80272. dispose(): void;
  80273. protected _onXRFrame(frame: XRFrame): void;
  80274. private _processWebXRHitTestResult;
  80275. }
  80276. }
  80277. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  80278. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80279. import { Observable } from "babylonjs/Misc/observable";
  80280. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  80281. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80282. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80283. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  80284. /**
  80285. * Configuration options of the anchor system
  80286. */
  80287. export interface IWebXRAnchorSystemOptions {
  80288. /**
  80289. * a node that will be used to convert local to world coordinates
  80290. */
  80291. worldParentNode?: TransformNode;
  80292. /**
  80293. * If set to true a reference of the created anchors will be kept until the next session starts
  80294. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  80295. */
  80296. doNotRemoveAnchorsOnSessionEnded?: boolean;
  80297. }
  80298. /**
  80299. * A babylon container for an XR Anchor
  80300. */
  80301. export interface IWebXRAnchor {
  80302. /**
  80303. * A babylon-assigned ID for this anchor
  80304. */
  80305. id: number;
  80306. /**
  80307. * Transformation matrix to apply to an object attached to this anchor
  80308. */
  80309. transformationMatrix: Matrix;
  80310. /**
  80311. * The native anchor object
  80312. */
  80313. xrAnchor: XRAnchor;
  80314. /**
  80315. * if defined, this object will be constantly updated by the anchor's position and rotation
  80316. */
  80317. attachedNode?: TransformNode;
  80318. }
  80319. /**
  80320. * An implementation of the anchor system for WebXR.
  80321. * For further information see https://github.com/immersive-web/anchors/
  80322. */
  80323. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  80324. private _options;
  80325. private _lastFrameDetected;
  80326. private _trackedAnchors;
  80327. private _referenceSpaceForFrameAnchors;
  80328. private _futureAnchors;
  80329. /**
  80330. * The module's name
  80331. */
  80332. static readonly Name: string;
  80333. /**
  80334. * The (Babylon) version of this module.
  80335. * This is an integer representing the implementation version.
  80336. * This number does not correspond to the WebXR specs version
  80337. */
  80338. static readonly Version: number;
  80339. /**
  80340. * Observers registered here will be executed when a new anchor was added to the session
  80341. */
  80342. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  80343. /**
  80344. * Observers registered here will be executed when an anchor was removed from the session
  80345. */
  80346. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  80347. /**
  80348. * Observers registered here will be executed when an existing anchor updates
  80349. * This can execute N times every frame
  80350. */
  80351. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  80352. /**
  80353. * Set the reference space to use for anchor creation, when not using a hit test.
  80354. * Will default to the session's reference space if not defined
  80355. */
  80356. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  80357. /**
  80358. * constructs a new anchor system
  80359. * @param _xrSessionManager an instance of WebXRSessionManager
  80360. * @param _options configuration object for this feature
  80361. */
  80362. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  80363. private _tmpVector;
  80364. private _tmpQuaternion;
  80365. private _populateTmpTransformation;
  80366. /**
  80367. * Create a new anchor point using a hit test result at a specific point in the scene
  80368. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80369. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80370. *
  80371. * @param hitTestResult The hit test result to use for this anchor creation
  80372. * @param position an optional position offset for this anchor
  80373. * @param rotationQuaternion an optional rotation offset for this anchor
  80374. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  80375. */
  80376. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  80377. /**
  80378. * Add a new anchor at a specific position and rotation
  80379. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  80380. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  80381. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80382. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80383. *
  80384. * @param position the position in which to add an anchor
  80385. * @param rotationQuaternion an optional rotation for the anchor transformation
  80386. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  80387. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  80388. */
  80389. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  80390. /**
  80391. * detach this feature.
  80392. * Will usually be called by the features manager
  80393. *
  80394. * @returns true if successful.
  80395. */
  80396. detach(): boolean;
  80397. /**
  80398. * Dispose this feature and all of the resources attached
  80399. */
  80400. dispose(): void;
  80401. protected _onXRFrame(frame: XRFrame): void;
  80402. /**
  80403. * avoiding using Array.find for global support.
  80404. * @param xrAnchor the plane to find in the array
  80405. */
  80406. private _findIndexInAnchorArray;
  80407. private _updateAnchorWithXRFrame;
  80408. private _createAnchorAtTransformation;
  80409. }
  80410. }
  80411. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  80412. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80413. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80414. import { Observable } from "babylonjs/Misc/observable";
  80415. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  80416. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80417. /**
  80418. * Options used in the plane detector module
  80419. */
  80420. export interface IWebXRPlaneDetectorOptions {
  80421. /**
  80422. * The node to use to transform the local results to world coordinates
  80423. */
  80424. worldParentNode?: TransformNode;
  80425. /**
  80426. * If set to true a reference of the created planes will be kept until the next session starts
  80427. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  80428. */
  80429. doNotRemovePlanesOnSessionEnded?: boolean;
  80430. }
  80431. /**
  80432. * A babylon interface for a WebXR plane.
  80433. * A Plane is actually a polygon, built from N points in space
  80434. *
  80435. * Supported in chrome 79, not supported in canary 81 ATM
  80436. */
  80437. export interface IWebXRPlane {
  80438. /**
  80439. * a babylon-assigned ID for this polygon
  80440. */
  80441. id: number;
  80442. /**
  80443. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  80444. */
  80445. polygonDefinition: Array<Vector3>;
  80446. /**
  80447. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  80448. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  80449. */
  80450. transformationMatrix: Matrix;
  80451. /**
  80452. * the native xr-plane object
  80453. */
  80454. xrPlane: XRPlane;
  80455. }
  80456. /**
  80457. * The plane detector is used to detect planes in the real world when in AR
  80458. * For more information see https://github.com/immersive-web/real-world-geometry/
  80459. */
  80460. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  80461. private _options;
  80462. private _detectedPlanes;
  80463. private _enabled;
  80464. private _lastFrameDetected;
  80465. /**
  80466. * The module's name
  80467. */
  80468. static readonly Name: string;
  80469. /**
  80470. * The (Babylon) version of this module.
  80471. * This is an integer representing the implementation version.
  80472. * This number does not correspond to the WebXR specs version
  80473. */
  80474. static readonly Version: number;
  80475. /**
  80476. * Observers registered here will be executed when a new plane was added to the session
  80477. */
  80478. onPlaneAddedObservable: Observable<IWebXRPlane>;
  80479. /**
  80480. * Observers registered here will be executed when a plane is no longer detected in the session
  80481. */
  80482. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  80483. /**
  80484. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  80485. * This can execute N times every frame
  80486. */
  80487. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  80488. /**
  80489. * construct a new Plane Detector
  80490. * @param _xrSessionManager an instance of xr Session manager
  80491. * @param _options configuration to use when constructing this feature
  80492. */
  80493. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  80494. /**
  80495. * detach this feature.
  80496. * Will usually be called by the features manager
  80497. *
  80498. * @returns true if successful.
  80499. */
  80500. detach(): boolean;
  80501. /**
  80502. * Dispose this feature and all of the resources attached
  80503. */
  80504. dispose(): void;
  80505. /**
  80506. * Check if the needed objects are defined.
  80507. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80508. */
  80509. isCompatible(): boolean;
  80510. protected _onXRFrame(frame: XRFrame): void;
  80511. private _init;
  80512. private _updatePlaneWithXRPlane;
  80513. /**
  80514. * avoiding using Array.find for global support.
  80515. * @param xrPlane the plane to find in the array
  80516. */
  80517. private findIndexInPlaneArray;
  80518. }
  80519. }
  80520. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  80521. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80523. import { Observable } from "babylonjs/Misc/observable";
  80524. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80525. /**
  80526. * Options interface for the background remover plugin
  80527. */
  80528. export interface IWebXRBackgroundRemoverOptions {
  80529. /**
  80530. * Further background meshes to disable when entering AR
  80531. */
  80532. backgroundMeshes?: AbstractMesh[];
  80533. /**
  80534. * flags to configure the removal of the environment helper.
  80535. * If not set, the entire background will be removed. If set, flags should be set as well.
  80536. */
  80537. environmentHelperRemovalFlags?: {
  80538. /**
  80539. * Should the skybox be removed (default false)
  80540. */
  80541. skyBox?: boolean;
  80542. /**
  80543. * Should the ground be removed (default false)
  80544. */
  80545. ground?: boolean;
  80546. };
  80547. /**
  80548. * don't disable the environment helper
  80549. */
  80550. ignoreEnvironmentHelper?: boolean;
  80551. }
  80552. /**
  80553. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  80554. */
  80555. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  80556. /**
  80557. * read-only options to be used in this module
  80558. */
  80559. readonly options: IWebXRBackgroundRemoverOptions;
  80560. /**
  80561. * The module's name
  80562. */
  80563. static readonly Name: string;
  80564. /**
  80565. * The (Babylon) version of this module.
  80566. * This is an integer representing the implementation version.
  80567. * This number does not correspond to the WebXR specs version
  80568. */
  80569. static readonly Version: number;
  80570. /**
  80571. * registered observers will be triggered when the background state changes
  80572. */
  80573. onBackgroundStateChangedObservable: Observable<boolean>;
  80574. /**
  80575. * constructs a new background remover module
  80576. * @param _xrSessionManager the session manager for this module
  80577. * @param options read-only options to be used in this module
  80578. */
  80579. constructor(_xrSessionManager: WebXRSessionManager,
  80580. /**
  80581. * read-only options to be used in this module
  80582. */
  80583. options?: IWebXRBackgroundRemoverOptions);
  80584. /**
  80585. * attach this feature
  80586. * Will usually be called by the features manager
  80587. *
  80588. * @returns true if successful.
  80589. */
  80590. attach(): boolean;
  80591. /**
  80592. * detach this feature.
  80593. * Will usually be called by the features manager
  80594. *
  80595. * @returns true if successful.
  80596. */
  80597. detach(): boolean;
  80598. /**
  80599. * Dispose this feature and all of the resources attached
  80600. */
  80601. dispose(): void;
  80602. protected _onXRFrame(_xrFrame: XRFrame): void;
  80603. private _setBackgroundState;
  80604. }
  80605. }
  80606. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  80607. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80608. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80609. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  80610. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80611. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80612. import { Nullable } from "babylonjs/types";
  80613. /**
  80614. * Options for the controller physics feature
  80615. */
  80616. export class IWebXRControllerPhysicsOptions {
  80617. /**
  80618. * Should the headset get its own impostor
  80619. */
  80620. enableHeadsetImpostor?: boolean;
  80621. /**
  80622. * Optional parameters for the headset impostor
  80623. */
  80624. headsetImpostorParams?: {
  80625. /**
  80626. * The type of impostor to create. Default is sphere
  80627. */
  80628. impostorType: number;
  80629. /**
  80630. * the size of the impostor. Defaults to 10cm
  80631. */
  80632. impostorSize?: number | {
  80633. width: number;
  80634. height: number;
  80635. depth: number;
  80636. };
  80637. /**
  80638. * Friction definitions
  80639. */
  80640. friction?: number;
  80641. /**
  80642. * Restitution
  80643. */
  80644. restitution?: number;
  80645. };
  80646. /**
  80647. * The physics properties of the future impostors
  80648. */
  80649. physicsProperties?: {
  80650. /**
  80651. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  80652. * Note that this requires a physics engine that supports mesh impostors!
  80653. */
  80654. useControllerMesh?: boolean;
  80655. /**
  80656. * The type of impostor to create. Default is sphere
  80657. */
  80658. impostorType?: number;
  80659. /**
  80660. * the size of the impostor. Defaults to 10cm
  80661. */
  80662. impostorSize?: number | {
  80663. width: number;
  80664. height: number;
  80665. depth: number;
  80666. };
  80667. /**
  80668. * Friction definitions
  80669. */
  80670. friction?: number;
  80671. /**
  80672. * Restitution
  80673. */
  80674. restitution?: number;
  80675. };
  80676. /**
  80677. * the xr input to use with this pointer selection
  80678. */
  80679. xrInput: WebXRInput;
  80680. }
  80681. /**
  80682. * Add physics impostor to your webxr controllers,
  80683. * including naive calculation of their linear and angular velocity
  80684. */
  80685. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  80686. private readonly _options;
  80687. private _attachController;
  80688. private _controllers;
  80689. private _debugMode;
  80690. private _delta;
  80691. private _headsetImpostor?;
  80692. private _headsetMesh?;
  80693. private _lastTimestamp;
  80694. private _tmpQuaternion;
  80695. private _tmpVector;
  80696. /**
  80697. * The module's name
  80698. */
  80699. static readonly Name: string;
  80700. /**
  80701. * The (Babylon) version of this module.
  80702. * This is an integer representing the implementation version.
  80703. * This number does not correspond to the webxr specs version
  80704. */
  80705. static readonly Version: number;
  80706. /**
  80707. * Construct a new Controller Physics Feature
  80708. * @param _xrSessionManager the corresponding xr session manager
  80709. * @param _options options to create this feature with
  80710. */
  80711. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  80712. /**
  80713. * @hidden
  80714. * enable debugging - will show console outputs and the impostor mesh
  80715. */
  80716. _enablePhysicsDebug(): void;
  80717. /**
  80718. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  80719. * @param xrController the controller to add
  80720. */
  80721. addController(xrController: WebXRInputSource): void;
  80722. /**
  80723. * attach this feature
  80724. * Will usually be called by the features manager
  80725. *
  80726. * @returns true if successful.
  80727. */
  80728. attach(): boolean;
  80729. /**
  80730. * detach this feature.
  80731. * Will usually be called by the features manager
  80732. *
  80733. * @returns true if successful.
  80734. */
  80735. detach(): boolean;
  80736. /**
  80737. * Get the headset impostor, if enabled
  80738. * @returns the impostor
  80739. */
  80740. getHeadsetImpostor(): PhysicsImpostor | undefined;
  80741. /**
  80742. * Get the physics impostor of a specific controller.
  80743. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  80744. * @param controller the controller or the controller id of which to get the impostor
  80745. * @returns the impostor or null
  80746. */
  80747. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  80748. /**
  80749. * Update the physics properties provided in the constructor
  80750. * @param newProperties the new properties object
  80751. */
  80752. setPhysicsProperties(newProperties: {
  80753. impostorType?: number;
  80754. impostorSize?: number | {
  80755. width: number;
  80756. height: number;
  80757. depth: number;
  80758. };
  80759. friction?: number;
  80760. restitution?: number;
  80761. }): void;
  80762. protected _onXRFrame(_xrFrame: any): void;
  80763. private _detachController;
  80764. }
  80765. }
  80766. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  80767. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80768. import { Observable } from "babylonjs/Misc/observable";
  80769. import { Vector3 } from "babylonjs/Maths/math.vector";
  80770. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80771. /**
  80772. * A babylon interface for a "WebXR" feature point.
  80773. * Represents the position and confidence value of a given feature point.
  80774. */
  80775. export interface IWebXRFeaturePoint {
  80776. /**
  80777. * Represents the position of the feature point in world space.
  80778. */
  80779. position: Vector3;
  80780. /**
  80781. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  80782. */
  80783. confidenceValue: number;
  80784. }
  80785. /**
  80786. * The feature point system is used to detect feature points from real world geometry.
  80787. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  80788. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  80789. */
  80790. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80791. private _enabled;
  80792. private _featurePointCloud;
  80793. /**
  80794. * The module's name
  80795. */
  80796. static readonly Name: string;
  80797. /**
  80798. * The (Babylon) version of this module.
  80799. * This is an integer representing the implementation version.
  80800. * This number does not correspond to the WebXR specs version
  80801. */
  80802. static readonly Version: number;
  80803. /**
  80804. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  80805. * Will notify the observers about which feature points have been added.
  80806. */
  80807. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  80808. /**
  80809. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  80810. * Will notify the observers about which feature points have been updated.
  80811. */
  80812. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  80813. /**
  80814. * The current feature point cloud maintained across frames.
  80815. */
  80816. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  80817. /**
  80818. * construct the feature point system
  80819. * @param _xrSessionManager an instance of xr Session manager
  80820. */
  80821. constructor(_xrSessionManager: WebXRSessionManager);
  80822. /**
  80823. * Detach this feature.
  80824. * Will usually be called by the features manager
  80825. *
  80826. * @returns true if successful.
  80827. */
  80828. detach(): boolean;
  80829. /**
  80830. * Dispose this feature and all of the resources attached
  80831. */
  80832. dispose(): void;
  80833. /**
  80834. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80835. */
  80836. protected _onXRFrame(frame: XRFrame): void;
  80837. /**
  80838. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80839. */
  80840. private _init;
  80841. }
  80842. }
  80843. declare module "babylonjs/XR/features/WebXRHandTracking" {
  80844. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80845. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80847. import { Mesh } from "babylonjs/Meshes/mesh";
  80848. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80849. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80850. import { Nullable } from "babylonjs/types";
  80851. import { IDisposable } from "babylonjs/scene";
  80852. import { Observable } from "babylonjs/Misc/observable";
  80853. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  80854. /**
  80855. * Configuration interface for the hand tracking feature
  80856. */
  80857. export interface IWebXRHandTrackingOptions {
  80858. /**
  80859. * The xrInput that will be used as source for new hands
  80860. */
  80861. xrInput: WebXRInput;
  80862. /**
  80863. * Configuration object for the joint meshes
  80864. */
  80865. jointMeshes?: {
  80866. /**
  80867. * Should the meshes created be invisible (defaults to false)
  80868. */
  80869. invisible?: boolean;
  80870. /**
  80871. * A source mesh to be used to create instances. Defaults to a sphere.
  80872. * This mesh will be the source for all other (25) meshes.
  80873. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80874. */
  80875. sourceMesh?: Mesh;
  80876. /**
  80877. * This function will be called after a mesh was created for a specific joint.
  80878. * Using this function you can either manipulate the instance or return a new mesh.
  80879. * When returning a new mesh the instance created before will be disposed
  80880. */
  80881. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80882. /**
  80883. * Should the source mesh stay visible. Defaults to false
  80884. */
  80885. keepOriginalVisible?: boolean;
  80886. /**
  80887. * Scale factor for all instances (defaults to 2)
  80888. */
  80889. scaleFactor?: number;
  80890. /**
  80891. * Should each instance have its own physics impostor
  80892. */
  80893. enablePhysics?: boolean;
  80894. /**
  80895. * If enabled, override default physics properties
  80896. */
  80897. physicsProps?: {
  80898. friction?: number;
  80899. restitution?: number;
  80900. impostorType?: number;
  80901. };
  80902. /**
  80903. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  80904. */
  80905. handMesh?: AbstractMesh;
  80906. };
  80907. }
  80908. /**
  80909. * Parts of the hands divided to writs and finger names
  80910. */
  80911. export const enum HandPart {
  80912. /**
  80913. * HandPart - Wrist
  80914. */
  80915. WRIST = "wrist",
  80916. /**
  80917. * HandPart - The THumb
  80918. */
  80919. THUMB = "thumb",
  80920. /**
  80921. * HandPart - Index finger
  80922. */
  80923. INDEX = "index",
  80924. /**
  80925. * HandPart - Middle finger
  80926. */
  80927. MIDDLE = "middle",
  80928. /**
  80929. * HandPart - Ring finger
  80930. */
  80931. RING = "ring",
  80932. /**
  80933. * HandPart - Little finger
  80934. */
  80935. LITTLE = "little"
  80936. }
  80937. /**
  80938. * Representing a single hand (with its corresponding native XRHand object)
  80939. */
  80940. export class WebXRHand implements IDisposable {
  80941. /** the controller to which the hand correlates */
  80942. readonly xrController: WebXRInputSource;
  80943. /** the meshes to be used to track the hand joints */
  80944. readonly trackedMeshes: AbstractMesh[];
  80945. /**
  80946. * Hand-parts definition (key is HandPart)
  80947. */
  80948. handPartsDefinition: {
  80949. [key: string]: number[];
  80950. };
  80951. /**
  80952. * Populate the HandPartsDefinition object.
  80953. * This is called as a side effect since certain browsers don't have XRHand defined.
  80954. */
  80955. private generateHandPartsDefinition;
  80956. /**
  80957. * Construct a new hand object
  80958. * @param xrController the controller to which the hand correlates
  80959. * @param trackedMeshes the meshes to be used to track the hand joints
  80960. */
  80961. constructor(
  80962. /** the controller to which the hand correlates */
  80963. xrController: WebXRInputSource,
  80964. /** the meshes to be used to track the hand joints */
  80965. trackedMeshes: AbstractMesh[]);
  80966. /**
  80967. * Update this hand from the latest xr frame
  80968. * @param xrFrame xrFrame to update from
  80969. * @param referenceSpace The current viewer reference space
  80970. * @param scaleFactor optional scale factor for the meshes
  80971. */
  80972. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80973. /**
  80974. * Get meshes of part of the hand
  80975. * @param part the part of hand to get
  80976. * @returns An array of meshes that correlate to the hand part requested
  80977. */
  80978. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80979. /**
  80980. * Dispose this Hand object
  80981. */
  80982. dispose(): void;
  80983. }
  80984. /**
  80985. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80986. */
  80987. export class WebXRHandTracking extends WebXRAbstractFeature {
  80988. /**
  80989. * options to use when constructing this feature
  80990. */
  80991. readonly options: IWebXRHandTrackingOptions;
  80992. private static _idCounter;
  80993. /**
  80994. * The module's name
  80995. */
  80996. static readonly Name: string;
  80997. /**
  80998. * The (Babylon) version of this module.
  80999. * This is an integer representing the implementation version.
  81000. * This number does not correspond to the WebXR specs version
  81001. */
  81002. static readonly Version: number;
  81003. /**
  81004. * This observable will notify registered observers when a new hand object was added and initialized
  81005. */
  81006. onHandAddedObservable: Observable<WebXRHand>;
  81007. /**
  81008. * This observable will notify its observers right before the hand object is disposed
  81009. */
  81010. onHandRemovedObservable: Observable<WebXRHand>;
  81011. private _hands;
  81012. /**
  81013. * Creates a new instance of the hit test feature
  81014. * @param _xrSessionManager an instance of WebXRSessionManager
  81015. * @param options options to use when constructing this feature
  81016. */
  81017. constructor(_xrSessionManager: WebXRSessionManager,
  81018. /**
  81019. * options to use when constructing this feature
  81020. */
  81021. options: IWebXRHandTrackingOptions);
  81022. /**
  81023. * Check if the needed objects are defined.
  81024. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  81025. */
  81026. isCompatible(): boolean;
  81027. /**
  81028. * attach this feature
  81029. * Will usually be called by the features manager
  81030. *
  81031. * @returns true if successful.
  81032. */
  81033. attach(): boolean;
  81034. /**
  81035. * detach this feature.
  81036. * Will usually be called by the features manager
  81037. *
  81038. * @returns true if successful.
  81039. */
  81040. detach(): boolean;
  81041. /**
  81042. * Dispose this feature and all of the resources attached
  81043. */
  81044. dispose(): void;
  81045. /**
  81046. * Get the hand object according to the controller id
  81047. * @param controllerId the controller id to which we want to get the hand
  81048. * @returns null if not found or the WebXRHand object if found
  81049. */
  81050. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  81051. /**
  81052. * Get a hand object according to the requested handedness
  81053. * @param handedness the handedness to request
  81054. * @returns null if not found or the WebXRHand object if found
  81055. */
  81056. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  81057. protected _onXRFrame(_xrFrame: XRFrame): void;
  81058. private _attachHand;
  81059. private _detachHand;
  81060. }
  81061. }
  81062. declare module "babylonjs/XR/features/index" {
  81063. export * from "babylonjs/XR/features/WebXRAbstractFeature";
  81064. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  81065. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  81066. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  81067. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  81068. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  81069. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  81070. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  81071. export * from "babylonjs/XR/features/WebXRHitTest";
  81072. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  81073. export * from "babylonjs/XR/features/WebXRHandTracking";
  81074. }
  81075. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  81076. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81078. import { Scene } from "babylonjs/scene";
  81079. /**
  81080. * The motion controller class for all microsoft mixed reality controllers
  81081. */
  81082. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  81083. protected readonly _mapping: {
  81084. defaultButton: {
  81085. valueNodeName: string;
  81086. unpressedNodeName: string;
  81087. pressedNodeName: string;
  81088. };
  81089. defaultAxis: {
  81090. valueNodeName: string;
  81091. minNodeName: string;
  81092. maxNodeName: string;
  81093. };
  81094. buttons: {
  81095. "xr-standard-trigger": {
  81096. rootNodeName: string;
  81097. componentProperty: string;
  81098. states: string[];
  81099. };
  81100. "xr-standard-squeeze": {
  81101. rootNodeName: string;
  81102. componentProperty: string;
  81103. states: string[];
  81104. };
  81105. "xr-standard-touchpad": {
  81106. rootNodeName: string;
  81107. labelAnchorNodeName: string;
  81108. touchPointNodeName: string;
  81109. };
  81110. "xr-standard-thumbstick": {
  81111. rootNodeName: string;
  81112. componentProperty: string;
  81113. states: string[];
  81114. };
  81115. };
  81116. axes: {
  81117. "xr-standard-touchpad": {
  81118. "x-axis": {
  81119. rootNodeName: string;
  81120. };
  81121. "y-axis": {
  81122. rootNodeName: string;
  81123. };
  81124. };
  81125. "xr-standard-thumbstick": {
  81126. "x-axis": {
  81127. rootNodeName: string;
  81128. };
  81129. "y-axis": {
  81130. rootNodeName: string;
  81131. };
  81132. };
  81133. };
  81134. };
  81135. /**
  81136. * The base url used to load the left and right controller models
  81137. */
  81138. static MODEL_BASE_URL: string;
  81139. /**
  81140. * The name of the left controller model file
  81141. */
  81142. static MODEL_LEFT_FILENAME: string;
  81143. /**
  81144. * The name of the right controller model file
  81145. */
  81146. static MODEL_RIGHT_FILENAME: string;
  81147. profileId: string;
  81148. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  81149. protected _getFilenameAndPath(): {
  81150. filename: string;
  81151. path: string;
  81152. };
  81153. protected _getModelLoadingConstraints(): boolean;
  81154. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81155. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81156. protected _updateModel(): void;
  81157. }
  81158. }
  81159. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  81160. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81162. import { Scene } from "babylonjs/scene";
  81163. /**
  81164. * The motion controller class for oculus touch (quest, rift).
  81165. * This class supports legacy mapping as well the standard xr mapping
  81166. */
  81167. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  81168. private _forceLegacyControllers;
  81169. private _modelRootNode;
  81170. /**
  81171. * The base url used to load the left and right controller models
  81172. */
  81173. static MODEL_BASE_URL: string;
  81174. /**
  81175. * The name of the left controller model file
  81176. */
  81177. static MODEL_LEFT_FILENAME: string;
  81178. /**
  81179. * The name of the right controller model file
  81180. */
  81181. static MODEL_RIGHT_FILENAME: string;
  81182. /**
  81183. * Base Url for the Quest controller model.
  81184. */
  81185. static QUEST_MODEL_BASE_URL: string;
  81186. profileId: string;
  81187. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  81188. protected _getFilenameAndPath(): {
  81189. filename: string;
  81190. path: string;
  81191. };
  81192. protected _getModelLoadingConstraints(): boolean;
  81193. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81194. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81195. protected _updateModel(): void;
  81196. /**
  81197. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  81198. * between the touch and touch 2.
  81199. */
  81200. private _isQuest;
  81201. }
  81202. }
  81203. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  81204. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81205. import { Scene } from "babylonjs/scene";
  81206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81207. /**
  81208. * The motion controller class for the standard HTC-Vive controllers
  81209. */
  81210. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  81211. private _modelRootNode;
  81212. /**
  81213. * The base url used to load the left and right controller models
  81214. */
  81215. static MODEL_BASE_URL: string;
  81216. /**
  81217. * File name for the controller model.
  81218. */
  81219. static MODEL_FILENAME: string;
  81220. profileId: string;
  81221. /**
  81222. * Create a new Vive motion controller object
  81223. * @param scene the scene to use to create this controller
  81224. * @param gamepadObject the corresponding gamepad object
  81225. * @param handedness the handedness of the controller
  81226. */
  81227. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  81228. protected _getFilenameAndPath(): {
  81229. filename: string;
  81230. path: string;
  81231. };
  81232. protected _getModelLoadingConstraints(): boolean;
  81233. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81234. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81235. protected _updateModel(): void;
  81236. }
  81237. }
  81238. declare module "babylonjs/XR/motionController/index" {
  81239. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81240. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  81241. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  81242. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  81243. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  81244. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  81245. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  81246. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  81247. }
  81248. declare module "babylonjs/XR/index" {
  81249. export * from "babylonjs/XR/webXRCamera";
  81250. export * from "babylonjs/XR/webXREnterExitUI";
  81251. export * from "babylonjs/XR/webXRExperienceHelper";
  81252. export * from "babylonjs/XR/webXRInput";
  81253. export * from "babylonjs/XR/webXRInputSource";
  81254. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  81255. export * from "babylonjs/XR/webXRTypes";
  81256. export * from "babylonjs/XR/webXRSessionManager";
  81257. export * from "babylonjs/XR/webXRDefaultExperience";
  81258. export * from "babylonjs/XR/webXRFeaturesManager";
  81259. export * from "babylonjs/XR/features/index";
  81260. export * from "babylonjs/XR/motionController/index";
  81261. }
  81262. declare module "babylonjs/index" {
  81263. export * from "babylonjs/abstractScene";
  81264. export * from "babylonjs/Actions/index";
  81265. export * from "babylonjs/Animations/index";
  81266. export * from "babylonjs/assetContainer";
  81267. export * from "babylonjs/Audio/index";
  81268. export * from "babylonjs/Behaviors/index";
  81269. export * from "babylonjs/Bones/index";
  81270. export * from "babylonjs/Cameras/index";
  81271. export * from "babylonjs/Collisions/index";
  81272. export * from "babylonjs/Culling/index";
  81273. export * from "babylonjs/Debug/index";
  81274. export * from "babylonjs/DeviceInput/index";
  81275. export * from "babylonjs/Engines/index";
  81276. export * from "babylonjs/Events/index";
  81277. export * from "babylonjs/Gamepads/index";
  81278. export * from "babylonjs/Gizmos/index";
  81279. export * from "babylonjs/Helpers/index";
  81280. export * from "babylonjs/Instrumentation/index";
  81281. export * from "babylonjs/Layers/index";
  81282. export * from "babylonjs/LensFlares/index";
  81283. export * from "babylonjs/Lights/index";
  81284. export * from "babylonjs/Loading/index";
  81285. export * from "babylonjs/Materials/index";
  81286. export * from "babylonjs/Maths/index";
  81287. export * from "babylonjs/Meshes/index";
  81288. export * from "babylonjs/Morph/index";
  81289. export * from "babylonjs/Navigation/index";
  81290. export * from "babylonjs/node";
  81291. export * from "babylonjs/Offline/index";
  81292. export * from "babylonjs/Particles/index";
  81293. export * from "babylonjs/Physics/index";
  81294. export * from "babylonjs/PostProcesses/index";
  81295. export * from "babylonjs/Probes/index";
  81296. export * from "babylonjs/Rendering/index";
  81297. export * from "babylonjs/scene";
  81298. export * from "babylonjs/sceneComponent";
  81299. export * from "babylonjs/Sprites/index";
  81300. export * from "babylonjs/States/index";
  81301. export * from "babylonjs/Misc/index";
  81302. export * from "babylonjs/XR/index";
  81303. export * from "babylonjs/types";
  81304. }
  81305. declare module "babylonjs/Animations/pathCursor" {
  81306. import { Vector3 } from "babylonjs/Maths/math.vector";
  81307. import { Path2 } from "babylonjs/Maths/math.path";
  81308. /**
  81309. * A cursor which tracks a point on a path
  81310. */
  81311. export class PathCursor {
  81312. private path;
  81313. /**
  81314. * Stores path cursor callbacks for when an onchange event is triggered
  81315. */
  81316. private _onchange;
  81317. /**
  81318. * The value of the path cursor
  81319. */
  81320. value: number;
  81321. /**
  81322. * The animation array of the path cursor
  81323. */
  81324. animations: Animation[];
  81325. /**
  81326. * Initializes the path cursor
  81327. * @param path The path to track
  81328. */
  81329. constructor(path: Path2);
  81330. /**
  81331. * Gets the cursor point on the path
  81332. * @returns A point on the path cursor at the cursor location
  81333. */
  81334. getPoint(): Vector3;
  81335. /**
  81336. * Moves the cursor ahead by the step amount
  81337. * @param step The amount to move the cursor forward
  81338. * @returns This path cursor
  81339. */
  81340. moveAhead(step?: number): PathCursor;
  81341. /**
  81342. * Moves the cursor behind by the step amount
  81343. * @param step The amount to move the cursor back
  81344. * @returns This path cursor
  81345. */
  81346. moveBack(step?: number): PathCursor;
  81347. /**
  81348. * Moves the cursor by the step amount
  81349. * If the step amount is greater than one, an exception is thrown
  81350. * @param step The amount to move the cursor
  81351. * @returns This path cursor
  81352. */
  81353. move(step: number): PathCursor;
  81354. /**
  81355. * Ensures that the value is limited between zero and one
  81356. * @returns This path cursor
  81357. */
  81358. private ensureLimits;
  81359. /**
  81360. * Runs onchange callbacks on change (used by the animation engine)
  81361. * @returns This path cursor
  81362. */
  81363. private raiseOnChange;
  81364. /**
  81365. * Executes a function on change
  81366. * @param f A path cursor onchange callback
  81367. * @returns This path cursor
  81368. */
  81369. onchange(f: (cursor: PathCursor) => void): PathCursor;
  81370. }
  81371. }
  81372. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  81373. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  81374. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  81375. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  81376. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  81377. }
  81378. declare module "babylonjs/Engines/Processors/Expressions/index" {
  81379. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  81380. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  81381. }
  81382. declare module "babylonjs/Engines/Processors/index" {
  81383. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  81384. export * from "babylonjs/Engines/Processors/Expressions/index";
  81385. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  81386. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  81387. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  81388. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  81389. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  81390. export * from "babylonjs/Engines/Processors/shaderProcessor";
  81391. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  81392. }
  81393. declare module "babylonjs/Legacy/legacy" {
  81394. import * as Babylon from "babylonjs/index";
  81395. export * from "babylonjs/index";
  81396. }
  81397. declare module "babylonjs/Shaders/blur.fragment" {
  81398. /** @hidden */
  81399. export var blurPixelShader: {
  81400. name: string;
  81401. shader: string;
  81402. };
  81403. }
  81404. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  81405. /** @hidden */
  81406. export var pointCloudVertexDeclaration: {
  81407. name: string;
  81408. shader: string;
  81409. };
  81410. }
  81411. declare module "babylonjs" {
  81412. export * from "babylonjs/Legacy/legacy";
  81413. }
  81414. declare module BABYLON {
  81415. /** Alias type for value that can be null */
  81416. export type Nullable<T> = T | null;
  81417. /**
  81418. * Alias type for number that are floats
  81419. * @ignorenaming
  81420. */
  81421. export type float = number;
  81422. /**
  81423. * Alias type for number that are doubles.
  81424. * @ignorenaming
  81425. */
  81426. export type double = number;
  81427. /**
  81428. * Alias type for number that are integer
  81429. * @ignorenaming
  81430. */
  81431. export type int = number;
  81432. /** Alias type for number array or Float32Array */
  81433. export type FloatArray = number[] | Float32Array;
  81434. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  81435. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  81436. /**
  81437. * Alias for types that can be used by a Buffer or VertexBuffer.
  81438. */
  81439. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  81440. /**
  81441. * Alias type for primitive types
  81442. * @ignorenaming
  81443. */
  81444. type Primitive = undefined | null | boolean | string | number | Function;
  81445. /**
  81446. * Type modifier to make all the properties of an object Readonly
  81447. */
  81448. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  81449. /**
  81450. * Type modifier to make all the properties of an object Readonly recursively
  81451. */
  81452. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  81453. /**
  81454. * Type modifier to make object properties readonly.
  81455. */
  81456. export type DeepImmutableObject<T> = {
  81457. readonly [K in keyof T]: DeepImmutable<T[K]>;
  81458. };
  81459. /** @hidden */
  81460. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  81461. }
  81462. }
  81463. declare module BABYLON {
  81464. /**
  81465. * A class serves as a medium between the observable and its observers
  81466. */
  81467. export class EventState {
  81468. /**
  81469. * Create a new EventState
  81470. * @param mask defines the mask associated with this state
  81471. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  81472. * @param target defines the original target of the state
  81473. * @param currentTarget defines the current target of the state
  81474. */
  81475. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  81476. /**
  81477. * Initialize the current event state
  81478. * @param mask defines the mask associated with this state
  81479. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  81480. * @param target defines the original target of the state
  81481. * @param currentTarget defines the current target of the state
  81482. * @returns the current event state
  81483. */
  81484. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  81485. /**
  81486. * An Observer can set this property to true to prevent subsequent observers of being notified
  81487. */
  81488. skipNextObservers: boolean;
  81489. /**
  81490. * Get the mask value that were used to trigger the event corresponding to this EventState object
  81491. */
  81492. mask: number;
  81493. /**
  81494. * The object that originally notified the event
  81495. */
  81496. target?: any;
  81497. /**
  81498. * The current object in the bubbling phase
  81499. */
  81500. currentTarget?: any;
  81501. /**
  81502. * This will be populated with the return value of the last function that was executed.
  81503. * If it is the first function in the callback chain it will be the event data.
  81504. */
  81505. lastReturnValue?: any;
  81506. /**
  81507. * User defined information that will be sent to observers
  81508. */
  81509. userInfo?: any;
  81510. }
  81511. /**
  81512. * Represent an Observer registered to a given Observable object.
  81513. */
  81514. export class Observer<T> {
  81515. /**
  81516. * Defines the callback to call when the observer is notified
  81517. */
  81518. callback: (eventData: T, eventState: EventState) => void;
  81519. /**
  81520. * Defines the mask of the observer (used to filter notifications)
  81521. */
  81522. mask: number;
  81523. /**
  81524. * Defines the current scope used to restore the JS context
  81525. */
  81526. scope: any;
  81527. /** @hidden */
  81528. _willBeUnregistered: boolean;
  81529. /**
  81530. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  81531. */
  81532. unregisterOnNextCall: boolean;
  81533. /**
  81534. * Creates a new observer
  81535. * @param callback defines the callback to call when the observer is notified
  81536. * @param mask defines the mask of the observer (used to filter notifications)
  81537. * @param scope defines the current scope used to restore the JS context
  81538. */
  81539. constructor(
  81540. /**
  81541. * Defines the callback to call when the observer is notified
  81542. */
  81543. callback: (eventData: T, eventState: EventState) => void,
  81544. /**
  81545. * Defines the mask of the observer (used to filter notifications)
  81546. */
  81547. mask: number,
  81548. /**
  81549. * Defines the current scope used to restore the JS context
  81550. */
  81551. scope?: any);
  81552. }
  81553. /**
  81554. * Represent a list of observers registered to multiple Observables object.
  81555. */
  81556. export class MultiObserver<T> {
  81557. private _observers;
  81558. private _observables;
  81559. /**
  81560. * Release associated resources
  81561. */
  81562. dispose(): void;
  81563. /**
  81564. * Raise a callback when one of the observable will notify
  81565. * @param observables defines a list of observables to watch
  81566. * @param callback defines the callback to call on notification
  81567. * @param mask defines the mask used to filter notifications
  81568. * @param scope defines the current scope used to restore the JS context
  81569. * @returns the new MultiObserver
  81570. */
  81571. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  81572. }
  81573. /**
  81574. * The Observable class is a simple implementation of the Observable pattern.
  81575. *
  81576. * 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.
  81577. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  81578. * 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).
  81579. * 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.
  81580. */
  81581. export class Observable<T> {
  81582. private _observers;
  81583. private _eventState;
  81584. private _onObserverAdded;
  81585. /**
  81586. * Gets the list of observers
  81587. */
  81588. get observers(): Array<Observer<T>>;
  81589. /**
  81590. * Creates a new observable
  81591. * @param onObserverAdded defines a callback to call when a new observer is added
  81592. */
  81593. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  81594. /**
  81595. * Create a new Observer with the specified callback
  81596. * @param callback the callback that will be executed for that Observer
  81597. * @param mask the mask used to filter observers
  81598. * @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.
  81599. * @param scope optional scope for the callback to be called from
  81600. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  81601. * @returns the new observer created for the callback
  81602. */
  81603. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  81604. /**
  81605. * Create a new Observer with the specified callback and unregisters after the next notification
  81606. * @param callback the callback that will be executed for that Observer
  81607. * @returns the new observer created for the callback
  81608. */
  81609. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  81610. /**
  81611. * Remove an Observer from the Observable object
  81612. * @param observer the instance of the Observer to remove
  81613. * @returns false if it doesn't belong to this Observable
  81614. */
  81615. remove(observer: Nullable<Observer<T>>): boolean;
  81616. /**
  81617. * Remove a callback from the Observable object
  81618. * @param callback the callback to remove
  81619. * @param scope optional scope. If used only the callbacks with this scope will be removed
  81620. * @returns false if it doesn't belong to this Observable
  81621. */
  81622. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  81623. private _deferUnregister;
  81624. private _remove;
  81625. /**
  81626. * Moves the observable to the top of the observer list making it get called first when notified
  81627. * @param observer the observer to move
  81628. */
  81629. makeObserverTopPriority(observer: Observer<T>): void;
  81630. /**
  81631. * Moves the observable to the bottom of the observer list making it get called last when notified
  81632. * @param observer the observer to move
  81633. */
  81634. makeObserverBottomPriority(observer: Observer<T>): void;
  81635. /**
  81636. * Notify all Observers by calling their respective callback with the given data
  81637. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  81638. * @param eventData defines the data to send to all observers
  81639. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  81640. * @param target defines the original target of the state
  81641. * @param currentTarget defines the current target of the state
  81642. * @param userInfo defines any user info to send to observers
  81643. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  81644. */
  81645. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  81646. /**
  81647. * Calling this will execute each callback, expecting it to be a promise or return a value.
  81648. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  81649. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  81650. * and it is crucial that all callbacks will be executed.
  81651. * The order of the callbacks is kept, callbacks are not executed parallel.
  81652. *
  81653. * @param eventData The data to be sent to each callback
  81654. * @param mask is used to filter observers defaults to -1
  81655. * @param target defines the callback target (see EventState)
  81656. * @param currentTarget defines he current object in the bubbling phase
  81657. * @param userInfo defines any user info to send to observers
  81658. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  81659. */
  81660. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  81661. /**
  81662. * Notify a specific observer
  81663. * @param observer defines the observer to notify
  81664. * @param eventData defines the data to be sent to each callback
  81665. * @param mask is used to filter observers defaults to -1
  81666. */
  81667. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  81668. /**
  81669. * Gets a boolean indicating if the observable has at least one observer
  81670. * @returns true is the Observable has at least one Observer registered
  81671. */
  81672. hasObservers(): boolean;
  81673. /**
  81674. * Clear the list of observers
  81675. */
  81676. clear(): void;
  81677. /**
  81678. * Clone the current observable
  81679. * @returns a new observable
  81680. */
  81681. clone(): Observable<T>;
  81682. /**
  81683. * Does this observable handles observer registered with a given mask
  81684. * @param mask defines the mask to be tested
  81685. * @return whether or not one observer registered with the given mask is handeled
  81686. **/
  81687. hasSpecificMask(mask?: number): boolean;
  81688. }
  81689. }
  81690. declare module BABYLON {
  81691. /**
  81692. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  81693. * Babylon.js
  81694. */
  81695. export class DomManagement {
  81696. /**
  81697. * Checks if the window object exists
  81698. * @returns true if the window object exists
  81699. */
  81700. static IsWindowObjectExist(): boolean;
  81701. /**
  81702. * Checks if the navigator object exists
  81703. * @returns true if the navigator object exists
  81704. */
  81705. static IsNavigatorAvailable(): boolean;
  81706. /**
  81707. * Check if the document object exists
  81708. * @returns true if the document object exists
  81709. */
  81710. static IsDocumentAvailable(): boolean;
  81711. /**
  81712. * Extracts text content from a DOM element hierarchy
  81713. * @param element defines the root element
  81714. * @returns a string
  81715. */
  81716. static GetDOMTextContent(element: HTMLElement): string;
  81717. }
  81718. }
  81719. declare module BABYLON {
  81720. /**
  81721. * Logger used througouht the application to allow configuration of
  81722. * the log level required for the messages.
  81723. */
  81724. export class Logger {
  81725. /**
  81726. * No log
  81727. */
  81728. static readonly NoneLogLevel: number;
  81729. /**
  81730. * Only message logs
  81731. */
  81732. static readonly MessageLogLevel: number;
  81733. /**
  81734. * Only warning logs
  81735. */
  81736. static readonly WarningLogLevel: number;
  81737. /**
  81738. * Only error logs
  81739. */
  81740. static readonly ErrorLogLevel: number;
  81741. /**
  81742. * All logs
  81743. */
  81744. static readonly AllLogLevel: number;
  81745. private static _LogCache;
  81746. /**
  81747. * Gets a value indicating the number of loading errors
  81748. * @ignorenaming
  81749. */
  81750. static errorsCount: number;
  81751. /**
  81752. * Callback called when a new log is added
  81753. */
  81754. static OnNewCacheEntry: (entry: string) => void;
  81755. private static _AddLogEntry;
  81756. private static _FormatMessage;
  81757. private static _LogDisabled;
  81758. private static _LogEnabled;
  81759. private static _WarnDisabled;
  81760. private static _WarnEnabled;
  81761. private static _ErrorDisabled;
  81762. private static _ErrorEnabled;
  81763. /**
  81764. * Log a message to the console
  81765. */
  81766. static Log: (message: string) => void;
  81767. /**
  81768. * Write a warning message to the console
  81769. */
  81770. static Warn: (message: string) => void;
  81771. /**
  81772. * Write an error message to the console
  81773. */
  81774. static Error: (message: string) => void;
  81775. /**
  81776. * Gets current log cache (list of logs)
  81777. */
  81778. static get LogCache(): string;
  81779. /**
  81780. * Clears the log cache
  81781. */
  81782. static ClearLogCache(): void;
  81783. /**
  81784. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  81785. */
  81786. static set LogLevels(level: number);
  81787. }
  81788. }
  81789. declare module BABYLON {
  81790. /** @hidden */
  81791. export class _TypeStore {
  81792. /** @hidden */
  81793. static RegisteredTypes: {
  81794. [key: string]: Object;
  81795. };
  81796. /** @hidden */
  81797. static GetClass(fqdn: string): any;
  81798. }
  81799. }
  81800. declare module BABYLON {
  81801. /**
  81802. * Helper to manipulate strings
  81803. */
  81804. export class StringTools {
  81805. /**
  81806. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  81807. * @param str Source string
  81808. * @param suffix Suffix to search for in the source string
  81809. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81810. */
  81811. static EndsWith(str: string, suffix: string): boolean;
  81812. /**
  81813. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  81814. * @param str Source string
  81815. * @param suffix Suffix to search for in the source string
  81816. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81817. */
  81818. static StartsWith(str: string, suffix: string): boolean;
  81819. /**
  81820. * Decodes a buffer into a string
  81821. * @param buffer The buffer to decode
  81822. * @returns The decoded string
  81823. */
  81824. static Decode(buffer: Uint8Array | Uint16Array): string;
  81825. /**
  81826. * Encode a buffer to a base64 string
  81827. * @param buffer defines the buffer to encode
  81828. * @returns the encoded string
  81829. */
  81830. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  81831. /**
  81832. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  81833. * @param num the number to convert and pad
  81834. * @param length the expected length of the string
  81835. * @returns the padded string
  81836. */
  81837. static PadNumber(num: number, length: number): string;
  81838. }
  81839. }
  81840. declare module BABYLON {
  81841. /**
  81842. * Class containing a set of static utilities functions for deep copy.
  81843. */
  81844. export class DeepCopier {
  81845. /**
  81846. * Tries to copy an object by duplicating every property
  81847. * @param source defines the source object
  81848. * @param destination defines the target object
  81849. * @param doNotCopyList defines a list of properties to avoid
  81850. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  81851. */
  81852. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  81853. }
  81854. }
  81855. declare module BABYLON {
  81856. /**
  81857. * Class containing a set of static utilities functions for precision date
  81858. */
  81859. export class PrecisionDate {
  81860. /**
  81861. * Gets either window.performance.now() if supported or Date.now() else
  81862. */
  81863. static get Now(): number;
  81864. }
  81865. }
  81866. declare module BABYLON {
  81867. /** @hidden */
  81868. export class _DevTools {
  81869. static WarnImport(name: string): string;
  81870. }
  81871. }
  81872. declare module BABYLON {
  81873. /**
  81874. * Interface used to define the mechanism to get data from the network
  81875. */
  81876. export interface IWebRequest {
  81877. /**
  81878. * Returns client's response url
  81879. */
  81880. responseURL: string;
  81881. /**
  81882. * Returns client's status
  81883. */
  81884. status: number;
  81885. /**
  81886. * Returns client's status as a text
  81887. */
  81888. statusText: string;
  81889. }
  81890. }
  81891. declare module BABYLON {
  81892. /**
  81893. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  81894. */
  81895. export class WebRequest implements IWebRequest {
  81896. private readonly _xhr;
  81897. /**
  81898. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  81899. * i.e. when loading files, where the server/service expects an Authorization header
  81900. */
  81901. static CustomRequestHeaders: {
  81902. [key: string]: string;
  81903. };
  81904. /**
  81905. * Add callback functions in this array to update all the requests before they get sent to the network
  81906. */
  81907. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  81908. private _injectCustomRequestHeaders;
  81909. /**
  81910. * Gets or sets a function to be called when loading progress changes
  81911. */
  81912. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  81913. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  81914. /**
  81915. * Returns client's state
  81916. */
  81917. get readyState(): number;
  81918. /**
  81919. * Returns client's status
  81920. */
  81921. get status(): number;
  81922. /**
  81923. * Returns client's status as a text
  81924. */
  81925. get statusText(): string;
  81926. /**
  81927. * Returns client's response
  81928. */
  81929. get response(): any;
  81930. /**
  81931. * Returns client's response url
  81932. */
  81933. get responseURL(): string;
  81934. /**
  81935. * Returns client's response as text
  81936. */
  81937. get responseText(): string;
  81938. /**
  81939. * Gets or sets the expected response type
  81940. */
  81941. get responseType(): XMLHttpRequestResponseType;
  81942. set responseType(value: XMLHttpRequestResponseType);
  81943. /** @hidden */
  81944. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  81945. /** @hidden */
  81946. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  81947. /**
  81948. * Cancels any network activity
  81949. */
  81950. abort(): void;
  81951. /**
  81952. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  81953. * @param body defines an optional request body
  81954. */
  81955. send(body?: Document | BodyInit | null): void;
  81956. /**
  81957. * Sets the request method, request URL
  81958. * @param method defines the method to use (GET, POST, etc..)
  81959. * @param url defines the url to connect with
  81960. */
  81961. open(method: string, url: string): void;
  81962. /**
  81963. * Sets the value of a request header.
  81964. * @param name The name of the header whose value is to be set
  81965. * @param value The value to set as the body of the header
  81966. */
  81967. setRequestHeader(name: string, value: string): void;
  81968. /**
  81969. * Get the string containing the text of a particular header's value.
  81970. * @param name The name of the header
  81971. * @returns The string containing the text of the given header name
  81972. */
  81973. getResponseHeader(name: string): Nullable<string>;
  81974. }
  81975. }
  81976. declare module BABYLON {
  81977. /**
  81978. * File request interface
  81979. */
  81980. export interface IFileRequest {
  81981. /**
  81982. * Raised when the request is complete (success or error).
  81983. */
  81984. onCompleteObservable: Observable<IFileRequest>;
  81985. /**
  81986. * Aborts the request for a file.
  81987. */
  81988. abort: () => void;
  81989. }
  81990. }
  81991. declare module BABYLON {
  81992. /**
  81993. * Define options used to create a render target texture
  81994. */
  81995. export class RenderTargetCreationOptions {
  81996. /**
  81997. * Specifies is mipmaps must be generated
  81998. */
  81999. generateMipMaps?: boolean;
  82000. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  82001. generateDepthBuffer?: boolean;
  82002. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  82003. generateStencilBuffer?: boolean;
  82004. /** Defines texture type (int by default) */
  82005. type?: number;
  82006. /** Defines sampling mode (trilinear by default) */
  82007. samplingMode?: number;
  82008. /** Defines format (RGBA by default) */
  82009. format?: number;
  82010. }
  82011. }
  82012. declare module BABYLON {
  82013. /** Defines the cross module used constants to avoid circular dependncies */
  82014. export class Constants {
  82015. /** Defines that alpha blending is disabled */
  82016. static readonly ALPHA_DISABLE: number;
  82017. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  82018. static readonly ALPHA_ADD: number;
  82019. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  82020. static readonly ALPHA_COMBINE: number;
  82021. /** Defines that alpha blending is DEST - SRC * DEST */
  82022. static readonly ALPHA_SUBTRACT: number;
  82023. /** Defines that alpha blending is SRC * DEST */
  82024. static readonly ALPHA_MULTIPLY: number;
  82025. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  82026. static readonly ALPHA_MAXIMIZED: number;
  82027. /** Defines that alpha blending is SRC + DEST */
  82028. static readonly ALPHA_ONEONE: number;
  82029. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  82030. static readonly ALPHA_PREMULTIPLIED: number;
  82031. /**
  82032. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  82033. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  82034. */
  82035. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  82036. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  82037. static readonly ALPHA_INTERPOLATE: number;
  82038. /**
  82039. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  82040. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  82041. */
  82042. static readonly ALPHA_SCREENMODE: number;
  82043. /**
  82044. * Defines that alpha blending is SRC + DST
  82045. * Alpha will be set to SRC ALPHA + DST ALPHA
  82046. */
  82047. static readonly ALPHA_ONEONE_ONEONE: number;
  82048. /**
  82049. * Defines that alpha blending is SRC * DST ALPHA + DST
  82050. * Alpha will be set to 0
  82051. */
  82052. static readonly ALPHA_ALPHATOCOLOR: number;
  82053. /**
  82054. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  82055. */
  82056. static readonly ALPHA_REVERSEONEMINUS: number;
  82057. /**
  82058. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  82059. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  82060. */
  82061. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  82062. /**
  82063. * Defines that alpha blending is SRC + DST
  82064. * Alpha will be set to SRC ALPHA
  82065. */
  82066. static readonly ALPHA_ONEONE_ONEZERO: number;
  82067. /**
  82068. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  82069. * Alpha will be set to DST ALPHA
  82070. */
  82071. static readonly ALPHA_EXCLUSION: number;
  82072. /** Defines that alpha blending equation a SUM */
  82073. static readonly ALPHA_EQUATION_ADD: number;
  82074. /** Defines that alpha blending equation a SUBSTRACTION */
  82075. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  82076. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  82077. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  82078. /** Defines that alpha blending equation a MAX operation */
  82079. static readonly ALPHA_EQUATION_MAX: number;
  82080. /** Defines that alpha blending equation a MIN operation */
  82081. static readonly ALPHA_EQUATION_MIN: number;
  82082. /**
  82083. * Defines that alpha blending equation a DARKEN operation:
  82084. * It takes the min of the src and sums the alpha channels.
  82085. */
  82086. static readonly ALPHA_EQUATION_DARKEN: number;
  82087. /** Defines that the ressource is not delayed*/
  82088. static readonly DELAYLOADSTATE_NONE: number;
  82089. /** Defines that the ressource was successfully delay loaded */
  82090. static readonly DELAYLOADSTATE_LOADED: number;
  82091. /** Defines that the ressource is currently delay loading */
  82092. static readonly DELAYLOADSTATE_LOADING: number;
  82093. /** Defines that the ressource is delayed and has not started loading */
  82094. static readonly DELAYLOADSTATE_NOTLOADED: number;
  82095. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  82096. static readonly NEVER: number;
  82097. /** 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 */
  82098. static readonly ALWAYS: number;
  82099. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  82100. static readonly LESS: number;
  82101. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  82102. static readonly EQUAL: number;
  82103. /** 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 */
  82104. static readonly LEQUAL: number;
  82105. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  82106. static readonly GREATER: number;
  82107. /** 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 */
  82108. static readonly GEQUAL: number;
  82109. /** 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 */
  82110. static readonly NOTEQUAL: number;
  82111. /** Passed to stencilOperation to specify that stencil value must be kept */
  82112. static readonly KEEP: number;
  82113. /** Passed to stencilOperation to specify that stencil value must be replaced */
  82114. static readonly REPLACE: number;
  82115. /** Passed to stencilOperation to specify that stencil value must be incremented */
  82116. static readonly INCR: number;
  82117. /** Passed to stencilOperation to specify that stencil value must be decremented */
  82118. static readonly DECR: number;
  82119. /** Passed to stencilOperation to specify that stencil value must be inverted */
  82120. static readonly INVERT: number;
  82121. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  82122. static readonly INCR_WRAP: number;
  82123. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  82124. static readonly DECR_WRAP: number;
  82125. /** Texture is not repeating outside of 0..1 UVs */
  82126. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  82127. /** Texture is repeating outside of 0..1 UVs */
  82128. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  82129. /** Texture is repeating and mirrored */
  82130. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  82131. /** ALPHA */
  82132. static readonly TEXTUREFORMAT_ALPHA: number;
  82133. /** LUMINANCE */
  82134. static readonly TEXTUREFORMAT_LUMINANCE: number;
  82135. /** LUMINANCE_ALPHA */
  82136. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  82137. /** RGB */
  82138. static readonly TEXTUREFORMAT_RGB: number;
  82139. /** RGBA */
  82140. static readonly TEXTUREFORMAT_RGBA: number;
  82141. /** RED */
  82142. static readonly TEXTUREFORMAT_RED: number;
  82143. /** RED (2nd reference) */
  82144. static readonly TEXTUREFORMAT_R: number;
  82145. /** RG */
  82146. static readonly TEXTUREFORMAT_RG: number;
  82147. /** RED_INTEGER */
  82148. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  82149. /** RED_INTEGER (2nd reference) */
  82150. static readonly TEXTUREFORMAT_R_INTEGER: number;
  82151. /** RG_INTEGER */
  82152. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  82153. /** RGB_INTEGER */
  82154. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  82155. /** RGBA_INTEGER */
  82156. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  82157. /** UNSIGNED_BYTE */
  82158. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  82159. /** UNSIGNED_BYTE (2nd reference) */
  82160. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  82161. /** FLOAT */
  82162. static readonly TEXTURETYPE_FLOAT: number;
  82163. /** HALF_FLOAT */
  82164. static readonly TEXTURETYPE_HALF_FLOAT: number;
  82165. /** BYTE */
  82166. static readonly TEXTURETYPE_BYTE: number;
  82167. /** SHORT */
  82168. static readonly TEXTURETYPE_SHORT: number;
  82169. /** UNSIGNED_SHORT */
  82170. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  82171. /** INT */
  82172. static readonly TEXTURETYPE_INT: number;
  82173. /** UNSIGNED_INT */
  82174. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  82175. /** UNSIGNED_SHORT_4_4_4_4 */
  82176. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  82177. /** UNSIGNED_SHORT_5_5_5_1 */
  82178. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  82179. /** UNSIGNED_SHORT_5_6_5 */
  82180. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  82181. /** UNSIGNED_INT_2_10_10_10_REV */
  82182. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  82183. /** UNSIGNED_INT_24_8 */
  82184. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  82185. /** UNSIGNED_INT_10F_11F_11F_REV */
  82186. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  82187. /** UNSIGNED_INT_5_9_9_9_REV */
  82188. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  82189. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  82190. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  82191. /** nearest is mag = nearest and min = nearest and no mip */
  82192. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  82193. /** mag = nearest and min = nearest and mip = none */
  82194. static readonly TEXTURE_NEAREST_NEAREST: number;
  82195. /** Bilinear is mag = linear and min = linear and no mip */
  82196. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  82197. /** mag = linear and min = linear and mip = none */
  82198. static readonly TEXTURE_LINEAR_LINEAR: number;
  82199. /** Trilinear is mag = linear and min = linear and mip = linear */
  82200. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  82201. /** Trilinear is mag = linear and min = linear and mip = linear */
  82202. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  82203. /** mag = nearest and min = nearest and mip = nearest */
  82204. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  82205. /** mag = nearest and min = linear and mip = nearest */
  82206. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  82207. /** mag = nearest and min = linear and mip = linear */
  82208. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  82209. /** mag = nearest and min = linear and mip = none */
  82210. static readonly TEXTURE_NEAREST_LINEAR: number;
  82211. /** nearest is mag = nearest and min = nearest and mip = linear */
  82212. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  82213. /** mag = linear and min = nearest and mip = nearest */
  82214. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  82215. /** mag = linear and min = nearest and mip = linear */
  82216. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  82217. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82218. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  82219. /** mag = linear and min = nearest and mip = none */
  82220. static readonly TEXTURE_LINEAR_NEAREST: number;
  82221. /** Explicit coordinates mode */
  82222. static readonly TEXTURE_EXPLICIT_MODE: number;
  82223. /** Spherical coordinates mode */
  82224. static readonly TEXTURE_SPHERICAL_MODE: number;
  82225. /** Planar coordinates mode */
  82226. static readonly TEXTURE_PLANAR_MODE: number;
  82227. /** Cubic coordinates mode */
  82228. static readonly TEXTURE_CUBIC_MODE: number;
  82229. /** Projection coordinates mode */
  82230. static readonly TEXTURE_PROJECTION_MODE: number;
  82231. /** Skybox coordinates mode */
  82232. static readonly TEXTURE_SKYBOX_MODE: number;
  82233. /** Inverse Cubic coordinates mode */
  82234. static readonly TEXTURE_INVCUBIC_MODE: number;
  82235. /** Equirectangular coordinates mode */
  82236. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  82237. /** Equirectangular Fixed coordinates mode */
  82238. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  82239. /** Equirectangular Fixed Mirrored coordinates mode */
  82240. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82241. /** Offline (baking) quality for texture filtering */
  82242. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  82243. /** High quality for texture filtering */
  82244. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  82245. /** Medium quality for texture filtering */
  82246. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  82247. /** Low quality for texture filtering */
  82248. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  82249. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  82250. static readonly SCALEMODE_FLOOR: number;
  82251. /** Defines that texture rescaling will look for the nearest power of 2 size */
  82252. static readonly SCALEMODE_NEAREST: number;
  82253. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  82254. static readonly SCALEMODE_CEILING: number;
  82255. /**
  82256. * The dirty texture flag value
  82257. */
  82258. static readonly MATERIAL_TextureDirtyFlag: number;
  82259. /**
  82260. * The dirty light flag value
  82261. */
  82262. static readonly MATERIAL_LightDirtyFlag: number;
  82263. /**
  82264. * The dirty fresnel flag value
  82265. */
  82266. static readonly MATERIAL_FresnelDirtyFlag: number;
  82267. /**
  82268. * The dirty attribute flag value
  82269. */
  82270. static readonly MATERIAL_AttributesDirtyFlag: number;
  82271. /**
  82272. * The dirty misc flag value
  82273. */
  82274. static readonly MATERIAL_MiscDirtyFlag: number;
  82275. /**
  82276. * The dirty prepass flag value
  82277. */
  82278. static readonly MATERIAL_PrePassDirtyFlag: number;
  82279. /**
  82280. * The all dirty flag value
  82281. */
  82282. static readonly MATERIAL_AllDirtyFlag: number;
  82283. /**
  82284. * Returns the triangle fill mode
  82285. */
  82286. static readonly MATERIAL_TriangleFillMode: number;
  82287. /**
  82288. * Returns the wireframe mode
  82289. */
  82290. static readonly MATERIAL_WireFrameFillMode: number;
  82291. /**
  82292. * Returns the point fill mode
  82293. */
  82294. static readonly MATERIAL_PointFillMode: number;
  82295. /**
  82296. * Returns the point list draw mode
  82297. */
  82298. static readonly MATERIAL_PointListDrawMode: number;
  82299. /**
  82300. * Returns the line list draw mode
  82301. */
  82302. static readonly MATERIAL_LineListDrawMode: number;
  82303. /**
  82304. * Returns the line loop draw mode
  82305. */
  82306. static readonly MATERIAL_LineLoopDrawMode: number;
  82307. /**
  82308. * Returns the line strip draw mode
  82309. */
  82310. static readonly MATERIAL_LineStripDrawMode: number;
  82311. /**
  82312. * Returns the triangle strip draw mode
  82313. */
  82314. static readonly MATERIAL_TriangleStripDrawMode: number;
  82315. /**
  82316. * Returns the triangle fan draw mode
  82317. */
  82318. static readonly MATERIAL_TriangleFanDrawMode: number;
  82319. /**
  82320. * Stores the clock-wise side orientation
  82321. */
  82322. static readonly MATERIAL_ClockWiseSideOrientation: number;
  82323. /**
  82324. * Stores the counter clock-wise side orientation
  82325. */
  82326. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  82327. /**
  82328. * Nothing
  82329. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82330. */
  82331. static readonly ACTION_NothingTrigger: number;
  82332. /**
  82333. * On pick
  82334. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82335. */
  82336. static readonly ACTION_OnPickTrigger: number;
  82337. /**
  82338. * On left pick
  82339. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82340. */
  82341. static readonly ACTION_OnLeftPickTrigger: number;
  82342. /**
  82343. * On right pick
  82344. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82345. */
  82346. static readonly ACTION_OnRightPickTrigger: number;
  82347. /**
  82348. * On center pick
  82349. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82350. */
  82351. static readonly ACTION_OnCenterPickTrigger: number;
  82352. /**
  82353. * On pick down
  82354. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82355. */
  82356. static readonly ACTION_OnPickDownTrigger: number;
  82357. /**
  82358. * On double pick
  82359. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82360. */
  82361. static readonly ACTION_OnDoublePickTrigger: number;
  82362. /**
  82363. * On pick up
  82364. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82365. */
  82366. static readonly ACTION_OnPickUpTrigger: number;
  82367. /**
  82368. * On pick out.
  82369. * This trigger will only be raised if you also declared a OnPickDown
  82370. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82371. */
  82372. static readonly ACTION_OnPickOutTrigger: number;
  82373. /**
  82374. * On long press
  82375. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82376. */
  82377. static readonly ACTION_OnLongPressTrigger: number;
  82378. /**
  82379. * On pointer over
  82380. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82381. */
  82382. static readonly ACTION_OnPointerOverTrigger: number;
  82383. /**
  82384. * On pointer out
  82385. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82386. */
  82387. static readonly ACTION_OnPointerOutTrigger: number;
  82388. /**
  82389. * On every frame
  82390. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82391. */
  82392. static readonly ACTION_OnEveryFrameTrigger: number;
  82393. /**
  82394. * On intersection enter
  82395. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82396. */
  82397. static readonly ACTION_OnIntersectionEnterTrigger: number;
  82398. /**
  82399. * On intersection exit
  82400. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82401. */
  82402. static readonly ACTION_OnIntersectionExitTrigger: number;
  82403. /**
  82404. * On key down
  82405. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82406. */
  82407. static readonly ACTION_OnKeyDownTrigger: number;
  82408. /**
  82409. * On key up
  82410. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82411. */
  82412. static readonly ACTION_OnKeyUpTrigger: number;
  82413. /**
  82414. * Billboard mode will only apply to Y axis
  82415. */
  82416. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  82417. /**
  82418. * Billboard mode will apply to all axes
  82419. */
  82420. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  82421. /**
  82422. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82423. */
  82424. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  82425. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  82426. * Test order :
  82427. * Is the bounding sphere outside the frustum ?
  82428. * If not, are the bounding box vertices outside the frustum ?
  82429. * It not, then the cullable object is in the frustum.
  82430. */
  82431. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  82432. /** Culling strategy : Bounding Sphere Only.
  82433. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  82434. * It's also less accurate than the standard because some not visible objects can still be selected.
  82435. * Test : is the bounding sphere outside the frustum ?
  82436. * If not, then the cullable object is in the frustum.
  82437. */
  82438. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  82439. /** Culling strategy : Optimistic Inclusion.
  82440. * This in an inclusion test first, then the standard exclusion test.
  82441. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  82442. * 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.
  82443. * Anyway, it's as accurate as the standard strategy.
  82444. * Test :
  82445. * Is the cullable object bounding sphere center in the frustum ?
  82446. * If not, apply the default culling strategy.
  82447. */
  82448. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  82449. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  82450. * This in an inclusion test first, then the bounding sphere only exclusion test.
  82451. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  82452. * 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.
  82453. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  82454. * Test :
  82455. * Is the cullable object bounding sphere center in the frustum ?
  82456. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  82457. */
  82458. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  82459. /**
  82460. * No logging while loading
  82461. */
  82462. static readonly SCENELOADER_NO_LOGGING: number;
  82463. /**
  82464. * Minimal logging while loading
  82465. */
  82466. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  82467. /**
  82468. * Summary logging while loading
  82469. */
  82470. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  82471. /**
  82472. * Detailled logging while loading
  82473. */
  82474. static readonly SCENELOADER_DETAILED_LOGGING: number;
  82475. /**
  82476. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  82477. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  82478. */
  82479. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  82480. /**
  82481. * Constant used to retrieve the position texture index in the textures array in the prepass
  82482. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  82483. */
  82484. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  82485. /**
  82486. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  82487. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  82488. */
  82489. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  82490. /**
  82491. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  82492. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  82493. */
  82494. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  82495. /**
  82496. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  82497. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  82498. */
  82499. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  82500. /**
  82501. * Constant used to retrieve depth + normal index in the textures array in the prepass
  82502. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  82503. */
  82504. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  82505. /**
  82506. * Constant used to retrieve albedo index in the textures array in the prepass
  82507. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  82508. */
  82509. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  82510. }
  82511. }
  82512. declare module BABYLON {
  82513. /**
  82514. * This represents the required contract to create a new type of texture loader.
  82515. */
  82516. export interface IInternalTextureLoader {
  82517. /**
  82518. * Defines wether the loader supports cascade loading the different faces.
  82519. */
  82520. supportCascades: boolean;
  82521. /**
  82522. * This returns if the loader support the current file information.
  82523. * @param extension defines the file extension of the file being loaded
  82524. * @param mimeType defines the optional mime type of the file being loaded
  82525. * @returns true if the loader can load the specified file
  82526. */
  82527. canLoad(extension: string, mimeType?: string): boolean;
  82528. /**
  82529. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  82530. * @param data contains the texture data
  82531. * @param texture defines the BabylonJS internal texture
  82532. * @param createPolynomials will be true if polynomials have been requested
  82533. * @param onLoad defines the callback to trigger once the texture is ready
  82534. * @param onError defines the callback to trigger in case of error
  82535. * @param options options to be passed to the loader
  82536. */
  82537. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  82538. /**
  82539. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  82540. * @param data contains the texture data
  82541. * @param texture defines the BabylonJS internal texture
  82542. * @param callback defines the method to call once ready to upload
  82543. * @param options options to be passed to the loader
  82544. */
  82545. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  82546. }
  82547. }
  82548. declare module BABYLON {
  82549. /**
  82550. * Class used to store and describe the pipeline context associated with an effect
  82551. */
  82552. export interface IPipelineContext {
  82553. /**
  82554. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  82555. */
  82556. isAsync: boolean;
  82557. /**
  82558. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  82559. */
  82560. isReady: boolean;
  82561. /** @hidden */
  82562. _getVertexShaderCode(): string | null;
  82563. /** @hidden */
  82564. _getFragmentShaderCode(): string | null;
  82565. /** @hidden */
  82566. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  82567. }
  82568. }
  82569. declare module BABYLON {
  82570. /**
  82571. * Class used to store gfx data (like WebGLBuffer)
  82572. */
  82573. export class DataBuffer {
  82574. /**
  82575. * Gets or sets the number of objects referencing this buffer
  82576. */
  82577. references: number;
  82578. /** Gets or sets the size of the underlying buffer */
  82579. capacity: number;
  82580. /**
  82581. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  82582. */
  82583. is32Bits: boolean;
  82584. /**
  82585. * Gets the underlying buffer
  82586. */
  82587. get underlyingResource(): any;
  82588. }
  82589. }
  82590. declare module BABYLON {
  82591. /** @hidden */
  82592. export interface IShaderProcessor {
  82593. attributeProcessor?: (attribute: string) => string;
  82594. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  82595. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  82596. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  82597. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  82598. lineProcessor?: (line: string, isFragment: boolean) => string;
  82599. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  82600. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  82601. }
  82602. }
  82603. declare module BABYLON {
  82604. /** @hidden */
  82605. export interface ProcessingOptions {
  82606. defines: string[];
  82607. indexParameters: any;
  82608. isFragment: boolean;
  82609. shouldUseHighPrecisionShader: boolean;
  82610. supportsUniformBuffers: boolean;
  82611. shadersRepository: string;
  82612. includesShadersStore: {
  82613. [key: string]: string;
  82614. };
  82615. processor?: IShaderProcessor;
  82616. version: string;
  82617. platformName: string;
  82618. lookForClosingBracketForUniformBuffer?: boolean;
  82619. }
  82620. }
  82621. declare module BABYLON {
  82622. /** @hidden */
  82623. export class ShaderCodeNode {
  82624. line: string;
  82625. children: ShaderCodeNode[];
  82626. additionalDefineKey?: string;
  82627. additionalDefineValue?: string;
  82628. isValid(preprocessors: {
  82629. [key: string]: string;
  82630. }): boolean;
  82631. process(preprocessors: {
  82632. [key: string]: string;
  82633. }, options: ProcessingOptions): string;
  82634. }
  82635. }
  82636. declare module BABYLON {
  82637. /** @hidden */
  82638. export class ShaderCodeCursor {
  82639. private _lines;
  82640. lineIndex: number;
  82641. get currentLine(): string;
  82642. get canRead(): boolean;
  82643. set lines(value: string[]);
  82644. }
  82645. }
  82646. declare module BABYLON {
  82647. /** @hidden */
  82648. export class ShaderCodeConditionNode extends ShaderCodeNode {
  82649. process(preprocessors: {
  82650. [key: string]: string;
  82651. }, options: ProcessingOptions): string;
  82652. }
  82653. }
  82654. declare module BABYLON {
  82655. /** @hidden */
  82656. export class ShaderDefineExpression {
  82657. isTrue(preprocessors: {
  82658. [key: string]: string;
  82659. }): boolean;
  82660. private static _OperatorPriority;
  82661. private static _Stack;
  82662. static postfixToInfix(postfix: string[]): string;
  82663. static infixToPostfix(infix: string): string[];
  82664. }
  82665. }
  82666. declare module BABYLON {
  82667. /** @hidden */
  82668. export class ShaderCodeTestNode extends ShaderCodeNode {
  82669. testExpression: ShaderDefineExpression;
  82670. isValid(preprocessors: {
  82671. [key: string]: string;
  82672. }): boolean;
  82673. }
  82674. }
  82675. declare module BABYLON {
  82676. /** @hidden */
  82677. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  82678. define: string;
  82679. not: boolean;
  82680. constructor(define: string, not?: boolean);
  82681. isTrue(preprocessors: {
  82682. [key: string]: string;
  82683. }): boolean;
  82684. }
  82685. }
  82686. declare module BABYLON {
  82687. /** @hidden */
  82688. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  82689. leftOperand: ShaderDefineExpression;
  82690. rightOperand: ShaderDefineExpression;
  82691. isTrue(preprocessors: {
  82692. [key: string]: string;
  82693. }): boolean;
  82694. }
  82695. }
  82696. declare module BABYLON {
  82697. /** @hidden */
  82698. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  82699. leftOperand: ShaderDefineExpression;
  82700. rightOperand: ShaderDefineExpression;
  82701. isTrue(preprocessors: {
  82702. [key: string]: string;
  82703. }): boolean;
  82704. }
  82705. }
  82706. declare module BABYLON {
  82707. /** @hidden */
  82708. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  82709. define: string;
  82710. operand: string;
  82711. testValue: string;
  82712. constructor(define: string, operand: string, testValue: string);
  82713. isTrue(preprocessors: {
  82714. [key: string]: string;
  82715. }): boolean;
  82716. }
  82717. }
  82718. declare module BABYLON {
  82719. /**
  82720. * Class used to enable access to offline support
  82721. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  82722. */
  82723. export interface IOfflineProvider {
  82724. /**
  82725. * Gets a boolean indicating if scene must be saved in the database
  82726. */
  82727. enableSceneOffline: boolean;
  82728. /**
  82729. * Gets a boolean indicating if textures must be saved in the database
  82730. */
  82731. enableTexturesOffline: boolean;
  82732. /**
  82733. * Open the offline support and make it available
  82734. * @param successCallback defines the callback to call on success
  82735. * @param errorCallback defines the callback to call on error
  82736. */
  82737. open(successCallback: () => void, errorCallback: () => void): void;
  82738. /**
  82739. * Loads an image from the offline support
  82740. * @param url defines the url to load from
  82741. * @param image defines the target DOM image
  82742. */
  82743. loadImage(url: string, image: HTMLImageElement): void;
  82744. /**
  82745. * Loads a file from offline support
  82746. * @param url defines the URL to load from
  82747. * @param sceneLoaded defines a callback to call on success
  82748. * @param progressCallBack defines a callback to call when progress changed
  82749. * @param errorCallback defines a callback to call on error
  82750. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  82751. */
  82752. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  82753. }
  82754. }
  82755. declare module BABYLON {
  82756. /**
  82757. * Class used to help managing file picking and drag'n'drop
  82758. * File Storage
  82759. */
  82760. export class FilesInputStore {
  82761. /**
  82762. * List of files ready to be loaded
  82763. */
  82764. static FilesToLoad: {
  82765. [key: string]: File;
  82766. };
  82767. }
  82768. }
  82769. declare module BABYLON {
  82770. /**
  82771. * Class used to define a retry strategy when error happens while loading assets
  82772. */
  82773. export class RetryStrategy {
  82774. /**
  82775. * Function used to defines an exponential back off strategy
  82776. * @param maxRetries defines the maximum number of retries (3 by default)
  82777. * @param baseInterval defines the interval between retries
  82778. * @returns the strategy function to use
  82779. */
  82780. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  82781. }
  82782. }
  82783. declare module BABYLON {
  82784. /**
  82785. * @ignore
  82786. * Application error to support additional information when loading a file
  82787. */
  82788. export abstract class BaseError extends Error {
  82789. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  82790. }
  82791. }
  82792. declare module BABYLON {
  82793. /** @ignore */
  82794. export class LoadFileError extends BaseError {
  82795. request?: WebRequest;
  82796. file?: File;
  82797. /**
  82798. * Creates a new LoadFileError
  82799. * @param message defines the message of the error
  82800. * @param request defines the optional web request
  82801. * @param file defines the optional file
  82802. */
  82803. constructor(message: string, object?: WebRequest | File);
  82804. }
  82805. /** @ignore */
  82806. export class RequestFileError extends BaseError {
  82807. request: WebRequest;
  82808. /**
  82809. * Creates a new LoadFileError
  82810. * @param message defines the message of the error
  82811. * @param request defines the optional web request
  82812. */
  82813. constructor(message: string, request: WebRequest);
  82814. }
  82815. /** @ignore */
  82816. export class ReadFileError extends BaseError {
  82817. file: File;
  82818. /**
  82819. * Creates a new ReadFileError
  82820. * @param message defines the message of the error
  82821. * @param file defines the optional file
  82822. */
  82823. constructor(message: string, file: File);
  82824. }
  82825. /**
  82826. * @hidden
  82827. */
  82828. export class FileTools {
  82829. /**
  82830. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  82831. */
  82832. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  82833. /**
  82834. * Gets or sets the base URL to use to load assets
  82835. */
  82836. static BaseUrl: string;
  82837. /**
  82838. * Default behaviour for cors in the application.
  82839. * It can be a string if the expected behavior is identical in the entire app.
  82840. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  82841. */
  82842. static CorsBehavior: string | ((url: string | string[]) => string);
  82843. /**
  82844. * Gets or sets a function used to pre-process url before using them to load assets
  82845. */
  82846. static PreprocessUrl: (url: string) => string;
  82847. /**
  82848. * Removes unwanted characters from an url
  82849. * @param url defines the url to clean
  82850. * @returns the cleaned url
  82851. */
  82852. private static _CleanUrl;
  82853. /**
  82854. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  82855. * @param url define the url we are trying
  82856. * @param element define the dom element where to configure the cors policy
  82857. */
  82858. static SetCorsBehavior(url: string | string[], element: {
  82859. crossOrigin: string | null;
  82860. }): void;
  82861. /**
  82862. * Loads an image as an HTMLImageElement.
  82863. * @param input url string, ArrayBuffer, or Blob to load
  82864. * @param onLoad callback called when the image successfully loads
  82865. * @param onError callback called when the image fails to load
  82866. * @param offlineProvider offline provider for caching
  82867. * @param mimeType optional mime type
  82868. * @returns the HTMLImageElement of the loaded image
  82869. */
  82870. 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>;
  82871. /**
  82872. * Reads a file from a File object
  82873. * @param file defines the file to load
  82874. * @param onSuccess defines the callback to call when data is loaded
  82875. * @param onProgress defines the callback to call during loading process
  82876. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  82877. * @param onError defines the callback to call when an error occurs
  82878. * @returns a file request object
  82879. */
  82880. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  82881. /**
  82882. * Loads a file from a url
  82883. * @param url url to load
  82884. * @param onSuccess callback called when the file successfully loads
  82885. * @param onProgress callback called while file is loading (if the server supports this mode)
  82886. * @param offlineProvider defines the offline provider for caching
  82887. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82888. * @param onError callback called when the file fails to load
  82889. * @returns a file request object
  82890. */
  82891. 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;
  82892. /**
  82893. * Loads a file
  82894. * @param url url to load
  82895. * @param onSuccess callback called when the file successfully loads
  82896. * @param onProgress callback called while file is loading (if the server supports this mode)
  82897. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82898. * @param onError callback called when the file fails to load
  82899. * @param onOpened callback called when the web request is opened
  82900. * @returns a file request object
  82901. */
  82902. 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;
  82903. /**
  82904. * Checks if the loaded document was accessed via `file:`-Protocol.
  82905. * @returns boolean
  82906. */
  82907. static IsFileURL(): boolean;
  82908. }
  82909. }
  82910. declare module BABYLON {
  82911. /** @hidden */
  82912. export class ShaderProcessor {
  82913. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  82914. private static _ProcessPrecision;
  82915. private static _ExtractOperation;
  82916. private static _BuildSubExpression;
  82917. private static _BuildExpression;
  82918. private static _MoveCursorWithinIf;
  82919. private static _MoveCursor;
  82920. private static _EvaluatePreProcessors;
  82921. private static _PreparePreProcessors;
  82922. private static _ProcessShaderConversion;
  82923. private static _ProcessIncludes;
  82924. /**
  82925. * Loads a file from a url
  82926. * @param url url to load
  82927. * @param onSuccess callback called when the file successfully loads
  82928. * @param onProgress callback called while file is loading (if the server supports this mode)
  82929. * @param offlineProvider defines the offline provider for caching
  82930. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82931. * @param onError callback called when the file fails to load
  82932. * @returns a file request object
  82933. * @hidden
  82934. */
  82935. 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;
  82936. }
  82937. }
  82938. declare module BABYLON {
  82939. /**
  82940. * @hidden
  82941. */
  82942. export interface IColor4Like {
  82943. r: float;
  82944. g: float;
  82945. b: float;
  82946. a: float;
  82947. }
  82948. /**
  82949. * @hidden
  82950. */
  82951. export interface IColor3Like {
  82952. r: float;
  82953. g: float;
  82954. b: float;
  82955. }
  82956. /**
  82957. * @hidden
  82958. */
  82959. export interface IVector4Like {
  82960. x: float;
  82961. y: float;
  82962. z: float;
  82963. w: float;
  82964. }
  82965. /**
  82966. * @hidden
  82967. */
  82968. export interface IVector3Like {
  82969. x: float;
  82970. y: float;
  82971. z: float;
  82972. }
  82973. /**
  82974. * @hidden
  82975. */
  82976. export interface IVector2Like {
  82977. x: float;
  82978. y: float;
  82979. }
  82980. /**
  82981. * @hidden
  82982. */
  82983. export interface IMatrixLike {
  82984. toArray(): DeepImmutable<Float32Array | Array<number>>;
  82985. updateFlag: int;
  82986. }
  82987. /**
  82988. * @hidden
  82989. */
  82990. export interface IViewportLike {
  82991. x: float;
  82992. y: float;
  82993. width: float;
  82994. height: float;
  82995. }
  82996. /**
  82997. * @hidden
  82998. */
  82999. export interface IPlaneLike {
  83000. normal: IVector3Like;
  83001. d: float;
  83002. normalize(): void;
  83003. }
  83004. }
  83005. declare module BABYLON {
  83006. /**
  83007. * Interface used to define common properties for effect fallbacks
  83008. */
  83009. export interface IEffectFallbacks {
  83010. /**
  83011. * Removes the defines that should be removed when falling back.
  83012. * @param currentDefines defines the current define statements for the shader.
  83013. * @param effect defines the current effect we try to compile
  83014. * @returns The resulting defines with defines of the current rank removed.
  83015. */
  83016. reduce(currentDefines: string, effect: Effect): string;
  83017. /**
  83018. * Removes the fallback from the bound mesh.
  83019. */
  83020. unBindMesh(): void;
  83021. /**
  83022. * Checks to see if more fallbacks are still availible.
  83023. */
  83024. hasMoreFallbacks: boolean;
  83025. }
  83026. }
  83027. declare module BABYLON {
  83028. /**
  83029. * Interface for the size containing width and height
  83030. */
  83031. export interface ISize {
  83032. /**
  83033. * Width
  83034. */
  83035. width: number;
  83036. /**
  83037. * Heighht
  83038. */
  83039. height: number;
  83040. }
  83041. /**
  83042. * Size containing widht and height
  83043. */
  83044. export class Size implements ISize {
  83045. /**
  83046. * Width
  83047. */
  83048. width: number;
  83049. /**
  83050. * Height
  83051. */
  83052. height: number;
  83053. /**
  83054. * Creates a Size object from the given width and height (floats).
  83055. * @param width width of the new size
  83056. * @param height height of the new size
  83057. */
  83058. constructor(width: number, height: number);
  83059. /**
  83060. * Returns a string with the Size width and height
  83061. * @returns a string with the Size width and height
  83062. */
  83063. toString(): string;
  83064. /**
  83065. * "Size"
  83066. * @returns the string "Size"
  83067. */
  83068. getClassName(): string;
  83069. /**
  83070. * Returns the Size hash code.
  83071. * @returns a hash code for a unique width and height
  83072. */
  83073. getHashCode(): number;
  83074. /**
  83075. * Updates the current size from the given one.
  83076. * @param src the given size
  83077. */
  83078. copyFrom(src: Size): void;
  83079. /**
  83080. * Updates in place the current Size from the given floats.
  83081. * @param width width of the new size
  83082. * @param height height of the new size
  83083. * @returns the updated Size.
  83084. */
  83085. copyFromFloats(width: number, height: number): Size;
  83086. /**
  83087. * Updates in place the current Size from the given floats.
  83088. * @param width width to set
  83089. * @param height height to set
  83090. * @returns the updated Size.
  83091. */
  83092. set(width: number, height: number): Size;
  83093. /**
  83094. * Multiplies the width and height by numbers
  83095. * @param w factor to multiple the width by
  83096. * @param h factor to multiple the height by
  83097. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83098. */
  83099. multiplyByFloats(w: number, h: number): Size;
  83100. /**
  83101. * Clones the size
  83102. * @returns a new Size copied from the given one.
  83103. */
  83104. clone(): Size;
  83105. /**
  83106. * True if the current Size and the given one width and height are strictly equal.
  83107. * @param other the other size to compare against
  83108. * @returns True if the current Size and the given one width and height are strictly equal.
  83109. */
  83110. equals(other: Size): boolean;
  83111. /**
  83112. * The surface of the Size : width * height (float).
  83113. */
  83114. get surface(): number;
  83115. /**
  83116. * Create a new size of zero
  83117. * @returns a new Size set to (0.0, 0.0)
  83118. */
  83119. static Zero(): Size;
  83120. /**
  83121. * Sums the width and height of two sizes
  83122. * @param otherSize size to add to this size
  83123. * @returns a new Size set as the addition result of the current Size and the given one.
  83124. */
  83125. add(otherSize: Size): Size;
  83126. /**
  83127. * Subtracts the width and height of two
  83128. * @param otherSize size to subtract to this size
  83129. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83130. */
  83131. subtract(otherSize: Size): Size;
  83132. /**
  83133. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83134. * @param start starting size to lerp between
  83135. * @param end end size to lerp between
  83136. * @param amount amount to lerp between the start and end values
  83137. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83138. */
  83139. static Lerp(start: Size, end: Size, amount: number): Size;
  83140. }
  83141. }
  83142. declare module BABYLON {
  83143. /**
  83144. * Base class of all the textures in babylon.
  83145. * It groups all the common properties required to work with Thin Engine.
  83146. */
  83147. export class ThinTexture {
  83148. protected _wrapU: number;
  83149. /**
  83150. * | Value | Type | Description |
  83151. * | ----- | ------------------ | ----------- |
  83152. * | 0 | CLAMP_ADDRESSMODE | |
  83153. * | 1 | WRAP_ADDRESSMODE | |
  83154. * | 2 | MIRROR_ADDRESSMODE | |
  83155. */
  83156. get wrapU(): number;
  83157. set wrapU(value: number);
  83158. protected _wrapV: number;
  83159. /**
  83160. * | Value | Type | Description |
  83161. * | ----- | ------------------ | ----------- |
  83162. * | 0 | CLAMP_ADDRESSMODE | |
  83163. * | 1 | WRAP_ADDRESSMODE | |
  83164. * | 2 | MIRROR_ADDRESSMODE | |
  83165. */
  83166. get wrapV(): number;
  83167. set wrapV(value: number);
  83168. /**
  83169. * | Value | Type | Description |
  83170. * | ----- | ------------------ | ----------- |
  83171. * | 0 | CLAMP_ADDRESSMODE | |
  83172. * | 1 | WRAP_ADDRESSMODE | |
  83173. * | 2 | MIRROR_ADDRESSMODE | |
  83174. */
  83175. wrapR: number;
  83176. /**
  83177. * With compliant hardware and browser (supporting anisotropic filtering)
  83178. * this defines the level of anisotropic filtering in the texture.
  83179. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  83180. */
  83181. anisotropicFilteringLevel: number;
  83182. /**
  83183. * Define the current state of the loading sequence when in delayed load mode.
  83184. */
  83185. delayLoadState: number;
  83186. /**
  83187. * How a texture is mapped.
  83188. * Unused in thin texture mode.
  83189. */
  83190. get coordinatesMode(): number;
  83191. /**
  83192. * Define if the texture is a cube texture or if false a 2d texture.
  83193. */
  83194. get isCube(): boolean;
  83195. set isCube(value: boolean);
  83196. /**
  83197. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  83198. */
  83199. get is3D(): boolean;
  83200. set is3D(value: boolean);
  83201. /**
  83202. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  83203. */
  83204. get is2DArray(): boolean;
  83205. set is2DArray(value: boolean);
  83206. /**
  83207. * Get the class name of the texture.
  83208. * @returns "ThinTexture"
  83209. */
  83210. getClassName(): string;
  83211. /** @hidden */
  83212. _texture: Nullable<InternalTexture>;
  83213. protected _engine: Nullable<ThinEngine>;
  83214. private _cachedSize;
  83215. private _cachedBaseSize;
  83216. /**
  83217. * Instantiates a new ThinTexture.
  83218. * Base class of all the textures in babylon.
  83219. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  83220. * @param internalTexture Define the internalTexture to wrap
  83221. */
  83222. constructor(internalTexture: Nullable<InternalTexture>);
  83223. /**
  83224. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  83225. * @returns true if fully ready
  83226. */
  83227. isReady(): boolean;
  83228. /**
  83229. * Triggers the load sequence in delayed load mode.
  83230. */
  83231. delayLoad(): void;
  83232. /**
  83233. * Get the underlying lower level texture from Babylon.
  83234. * @returns the insternal texture
  83235. */
  83236. getInternalTexture(): Nullable<InternalTexture>;
  83237. /**
  83238. * Get the size of the texture.
  83239. * @returns the texture size.
  83240. */
  83241. getSize(): ISize;
  83242. /**
  83243. * Get the base size of the texture.
  83244. * It can be different from the size if the texture has been resized for POT for instance
  83245. * @returns the base size
  83246. */
  83247. getBaseSize(): ISize;
  83248. /**
  83249. * Update the sampling mode of the texture.
  83250. * Default is Trilinear mode.
  83251. *
  83252. * | Value | Type | Description |
  83253. * | ----- | ------------------ | ----------- |
  83254. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  83255. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  83256. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  83257. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  83258. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  83259. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  83260. * | 7 | NEAREST_LINEAR | |
  83261. * | 8 | NEAREST_NEAREST | |
  83262. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  83263. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  83264. * | 11 | LINEAR_LINEAR | |
  83265. * | 12 | LINEAR_NEAREST | |
  83266. *
  83267. * > _mag_: magnification filter (close to the viewer)
  83268. * > _min_: minification filter (far from the viewer)
  83269. * > _mip_: filter used between mip map levels
  83270. *@param samplingMode Define the new sampling mode of the texture
  83271. */
  83272. updateSamplingMode(samplingMode: number): void;
  83273. /**
  83274. * Release and destroy the underlying lower level texture aka internalTexture.
  83275. */
  83276. releaseInternalTexture(): void;
  83277. /**
  83278. * Dispose the texture and release its associated resources.
  83279. */
  83280. dispose(): void;
  83281. }
  83282. }
  83283. declare module BABYLON {
  83284. /**
  83285. * Defines an array and its length.
  83286. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  83287. */
  83288. export interface ISmartArrayLike<T> {
  83289. /**
  83290. * The data of the array.
  83291. */
  83292. data: Array<T>;
  83293. /**
  83294. * The active length of the array.
  83295. */
  83296. length: number;
  83297. }
  83298. /**
  83299. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83300. */
  83301. export class SmartArray<T> implements ISmartArrayLike<T> {
  83302. /**
  83303. * The full set of data from the array.
  83304. */
  83305. data: Array<T>;
  83306. /**
  83307. * The active length of the array.
  83308. */
  83309. length: number;
  83310. protected _id: number;
  83311. /**
  83312. * Instantiates a Smart Array.
  83313. * @param capacity defines the default capacity of the array.
  83314. */
  83315. constructor(capacity: number);
  83316. /**
  83317. * Pushes a value at the end of the active data.
  83318. * @param value defines the object to push in the array.
  83319. */
  83320. push(value: T): void;
  83321. /**
  83322. * Iterates over the active data and apply the lambda to them.
  83323. * @param func defines the action to apply on each value.
  83324. */
  83325. forEach(func: (content: T) => void): void;
  83326. /**
  83327. * Sorts the full sets of data.
  83328. * @param compareFn defines the comparison function to apply.
  83329. */
  83330. sort(compareFn: (a: T, b: T) => number): void;
  83331. /**
  83332. * Resets the active data to an empty array.
  83333. */
  83334. reset(): void;
  83335. /**
  83336. * Releases all the data from the array as well as the array.
  83337. */
  83338. dispose(): void;
  83339. /**
  83340. * Concats the active data with a given array.
  83341. * @param array defines the data to concatenate with.
  83342. */
  83343. concat(array: any): void;
  83344. /**
  83345. * Returns the position of a value in the active data.
  83346. * @param value defines the value to find the index for
  83347. * @returns the index if found in the active data otherwise -1
  83348. */
  83349. indexOf(value: T): number;
  83350. /**
  83351. * Returns whether an element is part of the active data.
  83352. * @param value defines the value to look for
  83353. * @returns true if found in the active data otherwise false
  83354. */
  83355. contains(value: T): boolean;
  83356. private static _GlobalId;
  83357. }
  83358. /**
  83359. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83360. * The data in this array can only be present once
  83361. */
  83362. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  83363. private _duplicateId;
  83364. /**
  83365. * Pushes a value at the end of the active data.
  83366. * THIS DOES NOT PREVENT DUPPLICATE DATA
  83367. * @param value defines the object to push in the array.
  83368. */
  83369. push(value: T): void;
  83370. /**
  83371. * Pushes a value at the end of the active data.
  83372. * If the data is already present, it won t be added again
  83373. * @param value defines the object to push in the array.
  83374. * @returns true if added false if it was already present
  83375. */
  83376. pushNoDuplicate(value: T): boolean;
  83377. /**
  83378. * Resets the active data to an empty array.
  83379. */
  83380. reset(): void;
  83381. /**
  83382. * Concats the active data with a given array.
  83383. * This ensures no dupplicate will be present in the result.
  83384. * @param array defines the data to concatenate with.
  83385. */
  83386. concatWithNoDuplicate(array: any): void;
  83387. }
  83388. }
  83389. declare module BABYLON {
  83390. /**
  83391. * Class used to evalaute queries containing `and` and `or` operators
  83392. */
  83393. export class AndOrNotEvaluator {
  83394. /**
  83395. * Evaluate a query
  83396. * @param query defines the query to evaluate
  83397. * @param evaluateCallback defines the callback used to filter result
  83398. * @returns true if the query matches
  83399. */
  83400. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  83401. private static _HandleParenthesisContent;
  83402. private static _SimplifyNegation;
  83403. }
  83404. }
  83405. declare module BABYLON {
  83406. /**
  83407. * Class used to store custom tags
  83408. */
  83409. export class Tags {
  83410. /**
  83411. * Adds support for tags on the given object
  83412. * @param obj defines the object to use
  83413. */
  83414. static EnableFor(obj: any): void;
  83415. /**
  83416. * Removes tags support
  83417. * @param obj defines the object to use
  83418. */
  83419. static DisableFor(obj: any): void;
  83420. /**
  83421. * Gets a boolean indicating if the given object has tags
  83422. * @param obj defines the object to use
  83423. * @returns a boolean
  83424. */
  83425. static HasTags(obj: any): boolean;
  83426. /**
  83427. * Gets the tags available on a given object
  83428. * @param obj defines the object to use
  83429. * @param asString defines if the tags must be returned as a string instead of an array of strings
  83430. * @returns the tags
  83431. */
  83432. static GetTags(obj: any, asString?: boolean): any;
  83433. /**
  83434. * Adds tags to an object
  83435. * @param obj defines the object to use
  83436. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  83437. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  83438. */
  83439. static AddTagsTo(obj: any, tagsString: string): void;
  83440. /**
  83441. * @hidden
  83442. */
  83443. static _AddTagTo(obj: any, tag: string): void;
  83444. /**
  83445. * Removes specific tags from a specific object
  83446. * @param obj defines the object to use
  83447. * @param tagsString defines the tags to remove
  83448. */
  83449. static RemoveTagsFrom(obj: any, tagsString: string): void;
  83450. /**
  83451. * @hidden
  83452. */
  83453. static _RemoveTagFrom(obj: any, tag: string): void;
  83454. /**
  83455. * Defines if tags hosted on an object match a given query
  83456. * @param obj defines the object to use
  83457. * @param tagsQuery defines the tag query
  83458. * @returns a boolean
  83459. */
  83460. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  83461. }
  83462. }
  83463. declare module BABYLON {
  83464. /**
  83465. * Scalar computation library
  83466. */
  83467. export class Scalar {
  83468. /**
  83469. * Two pi constants convenient for computation.
  83470. */
  83471. static TwoPi: number;
  83472. /**
  83473. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  83474. * @param a number
  83475. * @param b number
  83476. * @param epsilon (default = 1.401298E-45)
  83477. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  83478. */
  83479. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  83480. /**
  83481. * Returns a string : the upper case translation of the number i to hexadecimal.
  83482. * @param i number
  83483. * @returns the upper case translation of the number i to hexadecimal.
  83484. */
  83485. static ToHex(i: number): string;
  83486. /**
  83487. * Returns -1 if value is negative and +1 is value is positive.
  83488. * @param value the value
  83489. * @returns the value itself if it's equal to zero.
  83490. */
  83491. static Sign(value: number): number;
  83492. /**
  83493. * Returns the value itself if it's between min and max.
  83494. * Returns min if the value is lower than min.
  83495. * Returns max if the value is greater than max.
  83496. * @param value the value to clmap
  83497. * @param min the min value to clamp to (default: 0)
  83498. * @param max the max value to clamp to (default: 1)
  83499. * @returns the clamped value
  83500. */
  83501. static Clamp(value: number, min?: number, max?: number): number;
  83502. /**
  83503. * the log2 of value.
  83504. * @param value the value to compute log2 of
  83505. * @returns the log2 of value.
  83506. */
  83507. static Log2(value: number): number;
  83508. /**
  83509. * Loops the value, so that it is never larger than length and never smaller than 0.
  83510. *
  83511. * This is similar to the modulo operator but it works with floating point numbers.
  83512. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  83513. * With t = 5 and length = 2.5, the result would be 0.0.
  83514. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  83515. * @param value the value
  83516. * @param length the length
  83517. * @returns the looped value
  83518. */
  83519. static Repeat(value: number, length: number): number;
  83520. /**
  83521. * Normalize the value between 0.0 and 1.0 using min and max values
  83522. * @param value value to normalize
  83523. * @param min max to normalize between
  83524. * @param max min to normalize between
  83525. * @returns the normalized value
  83526. */
  83527. static Normalize(value: number, min: number, max: number): number;
  83528. /**
  83529. * Denormalize the value from 0.0 and 1.0 using min and max values
  83530. * @param normalized value to denormalize
  83531. * @param min max to denormalize between
  83532. * @param max min to denormalize between
  83533. * @returns the denormalized value
  83534. */
  83535. static Denormalize(normalized: number, min: number, max: number): number;
  83536. /**
  83537. * Calculates the shortest difference between two given angles given in degrees.
  83538. * @param current current angle in degrees
  83539. * @param target target angle in degrees
  83540. * @returns the delta
  83541. */
  83542. static DeltaAngle(current: number, target: number): number;
  83543. /**
  83544. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  83545. * @param tx value
  83546. * @param length length
  83547. * @returns The returned value will move back and forth between 0 and length
  83548. */
  83549. static PingPong(tx: number, length: number): number;
  83550. /**
  83551. * Interpolates between min and max with smoothing at the limits.
  83552. *
  83553. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  83554. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  83555. * @param from from
  83556. * @param to to
  83557. * @param tx value
  83558. * @returns the smooth stepped value
  83559. */
  83560. static SmoothStep(from: number, to: number, tx: number): number;
  83561. /**
  83562. * Moves a value current towards target.
  83563. *
  83564. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  83565. * Negative values of maxDelta pushes the value away from target.
  83566. * @param current current value
  83567. * @param target target value
  83568. * @param maxDelta max distance to move
  83569. * @returns resulting value
  83570. */
  83571. static MoveTowards(current: number, target: number, maxDelta: number): number;
  83572. /**
  83573. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  83574. *
  83575. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  83576. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  83577. * @param current current value
  83578. * @param target target value
  83579. * @param maxDelta max distance to move
  83580. * @returns resulting angle
  83581. */
  83582. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  83583. /**
  83584. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  83585. * @param start start value
  83586. * @param end target value
  83587. * @param amount amount to lerp between
  83588. * @returns the lerped value
  83589. */
  83590. static Lerp(start: number, end: number, amount: number): number;
  83591. /**
  83592. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  83593. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  83594. * @param start start value
  83595. * @param end target value
  83596. * @param amount amount to lerp between
  83597. * @returns the lerped value
  83598. */
  83599. static LerpAngle(start: number, end: number, amount: number): number;
  83600. /**
  83601. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  83602. * @param a start value
  83603. * @param b target value
  83604. * @param value value between a and b
  83605. * @returns the inverseLerp value
  83606. */
  83607. static InverseLerp(a: number, b: number, value: number): number;
  83608. /**
  83609. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  83610. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  83611. * @param value1 spline value
  83612. * @param tangent1 spline value
  83613. * @param value2 spline value
  83614. * @param tangent2 spline value
  83615. * @param amount input value
  83616. * @returns hermite result
  83617. */
  83618. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  83619. /**
  83620. * Returns a random float number between and min and max values
  83621. * @param min min value of random
  83622. * @param max max value of random
  83623. * @returns random value
  83624. */
  83625. static RandomRange(min: number, max: number): number;
  83626. /**
  83627. * This function returns percentage of a number in a given range.
  83628. *
  83629. * RangeToPercent(40,20,60) will return 0.5 (50%)
  83630. * RangeToPercent(34,0,100) will return 0.34 (34%)
  83631. * @param number to convert to percentage
  83632. * @param min min range
  83633. * @param max max range
  83634. * @returns the percentage
  83635. */
  83636. static RangeToPercent(number: number, min: number, max: number): number;
  83637. /**
  83638. * This function returns number that corresponds to the percentage in a given range.
  83639. *
  83640. * PercentToRange(0.34,0,100) will return 34.
  83641. * @param percent to convert to number
  83642. * @param min min range
  83643. * @param max max range
  83644. * @returns the number
  83645. */
  83646. static PercentToRange(percent: number, min: number, max: number): number;
  83647. /**
  83648. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  83649. * @param angle The angle to normalize in radian.
  83650. * @return The converted angle.
  83651. */
  83652. static NormalizeRadians(angle: number): number;
  83653. }
  83654. }
  83655. declare module BABYLON {
  83656. /**
  83657. * Constant used to convert a value to gamma space
  83658. * @ignorenaming
  83659. */
  83660. export const ToGammaSpace: number;
  83661. /**
  83662. * Constant used to convert a value to linear space
  83663. * @ignorenaming
  83664. */
  83665. export const ToLinearSpace = 2.2;
  83666. /**
  83667. * Constant used to define the minimal number value in Babylon.js
  83668. * @ignorenaming
  83669. */
  83670. let Epsilon: number;
  83671. }
  83672. declare module BABYLON {
  83673. /**
  83674. * Class used to represent a viewport on screen
  83675. */
  83676. export class Viewport {
  83677. /** viewport left coordinate */
  83678. x: number;
  83679. /** viewport top coordinate */
  83680. y: number;
  83681. /**viewport width */
  83682. width: number;
  83683. /** viewport height */
  83684. height: number;
  83685. /**
  83686. * Creates a Viewport object located at (x, y) and sized (width, height)
  83687. * @param x defines viewport left coordinate
  83688. * @param y defines viewport top coordinate
  83689. * @param width defines the viewport width
  83690. * @param height defines the viewport height
  83691. */
  83692. constructor(
  83693. /** viewport left coordinate */
  83694. x: number,
  83695. /** viewport top coordinate */
  83696. y: number,
  83697. /**viewport width */
  83698. width: number,
  83699. /** viewport height */
  83700. height: number);
  83701. /**
  83702. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  83703. * @param renderWidth defines the rendering width
  83704. * @param renderHeight defines the rendering height
  83705. * @returns a new Viewport
  83706. */
  83707. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  83708. /**
  83709. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  83710. * @param renderWidth defines the rendering width
  83711. * @param renderHeight defines the rendering height
  83712. * @param ref defines the target viewport
  83713. * @returns the current viewport
  83714. */
  83715. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  83716. /**
  83717. * Returns a new Viewport copied from the current one
  83718. * @returns a new Viewport
  83719. */
  83720. clone(): Viewport;
  83721. }
  83722. }
  83723. declare module BABYLON {
  83724. /**
  83725. * Class containing a set of static utilities functions for arrays.
  83726. */
  83727. export class ArrayTools {
  83728. /**
  83729. * Returns an array of the given size filled with element built from the given constructor and the paramters
  83730. * @param size the number of element to construct and put in the array
  83731. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  83732. * @returns a new array filled with new objects
  83733. */
  83734. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  83735. }
  83736. }
  83737. declare module BABYLON {
  83738. /**
  83739. * Represents a plane by the equation ax + by + cz + d = 0
  83740. */
  83741. export class Plane {
  83742. private static _TmpMatrix;
  83743. /**
  83744. * Normal of the plane (a,b,c)
  83745. */
  83746. normal: Vector3;
  83747. /**
  83748. * d component of the plane
  83749. */
  83750. d: number;
  83751. /**
  83752. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  83753. * @param a a component of the plane
  83754. * @param b b component of the plane
  83755. * @param c c component of the plane
  83756. * @param d d component of the plane
  83757. */
  83758. constructor(a: number, b: number, c: number, d: number);
  83759. /**
  83760. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  83761. */
  83762. asArray(): number[];
  83763. /**
  83764. * @returns a new plane copied from the current Plane.
  83765. */
  83766. clone(): Plane;
  83767. /**
  83768. * @returns the string "Plane".
  83769. */
  83770. getClassName(): string;
  83771. /**
  83772. * @returns the Plane hash code.
  83773. */
  83774. getHashCode(): number;
  83775. /**
  83776. * Normalize the current Plane in place.
  83777. * @returns the updated Plane.
  83778. */
  83779. normalize(): Plane;
  83780. /**
  83781. * Applies a transformation the plane and returns the result
  83782. * @param transformation the transformation matrix to be applied to the plane
  83783. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  83784. */
  83785. transform(transformation: DeepImmutable<Matrix>): Plane;
  83786. /**
  83787. * Compute the dot product between the point and the plane normal
  83788. * @param point point to calculate the dot product with
  83789. * @returns the dot product (float) of the point coordinates and the plane normal.
  83790. */
  83791. dotCoordinate(point: DeepImmutable<Vector3>): number;
  83792. /**
  83793. * Updates the current Plane from the plane defined by the three given points.
  83794. * @param point1 one of the points used to contruct the plane
  83795. * @param point2 one of the points used to contruct the plane
  83796. * @param point3 one of the points used to contruct the plane
  83797. * @returns the updated Plane.
  83798. */
  83799. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  83800. /**
  83801. * Checks if the plane is facing a given direction
  83802. * @param direction the direction to check if the plane is facing
  83803. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  83804. * @returns True is the vector "direction" is the same side than the plane normal.
  83805. */
  83806. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  83807. /**
  83808. * Calculates the distance to a point
  83809. * @param point point to calculate distance to
  83810. * @returns the signed distance (float) from the given point to the Plane.
  83811. */
  83812. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  83813. /**
  83814. * Creates a plane from an array
  83815. * @param array the array to create a plane from
  83816. * @returns a new Plane from the given array.
  83817. */
  83818. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  83819. /**
  83820. * Creates a plane from three points
  83821. * @param point1 point used to create the plane
  83822. * @param point2 point used to create the plane
  83823. * @param point3 point used to create the plane
  83824. * @returns a new Plane defined by the three given points.
  83825. */
  83826. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  83827. /**
  83828. * Creates a plane from an origin point and a normal
  83829. * @param origin origin of the plane to be constructed
  83830. * @param normal normal of the plane to be constructed
  83831. * @returns a new Plane the normal vector to this plane at the given origin point.
  83832. * Note : the vector "normal" is updated because normalized.
  83833. */
  83834. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  83835. /**
  83836. * Calculates the distance from a plane and a point
  83837. * @param origin origin of the plane to be constructed
  83838. * @param normal normal of the plane to be constructed
  83839. * @param point point to calculate distance to
  83840. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  83841. */
  83842. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  83843. }
  83844. }
  83845. declare module BABYLON {
  83846. /** @hidden */
  83847. export class PerformanceConfigurator {
  83848. /** @hidden */
  83849. static MatrixUse64Bits: boolean;
  83850. /** @hidden */
  83851. static MatrixTrackPrecisionChange: boolean;
  83852. /** @hidden */
  83853. static MatrixCurrentType: any;
  83854. /** @hidden */
  83855. static MatrixTrackedMatrices: Array<any> | null;
  83856. /** @hidden */
  83857. static SetMatrixPrecision(use64bits: boolean): void;
  83858. }
  83859. }
  83860. declare module BABYLON {
  83861. /**
  83862. * Class representing a vector containing 2 coordinates
  83863. */
  83864. export class Vector2 {
  83865. /** defines the first coordinate */
  83866. x: number;
  83867. /** defines the second coordinate */
  83868. y: number;
  83869. /**
  83870. * Creates a new Vector2 from the given x and y coordinates
  83871. * @param x defines the first coordinate
  83872. * @param y defines the second coordinate
  83873. */
  83874. constructor(
  83875. /** defines the first coordinate */
  83876. x?: number,
  83877. /** defines the second coordinate */
  83878. y?: number);
  83879. /**
  83880. * Gets a string with the Vector2 coordinates
  83881. * @returns a string with the Vector2 coordinates
  83882. */
  83883. toString(): string;
  83884. /**
  83885. * Gets class name
  83886. * @returns the string "Vector2"
  83887. */
  83888. getClassName(): string;
  83889. /**
  83890. * Gets current vector hash code
  83891. * @returns the Vector2 hash code as a number
  83892. */
  83893. getHashCode(): number;
  83894. /**
  83895. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  83896. * @param array defines the source array
  83897. * @param index defines the offset in source array
  83898. * @returns the current Vector2
  83899. */
  83900. toArray(array: FloatArray, index?: number): Vector2;
  83901. /**
  83902. * Update the current vector from an array
  83903. * @param array defines the destination array
  83904. * @param index defines the offset in the destination array
  83905. * @returns the current Vector3
  83906. */
  83907. fromArray(array: FloatArray, index?: number): Vector2;
  83908. /**
  83909. * Copy the current vector to an array
  83910. * @returns a new array with 2 elements: the Vector2 coordinates.
  83911. */
  83912. asArray(): number[];
  83913. /**
  83914. * Sets the Vector2 coordinates with the given Vector2 coordinates
  83915. * @param source defines the source Vector2
  83916. * @returns the current updated Vector2
  83917. */
  83918. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  83919. /**
  83920. * Sets the Vector2 coordinates with the given floats
  83921. * @param x defines the first coordinate
  83922. * @param y defines the second coordinate
  83923. * @returns the current updated Vector2
  83924. */
  83925. copyFromFloats(x: number, y: number): Vector2;
  83926. /**
  83927. * Sets the Vector2 coordinates with the given floats
  83928. * @param x defines the first coordinate
  83929. * @param y defines the second coordinate
  83930. * @returns the current updated Vector2
  83931. */
  83932. set(x: number, y: number): Vector2;
  83933. /**
  83934. * Add another vector with the current one
  83935. * @param otherVector defines the other vector
  83936. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  83937. */
  83938. add(otherVector: DeepImmutable<Vector2>): Vector2;
  83939. /**
  83940. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  83941. * @param otherVector defines the other vector
  83942. * @param result defines the target vector
  83943. * @returns the unmodified current Vector2
  83944. */
  83945. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83946. /**
  83947. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  83948. * @param otherVector defines the other vector
  83949. * @returns the current updated Vector2
  83950. */
  83951. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83952. /**
  83953. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  83954. * @param otherVector defines the other vector
  83955. * @returns a new Vector2
  83956. */
  83957. addVector3(otherVector: Vector3): Vector2;
  83958. /**
  83959. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  83960. * @param otherVector defines the other vector
  83961. * @returns a new Vector2
  83962. */
  83963. subtract(otherVector: Vector2): Vector2;
  83964. /**
  83965. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  83966. * @param otherVector defines the other vector
  83967. * @param result defines the target vector
  83968. * @returns the unmodified current Vector2
  83969. */
  83970. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83971. /**
  83972. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  83973. * @param otherVector defines the other vector
  83974. * @returns the current updated Vector2
  83975. */
  83976. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83977. /**
  83978. * Multiplies in place the current Vector2 coordinates by the given ones
  83979. * @param otherVector defines the other vector
  83980. * @returns the current updated Vector2
  83981. */
  83982. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83983. /**
  83984. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  83985. * @param otherVector defines the other vector
  83986. * @returns a new Vector2
  83987. */
  83988. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  83989. /**
  83990. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  83991. * @param otherVector defines the other vector
  83992. * @param result defines the target vector
  83993. * @returns the unmodified current Vector2
  83994. */
  83995. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83996. /**
  83997. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  83998. * @param x defines the first coordinate
  83999. * @param y defines the second coordinate
  84000. * @returns a new Vector2
  84001. */
  84002. multiplyByFloats(x: number, y: number): Vector2;
  84003. /**
  84004. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  84005. * @param otherVector defines the other vector
  84006. * @returns a new Vector2
  84007. */
  84008. divide(otherVector: Vector2): Vector2;
  84009. /**
  84010. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  84011. * @param otherVector defines the other vector
  84012. * @param result defines the target vector
  84013. * @returns the unmodified current Vector2
  84014. */
  84015. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  84016. /**
  84017. * Divides the current Vector2 coordinates by the given ones
  84018. * @param otherVector defines the other vector
  84019. * @returns the current updated Vector2
  84020. */
  84021. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  84022. /**
  84023. * Gets a new Vector2 with current Vector2 negated coordinates
  84024. * @returns a new Vector2
  84025. */
  84026. negate(): Vector2;
  84027. /**
  84028. * Negate this vector in place
  84029. * @returns this
  84030. */
  84031. negateInPlace(): Vector2;
  84032. /**
  84033. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  84034. * @param result defines the Vector3 object where to store the result
  84035. * @returns the current Vector2
  84036. */
  84037. negateToRef(result: Vector2): Vector2;
  84038. /**
  84039. * Multiply the Vector2 coordinates by scale
  84040. * @param scale defines the scaling factor
  84041. * @returns the current updated Vector2
  84042. */
  84043. scaleInPlace(scale: number): Vector2;
  84044. /**
  84045. * Returns a new Vector2 scaled by "scale" from the current Vector2
  84046. * @param scale defines the scaling factor
  84047. * @returns a new Vector2
  84048. */
  84049. scale(scale: number): Vector2;
  84050. /**
  84051. * Scale the current Vector2 values by a factor to a given Vector2
  84052. * @param scale defines the scale factor
  84053. * @param result defines the Vector2 object where to store the result
  84054. * @returns the unmodified current Vector2
  84055. */
  84056. scaleToRef(scale: number, result: Vector2): Vector2;
  84057. /**
  84058. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  84059. * @param scale defines the scale factor
  84060. * @param result defines the Vector2 object where to store the result
  84061. * @returns the unmodified current Vector2
  84062. */
  84063. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  84064. /**
  84065. * Gets a boolean if two vectors are equals
  84066. * @param otherVector defines the other vector
  84067. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  84068. */
  84069. equals(otherVector: DeepImmutable<Vector2>): boolean;
  84070. /**
  84071. * Gets a boolean if two vectors are equals (using an epsilon value)
  84072. * @param otherVector defines the other vector
  84073. * @param epsilon defines the minimal distance to consider equality
  84074. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  84075. */
  84076. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  84077. /**
  84078. * Gets a new Vector2 from current Vector2 floored values
  84079. * @returns a new Vector2
  84080. */
  84081. floor(): Vector2;
  84082. /**
  84083. * Gets a new Vector2 from current Vector2 floored values
  84084. * @returns a new Vector2
  84085. */
  84086. fract(): Vector2;
  84087. /**
  84088. * Gets the length of the vector
  84089. * @returns the vector length (float)
  84090. */
  84091. length(): number;
  84092. /**
  84093. * Gets the vector squared length
  84094. * @returns the vector squared length (float)
  84095. */
  84096. lengthSquared(): number;
  84097. /**
  84098. * Normalize the vector
  84099. * @returns the current updated Vector2
  84100. */
  84101. normalize(): Vector2;
  84102. /**
  84103. * Gets a new Vector2 copied from the Vector2
  84104. * @returns a new Vector2
  84105. */
  84106. clone(): Vector2;
  84107. /**
  84108. * Gets a new Vector2(0, 0)
  84109. * @returns a new Vector2
  84110. */
  84111. static Zero(): Vector2;
  84112. /**
  84113. * Gets a new Vector2(1, 1)
  84114. * @returns a new Vector2
  84115. */
  84116. static One(): Vector2;
  84117. /**
  84118. * Gets a new Vector2 set from the given index element of the given array
  84119. * @param array defines the data source
  84120. * @param offset defines the offset in the data source
  84121. * @returns a new Vector2
  84122. */
  84123. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  84124. /**
  84125. * Sets "result" from the given index element of the given array
  84126. * @param array defines the data source
  84127. * @param offset defines the offset in the data source
  84128. * @param result defines the target vector
  84129. */
  84130. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  84131. /**
  84132. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  84133. * @param value1 defines 1st point of control
  84134. * @param value2 defines 2nd point of control
  84135. * @param value3 defines 3rd point of control
  84136. * @param value4 defines 4th point of control
  84137. * @param amount defines the interpolation factor
  84138. * @returns a new Vector2
  84139. */
  84140. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  84141. /**
  84142. * 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".
  84143. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  84144. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  84145. * @param value defines the value to clamp
  84146. * @param min defines the lower limit
  84147. * @param max defines the upper limit
  84148. * @returns a new Vector2
  84149. */
  84150. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  84151. /**
  84152. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  84153. * @param value1 defines the 1st control point
  84154. * @param tangent1 defines the outgoing tangent
  84155. * @param value2 defines the 2nd control point
  84156. * @param tangent2 defines the incoming tangent
  84157. * @param amount defines the interpolation factor
  84158. * @returns a new Vector2
  84159. */
  84160. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  84161. /**
  84162. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  84163. * @param start defines the start vector
  84164. * @param end defines the end vector
  84165. * @param amount defines the interpolation factor
  84166. * @returns a new Vector2
  84167. */
  84168. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  84169. /**
  84170. * Gets the dot product of the vector "left" and the vector "right"
  84171. * @param left defines first vector
  84172. * @param right defines second vector
  84173. * @returns the dot product (float)
  84174. */
  84175. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  84176. /**
  84177. * Returns a new Vector2 equal to the normalized given vector
  84178. * @param vector defines the vector to normalize
  84179. * @returns a new Vector2
  84180. */
  84181. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  84182. /**
  84183. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  84184. * @param left defines 1st vector
  84185. * @param right defines 2nd vector
  84186. * @returns a new Vector2
  84187. */
  84188. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  84189. /**
  84190. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  84191. * @param left defines 1st vector
  84192. * @param right defines 2nd vector
  84193. * @returns a new Vector2
  84194. */
  84195. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  84196. /**
  84197. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  84198. * @param vector defines the vector to transform
  84199. * @param transformation defines the matrix to apply
  84200. * @returns a new Vector2
  84201. */
  84202. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  84203. /**
  84204. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  84205. * @param vector defines the vector to transform
  84206. * @param transformation defines the matrix to apply
  84207. * @param result defines the target vector
  84208. */
  84209. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  84210. /**
  84211. * Determines if a given vector is included in a triangle
  84212. * @param p defines the vector to test
  84213. * @param p0 defines 1st triangle point
  84214. * @param p1 defines 2nd triangle point
  84215. * @param p2 defines 3rd triangle point
  84216. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  84217. */
  84218. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  84219. /**
  84220. * Gets the distance between the vectors "value1" and "value2"
  84221. * @param value1 defines first vector
  84222. * @param value2 defines second vector
  84223. * @returns the distance between vectors
  84224. */
  84225. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  84226. /**
  84227. * Returns the squared distance between the vectors "value1" and "value2"
  84228. * @param value1 defines first vector
  84229. * @param value2 defines second vector
  84230. * @returns the squared distance between vectors
  84231. */
  84232. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  84233. /**
  84234. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  84235. * @param value1 defines first vector
  84236. * @param value2 defines second vector
  84237. * @returns a new Vector2
  84238. */
  84239. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  84240. /**
  84241. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  84242. * @param p defines the middle point
  84243. * @param segA defines one point of the segment
  84244. * @param segB defines the other point of the segment
  84245. * @returns the shortest distance
  84246. */
  84247. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  84248. }
  84249. /**
  84250. * Class used to store (x,y,z) vector representation
  84251. * A Vector3 is the main object used in 3D geometry
  84252. * It can represent etiher the coordinates of a point the space, either a direction
  84253. * Reminder: js uses a left handed forward facing system
  84254. */
  84255. export class Vector3 {
  84256. private static _UpReadOnly;
  84257. private static _ZeroReadOnly;
  84258. /** @hidden */
  84259. _x: number;
  84260. /** @hidden */
  84261. _y: number;
  84262. /** @hidden */
  84263. _z: number;
  84264. /** @hidden */
  84265. _isDirty: boolean;
  84266. /** Gets or sets the x coordinate */
  84267. get x(): number;
  84268. set x(value: number);
  84269. /** Gets or sets the y coordinate */
  84270. get y(): number;
  84271. set y(value: number);
  84272. /** Gets or sets the z coordinate */
  84273. get z(): number;
  84274. set z(value: number);
  84275. /**
  84276. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  84277. * @param x defines the first coordinates (on X axis)
  84278. * @param y defines the second coordinates (on Y axis)
  84279. * @param z defines the third coordinates (on Z axis)
  84280. */
  84281. constructor(x?: number, y?: number, z?: number);
  84282. /**
  84283. * Creates a string representation of the Vector3
  84284. * @returns a string with the Vector3 coordinates.
  84285. */
  84286. toString(): string;
  84287. /**
  84288. * Gets the class name
  84289. * @returns the string "Vector3"
  84290. */
  84291. getClassName(): string;
  84292. /**
  84293. * Creates the Vector3 hash code
  84294. * @returns a number which tends to be unique between Vector3 instances
  84295. */
  84296. getHashCode(): number;
  84297. /**
  84298. * Creates an array containing three elements : the coordinates of the Vector3
  84299. * @returns a new array of numbers
  84300. */
  84301. asArray(): number[];
  84302. /**
  84303. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  84304. * @param array defines the destination array
  84305. * @param index defines the offset in the destination array
  84306. * @returns the current Vector3
  84307. */
  84308. toArray(array: FloatArray, index?: number): Vector3;
  84309. /**
  84310. * Update the current vector from an array
  84311. * @param array defines the destination array
  84312. * @param index defines the offset in the destination array
  84313. * @returns the current Vector3
  84314. */
  84315. fromArray(array: FloatArray, index?: number): Vector3;
  84316. /**
  84317. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  84318. * @returns a new Quaternion object, computed from the Vector3 coordinates
  84319. */
  84320. toQuaternion(): Quaternion;
  84321. /**
  84322. * Adds the given vector to the current Vector3
  84323. * @param otherVector defines the second operand
  84324. * @returns the current updated Vector3
  84325. */
  84326. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  84327. /**
  84328. * Adds the given coordinates to the current Vector3
  84329. * @param x defines the x coordinate of the operand
  84330. * @param y defines the y coordinate of the operand
  84331. * @param z defines the z coordinate of the operand
  84332. * @returns the current updated Vector3
  84333. */
  84334. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  84335. /**
  84336. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  84337. * @param otherVector defines the second operand
  84338. * @returns the resulting Vector3
  84339. */
  84340. add(otherVector: DeepImmutable<Vector3>): Vector3;
  84341. /**
  84342. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  84343. * @param otherVector defines the second operand
  84344. * @param result defines the Vector3 object where to store the result
  84345. * @returns the current Vector3
  84346. */
  84347. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  84348. /**
  84349. * Subtract the given vector from the current Vector3
  84350. * @param otherVector defines the second operand
  84351. * @returns the current updated Vector3
  84352. */
  84353. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  84354. /**
  84355. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  84356. * @param otherVector defines the second operand
  84357. * @returns the resulting Vector3
  84358. */
  84359. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  84360. /**
  84361. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  84362. * @param otherVector defines the second operand
  84363. * @param result defines the Vector3 object where to store the result
  84364. * @returns the current Vector3
  84365. */
  84366. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  84367. /**
  84368. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  84369. * @param x defines the x coordinate of the operand
  84370. * @param y defines the y coordinate of the operand
  84371. * @param z defines the z coordinate of the operand
  84372. * @returns the resulting Vector3
  84373. */
  84374. subtractFromFloats(x: number, y: number, z: number): Vector3;
  84375. /**
  84376. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  84377. * @param x defines the x coordinate of the operand
  84378. * @param y defines the y coordinate of the operand
  84379. * @param z defines the z coordinate of the operand
  84380. * @param result defines the Vector3 object where to store the result
  84381. * @returns the current Vector3
  84382. */
  84383. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  84384. /**
  84385. * Gets a new Vector3 set with the current Vector3 negated coordinates
  84386. * @returns a new Vector3
  84387. */
  84388. negate(): Vector3;
  84389. /**
  84390. * Negate this vector in place
  84391. * @returns this
  84392. */
  84393. negateInPlace(): Vector3;
  84394. /**
  84395. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  84396. * @param result defines the Vector3 object where to store the result
  84397. * @returns the current Vector3
  84398. */
  84399. negateToRef(result: Vector3): Vector3;
  84400. /**
  84401. * Multiplies the Vector3 coordinates by the float "scale"
  84402. * @param scale defines the multiplier factor
  84403. * @returns the current updated Vector3
  84404. */
  84405. scaleInPlace(scale: number): Vector3;
  84406. /**
  84407. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  84408. * @param scale defines the multiplier factor
  84409. * @returns a new Vector3
  84410. */
  84411. scale(scale: number): Vector3;
  84412. /**
  84413. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  84414. * @param scale defines the multiplier factor
  84415. * @param result defines the Vector3 object where to store the result
  84416. * @returns the current Vector3
  84417. */
  84418. scaleToRef(scale: number, result: Vector3): Vector3;
  84419. /**
  84420. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  84421. * @param scale defines the scale factor
  84422. * @param result defines the Vector3 object where to store the result
  84423. * @returns the unmodified current Vector3
  84424. */
  84425. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  84426. /**
  84427. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  84428. * @param origin defines the origin of the projection ray
  84429. * @param plane defines the plane to project to
  84430. * @returns the projected vector3
  84431. */
  84432. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  84433. /**
  84434. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  84435. * @param origin defines the origin of the projection ray
  84436. * @param plane defines the plane to project to
  84437. * @param result defines the Vector3 where to store the result
  84438. */
  84439. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  84440. /**
  84441. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  84442. * @param otherVector defines the second operand
  84443. * @returns true if both vectors are equals
  84444. */
  84445. equals(otherVector: DeepImmutable<Vector3>): boolean;
  84446. /**
  84447. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  84448. * @param otherVector defines the second operand
  84449. * @param epsilon defines the minimal distance to define values as equals
  84450. * @returns true if both vectors are distant less than epsilon
  84451. */
  84452. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  84453. /**
  84454. * Returns true if the current Vector3 coordinates equals the given floats
  84455. * @param x defines the x coordinate of the operand
  84456. * @param y defines the y coordinate of the operand
  84457. * @param z defines the z coordinate of the operand
  84458. * @returns true if both vectors are equals
  84459. */
  84460. equalsToFloats(x: number, y: number, z: number): boolean;
  84461. /**
  84462. * Multiplies the current Vector3 coordinates by the given ones
  84463. * @param otherVector defines the second operand
  84464. * @returns the current updated Vector3
  84465. */
  84466. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  84467. /**
  84468. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  84469. * @param otherVector defines the second operand
  84470. * @returns the new Vector3
  84471. */
  84472. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  84473. /**
  84474. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  84475. * @param otherVector defines the second operand
  84476. * @param result defines the Vector3 object where to store the result
  84477. * @returns the current Vector3
  84478. */
  84479. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  84480. /**
  84481. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  84482. * @param x defines the x coordinate of the operand
  84483. * @param y defines the y coordinate of the operand
  84484. * @param z defines the z coordinate of the operand
  84485. * @returns the new Vector3
  84486. */
  84487. multiplyByFloats(x: number, y: number, z: number): Vector3;
  84488. /**
  84489. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  84490. * @param otherVector defines the second operand
  84491. * @returns the new Vector3
  84492. */
  84493. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  84494. /**
  84495. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  84496. * @param otherVector defines the second operand
  84497. * @param result defines the Vector3 object where to store the result
  84498. * @returns the current Vector3
  84499. */
  84500. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  84501. /**
  84502. * Divides the current Vector3 coordinates by the given ones.
  84503. * @param otherVector defines the second operand
  84504. * @returns the current updated Vector3
  84505. */
  84506. divideInPlace(otherVector: Vector3): Vector3;
  84507. /**
  84508. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  84509. * @param other defines the second operand
  84510. * @returns the current updated Vector3
  84511. */
  84512. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  84513. /**
  84514. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  84515. * @param other defines the second operand
  84516. * @returns the current updated Vector3
  84517. */
  84518. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  84519. /**
  84520. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  84521. * @param x defines the x coordinate of the operand
  84522. * @param y defines the y coordinate of the operand
  84523. * @param z defines the z coordinate of the operand
  84524. * @returns the current updated Vector3
  84525. */
  84526. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  84527. /**
  84528. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  84529. * @param x defines the x coordinate of the operand
  84530. * @param y defines the y coordinate of the operand
  84531. * @param z defines the z coordinate of the operand
  84532. * @returns the current updated Vector3
  84533. */
  84534. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  84535. /**
  84536. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  84537. * Check if is non uniform within a certain amount of decimal places to account for this
  84538. * @param epsilon the amount the values can differ
  84539. * @returns if the the vector is non uniform to a certain number of decimal places
  84540. */
  84541. isNonUniformWithinEpsilon(epsilon: number): boolean;
  84542. /**
  84543. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  84544. */
  84545. get isNonUniform(): boolean;
  84546. /**
  84547. * Gets a new Vector3 from current Vector3 floored values
  84548. * @returns a new Vector3
  84549. */
  84550. floor(): Vector3;
  84551. /**
  84552. * Gets a new Vector3 from current Vector3 floored values
  84553. * @returns a new Vector3
  84554. */
  84555. fract(): Vector3;
  84556. /**
  84557. * Gets the length of the Vector3
  84558. * @returns the length of the Vector3
  84559. */
  84560. length(): number;
  84561. /**
  84562. * Gets the squared length of the Vector3
  84563. * @returns squared length of the Vector3
  84564. */
  84565. lengthSquared(): number;
  84566. /**
  84567. * Normalize the current Vector3.
  84568. * Please note that this is an in place operation.
  84569. * @returns the current updated Vector3
  84570. */
  84571. normalize(): Vector3;
  84572. /**
  84573. * Reorders the x y z properties of the vector in place
  84574. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  84575. * @returns the current updated vector
  84576. */
  84577. reorderInPlace(order: string): this;
  84578. /**
  84579. * Rotates the vector around 0,0,0 by a quaternion
  84580. * @param quaternion the rotation quaternion
  84581. * @param result vector to store the result
  84582. * @returns the resulting vector
  84583. */
  84584. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  84585. /**
  84586. * Rotates a vector around a given point
  84587. * @param quaternion the rotation quaternion
  84588. * @param point the point to rotate around
  84589. * @param result vector to store the result
  84590. * @returns the resulting vector
  84591. */
  84592. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  84593. /**
  84594. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  84595. * The cross product is then orthogonal to both current and "other"
  84596. * @param other defines the right operand
  84597. * @returns the cross product
  84598. */
  84599. cross(other: Vector3): Vector3;
  84600. /**
  84601. * Normalize the current Vector3 with the given input length.
  84602. * Please note that this is an in place operation.
  84603. * @param len the length of the vector
  84604. * @returns the current updated Vector3
  84605. */
  84606. normalizeFromLength(len: number): Vector3;
  84607. /**
  84608. * Normalize the current Vector3 to a new vector
  84609. * @returns the new Vector3
  84610. */
  84611. normalizeToNew(): Vector3;
  84612. /**
  84613. * Normalize the current Vector3 to the reference
  84614. * @param reference define the Vector3 to update
  84615. * @returns the updated Vector3
  84616. */
  84617. normalizeToRef(reference: Vector3): Vector3;
  84618. /**
  84619. * Creates a new Vector3 copied from the current Vector3
  84620. * @returns the new Vector3
  84621. */
  84622. clone(): Vector3;
  84623. /**
  84624. * Copies the given vector coordinates to the current Vector3 ones
  84625. * @param source defines the source Vector3
  84626. * @returns the current updated Vector3
  84627. */
  84628. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  84629. /**
  84630. * Copies the given floats to the current Vector3 coordinates
  84631. * @param x defines the x coordinate of the operand
  84632. * @param y defines the y coordinate of the operand
  84633. * @param z defines the z coordinate of the operand
  84634. * @returns the current updated Vector3
  84635. */
  84636. copyFromFloats(x: number, y: number, z: number): Vector3;
  84637. /**
  84638. * Copies the given floats to the current Vector3 coordinates
  84639. * @param x defines the x coordinate of the operand
  84640. * @param y defines the y coordinate of the operand
  84641. * @param z defines the z coordinate of the operand
  84642. * @returns the current updated Vector3
  84643. */
  84644. set(x: number, y: number, z: number): Vector3;
  84645. /**
  84646. * Copies the given float to the current Vector3 coordinates
  84647. * @param v defines the x, y and z coordinates of the operand
  84648. * @returns the current updated Vector3
  84649. */
  84650. setAll(v: number): Vector3;
  84651. /**
  84652. * Get the clip factor between two vectors
  84653. * @param vector0 defines the first operand
  84654. * @param vector1 defines the second operand
  84655. * @param axis defines the axis to use
  84656. * @param size defines the size along the axis
  84657. * @returns the clip factor
  84658. */
  84659. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  84660. /**
  84661. * Get angle between two vectors
  84662. * @param vector0 angle between vector0 and vector1
  84663. * @param vector1 angle between vector0 and vector1
  84664. * @param normal direction of the normal
  84665. * @return the angle between vector0 and vector1
  84666. */
  84667. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  84668. /**
  84669. * Returns a new Vector3 set from the index "offset" of the given array
  84670. * @param array defines the source array
  84671. * @param offset defines the offset in the source array
  84672. * @returns the new Vector3
  84673. */
  84674. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  84675. /**
  84676. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  84677. * @param array defines the source array
  84678. * @param offset defines the offset in the source array
  84679. * @returns the new Vector3
  84680. * @deprecated Please use FromArray instead.
  84681. */
  84682. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  84683. /**
  84684. * Sets the given vector "result" with the element values from the index "offset" of the given array
  84685. * @param array defines the source array
  84686. * @param offset defines the offset in the source array
  84687. * @param result defines the Vector3 where to store the result
  84688. */
  84689. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  84690. /**
  84691. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  84692. * @param array defines the source array
  84693. * @param offset defines the offset in the source array
  84694. * @param result defines the Vector3 where to store the result
  84695. * @deprecated Please use FromArrayToRef instead.
  84696. */
  84697. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  84698. /**
  84699. * Sets the given vector "result" with the given floats.
  84700. * @param x defines the x coordinate of the source
  84701. * @param y defines the y coordinate of the source
  84702. * @param z defines the z coordinate of the source
  84703. * @param result defines the Vector3 where to store the result
  84704. */
  84705. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  84706. /**
  84707. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  84708. * @returns a new empty Vector3
  84709. */
  84710. static Zero(): Vector3;
  84711. /**
  84712. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  84713. * @returns a new unit Vector3
  84714. */
  84715. static One(): Vector3;
  84716. /**
  84717. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  84718. * @returns a new up Vector3
  84719. */
  84720. static Up(): Vector3;
  84721. /**
  84722. * Gets a up Vector3 that must not be updated
  84723. */
  84724. static get UpReadOnly(): DeepImmutable<Vector3>;
  84725. /**
  84726. * Gets a zero Vector3 that must not be updated
  84727. */
  84728. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  84729. /**
  84730. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  84731. * @returns a new down Vector3
  84732. */
  84733. static Down(): Vector3;
  84734. /**
  84735. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  84736. * @param rightHandedSystem is the scene right-handed (negative z)
  84737. * @returns a new forward Vector3
  84738. */
  84739. static Forward(rightHandedSystem?: boolean): Vector3;
  84740. /**
  84741. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  84742. * @param rightHandedSystem is the scene right-handed (negative-z)
  84743. * @returns a new forward Vector3
  84744. */
  84745. static Backward(rightHandedSystem?: boolean): Vector3;
  84746. /**
  84747. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  84748. * @returns a new right Vector3
  84749. */
  84750. static Right(): Vector3;
  84751. /**
  84752. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  84753. * @returns a new left Vector3
  84754. */
  84755. static Left(): Vector3;
  84756. /**
  84757. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  84758. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  84759. * @param vector defines the Vector3 to transform
  84760. * @param transformation defines the transformation matrix
  84761. * @returns the transformed Vector3
  84762. */
  84763. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  84764. /**
  84765. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  84766. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  84767. * @param vector defines the Vector3 to transform
  84768. * @param transformation defines the transformation matrix
  84769. * @param result defines the Vector3 where to store the result
  84770. */
  84771. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84772. /**
  84773. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  84774. * This method computes tranformed coordinates only, not transformed direction vectors
  84775. * @param x define the x coordinate of the source vector
  84776. * @param y define the y coordinate of the source vector
  84777. * @param z define the z coordinate of the source vector
  84778. * @param transformation defines the transformation matrix
  84779. * @param result defines the Vector3 where to store the result
  84780. */
  84781. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84782. /**
  84783. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  84784. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84785. * @param vector defines the Vector3 to transform
  84786. * @param transformation defines the transformation matrix
  84787. * @returns the new Vector3
  84788. */
  84789. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  84790. /**
  84791. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  84792. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84793. * @param vector defines the Vector3 to transform
  84794. * @param transformation defines the transformation matrix
  84795. * @param result defines the Vector3 where to store the result
  84796. */
  84797. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84798. /**
  84799. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  84800. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84801. * @param x define the x coordinate of the source vector
  84802. * @param y define the y coordinate of the source vector
  84803. * @param z define the z coordinate of the source vector
  84804. * @param transformation defines the transformation matrix
  84805. * @param result defines the Vector3 where to store the result
  84806. */
  84807. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84808. /**
  84809. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  84810. * @param value1 defines the first control point
  84811. * @param value2 defines the second control point
  84812. * @param value3 defines the third control point
  84813. * @param value4 defines the fourth control point
  84814. * @param amount defines the amount on the spline to use
  84815. * @returns the new Vector3
  84816. */
  84817. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  84818. /**
  84819. * 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"
  84820. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  84821. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  84822. * @param value defines the current value
  84823. * @param min defines the lower range value
  84824. * @param max defines the upper range value
  84825. * @returns the new Vector3
  84826. */
  84827. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  84828. /**
  84829. * 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"
  84830. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  84831. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  84832. * @param value defines the current value
  84833. * @param min defines the lower range value
  84834. * @param max defines the upper range value
  84835. * @param result defines the Vector3 where to store the result
  84836. */
  84837. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  84838. /**
  84839. * Checks if a given vector is inside a specific range
  84840. * @param v defines the vector to test
  84841. * @param min defines the minimum range
  84842. * @param max defines the maximum range
  84843. */
  84844. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  84845. /**
  84846. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  84847. * @param value1 defines the first control point
  84848. * @param tangent1 defines the first tangent vector
  84849. * @param value2 defines the second control point
  84850. * @param tangent2 defines the second tangent vector
  84851. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  84852. * @returns the new Vector3
  84853. */
  84854. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  84855. /**
  84856. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  84857. * @param start defines the start value
  84858. * @param end defines the end value
  84859. * @param amount max defines amount between both (between 0 and 1)
  84860. * @returns the new Vector3
  84861. */
  84862. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  84863. /**
  84864. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  84865. * @param start defines the start value
  84866. * @param end defines the end value
  84867. * @param amount max defines amount between both (between 0 and 1)
  84868. * @param result defines the Vector3 where to store the result
  84869. */
  84870. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  84871. /**
  84872. * Returns the dot product (float) between the vectors "left" and "right"
  84873. * @param left defines the left operand
  84874. * @param right defines the right operand
  84875. * @returns the dot product
  84876. */
  84877. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  84878. /**
  84879. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  84880. * The cross product is then orthogonal to both "left" and "right"
  84881. * @param left defines the left operand
  84882. * @param right defines the right operand
  84883. * @returns the cross product
  84884. */
  84885. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  84886. /**
  84887. * Sets the given vector "result" with the cross product of "left" and "right"
  84888. * The cross product is then orthogonal to both "left" and "right"
  84889. * @param left defines the left operand
  84890. * @param right defines the right operand
  84891. * @param result defines the Vector3 where to store the result
  84892. */
  84893. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  84894. /**
  84895. * Returns a new Vector3 as the normalization of the given vector
  84896. * @param vector defines the Vector3 to normalize
  84897. * @returns the new Vector3
  84898. */
  84899. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  84900. /**
  84901. * Sets the given vector "result" with the normalization of the given first vector
  84902. * @param vector defines the Vector3 to normalize
  84903. * @param result defines the Vector3 where to store the result
  84904. */
  84905. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  84906. /**
  84907. * Project a Vector3 onto screen space
  84908. * @param vector defines the Vector3 to project
  84909. * @param world defines the world matrix to use
  84910. * @param transform defines the transform (view x projection) matrix to use
  84911. * @param viewport defines the screen viewport to use
  84912. * @returns the new Vector3
  84913. */
  84914. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  84915. /**
  84916. * Project a Vector3 onto screen space to reference
  84917. * @param vector defines the Vector3 to project
  84918. * @param world defines the world matrix to use
  84919. * @param transform defines the transform (view x projection) matrix to use
  84920. * @param viewport defines the screen viewport to use
  84921. * @param result the vector in which the screen space will be stored
  84922. * @returns the new Vector3
  84923. */
  84924. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  84925. /** @hidden */
  84926. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  84927. /**
  84928. * Unproject from screen space to object space
  84929. * @param source defines the screen space Vector3 to use
  84930. * @param viewportWidth defines the current width of the viewport
  84931. * @param viewportHeight defines the current height of the viewport
  84932. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84933. * @param transform defines the transform (view x projection) matrix to use
  84934. * @returns the new Vector3
  84935. */
  84936. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  84937. /**
  84938. * Unproject from screen space to object space
  84939. * @param source defines the screen space Vector3 to use
  84940. * @param viewportWidth defines the current width of the viewport
  84941. * @param viewportHeight defines the current height of the viewport
  84942. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84943. * @param view defines the view matrix to use
  84944. * @param projection defines the projection matrix to use
  84945. * @returns the new Vector3
  84946. */
  84947. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  84948. /**
  84949. * Unproject from screen space to object space
  84950. * @param source defines the screen space Vector3 to use
  84951. * @param viewportWidth defines the current width of the viewport
  84952. * @param viewportHeight defines the current height of the viewport
  84953. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84954. * @param view defines the view matrix to use
  84955. * @param projection defines the projection matrix to use
  84956. * @param result defines the Vector3 where to store the result
  84957. */
  84958. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  84959. /**
  84960. * Unproject from screen space to object space
  84961. * @param sourceX defines the screen space x coordinate to use
  84962. * @param sourceY defines the screen space y coordinate to use
  84963. * @param sourceZ defines the screen space z coordinate to use
  84964. * @param viewportWidth defines the current width of the viewport
  84965. * @param viewportHeight defines the current height of the viewport
  84966. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84967. * @param view defines the view matrix to use
  84968. * @param projection defines the projection matrix to use
  84969. * @param result defines the Vector3 where to store the result
  84970. */
  84971. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  84972. /**
  84973. * Gets the minimal coordinate values between two Vector3
  84974. * @param left defines the first operand
  84975. * @param right defines the second operand
  84976. * @returns the new Vector3
  84977. */
  84978. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  84979. /**
  84980. * Gets the maximal coordinate values between two Vector3
  84981. * @param left defines the first operand
  84982. * @param right defines the second operand
  84983. * @returns the new Vector3
  84984. */
  84985. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  84986. /**
  84987. * Returns the distance between the vectors "value1" and "value2"
  84988. * @param value1 defines the first operand
  84989. * @param value2 defines the second operand
  84990. * @returns the distance
  84991. */
  84992. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  84993. /**
  84994. * Returns the squared distance between the vectors "value1" and "value2"
  84995. * @param value1 defines the first operand
  84996. * @param value2 defines the second operand
  84997. * @returns the squared distance
  84998. */
  84999. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  85000. /**
  85001. * Returns a new Vector3 located at the center between "value1" and "value2"
  85002. * @param value1 defines the first operand
  85003. * @param value2 defines the second operand
  85004. * @returns the new Vector3
  85005. */
  85006. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  85007. /**
  85008. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  85009. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  85010. * to something in order to rotate it from its local system to the given target system
  85011. * Note: axis1, axis2 and axis3 are normalized during this operation
  85012. * @param axis1 defines the first axis
  85013. * @param axis2 defines the second axis
  85014. * @param axis3 defines the third axis
  85015. * @returns a new Vector3
  85016. */
  85017. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  85018. /**
  85019. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  85020. * @param axis1 defines the first axis
  85021. * @param axis2 defines the second axis
  85022. * @param axis3 defines the third axis
  85023. * @param ref defines the Vector3 where to store the result
  85024. */
  85025. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  85026. }
  85027. /**
  85028. * Vector4 class created for EulerAngle class conversion to Quaternion
  85029. */
  85030. export class Vector4 {
  85031. /** x value of the vector */
  85032. x: number;
  85033. /** y value of the vector */
  85034. y: number;
  85035. /** z value of the vector */
  85036. z: number;
  85037. /** w value of the vector */
  85038. w: number;
  85039. /**
  85040. * Creates a Vector4 object from the given floats.
  85041. * @param x x value of the vector
  85042. * @param y y value of the vector
  85043. * @param z z value of the vector
  85044. * @param w w value of the vector
  85045. */
  85046. constructor(
  85047. /** x value of the vector */
  85048. x: number,
  85049. /** y value of the vector */
  85050. y: number,
  85051. /** z value of the vector */
  85052. z: number,
  85053. /** w value of the vector */
  85054. w: number);
  85055. /**
  85056. * Returns the string with the Vector4 coordinates.
  85057. * @returns a string containing all the vector values
  85058. */
  85059. toString(): string;
  85060. /**
  85061. * Returns the string "Vector4".
  85062. * @returns "Vector4"
  85063. */
  85064. getClassName(): string;
  85065. /**
  85066. * Returns the Vector4 hash code.
  85067. * @returns a unique hash code
  85068. */
  85069. getHashCode(): number;
  85070. /**
  85071. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  85072. * @returns the resulting array
  85073. */
  85074. asArray(): number[];
  85075. /**
  85076. * Populates the given array from the given index with the Vector4 coordinates.
  85077. * @param array array to populate
  85078. * @param index index of the array to start at (default: 0)
  85079. * @returns the Vector4.
  85080. */
  85081. toArray(array: FloatArray, index?: number): Vector4;
  85082. /**
  85083. * Update the current vector from an array
  85084. * @param array defines the destination array
  85085. * @param index defines the offset in the destination array
  85086. * @returns the current Vector3
  85087. */
  85088. fromArray(array: FloatArray, index?: number): Vector4;
  85089. /**
  85090. * Adds the given vector to the current Vector4.
  85091. * @param otherVector the vector to add
  85092. * @returns the updated Vector4.
  85093. */
  85094. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  85095. /**
  85096. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  85097. * @param otherVector the vector to add
  85098. * @returns the resulting vector
  85099. */
  85100. add(otherVector: DeepImmutable<Vector4>): Vector4;
  85101. /**
  85102. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  85103. * @param otherVector the vector to add
  85104. * @param result the vector to store the result
  85105. * @returns the current Vector4.
  85106. */
  85107. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  85108. /**
  85109. * Subtract in place the given vector from the current Vector4.
  85110. * @param otherVector the vector to subtract
  85111. * @returns the updated Vector4.
  85112. */
  85113. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  85114. /**
  85115. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  85116. * @param otherVector the vector to add
  85117. * @returns the new vector with the result
  85118. */
  85119. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  85120. /**
  85121. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  85122. * @param otherVector the vector to subtract
  85123. * @param result the vector to store the result
  85124. * @returns the current Vector4.
  85125. */
  85126. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  85127. /**
  85128. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  85129. */
  85130. /**
  85131. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  85132. * @param x value to subtract
  85133. * @param y value to subtract
  85134. * @param z value to subtract
  85135. * @param w value to subtract
  85136. * @returns new vector containing the result
  85137. */
  85138. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  85139. /**
  85140. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  85141. * @param x value to subtract
  85142. * @param y value to subtract
  85143. * @param z value to subtract
  85144. * @param w value to subtract
  85145. * @param result the vector to store the result in
  85146. * @returns the current Vector4.
  85147. */
  85148. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  85149. /**
  85150. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  85151. * @returns a new vector with the negated values
  85152. */
  85153. negate(): Vector4;
  85154. /**
  85155. * Negate this vector in place
  85156. * @returns this
  85157. */
  85158. negateInPlace(): Vector4;
  85159. /**
  85160. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  85161. * @param result defines the Vector3 object where to store the result
  85162. * @returns the current Vector4
  85163. */
  85164. negateToRef(result: Vector4): Vector4;
  85165. /**
  85166. * Multiplies the current Vector4 coordinates by scale (float).
  85167. * @param scale the number to scale with
  85168. * @returns the updated Vector4.
  85169. */
  85170. scaleInPlace(scale: number): Vector4;
  85171. /**
  85172. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  85173. * @param scale the number to scale with
  85174. * @returns a new vector with the result
  85175. */
  85176. scale(scale: number): Vector4;
  85177. /**
  85178. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  85179. * @param scale the number to scale with
  85180. * @param result a vector to store the result in
  85181. * @returns the current Vector4.
  85182. */
  85183. scaleToRef(scale: number, result: Vector4): Vector4;
  85184. /**
  85185. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  85186. * @param scale defines the scale factor
  85187. * @param result defines the Vector4 object where to store the result
  85188. * @returns the unmodified current Vector4
  85189. */
  85190. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  85191. /**
  85192. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  85193. * @param otherVector the vector to compare against
  85194. * @returns true if they are equal
  85195. */
  85196. equals(otherVector: DeepImmutable<Vector4>): boolean;
  85197. /**
  85198. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  85199. * @param otherVector vector to compare against
  85200. * @param epsilon (Default: very small number)
  85201. * @returns true if they are equal
  85202. */
  85203. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  85204. /**
  85205. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  85206. * @param x x value to compare against
  85207. * @param y y value to compare against
  85208. * @param z z value to compare against
  85209. * @param w w value to compare against
  85210. * @returns true if equal
  85211. */
  85212. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  85213. /**
  85214. * Multiplies in place the current Vector4 by the given one.
  85215. * @param otherVector vector to multiple with
  85216. * @returns the updated Vector4.
  85217. */
  85218. multiplyInPlace(otherVector: Vector4): Vector4;
  85219. /**
  85220. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  85221. * @param otherVector vector to multiple with
  85222. * @returns resulting new vector
  85223. */
  85224. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  85225. /**
  85226. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  85227. * @param otherVector vector to multiple with
  85228. * @param result vector to store the result
  85229. * @returns the current Vector4.
  85230. */
  85231. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  85232. /**
  85233. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  85234. * @param x x value multiply with
  85235. * @param y y value multiply with
  85236. * @param z z value multiply with
  85237. * @param w w value multiply with
  85238. * @returns resulting new vector
  85239. */
  85240. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  85241. /**
  85242. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  85243. * @param otherVector vector to devide with
  85244. * @returns resulting new vector
  85245. */
  85246. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  85247. /**
  85248. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  85249. * @param otherVector vector to devide with
  85250. * @param result vector to store the result
  85251. * @returns the current Vector4.
  85252. */
  85253. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  85254. /**
  85255. * Divides the current Vector3 coordinates by the given ones.
  85256. * @param otherVector vector to devide with
  85257. * @returns the updated Vector3.
  85258. */
  85259. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  85260. /**
  85261. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  85262. * @param other defines the second operand
  85263. * @returns the current updated Vector4
  85264. */
  85265. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  85266. /**
  85267. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  85268. * @param other defines the second operand
  85269. * @returns the current updated Vector4
  85270. */
  85271. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  85272. /**
  85273. * Gets a new Vector4 from current Vector4 floored values
  85274. * @returns a new Vector4
  85275. */
  85276. floor(): Vector4;
  85277. /**
  85278. * Gets a new Vector4 from current Vector3 floored values
  85279. * @returns a new Vector4
  85280. */
  85281. fract(): Vector4;
  85282. /**
  85283. * Returns the Vector4 length (float).
  85284. * @returns the length
  85285. */
  85286. length(): number;
  85287. /**
  85288. * Returns the Vector4 squared length (float).
  85289. * @returns the length squared
  85290. */
  85291. lengthSquared(): number;
  85292. /**
  85293. * Normalizes in place the Vector4.
  85294. * @returns the updated Vector4.
  85295. */
  85296. normalize(): Vector4;
  85297. /**
  85298. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  85299. * @returns this converted to a new vector3
  85300. */
  85301. toVector3(): Vector3;
  85302. /**
  85303. * Returns a new Vector4 copied from the current one.
  85304. * @returns the new cloned vector
  85305. */
  85306. clone(): Vector4;
  85307. /**
  85308. * Updates the current Vector4 with the given one coordinates.
  85309. * @param source the source vector to copy from
  85310. * @returns the updated Vector4.
  85311. */
  85312. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  85313. /**
  85314. * Updates the current Vector4 coordinates with the given floats.
  85315. * @param x float to copy from
  85316. * @param y float to copy from
  85317. * @param z float to copy from
  85318. * @param w float to copy from
  85319. * @returns the updated Vector4.
  85320. */
  85321. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  85322. /**
  85323. * Updates the current Vector4 coordinates with the given floats.
  85324. * @param x float to set from
  85325. * @param y float to set from
  85326. * @param z float to set from
  85327. * @param w float to set from
  85328. * @returns the updated Vector4.
  85329. */
  85330. set(x: number, y: number, z: number, w: number): Vector4;
  85331. /**
  85332. * Copies the given float to the current Vector3 coordinates
  85333. * @param v defines the x, y, z and w coordinates of the operand
  85334. * @returns the current updated Vector3
  85335. */
  85336. setAll(v: number): Vector4;
  85337. /**
  85338. * Returns a new Vector4 set from the starting index of the given array.
  85339. * @param array the array to pull values from
  85340. * @param offset the offset into the array to start at
  85341. * @returns the new vector
  85342. */
  85343. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  85344. /**
  85345. * Updates the given vector "result" from the starting index of the given array.
  85346. * @param array the array to pull values from
  85347. * @param offset the offset into the array to start at
  85348. * @param result the vector to store the result in
  85349. */
  85350. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  85351. /**
  85352. * Updates the given vector "result" from the starting index of the given Float32Array.
  85353. * @param array the array to pull values from
  85354. * @param offset the offset into the array to start at
  85355. * @param result the vector to store the result in
  85356. */
  85357. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  85358. /**
  85359. * Updates the given vector "result" coordinates from the given floats.
  85360. * @param x float to set from
  85361. * @param y float to set from
  85362. * @param z float to set from
  85363. * @param w float to set from
  85364. * @param result the vector to the floats in
  85365. */
  85366. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  85367. /**
  85368. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  85369. * @returns the new vector
  85370. */
  85371. static Zero(): Vector4;
  85372. /**
  85373. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  85374. * @returns the new vector
  85375. */
  85376. static One(): Vector4;
  85377. /**
  85378. * Returns a new normalized Vector4 from the given one.
  85379. * @param vector the vector to normalize
  85380. * @returns the vector
  85381. */
  85382. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  85383. /**
  85384. * Updates the given vector "result" from the normalization of the given one.
  85385. * @param vector the vector to normalize
  85386. * @param result the vector to store the result in
  85387. */
  85388. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  85389. /**
  85390. * Returns a vector with the minimum values from the left and right vectors
  85391. * @param left left vector to minimize
  85392. * @param right right vector to minimize
  85393. * @returns a new vector with the minimum of the left and right vector values
  85394. */
  85395. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  85396. /**
  85397. * Returns a vector with the maximum values from the left and right vectors
  85398. * @param left left vector to maximize
  85399. * @param right right vector to maximize
  85400. * @returns a new vector with the maximum of the left and right vector values
  85401. */
  85402. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  85403. /**
  85404. * Returns the distance (float) between the vectors "value1" and "value2".
  85405. * @param value1 value to calulate the distance between
  85406. * @param value2 value to calulate the distance between
  85407. * @return the distance between the two vectors
  85408. */
  85409. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  85410. /**
  85411. * Returns the squared distance (float) between the vectors "value1" and "value2".
  85412. * @param value1 value to calulate the distance between
  85413. * @param value2 value to calulate the distance between
  85414. * @return the distance between the two vectors squared
  85415. */
  85416. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  85417. /**
  85418. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  85419. * @param value1 value to calulate the center between
  85420. * @param value2 value to calulate the center between
  85421. * @return the center between the two vectors
  85422. */
  85423. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  85424. /**
  85425. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  85426. * This methods computes transformed normalized direction vectors only.
  85427. * @param vector the vector to transform
  85428. * @param transformation the transformation matrix to apply
  85429. * @returns the new vector
  85430. */
  85431. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  85432. /**
  85433. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  85434. * This methods computes transformed normalized direction vectors only.
  85435. * @param vector the vector to transform
  85436. * @param transformation the transformation matrix to apply
  85437. * @param result the vector to store the result in
  85438. */
  85439. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  85440. /**
  85441. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  85442. * This methods computes transformed normalized direction vectors only.
  85443. * @param x value to transform
  85444. * @param y value to transform
  85445. * @param z value to transform
  85446. * @param w value to transform
  85447. * @param transformation the transformation matrix to apply
  85448. * @param result the vector to store the results in
  85449. */
  85450. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  85451. /**
  85452. * Creates a new Vector4 from a Vector3
  85453. * @param source defines the source data
  85454. * @param w defines the 4th component (default is 0)
  85455. * @returns a new Vector4
  85456. */
  85457. static FromVector3(source: Vector3, w?: number): Vector4;
  85458. }
  85459. /**
  85460. * Class used to store quaternion data
  85461. * @see https://en.wikipedia.org/wiki/Quaternion
  85462. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  85463. */
  85464. export class Quaternion {
  85465. /** @hidden */
  85466. _x: number;
  85467. /** @hidden */
  85468. _y: number;
  85469. /** @hidden */
  85470. _z: number;
  85471. /** @hidden */
  85472. _w: number;
  85473. /** @hidden */
  85474. _isDirty: boolean;
  85475. /** Gets or sets the x coordinate */
  85476. get x(): number;
  85477. set x(value: number);
  85478. /** Gets or sets the y coordinate */
  85479. get y(): number;
  85480. set y(value: number);
  85481. /** Gets or sets the z coordinate */
  85482. get z(): number;
  85483. set z(value: number);
  85484. /** Gets or sets the w coordinate */
  85485. get w(): number;
  85486. set w(value: number);
  85487. /**
  85488. * Creates a new Quaternion from the given floats
  85489. * @param x defines the first component (0 by default)
  85490. * @param y defines the second component (0 by default)
  85491. * @param z defines the third component (0 by default)
  85492. * @param w defines the fourth component (1.0 by default)
  85493. */
  85494. constructor(x?: number, y?: number, z?: number, w?: number);
  85495. /**
  85496. * Gets a string representation for the current quaternion
  85497. * @returns a string with the Quaternion coordinates
  85498. */
  85499. toString(): string;
  85500. /**
  85501. * Gets the class name of the quaternion
  85502. * @returns the string "Quaternion"
  85503. */
  85504. getClassName(): string;
  85505. /**
  85506. * Gets a hash code for this quaternion
  85507. * @returns the quaternion hash code
  85508. */
  85509. getHashCode(): number;
  85510. /**
  85511. * Copy the quaternion to an array
  85512. * @returns a new array populated with 4 elements from the quaternion coordinates
  85513. */
  85514. asArray(): number[];
  85515. /**
  85516. * Check if two quaternions are equals
  85517. * @param otherQuaternion defines the second operand
  85518. * @return true if the current quaternion and the given one coordinates are strictly equals
  85519. */
  85520. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  85521. /**
  85522. * Gets a boolean if two quaternions are equals (using an epsilon value)
  85523. * @param otherQuaternion defines the other quaternion
  85524. * @param epsilon defines the minimal distance to consider equality
  85525. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  85526. */
  85527. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  85528. /**
  85529. * Clone the current quaternion
  85530. * @returns a new quaternion copied from the current one
  85531. */
  85532. clone(): Quaternion;
  85533. /**
  85534. * Copy a quaternion to the current one
  85535. * @param other defines the other quaternion
  85536. * @returns the updated current quaternion
  85537. */
  85538. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  85539. /**
  85540. * Updates the current quaternion with the given float coordinates
  85541. * @param x defines the x coordinate
  85542. * @param y defines the y coordinate
  85543. * @param z defines the z coordinate
  85544. * @param w defines the w coordinate
  85545. * @returns the updated current quaternion
  85546. */
  85547. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  85548. /**
  85549. * Updates the current quaternion from the given float coordinates
  85550. * @param x defines the x coordinate
  85551. * @param y defines the y coordinate
  85552. * @param z defines the z coordinate
  85553. * @param w defines the w coordinate
  85554. * @returns the updated current quaternion
  85555. */
  85556. set(x: number, y: number, z: number, w: number): Quaternion;
  85557. /**
  85558. * Adds two quaternions
  85559. * @param other defines the second operand
  85560. * @returns a new quaternion as the addition result of the given one and the current quaternion
  85561. */
  85562. add(other: DeepImmutable<Quaternion>): Quaternion;
  85563. /**
  85564. * Add a quaternion to the current one
  85565. * @param other defines the quaternion to add
  85566. * @returns the current quaternion
  85567. */
  85568. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  85569. /**
  85570. * Subtract two quaternions
  85571. * @param other defines the second operand
  85572. * @returns a new quaternion as the subtraction result of the given one from the current one
  85573. */
  85574. subtract(other: Quaternion): Quaternion;
  85575. /**
  85576. * Multiplies the current quaternion by a scale factor
  85577. * @param value defines the scale factor
  85578. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  85579. */
  85580. scale(value: number): Quaternion;
  85581. /**
  85582. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  85583. * @param scale defines the scale factor
  85584. * @param result defines the Quaternion object where to store the result
  85585. * @returns the unmodified current quaternion
  85586. */
  85587. scaleToRef(scale: number, result: Quaternion): Quaternion;
  85588. /**
  85589. * Multiplies in place the current quaternion by a scale factor
  85590. * @param value defines the scale factor
  85591. * @returns the current modified quaternion
  85592. */
  85593. scaleInPlace(value: number): Quaternion;
  85594. /**
  85595. * Scale the current quaternion values by a factor and add the result to a given quaternion
  85596. * @param scale defines the scale factor
  85597. * @param result defines the Quaternion object where to store the result
  85598. * @returns the unmodified current quaternion
  85599. */
  85600. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  85601. /**
  85602. * Multiplies two quaternions
  85603. * @param q1 defines the second operand
  85604. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  85605. */
  85606. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  85607. /**
  85608. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  85609. * @param q1 defines the second operand
  85610. * @param result defines the target quaternion
  85611. * @returns the current quaternion
  85612. */
  85613. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  85614. /**
  85615. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  85616. * @param q1 defines the second operand
  85617. * @returns the currentupdated quaternion
  85618. */
  85619. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  85620. /**
  85621. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  85622. * @param ref defines the target quaternion
  85623. * @returns the current quaternion
  85624. */
  85625. conjugateToRef(ref: Quaternion): Quaternion;
  85626. /**
  85627. * Conjugates in place (1-q) the current quaternion
  85628. * @returns the current updated quaternion
  85629. */
  85630. conjugateInPlace(): Quaternion;
  85631. /**
  85632. * Conjugates in place (1-q) the current quaternion
  85633. * @returns a new quaternion
  85634. */
  85635. conjugate(): Quaternion;
  85636. /**
  85637. * Gets length of current quaternion
  85638. * @returns the quaternion length (float)
  85639. */
  85640. length(): number;
  85641. /**
  85642. * Normalize in place the current quaternion
  85643. * @returns the current updated quaternion
  85644. */
  85645. normalize(): Quaternion;
  85646. /**
  85647. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  85648. * @param order is a reserved parameter and is ignored for now
  85649. * @returns a new Vector3 containing the Euler angles
  85650. */
  85651. toEulerAngles(order?: string): Vector3;
  85652. /**
  85653. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  85654. * @param result defines the vector which will be filled with the Euler angles
  85655. * @returns the current unchanged quaternion
  85656. */
  85657. toEulerAnglesToRef(result: Vector3): Quaternion;
  85658. /**
  85659. * Updates the given rotation matrix with the current quaternion values
  85660. * @param result defines the target matrix
  85661. * @returns the current unchanged quaternion
  85662. */
  85663. toRotationMatrix(result: Matrix): Quaternion;
  85664. /**
  85665. * Updates the current quaternion from the given rotation matrix values
  85666. * @param matrix defines the source matrix
  85667. * @returns the current updated quaternion
  85668. */
  85669. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  85670. /**
  85671. * Creates a new quaternion from a rotation matrix
  85672. * @param matrix defines the source matrix
  85673. * @returns a new quaternion created from the given rotation matrix values
  85674. */
  85675. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  85676. /**
  85677. * Updates the given quaternion with the given rotation matrix values
  85678. * @param matrix defines the source matrix
  85679. * @param result defines the target quaternion
  85680. */
  85681. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  85682. /**
  85683. * Returns the dot product (float) between the quaternions "left" and "right"
  85684. * @param left defines the left operand
  85685. * @param right defines the right operand
  85686. * @returns the dot product
  85687. */
  85688. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  85689. /**
  85690. * Checks if the two quaternions are close to each other
  85691. * @param quat0 defines the first quaternion to check
  85692. * @param quat1 defines the second quaternion to check
  85693. * @returns true if the two quaternions are close to each other
  85694. */
  85695. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  85696. /**
  85697. * Creates an empty quaternion
  85698. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  85699. */
  85700. static Zero(): Quaternion;
  85701. /**
  85702. * Inverse a given quaternion
  85703. * @param q defines the source quaternion
  85704. * @returns a new quaternion as the inverted current quaternion
  85705. */
  85706. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  85707. /**
  85708. * Inverse a given quaternion
  85709. * @param q defines the source quaternion
  85710. * @param result the quaternion the result will be stored in
  85711. * @returns the result quaternion
  85712. */
  85713. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  85714. /**
  85715. * Creates an identity quaternion
  85716. * @returns the identity quaternion
  85717. */
  85718. static Identity(): Quaternion;
  85719. /**
  85720. * Gets a boolean indicating if the given quaternion is identity
  85721. * @param quaternion defines the quaternion to check
  85722. * @returns true if the quaternion is identity
  85723. */
  85724. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  85725. /**
  85726. * Creates a quaternion from a rotation around an axis
  85727. * @param axis defines the axis to use
  85728. * @param angle defines the angle to use
  85729. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  85730. */
  85731. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  85732. /**
  85733. * Creates a rotation around an axis and stores it into the given quaternion
  85734. * @param axis defines the axis to use
  85735. * @param angle defines the angle to use
  85736. * @param result defines the target quaternion
  85737. * @returns the target quaternion
  85738. */
  85739. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  85740. /**
  85741. * Creates a new quaternion from data stored into an array
  85742. * @param array defines the data source
  85743. * @param offset defines the offset in the source array where the data starts
  85744. * @returns a new quaternion
  85745. */
  85746. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  85747. /**
  85748. * Updates the given quaternion "result" from the starting index of the given array.
  85749. * @param array the array to pull values from
  85750. * @param offset the offset into the array to start at
  85751. * @param result the quaternion to store the result in
  85752. */
  85753. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  85754. /**
  85755. * Create a quaternion from Euler rotation angles
  85756. * @param x Pitch
  85757. * @param y Yaw
  85758. * @param z Roll
  85759. * @returns the new Quaternion
  85760. */
  85761. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  85762. /**
  85763. * Updates a quaternion from Euler rotation angles
  85764. * @param x Pitch
  85765. * @param y Yaw
  85766. * @param z Roll
  85767. * @param result the quaternion to store the result
  85768. * @returns the updated quaternion
  85769. */
  85770. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  85771. /**
  85772. * Create a quaternion from Euler rotation vector
  85773. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  85774. * @returns the new Quaternion
  85775. */
  85776. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  85777. /**
  85778. * Updates a quaternion from Euler rotation vector
  85779. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  85780. * @param result the quaternion to store the result
  85781. * @returns the updated quaternion
  85782. */
  85783. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  85784. /**
  85785. * Creates a new quaternion from the given Euler float angles (y, x, z)
  85786. * @param yaw defines the rotation around Y axis
  85787. * @param pitch defines the rotation around X axis
  85788. * @param roll defines the rotation around Z axis
  85789. * @returns the new quaternion
  85790. */
  85791. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  85792. /**
  85793. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  85794. * @param yaw defines the rotation around Y axis
  85795. * @param pitch defines the rotation around X axis
  85796. * @param roll defines the rotation around Z axis
  85797. * @param result defines the target quaternion
  85798. */
  85799. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  85800. /**
  85801. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  85802. * @param alpha defines the rotation around first axis
  85803. * @param beta defines the rotation around second axis
  85804. * @param gamma defines the rotation around third axis
  85805. * @returns the new quaternion
  85806. */
  85807. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  85808. /**
  85809. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  85810. * @param alpha defines the rotation around first axis
  85811. * @param beta defines the rotation around second axis
  85812. * @param gamma defines the rotation around third axis
  85813. * @param result defines the target quaternion
  85814. */
  85815. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  85816. /**
  85817. * 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)
  85818. * @param axis1 defines the first axis
  85819. * @param axis2 defines the second axis
  85820. * @param axis3 defines the third axis
  85821. * @returns the new quaternion
  85822. */
  85823. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  85824. /**
  85825. * 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
  85826. * @param axis1 defines the first axis
  85827. * @param axis2 defines the second axis
  85828. * @param axis3 defines the third axis
  85829. * @param ref defines the target quaternion
  85830. */
  85831. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  85832. /**
  85833. * Interpolates between two quaternions
  85834. * @param left defines first quaternion
  85835. * @param right defines second quaternion
  85836. * @param amount defines the gradient to use
  85837. * @returns the new interpolated quaternion
  85838. */
  85839. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  85840. /**
  85841. * Interpolates between two quaternions and stores it into a target quaternion
  85842. * @param left defines first quaternion
  85843. * @param right defines second quaternion
  85844. * @param amount defines the gradient to use
  85845. * @param result defines the target quaternion
  85846. */
  85847. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  85848. /**
  85849. * Interpolate between two quaternions using Hermite interpolation
  85850. * @param value1 defines first quaternion
  85851. * @param tangent1 defines the incoming tangent
  85852. * @param value2 defines second quaternion
  85853. * @param tangent2 defines the outgoing tangent
  85854. * @param amount defines the target quaternion
  85855. * @returns the new interpolated quaternion
  85856. */
  85857. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  85858. }
  85859. /**
  85860. * Class used to store matrix data (4x4)
  85861. */
  85862. export class Matrix {
  85863. /**
  85864. * Gets the precision of matrix computations
  85865. */
  85866. static get Use64Bits(): boolean;
  85867. private static _updateFlagSeed;
  85868. private static _identityReadOnly;
  85869. private _isIdentity;
  85870. private _isIdentityDirty;
  85871. private _isIdentity3x2;
  85872. private _isIdentity3x2Dirty;
  85873. /**
  85874. * Gets the update flag of the matrix which is an unique number for the matrix.
  85875. * It will be incremented every time the matrix data change.
  85876. * You can use it to speed the comparison between two versions of the same matrix.
  85877. */
  85878. updateFlag: number;
  85879. private readonly _m;
  85880. /**
  85881. * Gets the internal data of the matrix
  85882. */
  85883. get m(): DeepImmutable<Float32Array | Array<number>>;
  85884. /** @hidden */
  85885. _markAsUpdated(): void;
  85886. /** @hidden */
  85887. private _updateIdentityStatus;
  85888. /**
  85889. * Creates an empty matrix (filled with zeros)
  85890. */
  85891. constructor();
  85892. /**
  85893. * Check if the current matrix is identity
  85894. * @returns true is the matrix is the identity matrix
  85895. */
  85896. isIdentity(): boolean;
  85897. /**
  85898. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  85899. * @returns true is the matrix is the identity matrix
  85900. */
  85901. isIdentityAs3x2(): boolean;
  85902. /**
  85903. * Gets the determinant of the matrix
  85904. * @returns the matrix determinant
  85905. */
  85906. determinant(): number;
  85907. /**
  85908. * Returns the matrix as a Float32Array or Array<number>
  85909. * @returns the matrix underlying array
  85910. */
  85911. toArray(): DeepImmutable<Float32Array | Array<number>>;
  85912. /**
  85913. * Returns the matrix as a Float32Array or Array<number>
  85914. * @returns the matrix underlying array.
  85915. */
  85916. asArray(): DeepImmutable<Float32Array | Array<number>>;
  85917. /**
  85918. * Inverts the current matrix in place
  85919. * @returns the current inverted matrix
  85920. */
  85921. invert(): Matrix;
  85922. /**
  85923. * Sets all the matrix elements to zero
  85924. * @returns the current matrix
  85925. */
  85926. reset(): Matrix;
  85927. /**
  85928. * Adds the current matrix with a second one
  85929. * @param other defines the matrix to add
  85930. * @returns a new matrix as the addition of the current matrix and the given one
  85931. */
  85932. add(other: DeepImmutable<Matrix>): Matrix;
  85933. /**
  85934. * Sets the given matrix "result" to the addition of the current matrix and the given one
  85935. * @param other defines the matrix to add
  85936. * @param result defines the target matrix
  85937. * @returns the current matrix
  85938. */
  85939. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  85940. /**
  85941. * Adds in place the given matrix to the current matrix
  85942. * @param other defines the second operand
  85943. * @returns the current updated matrix
  85944. */
  85945. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  85946. /**
  85947. * Sets the given matrix to the current inverted Matrix
  85948. * @param other defines the target matrix
  85949. * @returns the unmodified current matrix
  85950. */
  85951. invertToRef(other: Matrix): Matrix;
  85952. /**
  85953. * add a value at the specified position in the current Matrix
  85954. * @param index the index of the value within the matrix. between 0 and 15.
  85955. * @param value the value to be added
  85956. * @returns the current updated matrix
  85957. */
  85958. addAtIndex(index: number, value: number): Matrix;
  85959. /**
  85960. * mutiply the specified position in the current Matrix by a value
  85961. * @param index the index of the value within the matrix. between 0 and 15.
  85962. * @param value the value to be added
  85963. * @returns the current updated matrix
  85964. */
  85965. multiplyAtIndex(index: number, value: number): Matrix;
  85966. /**
  85967. * Inserts the translation vector (using 3 floats) in the current matrix
  85968. * @param x defines the 1st component of the translation
  85969. * @param y defines the 2nd component of the translation
  85970. * @param z defines the 3rd component of the translation
  85971. * @returns the current updated matrix
  85972. */
  85973. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  85974. /**
  85975. * Adds the translation vector (using 3 floats) in the current matrix
  85976. * @param x defines the 1st component of the translation
  85977. * @param y defines the 2nd component of the translation
  85978. * @param z defines the 3rd component of the translation
  85979. * @returns the current updated matrix
  85980. */
  85981. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  85982. /**
  85983. * Inserts the translation vector in the current matrix
  85984. * @param vector3 defines the translation to insert
  85985. * @returns the current updated matrix
  85986. */
  85987. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  85988. /**
  85989. * Gets the translation value of the current matrix
  85990. * @returns a new Vector3 as the extracted translation from the matrix
  85991. */
  85992. getTranslation(): Vector3;
  85993. /**
  85994. * Fill a Vector3 with the extracted translation from the matrix
  85995. * @param result defines the Vector3 where to store the translation
  85996. * @returns the current matrix
  85997. */
  85998. getTranslationToRef(result: Vector3): Matrix;
  85999. /**
  86000. * Remove rotation and scaling part from the matrix
  86001. * @returns the updated matrix
  86002. */
  86003. removeRotationAndScaling(): Matrix;
  86004. /**
  86005. * Multiply two matrices
  86006. * @param other defines the second operand
  86007. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  86008. */
  86009. multiply(other: DeepImmutable<Matrix>): Matrix;
  86010. /**
  86011. * Copy the current matrix from the given one
  86012. * @param other defines the source matrix
  86013. * @returns the current updated matrix
  86014. */
  86015. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  86016. /**
  86017. * Populates the given array from the starting index with the current matrix values
  86018. * @param array defines the target array
  86019. * @param offset defines the offset in the target array where to start storing values
  86020. * @returns the current matrix
  86021. */
  86022. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  86023. /**
  86024. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  86025. * @param other defines the second operand
  86026. * @param result defines the matrix where to store the multiplication
  86027. * @returns the current matrix
  86028. */
  86029. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  86030. /**
  86031. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  86032. * @param other defines the second operand
  86033. * @param result defines the array where to store the multiplication
  86034. * @param offset defines the offset in the target array where to start storing values
  86035. * @returns the current matrix
  86036. */
  86037. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  86038. /**
  86039. * Check equality between this matrix and a second one
  86040. * @param value defines the second matrix to compare
  86041. * @returns true is the current matrix and the given one values are strictly equal
  86042. */
  86043. equals(value: DeepImmutable<Matrix>): boolean;
  86044. /**
  86045. * Clone the current matrix
  86046. * @returns a new matrix from the current matrix
  86047. */
  86048. clone(): Matrix;
  86049. /**
  86050. * Returns the name of the current matrix class
  86051. * @returns the string "Matrix"
  86052. */
  86053. getClassName(): string;
  86054. /**
  86055. * Gets the hash code of the current matrix
  86056. * @returns the hash code
  86057. */
  86058. getHashCode(): number;
  86059. /**
  86060. * Decomposes the current Matrix into a translation, rotation and scaling components
  86061. * @param scale defines the scale vector3 given as a reference to update
  86062. * @param rotation defines the rotation quaternion given as a reference to update
  86063. * @param translation defines the translation vector3 given as a reference to update
  86064. * @returns true if operation was successful
  86065. */
  86066. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  86067. /**
  86068. * Gets specific row of the matrix
  86069. * @param index defines the number of the row to get
  86070. * @returns the index-th row of the current matrix as a new Vector4
  86071. */
  86072. getRow(index: number): Nullable<Vector4>;
  86073. /**
  86074. * Sets the index-th row of the current matrix to the vector4 values
  86075. * @param index defines the number of the row to set
  86076. * @param row defines the target vector4
  86077. * @returns the updated current matrix
  86078. */
  86079. setRow(index: number, row: Vector4): Matrix;
  86080. /**
  86081. * Compute the transpose of the matrix
  86082. * @returns the new transposed matrix
  86083. */
  86084. transpose(): Matrix;
  86085. /**
  86086. * Compute the transpose of the matrix and store it in a given matrix
  86087. * @param result defines the target matrix
  86088. * @returns the current matrix
  86089. */
  86090. transposeToRef(result: Matrix): Matrix;
  86091. /**
  86092. * Sets the index-th row of the current matrix with the given 4 x float values
  86093. * @param index defines the row index
  86094. * @param x defines the x component to set
  86095. * @param y defines the y component to set
  86096. * @param z defines the z component to set
  86097. * @param w defines the w component to set
  86098. * @returns the updated current matrix
  86099. */
  86100. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  86101. /**
  86102. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  86103. * @param scale defines the scale factor
  86104. * @returns a new matrix
  86105. */
  86106. scale(scale: number): Matrix;
  86107. /**
  86108. * Scale the current matrix values by a factor to a given result matrix
  86109. * @param scale defines the scale factor
  86110. * @param result defines the matrix to store the result
  86111. * @returns the current matrix
  86112. */
  86113. scaleToRef(scale: number, result: Matrix): Matrix;
  86114. /**
  86115. * Scale the current matrix values by a factor and add the result to a given matrix
  86116. * @param scale defines the scale factor
  86117. * @param result defines the Matrix to store the result
  86118. * @returns the current matrix
  86119. */
  86120. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  86121. /**
  86122. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  86123. * @param ref matrix to store the result
  86124. */
  86125. toNormalMatrix(ref: Matrix): void;
  86126. /**
  86127. * Gets only rotation part of the current matrix
  86128. * @returns a new matrix sets to the extracted rotation matrix from the current one
  86129. */
  86130. getRotationMatrix(): Matrix;
  86131. /**
  86132. * Extracts the rotation matrix from the current one and sets it as the given "result"
  86133. * @param result defines the target matrix to store data to
  86134. * @returns the current matrix
  86135. */
  86136. getRotationMatrixToRef(result: Matrix): Matrix;
  86137. /**
  86138. * Toggles model matrix from being right handed to left handed in place and vice versa
  86139. */
  86140. toggleModelMatrixHandInPlace(): void;
  86141. /**
  86142. * Toggles projection matrix from being right handed to left handed in place and vice versa
  86143. */
  86144. toggleProjectionMatrixHandInPlace(): void;
  86145. /**
  86146. * Creates a matrix from an array
  86147. * @param array defines the source array
  86148. * @param offset defines an offset in the source array
  86149. * @returns a new Matrix set from the starting index of the given array
  86150. */
  86151. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  86152. /**
  86153. * Copy the content of an array into a given matrix
  86154. * @param array defines the source array
  86155. * @param offset defines an offset in the source array
  86156. * @param result defines the target matrix
  86157. */
  86158. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  86159. /**
  86160. * Stores an array into a matrix after having multiplied each component by a given factor
  86161. * @param array defines the source array
  86162. * @param offset defines the offset in the source array
  86163. * @param scale defines the scaling factor
  86164. * @param result defines the target matrix
  86165. */
  86166. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  86167. /**
  86168. * Gets an identity matrix that must not be updated
  86169. */
  86170. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  86171. /**
  86172. * Stores a list of values (16) inside a given matrix
  86173. * @param initialM11 defines 1st value of 1st row
  86174. * @param initialM12 defines 2nd value of 1st row
  86175. * @param initialM13 defines 3rd value of 1st row
  86176. * @param initialM14 defines 4th value of 1st row
  86177. * @param initialM21 defines 1st value of 2nd row
  86178. * @param initialM22 defines 2nd value of 2nd row
  86179. * @param initialM23 defines 3rd value of 2nd row
  86180. * @param initialM24 defines 4th value of 2nd row
  86181. * @param initialM31 defines 1st value of 3rd row
  86182. * @param initialM32 defines 2nd value of 3rd row
  86183. * @param initialM33 defines 3rd value of 3rd row
  86184. * @param initialM34 defines 4th value of 3rd row
  86185. * @param initialM41 defines 1st value of 4th row
  86186. * @param initialM42 defines 2nd value of 4th row
  86187. * @param initialM43 defines 3rd value of 4th row
  86188. * @param initialM44 defines 4th value of 4th row
  86189. * @param result defines the target matrix
  86190. */
  86191. 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;
  86192. /**
  86193. * Creates new matrix from a list of values (16)
  86194. * @param initialM11 defines 1st value of 1st row
  86195. * @param initialM12 defines 2nd value of 1st row
  86196. * @param initialM13 defines 3rd value of 1st row
  86197. * @param initialM14 defines 4th value of 1st row
  86198. * @param initialM21 defines 1st value of 2nd row
  86199. * @param initialM22 defines 2nd value of 2nd row
  86200. * @param initialM23 defines 3rd value of 2nd row
  86201. * @param initialM24 defines 4th value of 2nd row
  86202. * @param initialM31 defines 1st value of 3rd row
  86203. * @param initialM32 defines 2nd value of 3rd row
  86204. * @param initialM33 defines 3rd value of 3rd row
  86205. * @param initialM34 defines 4th value of 3rd row
  86206. * @param initialM41 defines 1st value of 4th row
  86207. * @param initialM42 defines 2nd value of 4th row
  86208. * @param initialM43 defines 3rd value of 4th row
  86209. * @param initialM44 defines 4th value of 4th row
  86210. * @returns the new matrix
  86211. */
  86212. 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;
  86213. /**
  86214. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  86215. * @param scale defines the scale vector3
  86216. * @param rotation defines the rotation quaternion
  86217. * @param translation defines the translation vector3
  86218. * @returns a new matrix
  86219. */
  86220. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  86221. /**
  86222. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  86223. * @param scale defines the scale vector3
  86224. * @param rotation defines the rotation quaternion
  86225. * @param translation defines the translation vector3
  86226. * @param result defines the target matrix
  86227. */
  86228. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  86229. /**
  86230. * Creates a new identity matrix
  86231. * @returns a new identity matrix
  86232. */
  86233. static Identity(): Matrix;
  86234. /**
  86235. * Creates a new identity matrix and stores the result in a given matrix
  86236. * @param result defines the target matrix
  86237. */
  86238. static IdentityToRef(result: Matrix): void;
  86239. /**
  86240. * Creates a new zero matrix
  86241. * @returns a new zero matrix
  86242. */
  86243. static Zero(): Matrix;
  86244. /**
  86245. * Creates a new rotation matrix for "angle" radians around the X axis
  86246. * @param angle defines the angle (in radians) to use
  86247. * @return the new matrix
  86248. */
  86249. static RotationX(angle: number): Matrix;
  86250. /**
  86251. * Creates a new matrix as the invert of a given matrix
  86252. * @param source defines the source matrix
  86253. * @returns the new matrix
  86254. */
  86255. static Invert(source: DeepImmutable<Matrix>): Matrix;
  86256. /**
  86257. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  86258. * @param angle defines the angle (in radians) to use
  86259. * @param result defines the target matrix
  86260. */
  86261. static RotationXToRef(angle: number, result: Matrix): void;
  86262. /**
  86263. * Creates a new rotation matrix for "angle" radians around the Y axis
  86264. * @param angle defines the angle (in radians) to use
  86265. * @return the new matrix
  86266. */
  86267. static RotationY(angle: number): Matrix;
  86268. /**
  86269. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  86270. * @param angle defines the angle (in radians) to use
  86271. * @param result defines the target matrix
  86272. */
  86273. static RotationYToRef(angle: number, result: Matrix): void;
  86274. /**
  86275. * Creates a new rotation matrix for "angle" radians around the Z axis
  86276. * @param angle defines the angle (in radians) to use
  86277. * @return the new matrix
  86278. */
  86279. static RotationZ(angle: number): Matrix;
  86280. /**
  86281. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  86282. * @param angle defines the angle (in radians) to use
  86283. * @param result defines the target matrix
  86284. */
  86285. static RotationZToRef(angle: number, result: Matrix): void;
  86286. /**
  86287. * Creates a new rotation matrix for "angle" radians around the given axis
  86288. * @param axis defines the axis to use
  86289. * @param angle defines the angle (in radians) to use
  86290. * @return the new matrix
  86291. */
  86292. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  86293. /**
  86294. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  86295. * @param axis defines the axis to use
  86296. * @param angle defines the angle (in radians) to use
  86297. * @param result defines the target matrix
  86298. */
  86299. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  86300. /**
  86301. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  86302. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  86303. * @param from defines the vector to align
  86304. * @param to defines the vector to align to
  86305. * @param result defines the target matrix
  86306. */
  86307. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  86308. /**
  86309. * Creates a rotation matrix
  86310. * @param yaw defines the yaw angle in radians (Y axis)
  86311. * @param pitch defines the pitch angle in radians (X axis)
  86312. * @param roll defines the roll angle in radians (Z axis)
  86313. * @returns the new rotation matrix
  86314. */
  86315. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  86316. /**
  86317. * Creates a rotation matrix and stores it in a given matrix
  86318. * @param yaw defines the yaw angle in radians (Y axis)
  86319. * @param pitch defines the pitch angle in radians (X axis)
  86320. * @param roll defines the roll angle in radians (Z axis)
  86321. * @param result defines the target matrix
  86322. */
  86323. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  86324. /**
  86325. * Creates a scaling matrix
  86326. * @param x defines the scale factor on X axis
  86327. * @param y defines the scale factor on Y axis
  86328. * @param z defines the scale factor on Z axis
  86329. * @returns the new matrix
  86330. */
  86331. static Scaling(x: number, y: number, z: number): Matrix;
  86332. /**
  86333. * Creates a scaling matrix and stores it in a given matrix
  86334. * @param x defines the scale factor on X axis
  86335. * @param y defines the scale factor on Y axis
  86336. * @param z defines the scale factor on Z axis
  86337. * @param result defines the target matrix
  86338. */
  86339. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  86340. /**
  86341. * Creates a translation matrix
  86342. * @param x defines the translation on X axis
  86343. * @param y defines the translation on Y axis
  86344. * @param z defines the translationon Z axis
  86345. * @returns the new matrix
  86346. */
  86347. static Translation(x: number, y: number, z: number): Matrix;
  86348. /**
  86349. * Creates a translation matrix and stores it in a given matrix
  86350. * @param x defines the translation on X axis
  86351. * @param y defines the translation on Y axis
  86352. * @param z defines the translationon Z axis
  86353. * @param result defines the target matrix
  86354. */
  86355. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  86356. /**
  86357. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  86358. * @param startValue defines the start value
  86359. * @param endValue defines the end value
  86360. * @param gradient defines the gradient factor
  86361. * @returns the new matrix
  86362. */
  86363. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  86364. /**
  86365. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  86366. * @param startValue defines the start value
  86367. * @param endValue defines the end value
  86368. * @param gradient defines the gradient factor
  86369. * @param result defines the Matrix object where to store data
  86370. */
  86371. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  86372. /**
  86373. * Builds a new matrix whose values are computed by:
  86374. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  86375. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  86376. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  86377. * @param startValue defines the first matrix
  86378. * @param endValue defines the second matrix
  86379. * @param gradient defines the gradient between the two matrices
  86380. * @returns the new matrix
  86381. */
  86382. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  86383. /**
  86384. * Update a matrix to values which are computed by:
  86385. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  86386. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  86387. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  86388. * @param startValue defines the first matrix
  86389. * @param endValue defines the second matrix
  86390. * @param gradient defines the gradient between the two matrices
  86391. * @param result defines the target matrix
  86392. */
  86393. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  86394. /**
  86395. * 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"
  86396. * This function works in left handed mode
  86397. * @param eye defines the final position of the entity
  86398. * @param target defines where the entity should look at
  86399. * @param up defines the up vector for the entity
  86400. * @returns the new matrix
  86401. */
  86402. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  86403. /**
  86404. * 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".
  86405. * This function works in left handed mode
  86406. * @param eye defines the final position of the entity
  86407. * @param target defines where the entity should look at
  86408. * @param up defines the up vector for the entity
  86409. * @param result defines the target matrix
  86410. */
  86411. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  86412. /**
  86413. * 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"
  86414. * This function works in right handed mode
  86415. * @param eye defines the final position of the entity
  86416. * @param target defines where the entity should look at
  86417. * @param up defines the up vector for the entity
  86418. * @returns the new matrix
  86419. */
  86420. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  86421. /**
  86422. * 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".
  86423. * This function works in right handed mode
  86424. * @param eye defines the final position of the entity
  86425. * @param target defines where the entity should look at
  86426. * @param up defines the up vector for the entity
  86427. * @param result defines the target matrix
  86428. */
  86429. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  86430. /**
  86431. * Create a left-handed orthographic projection matrix
  86432. * @param width defines the viewport width
  86433. * @param height defines the viewport height
  86434. * @param znear defines the near clip plane
  86435. * @param zfar defines the far clip plane
  86436. * @returns a new matrix as a left-handed orthographic projection matrix
  86437. */
  86438. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  86439. /**
  86440. * Store a left-handed orthographic projection to a given matrix
  86441. * @param width defines the viewport width
  86442. * @param height defines the viewport height
  86443. * @param znear defines the near clip plane
  86444. * @param zfar defines the far clip plane
  86445. * @param result defines the target matrix
  86446. */
  86447. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  86448. /**
  86449. * Create a left-handed orthographic projection matrix
  86450. * @param left defines the viewport left coordinate
  86451. * @param right defines the viewport right coordinate
  86452. * @param bottom defines the viewport bottom coordinate
  86453. * @param top defines the viewport top coordinate
  86454. * @param znear defines the near clip plane
  86455. * @param zfar defines the far clip plane
  86456. * @returns a new matrix as a left-handed orthographic projection matrix
  86457. */
  86458. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  86459. /**
  86460. * Stores a left-handed orthographic projection into a given matrix
  86461. * @param left defines the viewport left coordinate
  86462. * @param right defines the viewport right coordinate
  86463. * @param bottom defines the viewport bottom coordinate
  86464. * @param top defines the viewport top coordinate
  86465. * @param znear defines the near clip plane
  86466. * @param zfar defines the far clip plane
  86467. * @param result defines the target matrix
  86468. */
  86469. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  86470. /**
  86471. * Creates a right-handed orthographic projection matrix
  86472. * @param left defines the viewport left coordinate
  86473. * @param right defines the viewport right coordinate
  86474. * @param bottom defines the viewport bottom coordinate
  86475. * @param top defines the viewport top coordinate
  86476. * @param znear defines the near clip plane
  86477. * @param zfar defines the far clip plane
  86478. * @returns a new matrix as a right-handed orthographic projection matrix
  86479. */
  86480. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  86481. /**
  86482. * Stores a right-handed orthographic projection into a given matrix
  86483. * @param left defines the viewport left coordinate
  86484. * @param right defines the viewport right coordinate
  86485. * @param bottom defines the viewport bottom coordinate
  86486. * @param top defines the viewport top coordinate
  86487. * @param znear defines the near clip plane
  86488. * @param zfar defines the far clip plane
  86489. * @param result defines the target matrix
  86490. */
  86491. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  86492. /**
  86493. * Creates a left-handed perspective projection matrix
  86494. * @param width defines the viewport width
  86495. * @param height defines the viewport height
  86496. * @param znear defines the near clip plane
  86497. * @param zfar defines the far clip plane
  86498. * @returns a new matrix as a left-handed perspective projection matrix
  86499. */
  86500. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  86501. /**
  86502. * Creates a left-handed perspective projection matrix
  86503. * @param fov defines the horizontal field of view
  86504. * @param aspect defines the aspect ratio
  86505. * @param znear defines the near clip plane
  86506. * @param zfar defines the far clip plane
  86507. * @returns a new matrix as a left-handed perspective projection matrix
  86508. */
  86509. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  86510. /**
  86511. * Stores a left-handed perspective projection into a given matrix
  86512. * @param fov defines the horizontal field of view
  86513. * @param aspect defines the aspect ratio
  86514. * @param znear defines the near clip plane
  86515. * @param zfar defines the far clip plane
  86516. * @param result defines the target matrix
  86517. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86518. */
  86519. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86520. /**
  86521. * Stores a left-handed perspective projection into a given matrix with depth reversed
  86522. * @param fov defines the horizontal field of view
  86523. * @param aspect defines the aspect ratio
  86524. * @param znear defines the near clip plane
  86525. * @param zfar not used as infinity is used as far clip
  86526. * @param result defines the target matrix
  86527. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86528. */
  86529. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86530. /**
  86531. * Creates a right-handed perspective projection matrix
  86532. * @param fov defines the horizontal field of view
  86533. * @param aspect defines the aspect ratio
  86534. * @param znear defines the near clip plane
  86535. * @param zfar defines the far clip plane
  86536. * @returns a new matrix as a right-handed perspective projection matrix
  86537. */
  86538. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  86539. /**
  86540. * Stores a right-handed perspective projection into a given matrix
  86541. * @param fov defines the horizontal field of view
  86542. * @param aspect defines the aspect ratio
  86543. * @param znear defines the near clip plane
  86544. * @param zfar defines the far clip plane
  86545. * @param result defines the target matrix
  86546. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86547. */
  86548. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86549. /**
  86550. * Stores a right-handed perspective projection into a given matrix
  86551. * @param fov defines the horizontal field of view
  86552. * @param aspect defines the aspect ratio
  86553. * @param znear defines the near clip plane
  86554. * @param zfar not used as infinity is used as far clip
  86555. * @param result defines the target matrix
  86556. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86557. */
  86558. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86559. /**
  86560. * Stores a perspective projection for WebVR info a given matrix
  86561. * @param fov defines the field of view
  86562. * @param znear defines the near clip plane
  86563. * @param zfar defines the far clip plane
  86564. * @param result defines the target matrix
  86565. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  86566. */
  86567. static PerspectiveFovWebVRToRef(fov: {
  86568. upDegrees: number;
  86569. downDegrees: number;
  86570. leftDegrees: number;
  86571. rightDegrees: number;
  86572. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  86573. /**
  86574. * Computes a complete transformation matrix
  86575. * @param viewport defines the viewport to use
  86576. * @param world defines the world matrix
  86577. * @param view defines the view matrix
  86578. * @param projection defines the projection matrix
  86579. * @param zmin defines the near clip plane
  86580. * @param zmax defines the far clip plane
  86581. * @returns the transformation matrix
  86582. */
  86583. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  86584. /**
  86585. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  86586. * @param matrix defines the matrix to use
  86587. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  86588. */
  86589. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  86590. /**
  86591. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  86592. * @param matrix defines the matrix to use
  86593. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  86594. */
  86595. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  86596. /**
  86597. * Compute the transpose of a given matrix
  86598. * @param matrix defines the matrix to transpose
  86599. * @returns the new matrix
  86600. */
  86601. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  86602. /**
  86603. * Compute the transpose of a matrix and store it in a target matrix
  86604. * @param matrix defines the matrix to transpose
  86605. * @param result defines the target matrix
  86606. */
  86607. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  86608. /**
  86609. * Computes a reflection matrix from a plane
  86610. * @param plane defines the reflection plane
  86611. * @returns a new matrix
  86612. */
  86613. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  86614. /**
  86615. * Computes a reflection matrix from a plane
  86616. * @param plane defines the reflection plane
  86617. * @param result defines the target matrix
  86618. */
  86619. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  86620. /**
  86621. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  86622. * @param xaxis defines the value of the 1st axis
  86623. * @param yaxis defines the value of the 2nd axis
  86624. * @param zaxis defines the value of the 3rd axis
  86625. * @param result defines the target matrix
  86626. */
  86627. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  86628. /**
  86629. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  86630. * @param quat defines the quaternion to use
  86631. * @param result defines the target matrix
  86632. */
  86633. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  86634. }
  86635. /**
  86636. * @hidden
  86637. */
  86638. export class TmpVectors {
  86639. static Vector2: Vector2[];
  86640. static Vector3: Vector3[];
  86641. static Vector4: Vector4[];
  86642. static Quaternion: Quaternion[];
  86643. static Matrix: Matrix[];
  86644. }
  86645. }
  86646. declare module BABYLON {
  86647. /**
  86648. * Defines potential orientation for back face culling
  86649. */
  86650. export enum Orientation {
  86651. /**
  86652. * Clockwise
  86653. */
  86654. CW = 0,
  86655. /** Counter clockwise */
  86656. CCW = 1
  86657. }
  86658. /** Class used to represent a Bezier curve */
  86659. export class BezierCurve {
  86660. /**
  86661. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  86662. * @param t defines the time
  86663. * @param x1 defines the left coordinate on X axis
  86664. * @param y1 defines the left coordinate on Y axis
  86665. * @param x2 defines the right coordinate on X axis
  86666. * @param y2 defines the right coordinate on Y axis
  86667. * @returns the interpolated value
  86668. */
  86669. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  86670. }
  86671. /**
  86672. * Defines angle representation
  86673. */
  86674. export class Angle {
  86675. private _radians;
  86676. /**
  86677. * Creates an Angle object of "radians" radians (float).
  86678. * @param radians the angle in radians
  86679. */
  86680. constructor(radians: number);
  86681. /**
  86682. * Get value in degrees
  86683. * @returns the Angle value in degrees (float)
  86684. */
  86685. degrees(): number;
  86686. /**
  86687. * Get value in radians
  86688. * @returns the Angle value in radians (float)
  86689. */
  86690. radians(): number;
  86691. /**
  86692. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  86693. * @param a defines first point as the origin
  86694. * @param b defines point
  86695. * @returns a new Angle
  86696. */
  86697. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  86698. /**
  86699. * Gets a new Angle object from the given float in radians
  86700. * @param radians defines the angle value in radians
  86701. * @returns a new Angle
  86702. */
  86703. static FromRadians(radians: number): Angle;
  86704. /**
  86705. * Gets a new Angle object from the given float in degrees
  86706. * @param degrees defines the angle value in degrees
  86707. * @returns a new Angle
  86708. */
  86709. static FromDegrees(degrees: number): Angle;
  86710. }
  86711. /**
  86712. * This represents an arc in a 2d space.
  86713. */
  86714. export class Arc2 {
  86715. /** Defines the start point of the arc */
  86716. startPoint: Vector2;
  86717. /** Defines the mid point of the arc */
  86718. midPoint: Vector2;
  86719. /** Defines the end point of the arc */
  86720. endPoint: Vector2;
  86721. /**
  86722. * Defines the center point of the arc.
  86723. */
  86724. centerPoint: Vector2;
  86725. /**
  86726. * Defines the radius of the arc.
  86727. */
  86728. radius: number;
  86729. /**
  86730. * Defines the angle of the arc (from mid point to end point).
  86731. */
  86732. angle: Angle;
  86733. /**
  86734. * Defines the start angle of the arc (from start point to middle point).
  86735. */
  86736. startAngle: Angle;
  86737. /**
  86738. * Defines the orientation of the arc (clock wise/counter clock wise).
  86739. */
  86740. orientation: Orientation;
  86741. /**
  86742. * Creates an Arc object from the three given points : start, middle and end.
  86743. * @param startPoint Defines the start point of the arc
  86744. * @param midPoint Defines the midlle point of the arc
  86745. * @param endPoint Defines the end point of the arc
  86746. */
  86747. constructor(
  86748. /** Defines the start point of the arc */
  86749. startPoint: Vector2,
  86750. /** Defines the mid point of the arc */
  86751. midPoint: Vector2,
  86752. /** Defines the end point of the arc */
  86753. endPoint: Vector2);
  86754. }
  86755. /**
  86756. * Represents a 2D path made up of multiple 2D points
  86757. */
  86758. export class Path2 {
  86759. private _points;
  86760. private _length;
  86761. /**
  86762. * If the path start and end point are the same
  86763. */
  86764. closed: boolean;
  86765. /**
  86766. * Creates a Path2 object from the starting 2D coordinates x and y.
  86767. * @param x the starting points x value
  86768. * @param y the starting points y value
  86769. */
  86770. constructor(x: number, y: number);
  86771. /**
  86772. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  86773. * @param x the added points x value
  86774. * @param y the added points y value
  86775. * @returns the updated Path2.
  86776. */
  86777. addLineTo(x: number, y: number): Path2;
  86778. /**
  86779. * 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.
  86780. * @param midX middle point x value
  86781. * @param midY middle point y value
  86782. * @param endX end point x value
  86783. * @param endY end point y value
  86784. * @param numberOfSegments (default: 36)
  86785. * @returns the updated Path2.
  86786. */
  86787. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  86788. /**
  86789. * Closes the Path2.
  86790. * @returns the Path2.
  86791. */
  86792. close(): Path2;
  86793. /**
  86794. * Gets the sum of the distance between each sequential point in the path
  86795. * @returns the Path2 total length (float).
  86796. */
  86797. length(): number;
  86798. /**
  86799. * Gets the points which construct the path
  86800. * @returns the Path2 internal array of points.
  86801. */
  86802. getPoints(): Vector2[];
  86803. /**
  86804. * Retreives the point at the distance aways from the starting point
  86805. * @param normalizedLengthPosition the length along the path to retreive the point from
  86806. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  86807. */
  86808. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  86809. /**
  86810. * Creates a new path starting from an x and y position
  86811. * @param x starting x value
  86812. * @param y starting y value
  86813. * @returns a new Path2 starting at the coordinates (x, y).
  86814. */
  86815. static StartingAt(x: number, y: number): Path2;
  86816. }
  86817. /**
  86818. * Represents a 3D path made up of multiple 3D points
  86819. */
  86820. export class Path3D {
  86821. /**
  86822. * an array of Vector3, the curve axis of the Path3D
  86823. */
  86824. path: Vector3[];
  86825. private _curve;
  86826. private _distances;
  86827. private _tangents;
  86828. private _normals;
  86829. private _binormals;
  86830. private _raw;
  86831. private _alignTangentsWithPath;
  86832. private readonly _pointAtData;
  86833. /**
  86834. * new Path3D(path, normal, raw)
  86835. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  86836. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  86837. * @param path an array of Vector3, the curve axis of the Path3D
  86838. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  86839. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  86840. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  86841. */
  86842. constructor(
  86843. /**
  86844. * an array of Vector3, the curve axis of the Path3D
  86845. */
  86846. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  86847. /**
  86848. * Returns the Path3D array of successive Vector3 designing its curve.
  86849. * @returns the Path3D array of successive Vector3 designing its curve.
  86850. */
  86851. getCurve(): Vector3[];
  86852. /**
  86853. * Returns the Path3D array of successive Vector3 designing its curve.
  86854. * @returns the Path3D array of successive Vector3 designing its curve.
  86855. */
  86856. getPoints(): Vector3[];
  86857. /**
  86858. * @returns the computed length (float) of the path.
  86859. */
  86860. length(): number;
  86861. /**
  86862. * Returns an array populated with tangent vectors on each Path3D curve point.
  86863. * @returns an array populated with tangent vectors on each Path3D curve point.
  86864. */
  86865. getTangents(): Vector3[];
  86866. /**
  86867. * Returns an array populated with normal vectors on each Path3D curve point.
  86868. * @returns an array populated with normal vectors on each Path3D curve point.
  86869. */
  86870. getNormals(): Vector3[];
  86871. /**
  86872. * Returns an array populated with binormal vectors on each Path3D curve point.
  86873. * @returns an array populated with binormal vectors on each Path3D curve point.
  86874. */
  86875. getBinormals(): Vector3[];
  86876. /**
  86877. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  86878. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  86879. */
  86880. getDistances(): number[];
  86881. /**
  86882. * Returns an interpolated point along this path
  86883. * @param position the position of the point along this path, from 0.0 to 1.0
  86884. * @returns a new Vector3 as the point
  86885. */
  86886. getPointAt(position: number): Vector3;
  86887. /**
  86888. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  86889. * @param position the position of the point along this path, from 0.0 to 1.0
  86890. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  86891. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  86892. */
  86893. getTangentAt(position: number, interpolated?: boolean): Vector3;
  86894. /**
  86895. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  86896. * @param position the position of the point along this path, from 0.0 to 1.0
  86897. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  86898. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  86899. */
  86900. getNormalAt(position: number, interpolated?: boolean): Vector3;
  86901. /**
  86902. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  86903. * @param position the position of the point along this path, from 0.0 to 1.0
  86904. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  86905. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  86906. */
  86907. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  86908. /**
  86909. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  86910. * @param position the position of the point along this path, from 0.0 to 1.0
  86911. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  86912. */
  86913. getDistanceAt(position: number): number;
  86914. /**
  86915. * Returns the array index of the previous point of an interpolated point along this path
  86916. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  86917. * @returns the array index
  86918. */
  86919. getPreviousPointIndexAt(position: number): number;
  86920. /**
  86921. * 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)
  86922. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  86923. * @returns the sub position
  86924. */
  86925. getSubPositionAt(position: number): number;
  86926. /**
  86927. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  86928. * @param target the vector of which to get the closest position to
  86929. * @returns the position of the closest virtual point on this path to the target vector
  86930. */
  86931. getClosestPositionTo(target: Vector3): number;
  86932. /**
  86933. * Returns a sub path (slice) of this path
  86934. * @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
  86935. * @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
  86936. * @returns a sub path (slice) of this path
  86937. */
  86938. slice(start?: number, end?: number): Path3D;
  86939. /**
  86940. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  86941. * @param path path which all values are copied into the curves points
  86942. * @param firstNormal which should be projected onto the curve
  86943. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  86944. * @returns the same object updated.
  86945. */
  86946. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  86947. private _compute;
  86948. private _getFirstNonNullVector;
  86949. private _getLastNonNullVector;
  86950. private _normalVector;
  86951. /**
  86952. * Updates the point at data for an interpolated point along this curve
  86953. * @param position the position of the point along this curve, from 0.0 to 1.0
  86954. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  86955. * @returns the (updated) point at data
  86956. */
  86957. private _updatePointAtData;
  86958. /**
  86959. * Updates the point at data from the specified parameters
  86960. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  86961. * @param point the interpolated point
  86962. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  86963. */
  86964. private _setPointAtData;
  86965. /**
  86966. * Updates the point at interpolation matrix for the tangents, normals and binormals
  86967. */
  86968. private _updateInterpolationMatrix;
  86969. }
  86970. /**
  86971. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  86972. * A Curve3 is designed from a series of successive Vector3.
  86973. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  86974. */
  86975. export class Curve3 {
  86976. private _points;
  86977. private _length;
  86978. /**
  86979. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  86980. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  86981. * @param v1 (Vector3) the control point
  86982. * @param v2 (Vector3) the end point of the Quadratic Bezier
  86983. * @param nbPoints (integer) the wanted number of points in the curve
  86984. * @returns the created Curve3
  86985. */
  86986. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  86987. /**
  86988. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  86989. * @param v0 (Vector3) the origin point of the Cubic Bezier
  86990. * @param v1 (Vector3) the first control point
  86991. * @param v2 (Vector3) the second control point
  86992. * @param v3 (Vector3) the end point of the Cubic Bezier
  86993. * @param nbPoints (integer) the wanted number of points in the curve
  86994. * @returns the created Curve3
  86995. */
  86996. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  86997. /**
  86998. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  86999. * @param p1 (Vector3) the origin point of the Hermite Spline
  87000. * @param t1 (Vector3) the tangent vector at the origin point
  87001. * @param p2 (Vector3) the end point of the Hermite Spline
  87002. * @param t2 (Vector3) the tangent vector at the end point
  87003. * @param nbPoints (integer) the wanted number of points in the curve
  87004. * @returns the created Curve3
  87005. */
  87006. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  87007. /**
  87008. * Returns a Curve3 object along a CatmullRom Spline curve :
  87009. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  87010. * @param nbPoints (integer) the wanted number of points between each curve control points
  87011. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  87012. * @returns the created Curve3
  87013. */
  87014. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  87015. /**
  87016. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  87017. * A Curve3 is designed from a series of successive Vector3.
  87018. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  87019. * @param points points which make up the curve
  87020. */
  87021. constructor(points: Vector3[]);
  87022. /**
  87023. * @returns the Curve3 stored array of successive Vector3
  87024. */
  87025. getPoints(): Vector3[];
  87026. /**
  87027. * @returns the computed length (float) of the curve.
  87028. */
  87029. length(): number;
  87030. /**
  87031. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  87032. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  87033. * curveA and curveB keep unchanged.
  87034. * @param curve the curve to continue from this curve
  87035. * @returns the newly constructed curve
  87036. */
  87037. continue(curve: DeepImmutable<Curve3>): Curve3;
  87038. private _computeLength;
  87039. }
  87040. }
  87041. declare module BABYLON {
  87042. /**
  87043. * This represents the main contract an easing function should follow.
  87044. * Easing functions are used throughout the animation system.
  87045. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87046. */
  87047. export interface IEasingFunction {
  87048. /**
  87049. * Given an input gradient between 0 and 1, this returns the corrseponding value
  87050. * of the easing function.
  87051. * The link below provides some of the most common examples of easing functions.
  87052. * @see https://easings.net/
  87053. * @param gradient Defines the value between 0 and 1 we want the easing value for
  87054. * @returns the corresponding value on the curve defined by the easing function
  87055. */
  87056. ease(gradient: number): number;
  87057. }
  87058. /**
  87059. * Base class used for every default easing function.
  87060. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87061. */
  87062. export class EasingFunction implements IEasingFunction {
  87063. /**
  87064. * Interpolation follows the mathematical formula associated with the easing function.
  87065. */
  87066. static readonly EASINGMODE_EASEIN: number;
  87067. /**
  87068. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  87069. */
  87070. static readonly EASINGMODE_EASEOUT: number;
  87071. /**
  87072. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  87073. */
  87074. static readonly EASINGMODE_EASEINOUT: number;
  87075. private _easingMode;
  87076. /**
  87077. * Sets the easing mode of the current function.
  87078. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  87079. */
  87080. setEasingMode(easingMode: number): void;
  87081. /**
  87082. * Gets the current easing mode.
  87083. * @returns the easing mode
  87084. */
  87085. getEasingMode(): number;
  87086. /**
  87087. * @hidden
  87088. */
  87089. easeInCore(gradient: number): number;
  87090. /**
  87091. * Given an input gradient between 0 and 1, this returns the corresponding value
  87092. * of the easing function.
  87093. * @param gradient Defines the value between 0 and 1 we want the easing value for
  87094. * @returns the corresponding value on the curve defined by the easing function
  87095. */
  87096. ease(gradient: number): number;
  87097. }
  87098. /**
  87099. * Easing function with a circle shape (see link below).
  87100. * @see https://easings.net/#easeInCirc
  87101. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87102. */
  87103. export class CircleEase extends EasingFunction implements IEasingFunction {
  87104. /** @hidden */
  87105. easeInCore(gradient: number): number;
  87106. }
  87107. /**
  87108. * Easing function with a ease back shape (see link below).
  87109. * @see https://easings.net/#easeInBack
  87110. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87111. */
  87112. export class BackEase extends EasingFunction implements IEasingFunction {
  87113. /** Defines the amplitude of the function */
  87114. amplitude: number;
  87115. /**
  87116. * Instantiates a back ease easing
  87117. * @see https://easings.net/#easeInBack
  87118. * @param amplitude Defines the amplitude of the function
  87119. */
  87120. constructor(
  87121. /** Defines the amplitude of the function */
  87122. amplitude?: number);
  87123. /** @hidden */
  87124. easeInCore(gradient: number): number;
  87125. }
  87126. /**
  87127. * Easing function with a bouncing shape (see link below).
  87128. * @see https://easings.net/#easeInBounce
  87129. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87130. */
  87131. export class BounceEase extends EasingFunction implements IEasingFunction {
  87132. /** Defines the number of bounces */
  87133. bounces: number;
  87134. /** Defines the amplitude of the bounce */
  87135. bounciness: number;
  87136. /**
  87137. * Instantiates a bounce easing
  87138. * @see https://easings.net/#easeInBounce
  87139. * @param bounces Defines the number of bounces
  87140. * @param bounciness Defines the amplitude of the bounce
  87141. */
  87142. constructor(
  87143. /** Defines the number of bounces */
  87144. bounces?: number,
  87145. /** Defines the amplitude of the bounce */
  87146. bounciness?: number);
  87147. /** @hidden */
  87148. easeInCore(gradient: number): number;
  87149. }
  87150. /**
  87151. * Easing function with a power of 3 shape (see link below).
  87152. * @see https://easings.net/#easeInCubic
  87153. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87154. */
  87155. export class CubicEase extends EasingFunction implements IEasingFunction {
  87156. /** @hidden */
  87157. easeInCore(gradient: number): number;
  87158. }
  87159. /**
  87160. * Easing function with an elastic shape (see link below).
  87161. * @see https://easings.net/#easeInElastic
  87162. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87163. */
  87164. export class ElasticEase extends EasingFunction implements IEasingFunction {
  87165. /** Defines the number of oscillations*/
  87166. oscillations: number;
  87167. /** Defines the amplitude of the oscillations*/
  87168. springiness: number;
  87169. /**
  87170. * Instantiates an elastic easing function
  87171. * @see https://easings.net/#easeInElastic
  87172. * @param oscillations Defines the number of oscillations
  87173. * @param springiness Defines the amplitude of the oscillations
  87174. */
  87175. constructor(
  87176. /** Defines the number of oscillations*/
  87177. oscillations?: number,
  87178. /** Defines the amplitude of the oscillations*/
  87179. springiness?: number);
  87180. /** @hidden */
  87181. easeInCore(gradient: number): number;
  87182. }
  87183. /**
  87184. * Easing function with an exponential shape (see link below).
  87185. * @see https://easings.net/#easeInExpo
  87186. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87187. */
  87188. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  87189. /** Defines the exponent of the function */
  87190. exponent: number;
  87191. /**
  87192. * Instantiates an exponential easing function
  87193. * @see https://easings.net/#easeInExpo
  87194. * @param exponent Defines the exponent of the function
  87195. */
  87196. constructor(
  87197. /** Defines the exponent of the function */
  87198. exponent?: number);
  87199. /** @hidden */
  87200. easeInCore(gradient: number): number;
  87201. }
  87202. /**
  87203. * Easing function with a power shape (see link below).
  87204. * @see https://easings.net/#easeInQuad
  87205. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87206. */
  87207. export class PowerEase extends EasingFunction implements IEasingFunction {
  87208. /** Defines the power of the function */
  87209. power: number;
  87210. /**
  87211. * Instantiates an power base easing function
  87212. * @see https://easings.net/#easeInQuad
  87213. * @param power Defines the power of the function
  87214. */
  87215. constructor(
  87216. /** Defines the power of the function */
  87217. power?: number);
  87218. /** @hidden */
  87219. easeInCore(gradient: number): number;
  87220. }
  87221. /**
  87222. * Easing function with a power of 2 shape (see link below).
  87223. * @see https://easings.net/#easeInQuad
  87224. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87225. */
  87226. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  87227. /** @hidden */
  87228. easeInCore(gradient: number): number;
  87229. }
  87230. /**
  87231. * Easing function with a power of 4 shape (see link below).
  87232. * @see https://easings.net/#easeInQuart
  87233. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87234. */
  87235. export class QuarticEase extends EasingFunction implements IEasingFunction {
  87236. /** @hidden */
  87237. easeInCore(gradient: number): number;
  87238. }
  87239. /**
  87240. * Easing function with a power of 5 shape (see link below).
  87241. * @see https://easings.net/#easeInQuint
  87242. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87243. */
  87244. export class QuinticEase extends EasingFunction implements IEasingFunction {
  87245. /** @hidden */
  87246. easeInCore(gradient: number): number;
  87247. }
  87248. /**
  87249. * Easing function with a sin shape (see link below).
  87250. * @see https://easings.net/#easeInSine
  87251. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87252. */
  87253. export class SineEase extends EasingFunction implements IEasingFunction {
  87254. /** @hidden */
  87255. easeInCore(gradient: number): number;
  87256. }
  87257. /**
  87258. * Easing function with a bezier shape (see link below).
  87259. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  87260. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87261. */
  87262. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  87263. /** Defines the x component of the start tangent in the bezier curve */
  87264. x1: number;
  87265. /** Defines the y component of the start tangent in the bezier curve */
  87266. y1: number;
  87267. /** Defines the x component of the end tangent in the bezier curve */
  87268. x2: number;
  87269. /** Defines the y component of the end tangent in the bezier curve */
  87270. y2: number;
  87271. /**
  87272. * Instantiates a bezier function
  87273. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  87274. * @param x1 Defines the x component of the start tangent in the bezier curve
  87275. * @param y1 Defines the y component of the start tangent in the bezier curve
  87276. * @param x2 Defines the x component of the end tangent in the bezier curve
  87277. * @param y2 Defines the y component of the end tangent in the bezier curve
  87278. */
  87279. constructor(
  87280. /** Defines the x component of the start tangent in the bezier curve */
  87281. x1?: number,
  87282. /** Defines the y component of the start tangent in the bezier curve */
  87283. y1?: number,
  87284. /** Defines the x component of the end tangent in the bezier curve */
  87285. x2?: number,
  87286. /** Defines the y component of the end tangent in the bezier curve */
  87287. y2?: number);
  87288. /** @hidden */
  87289. easeInCore(gradient: number): number;
  87290. }
  87291. }
  87292. declare module BABYLON {
  87293. /**
  87294. * Class used to hold a RBG color
  87295. */
  87296. export class Color3 {
  87297. /**
  87298. * Defines the red component (between 0 and 1, default is 0)
  87299. */
  87300. r: number;
  87301. /**
  87302. * Defines the green component (between 0 and 1, default is 0)
  87303. */
  87304. g: number;
  87305. /**
  87306. * Defines the blue component (between 0 and 1, default is 0)
  87307. */
  87308. b: number;
  87309. /**
  87310. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  87311. * @param r defines the red component (between 0 and 1, default is 0)
  87312. * @param g defines the green component (between 0 and 1, default is 0)
  87313. * @param b defines the blue component (between 0 and 1, default is 0)
  87314. */
  87315. constructor(
  87316. /**
  87317. * Defines the red component (between 0 and 1, default is 0)
  87318. */
  87319. r?: number,
  87320. /**
  87321. * Defines the green component (between 0 and 1, default is 0)
  87322. */
  87323. g?: number,
  87324. /**
  87325. * Defines the blue component (between 0 and 1, default is 0)
  87326. */
  87327. b?: number);
  87328. /**
  87329. * Creates a string with the Color3 current values
  87330. * @returns the string representation of the Color3 object
  87331. */
  87332. toString(): string;
  87333. /**
  87334. * Returns the string "Color3"
  87335. * @returns "Color3"
  87336. */
  87337. getClassName(): string;
  87338. /**
  87339. * Compute the Color3 hash code
  87340. * @returns an unique number that can be used to hash Color3 objects
  87341. */
  87342. getHashCode(): number;
  87343. /**
  87344. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  87345. * @param array defines the array where to store the r,g,b components
  87346. * @param index defines an optional index in the target array to define where to start storing values
  87347. * @returns the current Color3 object
  87348. */
  87349. toArray(array: FloatArray, index?: number): Color3;
  87350. /**
  87351. * Update the current color with values stored in an array from the starting index of the given array
  87352. * @param array defines the source array
  87353. * @param offset defines an offset in the source array
  87354. * @returns the current Color3 object
  87355. */
  87356. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  87357. /**
  87358. * Returns a new Color4 object from the current Color3 and the given alpha
  87359. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  87360. * @returns a new Color4 object
  87361. */
  87362. toColor4(alpha?: number): Color4;
  87363. /**
  87364. * Returns a new array populated with 3 numeric elements : red, green and blue values
  87365. * @returns the new array
  87366. */
  87367. asArray(): number[];
  87368. /**
  87369. * Returns the luminance value
  87370. * @returns a float value
  87371. */
  87372. toLuminance(): number;
  87373. /**
  87374. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  87375. * @param otherColor defines the second operand
  87376. * @returns the new Color3 object
  87377. */
  87378. multiply(otherColor: DeepImmutable<Color3>): Color3;
  87379. /**
  87380. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  87381. * @param otherColor defines the second operand
  87382. * @param result defines the Color3 object where to store the result
  87383. * @returns the current Color3
  87384. */
  87385. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  87386. /**
  87387. * Determines equality between Color3 objects
  87388. * @param otherColor defines the second operand
  87389. * @returns true if the rgb values are equal to the given ones
  87390. */
  87391. equals(otherColor: DeepImmutable<Color3>): boolean;
  87392. /**
  87393. * Determines equality between the current Color3 object and a set of r,b,g values
  87394. * @param r defines the red component to check
  87395. * @param g defines the green component to check
  87396. * @param b defines the blue component to check
  87397. * @returns true if the rgb values are equal to the given ones
  87398. */
  87399. equalsFloats(r: number, g: number, b: number): boolean;
  87400. /**
  87401. * Multiplies in place each rgb value by scale
  87402. * @param scale defines the scaling factor
  87403. * @returns the updated Color3
  87404. */
  87405. scale(scale: number): Color3;
  87406. /**
  87407. * Multiplies the rgb values by scale and stores the result into "result"
  87408. * @param scale defines the scaling factor
  87409. * @param result defines the Color3 object where to store the result
  87410. * @returns the unmodified current Color3
  87411. */
  87412. scaleToRef(scale: number, result: Color3): Color3;
  87413. /**
  87414. * Scale the current Color3 values by a factor and add the result to a given Color3
  87415. * @param scale defines the scale factor
  87416. * @param result defines color to store the result into
  87417. * @returns the unmodified current Color3
  87418. */
  87419. scaleAndAddToRef(scale: number, result: Color3): Color3;
  87420. /**
  87421. * Clamps the rgb values by the min and max values and stores the result into "result"
  87422. * @param min defines minimum clamping value (default is 0)
  87423. * @param max defines maximum clamping value (default is 1)
  87424. * @param result defines color to store the result into
  87425. * @returns the original Color3
  87426. */
  87427. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  87428. /**
  87429. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  87430. * @param otherColor defines the second operand
  87431. * @returns the new Color3
  87432. */
  87433. add(otherColor: DeepImmutable<Color3>): Color3;
  87434. /**
  87435. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  87436. * @param otherColor defines the second operand
  87437. * @param result defines Color3 object to store the result into
  87438. * @returns the unmodified current Color3
  87439. */
  87440. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  87441. /**
  87442. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  87443. * @param otherColor defines the second operand
  87444. * @returns the new Color3
  87445. */
  87446. subtract(otherColor: DeepImmutable<Color3>): Color3;
  87447. /**
  87448. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  87449. * @param otherColor defines the second operand
  87450. * @param result defines Color3 object to store the result into
  87451. * @returns the unmodified current Color3
  87452. */
  87453. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  87454. /**
  87455. * Copy the current object
  87456. * @returns a new Color3 copied the current one
  87457. */
  87458. clone(): Color3;
  87459. /**
  87460. * Copies the rgb values from the source in the current Color3
  87461. * @param source defines the source Color3 object
  87462. * @returns the updated Color3 object
  87463. */
  87464. copyFrom(source: DeepImmutable<Color3>): Color3;
  87465. /**
  87466. * Updates the Color3 rgb values from the given floats
  87467. * @param r defines the red component to read from
  87468. * @param g defines the green component to read from
  87469. * @param b defines the blue component to read from
  87470. * @returns the current Color3 object
  87471. */
  87472. copyFromFloats(r: number, g: number, b: number): Color3;
  87473. /**
  87474. * Updates the Color3 rgb values from the given floats
  87475. * @param r defines the red component to read from
  87476. * @param g defines the green component to read from
  87477. * @param b defines the blue component to read from
  87478. * @returns the current Color3 object
  87479. */
  87480. set(r: number, g: number, b: number): Color3;
  87481. /**
  87482. * Compute the Color3 hexadecimal code as a string
  87483. * @returns a string containing the hexadecimal representation of the Color3 object
  87484. */
  87485. toHexString(): string;
  87486. /**
  87487. * Computes a new Color3 converted from the current one to linear space
  87488. * @returns a new Color3 object
  87489. */
  87490. toLinearSpace(): Color3;
  87491. /**
  87492. * Converts current color in rgb space to HSV values
  87493. * @returns a new color3 representing the HSV values
  87494. */
  87495. toHSV(): Color3;
  87496. /**
  87497. * Converts current color in rgb space to HSV values
  87498. * @param result defines the Color3 where to store the HSV values
  87499. */
  87500. toHSVToRef(result: Color3): void;
  87501. /**
  87502. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  87503. * @param convertedColor defines the Color3 object where to store the linear space version
  87504. * @returns the unmodified Color3
  87505. */
  87506. toLinearSpaceToRef(convertedColor: Color3): Color3;
  87507. /**
  87508. * Computes a new Color3 converted from the current one to gamma space
  87509. * @returns a new Color3 object
  87510. */
  87511. toGammaSpace(): Color3;
  87512. /**
  87513. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  87514. * @param convertedColor defines the Color3 object where to store the gamma space version
  87515. * @returns the unmodified Color3
  87516. */
  87517. toGammaSpaceToRef(convertedColor: Color3): Color3;
  87518. private static _BlackReadOnly;
  87519. /**
  87520. * Convert Hue, saturation and value to a Color3 (RGB)
  87521. * @param hue defines the hue
  87522. * @param saturation defines the saturation
  87523. * @param value defines the value
  87524. * @param result defines the Color3 where to store the RGB values
  87525. */
  87526. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  87527. /**
  87528. * Creates a new Color3 from the string containing valid hexadecimal values
  87529. * @param hex defines a string containing valid hexadecimal values
  87530. * @returns a new Color3 object
  87531. */
  87532. static FromHexString(hex: string): Color3;
  87533. /**
  87534. * Creates a new Color3 from the starting index of the given array
  87535. * @param array defines the source array
  87536. * @param offset defines an offset in the source array
  87537. * @returns a new Color3 object
  87538. */
  87539. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  87540. /**
  87541. * Creates a new Color3 from the starting index element of the given array
  87542. * @param array defines the source array to read from
  87543. * @param offset defines the offset in the source array
  87544. * @param result defines the target Color3 object
  87545. */
  87546. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  87547. /**
  87548. * Creates a new Color3 from integer values (< 256)
  87549. * @param r defines the red component to read from (value between 0 and 255)
  87550. * @param g defines the green component to read from (value between 0 and 255)
  87551. * @param b defines the blue component to read from (value between 0 and 255)
  87552. * @returns a new Color3 object
  87553. */
  87554. static FromInts(r: number, g: number, b: number): Color3;
  87555. /**
  87556. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  87557. * @param start defines the start Color3 value
  87558. * @param end defines the end Color3 value
  87559. * @param amount defines the gradient value between start and end
  87560. * @returns a new Color3 object
  87561. */
  87562. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  87563. /**
  87564. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  87565. * @param left defines the start value
  87566. * @param right defines the end value
  87567. * @param amount defines the gradient factor
  87568. * @param result defines the Color3 object where to store the result
  87569. */
  87570. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  87571. /**
  87572. * Returns a Color3 value containing a red color
  87573. * @returns a new Color3 object
  87574. */
  87575. static Red(): Color3;
  87576. /**
  87577. * Returns a Color3 value containing a green color
  87578. * @returns a new Color3 object
  87579. */
  87580. static Green(): Color3;
  87581. /**
  87582. * Returns a Color3 value containing a blue color
  87583. * @returns a new Color3 object
  87584. */
  87585. static Blue(): Color3;
  87586. /**
  87587. * Returns a Color3 value containing a black color
  87588. * @returns a new Color3 object
  87589. */
  87590. static Black(): Color3;
  87591. /**
  87592. * Gets a Color3 value containing a black color that must not be updated
  87593. */
  87594. static get BlackReadOnly(): DeepImmutable<Color3>;
  87595. /**
  87596. * Returns a Color3 value containing a white color
  87597. * @returns a new Color3 object
  87598. */
  87599. static White(): Color3;
  87600. /**
  87601. * Returns a Color3 value containing a purple color
  87602. * @returns a new Color3 object
  87603. */
  87604. static Purple(): Color3;
  87605. /**
  87606. * Returns a Color3 value containing a magenta color
  87607. * @returns a new Color3 object
  87608. */
  87609. static Magenta(): Color3;
  87610. /**
  87611. * Returns a Color3 value containing a yellow color
  87612. * @returns a new Color3 object
  87613. */
  87614. static Yellow(): Color3;
  87615. /**
  87616. * Returns a Color3 value containing a gray color
  87617. * @returns a new Color3 object
  87618. */
  87619. static Gray(): Color3;
  87620. /**
  87621. * Returns a Color3 value containing a teal color
  87622. * @returns a new Color3 object
  87623. */
  87624. static Teal(): Color3;
  87625. /**
  87626. * Returns a Color3 value containing a random color
  87627. * @returns a new Color3 object
  87628. */
  87629. static Random(): Color3;
  87630. }
  87631. /**
  87632. * Class used to hold a RBGA color
  87633. */
  87634. export class Color4 {
  87635. /**
  87636. * Defines the red component (between 0 and 1, default is 0)
  87637. */
  87638. r: number;
  87639. /**
  87640. * Defines the green component (between 0 and 1, default is 0)
  87641. */
  87642. g: number;
  87643. /**
  87644. * Defines the blue component (between 0 and 1, default is 0)
  87645. */
  87646. b: number;
  87647. /**
  87648. * Defines the alpha component (between 0 and 1, default is 1)
  87649. */
  87650. a: number;
  87651. /**
  87652. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  87653. * @param r defines the red component (between 0 and 1, default is 0)
  87654. * @param g defines the green component (between 0 and 1, default is 0)
  87655. * @param b defines the blue component (between 0 and 1, default is 0)
  87656. * @param a defines the alpha component (between 0 and 1, default is 1)
  87657. */
  87658. constructor(
  87659. /**
  87660. * Defines the red component (between 0 and 1, default is 0)
  87661. */
  87662. r?: number,
  87663. /**
  87664. * Defines the green component (between 0 and 1, default is 0)
  87665. */
  87666. g?: number,
  87667. /**
  87668. * Defines the blue component (between 0 and 1, default is 0)
  87669. */
  87670. b?: number,
  87671. /**
  87672. * Defines the alpha component (between 0 and 1, default is 1)
  87673. */
  87674. a?: number);
  87675. /**
  87676. * Adds in place the given Color4 values to the current Color4 object
  87677. * @param right defines the second operand
  87678. * @returns the current updated Color4 object
  87679. */
  87680. addInPlace(right: DeepImmutable<Color4>): Color4;
  87681. /**
  87682. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  87683. * @returns the new array
  87684. */
  87685. asArray(): number[];
  87686. /**
  87687. * Stores from the starting index in the given array the Color4 successive values
  87688. * @param array defines the array where to store the r,g,b components
  87689. * @param index defines an optional index in the target array to define where to start storing values
  87690. * @returns the current Color4 object
  87691. */
  87692. toArray(array: number[], index?: number): Color4;
  87693. /**
  87694. * Update the current color with values stored in an array from the starting index of the given array
  87695. * @param array defines the source array
  87696. * @param offset defines an offset in the source array
  87697. * @returns the current Color4 object
  87698. */
  87699. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  87700. /**
  87701. * Determines equality between Color4 objects
  87702. * @param otherColor defines the second operand
  87703. * @returns true if the rgba values are equal to the given ones
  87704. */
  87705. equals(otherColor: DeepImmutable<Color4>): boolean;
  87706. /**
  87707. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  87708. * @param right defines the second operand
  87709. * @returns a new Color4 object
  87710. */
  87711. add(right: DeepImmutable<Color4>): Color4;
  87712. /**
  87713. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  87714. * @param right defines the second operand
  87715. * @returns a new Color4 object
  87716. */
  87717. subtract(right: DeepImmutable<Color4>): Color4;
  87718. /**
  87719. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  87720. * @param right defines the second operand
  87721. * @param result defines the Color4 object where to store the result
  87722. * @returns the current Color4 object
  87723. */
  87724. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  87725. /**
  87726. * Creates a new Color4 with the current Color4 values multiplied by scale
  87727. * @param scale defines the scaling factor to apply
  87728. * @returns a new Color4 object
  87729. */
  87730. scale(scale: number): Color4;
  87731. /**
  87732. * Multiplies the current Color4 values by scale and stores the result in "result"
  87733. * @param scale defines the scaling factor to apply
  87734. * @param result defines the Color4 object where to store the result
  87735. * @returns the current unmodified Color4
  87736. */
  87737. scaleToRef(scale: number, result: Color4): Color4;
  87738. /**
  87739. * Scale the current Color4 values by a factor and add the result to a given Color4
  87740. * @param scale defines the scale factor
  87741. * @param result defines the Color4 object where to store the result
  87742. * @returns the unmodified current Color4
  87743. */
  87744. scaleAndAddToRef(scale: number, result: Color4): Color4;
  87745. /**
  87746. * Clamps the rgb values by the min and max values and stores the result into "result"
  87747. * @param min defines minimum clamping value (default is 0)
  87748. * @param max defines maximum clamping value (default is 1)
  87749. * @param result defines color to store the result into.
  87750. * @returns the cuurent Color4
  87751. */
  87752. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  87753. /**
  87754. * Multipy an Color4 value by another and return a new Color4 object
  87755. * @param color defines the Color4 value to multiply by
  87756. * @returns a new Color4 object
  87757. */
  87758. multiply(color: Color4): Color4;
  87759. /**
  87760. * Multipy a Color4 value by another and push the result in a reference value
  87761. * @param color defines the Color4 value to multiply by
  87762. * @param result defines the Color4 to fill the result in
  87763. * @returns the result Color4
  87764. */
  87765. multiplyToRef(color: Color4, result: Color4): Color4;
  87766. /**
  87767. * Creates a string with the Color4 current values
  87768. * @returns the string representation of the Color4 object
  87769. */
  87770. toString(): string;
  87771. /**
  87772. * Returns the string "Color4"
  87773. * @returns "Color4"
  87774. */
  87775. getClassName(): string;
  87776. /**
  87777. * Compute the Color4 hash code
  87778. * @returns an unique number that can be used to hash Color4 objects
  87779. */
  87780. getHashCode(): number;
  87781. /**
  87782. * Creates a new Color4 copied from the current one
  87783. * @returns a new Color4 object
  87784. */
  87785. clone(): Color4;
  87786. /**
  87787. * Copies the given Color4 values into the current one
  87788. * @param source defines the source Color4 object
  87789. * @returns the current updated Color4 object
  87790. */
  87791. copyFrom(source: Color4): Color4;
  87792. /**
  87793. * Copies the given float values into the current one
  87794. * @param r defines the red component to read from
  87795. * @param g defines the green component to read from
  87796. * @param b defines the blue component to read from
  87797. * @param a defines the alpha component to read from
  87798. * @returns the current updated Color4 object
  87799. */
  87800. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  87801. /**
  87802. * Copies the given float values into the current one
  87803. * @param r defines the red component to read from
  87804. * @param g defines the green component to read from
  87805. * @param b defines the blue component to read from
  87806. * @param a defines the alpha component to read from
  87807. * @returns the current updated Color4 object
  87808. */
  87809. set(r: number, g: number, b: number, a: number): Color4;
  87810. /**
  87811. * Compute the Color4 hexadecimal code as a string
  87812. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  87813. * @returns a string containing the hexadecimal representation of the Color4 object
  87814. */
  87815. toHexString(returnAsColor3?: boolean): string;
  87816. /**
  87817. * Computes a new Color4 converted from the current one to linear space
  87818. * @returns a new Color4 object
  87819. */
  87820. toLinearSpace(): Color4;
  87821. /**
  87822. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  87823. * @param convertedColor defines the Color4 object where to store the linear space version
  87824. * @returns the unmodified Color4
  87825. */
  87826. toLinearSpaceToRef(convertedColor: Color4): Color4;
  87827. /**
  87828. * Computes a new Color4 converted from the current one to gamma space
  87829. * @returns a new Color4 object
  87830. */
  87831. toGammaSpace(): Color4;
  87832. /**
  87833. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  87834. * @param convertedColor defines the Color4 object where to store the gamma space version
  87835. * @returns the unmodified Color4
  87836. */
  87837. toGammaSpaceToRef(convertedColor: Color4): Color4;
  87838. /**
  87839. * Creates a new Color4 from the string containing valid hexadecimal values
  87840. * @param hex defines a string containing valid hexadecimal values
  87841. * @returns a new Color4 object
  87842. */
  87843. static FromHexString(hex: string): Color4;
  87844. /**
  87845. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  87846. * @param left defines the start value
  87847. * @param right defines the end value
  87848. * @param amount defines the gradient factor
  87849. * @returns a new Color4 object
  87850. */
  87851. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  87852. /**
  87853. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  87854. * @param left defines the start value
  87855. * @param right defines the end value
  87856. * @param amount defines the gradient factor
  87857. * @param result defines the Color4 object where to store data
  87858. */
  87859. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  87860. /**
  87861. * Creates a new Color4 from a Color3 and an alpha value
  87862. * @param color3 defines the source Color3 to read from
  87863. * @param alpha defines the alpha component (1.0 by default)
  87864. * @returns a new Color4 object
  87865. */
  87866. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  87867. /**
  87868. * Creates a new Color4 from the starting index element of the given array
  87869. * @param array defines the source array to read from
  87870. * @param offset defines the offset in the source array
  87871. * @returns a new Color4 object
  87872. */
  87873. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  87874. /**
  87875. * Creates a new Color4 from the starting index element of the given array
  87876. * @param array defines the source array to read from
  87877. * @param offset defines the offset in the source array
  87878. * @param result defines the target Color4 object
  87879. */
  87880. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  87881. /**
  87882. * Creates a new Color3 from integer values (< 256)
  87883. * @param r defines the red component to read from (value between 0 and 255)
  87884. * @param g defines the green component to read from (value between 0 and 255)
  87885. * @param b defines the blue component to read from (value between 0 and 255)
  87886. * @param a defines the alpha component to read from (value between 0 and 255)
  87887. * @returns a new Color3 object
  87888. */
  87889. static FromInts(r: number, g: number, b: number, a: number): Color4;
  87890. /**
  87891. * Check the content of a given array and convert it to an array containing RGBA data
  87892. * If the original array was already containing count * 4 values then it is returned directly
  87893. * @param colors defines the array to check
  87894. * @param count defines the number of RGBA data to expect
  87895. * @returns an array containing count * 4 values (RGBA)
  87896. */
  87897. static CheckColors4(colors: number[], count: number): number[];
  87898. }
  87899. /**
  87900. * @hidden
  87901. */
  87902. export class TmpColors {
  87903. static Color3: Color3[];
  87904. static Color4: Color4[];
  87905. }
  87906. }
  87907. declare module BABYLON {
  87908. /**
  87909. * Defines an interface which represents an animation key frame
  87910. */
  87911. export interface IAnimationKey {
  87912. /**
  87913. * Frame of the key frame
  87914. */
  87915. frame: number;
  87916. /**
  87917. * Value at the specifies key frame
  87918. */
  87919. value: any;
  87920. /**
  87921. * The input tangent for the cubic hermite spline
  87922. */
  87923. inTangent?: any;
  87924. /**
  87925. * The output tangent for the cubic hermite spline
  87926. */
  87927. outTangent?: any;
  87928. /**
  87929. * The animation interpolation type
  87930. */
  87931. interpolation?: AnimationKeyInterpolation;
  87932. }
  87933. /**
  87934. * Enum for the animation key frame interpolation type
  87935. */
  87936. export enum AnimationKeyInterpolation {
  87937. /**
  87938. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  87939. */
  87940. STEP = 1
  87941. }
  87942. }
  87943. declare module BABYLON {
  87944. /**
  87945. * Represents the range of an animation
  87946. */
  87947. export class AnimationRange {
  87948. /**The name of the animation range**/
  87949. name: string;
  87950. /**The starting frame of the animation */
  87951. from: number;
  87952. /**The ending frame of the animation*/
  87953. to: number;
  87954. /**
  87955. * Initializes the range of an animation
  87956. * @param name The name of the animation range
  87957. * @param from The starting frame of the animation
  87958. * @param to The ending frame of the animation
  87959. */
  87960. constructor(
  87961. /**The name of the animation range**/
  87962. name: string,
  87963. /**The starting frame of the animation */
  87964. from: number,
  87965. /**The ending frame of the animation*/
  87966. to: number);
  87967. /**
  87968. * Makes a copy of the animation range
  87969. * @returns A copy of the animation range
  87970. */
  87971. clone(): AnimationRange;
  87972. }
  87973. }
  87974. declare module BABYLON {
  87975. /**
  87976. * Composed of a frame, and an action function
  87977. */
  87978. export class AnimationEvent {
  87979. /** The frame for which the event is triggered **/
  87980. frame: number;
  87981. /** The event to perform when triggered **/
  87982. action: (currentFrame: number) => void;
  87983. /** Specifies if the event should be triggered only once**/
  87984. onlyOnce?: boolean | undefined;
  87985. /**
  87986. * Specifies if the animation event is done
  87987. */
  87988. isDone: boolean;
  87989. /**
  87990. * Initializes the animation event
  87991. * @param frame The frame for which the event is triggered
  87992. * @param action The event to perform when triggered
  87993. * @param onlyOnce Specifies if the event should be triggered only once
  87994. */
  87995. constructor(
  87996. /** The frame for which the event is triggered **/
  87997. frame: number,
  87998. /** The event to perform when triggered **/
  87999. action: (currentFrame: number) => void,
  88000. /** Specifies if the event should be triggered only once**/
  88001. onlyOnce?: boolean | undefined);
  88002. /** @hidden */
  88003. _clone(): AnimationEvent;
  88004. }
  88005. }
  88006. declare module BABYLON {
  88007. /**
  88008. * Interface used to define a behavior
  88009. */
  88010. export interface Behavior<T> {
  88011. /** gets or sets behavior's name */
  88012. name: string;
  88013. /**
  88014. * Function called when the behavior needs to be initialized (after attaching it to a target)
  88015. */
  88016. init(): void;
  88017. /**
  88018. * Called when the behavior is attached to a target
  88019. * @param target defines the target where the behavior is attached to
  88020. */
  88021. attach(target: T): void;
  88022. /**
  88023. * Called when the behavior is detached from its target
  88024. */
  88025. detach(): void;
  88026. }
  88027. /**
  88028. * Interface implemented by classes supporting behaviors
  88029. */
  88030. export interface IBehaviorAware<T> {
  88031. /**
  88032. * Attach a behavior
  88033. * @param behavior defines the behavior to attach
  88034. * @returns the current host
  88035. */
  88036. addBehavior(behavior: Behavior<T>): T;
  88037. /**
  88038. * Remove a behavior from the current object
  88039. * @param behavior defines the behavior to detach
  88040. * @returns the current host
  88041. */
  88042. removeBehavior(behavior: Behavior<T>): T;
  88043. /**
  88044. * Gets a behavior using its name to search
  88045. * @param name defines the name to search
  88046. * @returns the behavior or null if not found
  88047. */
  88048. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  88049. }
  88050. }
  88051. declare module BABYLON {
  88052. /**
  88053. * Class used to store data that will be store in GPU memory
  88054. */
  88055. export class Buffer {
  88056. private _engine;
  88057. private _buffer;
  88058. /** @hidden */
  88059. _data: Nullable<DataArray>;
  88060. private _updatable;
  88061. private _instanced;
  88062. private _divisor;
  88063. /**
  88064. * Gets the byte stride.
  88065. */
  88066. readonly byteStride: number;
  88067. /**
  88068. * Constructor
  88069. * @param engine the engine
  88070. * @param data the data to use for this buffer
  88071. * @param updatable whether the data is updatable
  88072. * @param stride the stride (optional)
  88073. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  88074. * @param instanced whether the buffer is instanced (optional)
  88075. * @param useBytes set to true if the stride in in bytes (optional)
  88076. * @param divisor sets an optional divisor for instances (1 by default)
  88077. */
  88078. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  88079. /**
  88080. * Create a new VertexBuffer based on the current buffer
  88081. * @param kind defines the vertex buffer kind (position, normal, etc.)
  88082. * @param offset defines offset in the buffer (0 by default)
  88083. * @param size defines the size in floats of attributes (position is 3 for instance)
  88084. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  88085. * @param instanced defines if the vertex buffer contains indexed data
  88086. * @param useBytes defines if the offset and stride are in bytes *
  88087. * @param divisor sets an optional divisor for instances (1 by default)
  88088. * @returns the new vertex buffer
  88089. */
  88090. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  88091. /**
  88092. * Gets a boolean indicating if the Buffer is updatable?
  88093. * @returns true if the buffer is updatable
  88094. */
  88095. isUpdatable(): boolean;
  88096. /**
  88097. * Gets current buffer's data
  88098. * @returns a DataArray or null
  88099. */
  88100. getData(): Nullable<DataArray>;
  88101. /**
  88102. * Gets underlying native buffer
  88103. * @returns underlying native buffer
  88104. */
  88105. getBuffer(): Nullable<DataBuffer>;
  88106. /**
  88107. * Gets the stride in float32 units (i.e. byte stride / 4).
  88108. * May not be an integer if the byte stride is not divisible by 4.
  88109. * @returns the stride in float32 units
  88110. * @deprecated Please use byteStride instead.
  88111. */
  88112. getStrideSize(): number;
  88113. /**
  88114. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  88115. * @param data defines the data to store
  88116. */
  88117. create(data?: Nullable<DataArray>): void;
  88118. /** @hidden */
  88119. _rebuild(): void;
  88120. /**
  88121. * Update current buffer data
  88122. * @param data defines the data to store
  88123. */
  88124. update(data: DataArray): void;
  88125. /**
  88126. * Updates the data directly.
  88127. * @param data the new data
  88128. * @param offset the new offset
  88129. * @param vertexCount the vertex count (optional)
  88130. * @param useBytes set to true if the offset is in bytes
  88131. */
  88132. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  88133. /**
  88134. * Release all resources
  88135. */
  88136. dispose(): void;
  88137. }
  88138. /**
  88139. * Specialized buffer used to store vertex data
  88140. */
  88141. export class VertexBuffer {
  88142. /** @hidden */
  88143. _buffer: Buffer;
  88144. private _kind;
  88145. private _size;
  88146. private _ownsBuffer;
  88147. private _instanced;
  88148. private _instanceDivisor;
  88149. /**
  88150. * The byte type.
  88151. */
  88152. static readonly BYTE: number;
  88153. /**
  88154. * The unsigned byte type.
  88155. */
  88156. static readonly UNSIGNED_BYTE: number;
  88157. /**
  88158. * The short type.
  88159. */
  88160. static readonly SHORT: number;
  88161. /**
  88162. * The unsigned short type.
  88163. */
  88164. static readonly UNSIGNED_SHORT: number;
  88165. /**
  88166. * The integer type.
  88167. */
  88168. static readonly INT: number;
  88169. /**
  88170. * The unsigned integer type.
  88171. */
  88172. static readonly UNSIGNED_INT: number;
  88173. /**
  88174. * The float type.
  88175. */
  88176. static readonly FLOAT: number;
  88177. /**
  88178. * Gets or sets the instance divisor when in instanced mode
  88179. */
  88180. get instanceDivisor(): number;
  88181. set instanceDivisor(value: number);
  88182. /**
  88183. * Gets the byte stride.
  88184. */
  88185. readonly byteStride: number;
  88186. /**
  88187. * Gets the byte offset.
  88188. */
  88189. readonly byteOffset: number;
  88190. /**
  88191. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  88192. */
  88193. readonly normalized: boolean;
  88194. /**
  88195. * Gets the data type of each component in the array.
  88196. */
  88197. readonly type: number;
  88198. /**
  88199. * Constructor
  88200. * @param engine the engine
  88201. * @param data the data to use for this vertex buffer
  88202. * @param kind the vertex buffer kind
  88203. * @param updatable whether the data is updatable
  88204. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  88205. * @param stride the stride (optional)
  88206. * @param instanced whether the buffer is instanced (optional)
  88207. * @param offset the offset of the data (optional)
  88208. * @param size the number of components (optional)
  88209. * @param type the type of the component (optional)
  88210. * @param normalized whether the data contains normalized data (optional)
  88211. * @param useBytes set to true if stride and offset are in bytes (optional)
  88212. * @param divisor defines the instance divisor to use (1 by default)
  88213. */
  88214. 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);
  88215. /** @hidden */
  88216. _rebuild(): void;
  88217. /**
  88218. * Returns the kind of the VertexBuffer (string)
  88219. * @returns a string
  88220. */
  88221. getKind(): string;
  88222. /**
  88223. * Gets a boolean indicating if the VertexBuffer is updatable?
  88224. * @returns true if the buffer is updatable
  88225. */
  88226. isUpdatable(): boolean;
  88227. /**
  88228. * Gets current buffer's data
  88229. * @returns a DataArray or null
  88230. */
  88231. getData(): Nullable<DataArray>;
  88232. /**
  88233. * Gets underlying native buffer
  88234. * @returns underlying native buffer
  88235. */
  88236. getBuffer(): Nullable<DataBuffer>;
  88237. /**
  88238. * Gets the stride in float32 units (i.e. byte stride / 4).
  88239. * May not be an integer if the byte stride is not divisible by 4.
  88240. * @returns the stride in float32 units
  88241. * @deprecated Please use byteStride instead.
  88242. */
  88243. getStrideSize(): number;
  88244. /**
  88245. * Returns the offset as a multiple of the type byte length.
  88246. * @returns the offset in bytes
  88247. * @deprecated Please use byteOffset instead.
  88248. */
  88249. getOffset(): number;
  88250. /**
  88251. * Returns the number of components per vertex attribute (integer)
  88252. * @returns the size in float
  88253. */
  88254. getSize(): number;
  88255. /**
  88256. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  88257. * @returns true if this buffer is instanced
  88258. */
  88259. getIsInstanced(): boolean;
  88260. /**
  88261. * Returns the instancing divisor, zero for non-instanced (integer).
  88262. * @returns a number
  88263. */
  88264. getInstanceDivisor(): number;
  88265. /**
  88266. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  88267. * @param data defines the data to store
  88268. */
  88269. create(data?: DataArray): void;
  88270. /**
  88271. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  88272. * This function will create a new buffer if the current one is not updatable
  88273. * @param data defines the data to store
  88274. */
  88275. update(data: DataArray): void;
  88276. /**
  88277. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  88278. * Returns the directly updated WebGLBuffer.
  88279. * @param data the new data
  88280. * @param offset the new offset
  88281. * @param useBytes set to true if the offset is in bytes
  88282. */
  88283. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  88284. /**
  88285. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  88286. */
  88287. dispose(): void;
  88288. /**
  88289. * Enumerates each value of this vertex buffer as numbers.
  88290. * @param count the number of values to enumerate
  88291. * @param callback the callback function called for each value
  88292. */
  88293. forEach(count: number, callback: (value: number, index: number) => void): void;
  88294. /**
  88295. * Positions
  88296. */
  88297. static readonly PositionKind: string;
  88298. /**
  88299. * Normals
  88300. */
  88301. static readonly NormalKind: string;
  88302. /**
  88303. * Tangents
  88304. */
  88305. static readonly TangentKind: string;
  88306. /**
  88307. * Texture coordinates
  88308. */
  88309. static readonly UVKind: string;
  88310. /**
  88311. * Texture coordinates 2
  88312. */
  88313. static readonly UV2Kind: string;
  88314. /**
  88315. * Texture coordinates 3
  88316. */
  88317. static readonly UV3Kind: string;
  88318. /**
  88319. * Texture coordinates 4
  88320. */
  88321. static readonly UV4Kind: string;
  88322. /**
  88323. * Texture coordinates 5
  88324. */
  88325. static readonly UV5Kind: string;
  88326. /**
  88327. * Texture coordinates 6
  88328. */
  88329. static readonly UV6Kind: string;
  88330. /**
  88331. * Colors
  88332. */
  88333. static readonly ColorKind: string;
  88334. /**
  88335. * Matrix indices (for bones)
  88336. */
  88337. static readonly MatricesIndicesKind: string;
  88338. /**
  88339. * Matrix weights (for bones)
  88340. */
  88341. static readonly MatricesWeightsKind: string;
  88342. /**
  88343. * Additional matrix indices (for bones)
  88344. */
  88345. static readonly MatricesIndicesExtraKind: string;
  88346. /**
  88347. * Additional matrix weights (for bones)
  88348. */
  88349. static readonly MatricesWeightsExtraKind: string;
  88350. /**
  88351. * Deduces the stride given a kind.
  88352. * @param kind The kind string to deduce
  88353. * @returns The deduced stride
  88354. */
  88355. static DeduceStride(kind: string): number;
  88356. /**
  88357. * Gets the byte length of the given type.
  88358. * @param type the type
  88359. * @returns the number of bytes
  88360. */
  88361. static GetTypeByteLength(type: number): number;
  88362. /**
  88363. * Enumerates each value of the given parameters as numbers.
  88364. * @param data the data to enumerate
  88365. * @param byteOffset the byte offset of the data
  88366. * @param byteStride the byte stride of the data
  88367. * @param componentCount the number of components per element
  88368. * @param componentType the type of the component
  88369. * @param count the number of values to enumerate
  88370. * @param normalized whether the data is normalized
  88371. * @param callback the callback function called for each value
  88372. */
  88373. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  88374. private static _GetFloatValue;
  88375. }
  88376. }
  88377. declare module BABYLON {
  88378. /**
  88379. * @hidden
  88380. */
  88381. export class IntersectionInfo {
  88382. bu: Nullable<number>;
  88383. bv: Nullable<number>;
  88384. distance: number;
  88385. faceId: number;
  88386. subMeshId: number;
  88387. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  88388. }
  88389. }
  88390. declare module BABYLON {
  88391. /**
  88392. * Class used to store bounding sphere information
  88393. */
  88394. export class BoundingSphere {
  88395. /**
  88396. * Gets the center of the bounding sphere in local space
  88397. */
  88398. readonly center: Vector3;
  88399. /**
  88400. * Radius of the bounding sphere in local space
  88401. */
  88402. radius: number;
  88403. /**
  88404. * Gets the center of the bounding sphere in world space
  88405. */
  88406. readonly centerWorld: Vector3;
  88407. /**
  88408. * Radius of the bounding sphere in world space
  88409. */
  88410. radiusWorld: number;
  88411. /**
  88412. * Gets the minimum vector in local space
  88413. */
  88414. readonly minimum: Vector3;
  88415. /**
  88416. * Gets the maximum vector in local space
  88417. */
  88418. readonly maximum: Vector3;
  88419. private _worldMatrix;
  88420. private static readonly TmpVector3;
  88421. /**
  88422. * Creates a new bounding sphere
  88423. * @param min defines the minimum vector (in local space)
  88424. * @param max defines the maximum vector (in local space)
  88425. * @param worldMatrix defines the new world matrix
  88426. */
  88427. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88428. /**
  88429. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  88430. * @param min defines the new minimum vector (in local space)
  88431. * @param max defines the new maximum vector (in local space)
  88432. * @param worldMatrix defines the new world matrix
  88433. */
  88434. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88435. /**
  88436. * Scale the current bounding sphere by applying a scale factor
  88437. * @param factor defines the scale factor to apply
  88438. * @returns the current bounding box
  88439. */
  88440. scale(factor: number): BoundingSphere;
  88441. /**
  88442. * Gets the world matrix of the bounding box
  88443. * @returns a matrix
  88444. */
  88445. getWorldMatrix(): DeepImmutable<Matrix>;
  88446. /** @hidden */
  88447. _update(worldMatrix: DeepImmutable<Matrix>): void;
  88448. /**
  88449. * Tests if the bounding sphere is intersecting the frustum planes
  88450. * @param frustumPlanes defines the frustum planes to test
  88451. * @returns true if there is an intersection
  88452. */
  88453. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88454. /**
  88455. * Tests if the bounding sphere center is in between the frustum planes.
  88456. * Used for optimistic fast inclusion.
  88457. * @param frustumPlanes defines the frustum planes to test
  88458. * @returns true if the sphere center is in between the frustum planes
  88459. */
  88460. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88461. /**
  88462. * Tests if a point is inside the bounding sphere
  88463. * @param point defines the point to test
  88464. * @returns true if the point is inside the bounding sphere
  88465. */
  88466. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88467. /**
  88468. * Checks if two sphere intersct
  88469. * @param sphere0 sphere 0
  88470. * @param sphere1 sphere 1
  88471. * @returns true if the speres intersect
  88472. */
  88473. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  88474. }
  88475. }
  88476. declare module BABYLON {
  88477. /**
  88478. * Class used to store bounding box information
  88479. */
  88480. export class BoundingBox implements ICullable {
  88481. /**
  88482. * Gets the 8 vectors representing the bounding box in local space
  88483. */
  88484. readonly vectors: Vector3[];
  88485. /**
  88486. * Gets the center of the bounding box in local space
  88487. */
  88488. readonly center: Vector3;
  88489. /**
  88490. * Gets the center of the bounding box in world space
  88491. */
  88492. readonly centerWorld: Vector3;
  88493. /**
  88494. * Gets the extend size in local space
  88495. */
  88496. readonly extendSize: Vector3;
  88497. /**
  88498. * Gets the extend size in world space
  88499. */
  88500. readonly extendSizeWorld: Vector3;
  88501. /**
  88502. * Gets the OBB (object bounding box) directions
  88503. */
  88504. readonly directions: Vector3[];
  88505. /**
  88506. * Gets the 8 vectors representing the bounding box in world space
  88507. */
  88508. readonly vectorsWorld: Vector3[];
  88509. /**
  88510. * Gets the minimum vector in world space
  88511. */
  88512. readonly minimumWorld: Vector3;
  88513. /**
  88514. * Gets the maximum vector in world space
  88515. */
  88516. readonly maximumWorld: Vector3;
  88517. /**
  88518. * Gets the minimum vector in local space
  88519. */
  88520. readonly minimum: Vector3;
  88521. /**
  88522. * Gets the maximum vector in local space
  88523. */
  88524. readonly maximum: Vector3;
  88525. private _worldMatrix;
  88526. private static readonly TmpVector3;
  88527. /**
  88528. * @hidden
  88529. */
  88530. _tag: number;
  88531. /**
  88532. * Creates a new bounding box
  88533. * @param min defines the minimum vector (in local space)
  88534. * @param max defines the maximum vector (in local space)
  88535. * @param worldMatrix defines the new world matrix
  88536. */
  88537. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88538. /**
  88539. * Recreates the entire bounding box from scratch as if we call the constructor in place
  88540. * @param min defines the new minimum vector (in local space)
  88541. * @param max defines the new maximum vector (in local space)
  88542. * @param worldMatrix defines the new world matrix
  88543. */
  88544. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88545. /**
  88546. * Scale the current bounding box by applying a scale factor
  88547. * @param factor defines the scale factor to apply
  88548. * @returns the current bounding box
  88549. */
  88550. scale(factor: number): BoundingBox;
  88551. /**
  88552. * Gets the world matrix of the bounding box
  88553. * @returns a matrix
  88554. */
  88555. getWorldMatrix(): DeepImmutable<Matrix>;
  88556. /** @hidden */
  88557. _update(world: DeepImmutable<Matrix>): void;
  88558. /**
  88559. * Tests if the bounding box is intersecting the frustum planes
  88560. * @param frustumPlanes defines the frustum planes to test
  88561. * @returns true if there is an intersection
  88562. */
  88563. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88564. /**
  88565. * Tests if the bounding box is entirely inside the frustum planes
  88566. * @param frustumPlanes defines the frustum planes to test
  88567. * @returns true if there is an inclusion
  88568. */
  88569. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88570. /**
  88571. * Tests if a point is inside the bounding box
  88572. * @param point defines the point to test
  88573. * @returns true if the point is inside the bounding box
  88574. */
  88575. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88576. /**
  88577. * Tests if the bounding box intersects with a bounding sphere
  88578. * @param sphere defines the sphere to test
  88579. * @returns true if there is an intersection
  88580. */
  88581. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  88582. /**
  88583. * Tests if the bounding box intersects with a box defined by a min and max vectors
  88584. * @param min defines the min vector to use
  88585. * @param max defines the max vector to use
  88586. * @returns true if there is an intersection
  88587. */
  88588. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  88589. /**
  88590. * Tests if two bounding boxes are intersections
  88591. * @param box0 defines the first box to test
  88592. * @param box1 defines the second box to test
  88593. * @returns true if there is an intersection
  88594. */
  88595. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  88596. /**
  88597. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  88598. * @param minPoint defines the minimum vector of the bounding box
  88599. * @param maxPoint defines the maximum vector of the bounding box
  88600. * @param sphereCenter defines the sphere center
  88601. * @param sphereRadius defines the sphere radius
  88602. * @returns true if there is an intersection
  88603. */
  88604. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  88605. /**
  88606. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  88607. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  88608. * @param frustumPlanes defines the frustum planes to test
  88609. * @return true if there is an inclusion
  88610. */
  88611. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88612. /**
  88613. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  88614. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  88615. * @param frustumPlanes defines the frustum planes to test
  88616. * @return true if there is an intersection
  88617. */
  88618. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88619. }
  88620. }
  88621. declare module BABYLON {
  88622. /** @hidden */
  88623. export class Collider {
  88624. /** Define if a collision was found */
  88625. collisionFound: boolean;
  88626. /**
  88627. * Define last intersection point in local space
  88628. */
  88629. intersectionPoint: Vector3;
  88630. /**
  88631. * Define last collided mesh
  88632. */
  88633. collidedMesh: Nullable<AbstractMesh>;
  88634. private _collisionPoint;
  88635. private _planeIntersectionPoint;
  88636. private _tempVector;
  88637. private _tempVector2;
  88638. private _tempVector3;
  88639. private _tempVector4;
  88640. private _edge;
  88641. private _baseToVertex;
  88642. private _destinationPoint;
  88643. private _slidePlaneNormal;
  88644. private _displacementVector;
  88645. /** @hidden */
  88646. _radius: Vector3;
  88647. /** @hidden */
  88648. _retry: number;
  88649. private _velocity;
  88650. private _basePoint;
  88651. private _epsilon;
  88652. /** @hidden */
  88653. _velocityWorldLength: number;
  88654. /** @hidden */
  88655. _basePointWorld: Vector3;
  88656. private _velocityWorld;
  88657. private _normalizedVelocity;
  88658. /** @hidden */
  88659. _initialVelocity: Vector3;
  88660. /** @hidden */
  88661. _initialPosition: Vector3;
  88662. private _nearestDistance;
  88663. private _collisionMask;
  88664. get collisionMask(): number;
  88665. set collisionMask(mask: number);
  88666. /**
  88667. * Gets the plane normal used to compute the sliding response (in local space)
  88668. */
  88669. get slidePlaneNormal(): Vector3;
  88670. /** @hidden */
  88671. _initialize(source: Vector3, dir: Vector3, e: number): void;
  88672. /** @hidden */
  88673. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  88674. /** @hidden */
  88675. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  88676. /** @hidden */
  88677. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  88678. /** @hidden */
  88679. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  88680. /** @hidden */
  88681. _getResponse(pos: Vector3, vel: Vector3): void;
  88682. }
  88683. }
  88684. declare module BABYLON {
  88685. /**
  88686. * Interface for cullable objects
  88687. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  88688. */
  88689. export interface ICullable {
  88690. /**
  88691. * Checks if the object or part of the object is in the frustum
  88692. * @param frustumPlanes Camera near/planes
  88693. * @returns true if the object is in frustum otherwise false
  88694. */
  88695. isInFrustum(frustumPlanes: Plane[]): boolean;
  88696. /**
  88697. * Checks if a cullable object (mesh...) is in the camera frustum
  88698. * Unlike isInFrustum this cheks the full bounding box
  88699. * @param frustumPlanes Camera near/planes
  88700. * @returns true if the object is in frustum otherwise false
  88701. */
  88702. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  88703. }
  88704. /**
  88705. * Info for a bounding data of a mesh
  88706. */
  88707. export class BoundingInfo implements ICullable {
  88708. /**
  88709. * Bounding box for the mesh
  88710. */
  88711. readonly boundingBox: BoundingBox;
  88712. /**
  88713. * Bounding sphere for the mesh
  88714. */
  88715. readonly boundingSphere: BoundingSphere;
  88716. private _isLocked;
  88717. private static readonly TmpVector3;
  88718. /**
  88719. * Constructs bounding info
  88720. * @param minimum min vector of the bounding box/sphere
  88721. * @param maximum max vector of the bounding box/sphere
  88722. * @param worldMatrix defines the new world matrix
  88723. */
  88724. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88725. /**
  88726. * Recreates the entire bounding info from scratch as if we call the constructor in place
  88727. * @param min defines the new minimum vector (in local space)
  88728. * @param max defines the new maximum vector (in local space)
  88729. * @param worldMatrix defines the new world matrix
  88730. */
  88731. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88732. /**
  88733. * min vector of the bounding box/sphere
  88734. */
  88735. get minimum(): Vector3;
  88736. /**
  88737. * max vector of the bounding box/sphere
  88738. */
  88739. get maximum(): Vector3;
  88740. /**
  88741. * If the info is locked and won't be updated to avoid perf overhead
  88742. */
  88743. get isLocked(): boolean;
  88744. set isLocked(value: boolean);
  88745. /**
  88746. * Updates the bounding sphere and box
  88747. * @param world world matrix to be used to update
  88748. */
  88749. update(world: DeepImmutable<Matrix>): void;
  88750. /**
  88751. * Recreate the bounding info to be centered around a specific point given a specific extend.
  88752. * @param center New center of the bounding info
  88753. * @param extend New extend of the bounding info
  88754. * @returns the current bounding info
  88755. */
  88756. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  88757. /**
  88758. * Scale the current bounding info by applying a scale factor
  88759. * @param factor defines the scale factor to apply
  88760. * @returns the current bounding info
  88761. */
  88762. scale(factor: number): BoundingInfo;
  88763. /**
  88764. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  88765. * @param frustumPlanes defines the frustum to test
  88766. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  88767. * @returns true if the bounding info is in the frustum planes
  88768. */
  88769. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  88770. /**
  88771. * Gets the world distance between the min and max points of the bounding box
  88772. */
  88773. get diagonalLength(): number;
  88774. /**
  88775. * Checks if a cullable object (mesh...) is in the camera frustum
  88776. * Unlike isInFrustum this cheks the full bounding box
  88777. * @param frustumPlanes Camera near/planes
  88778. * @returns true if the object is in frustum otherwise false
  88779. */
  88780. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88781. /** @hidden */
  88782. _checkCollision(collider: Collider): boolean;
  88783. /**
  88784. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  88785. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88786. * @param point the point to check intersection with
  88787. * @returns if the point intersects
  88788. */
  88789. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88790. /**
  88791. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  88792. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88793. * @param boundingInfo the bounding info to check intersection with
  88794. * @param precise if the intersection should be done using OBB
  88795. * @returns if the bounding info intersects
  88796. */
  88797. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  88798. }
  88799. }
  88800. declare module BABYLON {
  88801. /**
  88802. * Extracts minimum and maximum values from a list of indexed positions
  88803. * @param positions defines the positions to use
  88804. * @param indices defines the indices to the positions
  88805. * @param indexStart defines the start index
  88806. * @param indexCount defines the end index
  88807. * @param bias defines bias value to add to the result
  88808. * @return minimum and maximum values
  88809. */
  88810. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  88811. minimum: Vector3;
  88812. maximum: Vector3;
  88813. };
  88814. /**
  88815. * Extracts minimum and maximum values from a list of positions
  88816. * @param positions defines the positions to use
  88817. * @param start defines the start index in the positions array
  88818. * @param count defines the number of positions to handle
  88819. * @param bias defines bias value to add to the result
  88820. * @param stride defines the stride size to use (distance between two positions in the positions array)
  88821. * @return minimum and maximum values
  88822. */
  88823. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  88824. minimum: Vector3;
  88825. maximum: Vector3;
  88826. };
  88827. }
  88828. declare module BABYLON {
  88829. /**
  88830. * Class used to manipulate GUIDs
  88831. */
  88832. export class GUID {
  88833. /**
  88834. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88835. * Be aware Math.random() could cause collisions, but:
  88836. * "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"
  88837. * @returns a pseudo random id
  88838. */
  88839. static RandomId(): string;
  88840. }
  88841. }
  88842. declare module BABYLON {
  88843. /**
  88844. * Base class of all the textures in babylon.
  88845. * It groups all the common properties the materials, post process, lights... might need
  88846. * in order to make a correct use of the texture.
  88847. */
  88848. export class BaseTexture extends ThinTexture implements IAnimatable {
  88849. /**
  88850. * Default anisotropic filtering level for the application.
  88851. * It is set to 4 as a good tradeoff between perf and quality.
  88852. */
  88853. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  88854. /**
  88855. * Gets or sets the unique id of the texture
  88856. */
  88857. uniqueId: number;
  88858. /**
  88859. * Define the name of the texture.
  88860. */
  88861. name: string;
  88862. /**
  88863. * Gets or sets an object used to store user defined information.
  88864. */
  88865. metadata: any;
  88866. /**
  88867. * For internal use only. Please do not use.
  88868. */
  88869. reservedDataStore: any;
  88870. private _hasAlpha;
  88871. /**
  88872. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  88873. */
  88874. set hasAlpha(value: boolean);
  88875. get hasAlpha(): boolean;
  88876. /**
  88877. * Defines if the alpha value should be determined via the rgb values.
  88878. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  88879. */
  88880. getAlphaFromRGB: boolean;
  88881. /**
  88882. * Intensity or strength of the texture.
  88883. * It is commonly used by materials to fine tune the intensity of the texture
  88884. */
  88885. level: number;
  88886. /**
  88887. * Define the UV chanel to use starting from 0 and defaulting to 0.
  88888. * This is part of the texture as textures usually maps to one uv set.
  88889. */
  88890. coordinatesIndex: number;
  88891. protected _coordinatesMode: number;
  88892. /**
  88893. * How a texture is mapped.
  88894. *
  88895. * | Value | Type | Description |
  88896. * | ----- | ----------------------------------- | ----------- |
  88897. * | 0 | EXPLICIT_MODE | |
  88898. * | 1 | SPHERICAL_MODE | |
  88899. * | 2 | PLANAR_MODE | |
  88900. * | 3 | CUBIC_MODE | |
  88901. * | 4 | PROJECTION_MODE | |
  88902. * | 5 | SKYBOX_MODE | |
  88903. * | 6 | INVCUBIC_MODE | |
  88904. * | 7 | EQUIRECTANGULAR_MODE | |
  88905. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  88906. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  88907. */
  88908. set coordinatesMode(value: number);
  88909. get coordinatesMode(): number;
  88910. /**
  88911. * | Value | Type | Description |
  88912. * | ----- | ------------------ | ----------- |
  88913. * | 0 | CLAMP_ADDRESSMODE | |
  88914. * | 1 | WRAP_ADDRESSMODE | |
  88915. * | 2 | MIRROR_ADDRESSMODE | |
  88916. */
  88917. get wrapU(): number;
  88918. set wrapU(value: number);
  88919. /**
  88920. * | Value | Type | Description |
  88921. * | ----- | ------------------ | ----------- |
  88922. * | 0 | CLAMP_ADDRESSMODE | |
  88923. * | 1 | WRAP_ADDRESSMODE | |
  88924. * | 2 | MIRROR_ADDRESSMODE | |
  88925. */
  88926. get wrapV(): number;
  88927. set wrapV(value: number);
  88928. /**
  88929. * | Value | Type | Description |
  88930. * | ----- | ------------------ | ----------- |
  88931. * | 0 | CLAMP_ADDRESSMODE | |
  88932. * | 1 | WRAP_ADDRESSMODE | |
  88933. * | 2 | MIRROR_ADDRESSMODE | |
  88934. */
  88935. wrapR: number;
  88936. /**
  88937. * With compliant hardware and browser (supporting anisotropic filtering)
  88938. * this defines the level of anisotropic filtering in the texture.
  88939. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  88940. */
  88941. anisotropicFilteringLevel: number;
  88942. private _isCube;
  88943. /**
  88944. * Define if the texture is a cube texture or if false a 2d texture.
  88945. */
  88946. get isCube(): boolean;
  88947. set isCube(value: boolean);
  88948. /**
  88949. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  88950. */
  88951. get is3D(): boolean;
  88952. set is3D(value: boolean);
  88953. /**
  88954. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  88955. */
  88956. get is2DArray(): boolean;
  88957. set is2DArray(value: boolean);
  88958. private _gammaSpace;
  88959. /**
  88960. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  88961. * HDR texture are usually stored in linear space.
  88962. * This only impacts the PBR and Background materials
  88963. */
  88964. get gammaSpace(): boolean;
  88965. set gammaSpace(gamma: boolean);
  88966. /**
  88967. * Gets or sets whether or not the texture contains RGBD data.
  88968. */
  88969. get isRGBD(): boolean;
  88970. set isRGBD(value: boolean);
  88971. /**
  88972. * Is Z inverted in the texture (useful in a cube texture).
  88973. */
  88974. invertZ: boolean;
  88975. /**
  88976. * Are mip maps generated for this texture or not.
  88977. */
  88978. get noMipmap(): boolean;
  88979. /**
  88980. * @hidden
  88981. */
  88982. lodLevelInAlpha: boolean;
  88983. /**
  88984. * With prefiltered texture, defined the offset used during the prefiltering steps.
  88985. */
  88986. get lodGenerationOffset(): number;
  88987. set lodGenerationOffset(value: number);
  88988. /**
  88989. * With prefiltered texture, defined the scale used during the prefiltering steps.
  88990. */
  88991. get lodGenerationScale(): number;
  88992. set lodGenerationScale(value: number);
  88993. /**
  88994. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  88995. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  88996. * average roughness values.
  88997. */
  88998. get linearSpecularLOD(): boolean;
  88999. set linearSpecularLOD(value: boolean);
  89000. /**
  89001. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  89002. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  89003. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  89004. */
  89005. get irradianceTexture(): Nullable<BaseTexture>;
  89006. set irradianceTexture(value: Nullable<BaseTexture>);
  89007. /**
  89008. * Define if the texture is a render target.
  89009. */
  89010. isRenderTarget: boolean;
  89011. /**
  89012. * Define the unique id of the texture in the scene.
  89013. */
  89014. get uid(): string;
  89015. /** @hidden */
  89016. _prefiltered: boolean;
  89017. /**
  89018. * Return a string representation of the texture.
  89019. * @returns the texture as a string
  89020. */
  89021. toString(): string;
  89022. /**
  89023. * Get the class name of the texture.
  89024. * @returns "BaseTexture"
  89025. */
  89026. getClassName(): string;
  89027. /**
  89028. * Define the list of animation attached to the texture.
  89029. */
  89030. animations: Animation[];
  89031. /**
  89032. * An event triggered when the texture is disposed.
  89033. */
  89034. onDisposeObservable: Observable<BaseTexture>;
  89035. private _onDisposeObserver;
  89036. /**
  89037. * Callback triggered when the texture has been disposed.
  89038. * Kept for back compatibility, you can use the onDisposeObservable instead.
  89039. */
  89040. set onDispose(callback: () => void);
  89041. protected _scene: Nullable<Scene>;
  89042. /** @hidden */
  89043. _texture: Nullable<InternalTexture>;
  89044. private _uid;
  89045. /**
  89046. * Define if the texture is preventinga material to render or not.
  89047. * If not and the texture is not ready, the engine will use a default black texture instead.
  89048. */
  89049. get isBlocking(): boolean;
  89050. /**
  89051. * Instantiates a new BaseTexture.
  89052. * Base class of all the textures in babylon.
  89053. * It groups all the common properties the materials, post process, lights... might need
  89054. * in order to make a correct use of the texture.
  89055. * @param sceneOrEngine Define the scene or engine the texture blongs to
  89056. */
  89057. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  89058. /**
  89059. * Get the scene the texture belongs to.
  89060. * @returns the scene or null if undefined
  89061. */
  89062. getScene(): Nullable<Scene>;
  89063. /** @hidden */
  89064. protected _getEngine(): Nullable<ThinEngine>;
  89065. /**
  89066. * Checks if the texture has the same transform matrix than another texture
  89067. * @param texture texture to check against
  89068. * @returns true if the transforms are the same, else false
  89069. */
  89070. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  89071. /**
  89072. * Get the texture transform matrix used to offset tile the texture for istance.
  89073. * @returns the transformation matrix
  89074. */
  89075. getTextureMatrix(): Matrix;
  89076. /**
  89077. * Get the texture reflection matrix used to rotate/transform the reflection.
  89078. * @returns the reflection matrix
  89079. */
  89080. getReflectionTextureMatrix(): Matrix;
  89081. /**
  89082. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  89083. * @returns true if ready or not blocking
  89084. */
  89085. isReadyOrNotBlocking(): boolean;
  89086. /**
  89087. * Scales the texture if is `canRescale()`
  89088. * @param ratio the resize factor we want to use to rescale
  89089. */
  89090. scale(ratio: number): void;
  89091. /**
  89092. * Get if the texture can rescale.
  89093. */
  89094. get canRescale(): boolean;
  89095. /** @hidden */
  89096. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  89097. /** @hidden */
  89098. _rebuild(): void;
  89099. /**
  89100. * Clones the texture.
  89101. * @returns the cloned texture
  89102. */
  89103. clone(): Nullable<BaseTexture>;
  89104. /**
  89105. * Get the texture underlying type (INT, FLOAT...)
  89106. */
  89107. get textureType(): number;
  89108. /**
  89109. * Get the texture underlying format (RGB, RGBA...)
  89110. */
  89111. get textureFormat(): number;
  89112. /**
  89113. * Indicates that textures need to be re-calculated for all materials
  89114. */
  89115. protected _markAllSubMeshesAsTexturesDirty(): void;
  89116. /**
  89117. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  89118. * This will returns an RGBA array buffer containing either in values (0-255) or
  89119. * float values (0-1) depending of the underlying buffer type.
  89120. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  89121. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  89122. * @param buffer defines a user defined buffer to fill with data (can be null)
  89123. * @returns The Array buffer containing the pixels data.
  89124. */
  89125. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  89126. /** @hidden */
  89127. get _lodTextureHigh(): Nullable<BaseTexture>;
  89128. /** @hidden */
  89129. get _lodTextureMid(): Nullable<BaseTexture>;
  89130. /** @hidden */
  89131. get _lodTextureLow(): Nullable<BaseTexture>;
  89132. /**
  89133. * Dispose the texture and release its associated resources.
  89134. */
  89135. dispose(): void;
  89136. /**
  89137. * Serialize the texture into a JSON representation that can be parsed later on.
  89138. * @returns the JSON representation of the texture
  89139. */
  89140. serialize(): any;
  89141. /**
  89142. * Helper function to be called back once a list of texture contains only ready textures.
  89143. * @param textures Define the list of textures to wait for
  89144. * @param callback Define the callback triggered once the entire list will be ready
  89145. */
  89146. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  89147. private static _isScene;
  89148. }
  89149. }
  89150. declare module BABYLON {
  89151. /** @hidden */
  89152. export class WebGLDataBuffer extends DataBuffer {
  89153. private _buffer;
  89154. constructor(resource: WebGLBuffer);
  89155. get underlyingResource(): any;
  89156. }
  89157. }
  89158. declare module BABYLON {
  89159. /** @hidden */
  89160. export class WebGLPipelineContext implements IPipelineContext {
  89161. engine: ThinEngine;
  89162. program: Nullable<WebGLProgram>;
  89163. context?: WebGLRenderingContext;
  89164. vertexShader?: WebGLShader;
  89165. fragmentShader?: WebGLShader;
  89166. isParallelCompiled: boolean;
  89167. onCompiled?: () => void;
  89168. transformFeedback?: WebGLTransformFeedback | null;
  89169. vertexCompilationError: Nullable<string>;
  89170. fragmentCompilationError: Nullable<string>;
  89171. programLinkError: Nullable<string>;
  89172. programValidationError: Nullable<string>;
  89173. get isAsync(): boolean;
  89174. get isReady(): boolean;
  89175. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  89176. _getVertexShaderCode(): string | null;
  89177. _getFragmentShaderCode(): string | null;
  89178. }
  89179. }
  89180. declare module BABYLON {
  89181. interface ThinEngine {
  89182. /**
  89183. * Create an uniform buffer
  89184. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  89185. * @param elements defines the content of the uniform buffer
  89186. * @returns the webGL uniform buffer
  89187. */
  89188. createUniformBuffer(elements: FloatArray): DataBuffer;
  89189. /**
  89190. * Create a dynamic uniform buffer
  89191. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  89192. * @param elements defines the content of the uniform buffer
  89193. * @returns the webGL uniform buffer
  89194. */
  89195. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  89196. /**
  89197. * Update an existing uniform buffer
  89198. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  89199. * @param uniformBuffer defines the target uniform buffer
  89200. * @param elements defines the content to update
  89201. * @param offset defines the offset in the uniform buffer where update should start
  89202. * @param count defines the size of the data to update
  89203. */
  89204. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  89205. /**
  89206. * Bind an uniform buffer to the current webGL context
  89207. * @param buffer defines the buffer to bind
  89208. */
  89209. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  89210. /**
  89211. * Bind a buffer to the current webGL context at a given location
  89212. * @param buffer defines the buffer to bind
  89213. * @param location defines the index where to bind the buffer
  89214. */
  89215. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  89216. /**
  89217. * Bind a specific block at a given index in a specific shader program
  89218. * @param pipelineContext defines the pipeline context to use
  89219. * @param blockName defines the block name
  89220. * @param index defines the index where to bind the block
  89221. */
  89222. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  89223. }
  89224. }
  89225. declare module BABYLON {
  89226. /**
  89227. * Uniform buffer objects.
  89228. *
  89229. * Handles blocks of uniform on the GPU.
  89230. *
  89231. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89232. *
  89233. * For more information, please refer to :
  89234. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89235. */
  89236. export class UniformBuffer {
  89237. private _engine;
  89238. private _buffer;
  89239. private _data;
  89240. private _bufferData;
  89241. private _dynamic?;
  89242. private _uniformLocations;
  89243. private _uniformSizes;
  89244. private _uniformLocationPointer;
  89245. private _needSync;
  89246. private _noUBO;
  89247. private _currentEffect;
  89248. /** @hidden */
  89249. _alreadyBound: boolean;
  89250. private static _MAX_UNIFORM_SIZE;
  89251. private static _tempBuffer;
  89252. /**
  89253. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  89254. * This is dynamic to allow compat with webgl 1 and 2.
  89255. * You will need to pass the name of the uniform as well as the value.
  89256. */
  89257. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  89258. /**
  89259. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  89260. * This is dynamic to allow compat with webgl 1 and 2.
  89261. * You will need to pass the name of the uniform as well as the value.
  89262. */
  89263. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  89264. /**
  89265. * Lambda to Update a single float in a uniform buffer.
  89266. * This is dynamic to allow compat with webgl 1 and 2.
  89267. * You will need to pass the name of the uniform as well as the value.
  89268. */
  89269. updateFloat: (name: string, x: number) => void;
  89270. /**
  89271. * Lambda to Update a vec2 of float in a uniform buffer.
  89272. * This is dynamic to allow compat with webgl 1 and 2.
  89273. * You will need to pass the name of the uniform as well as the value.
  89274. */
  89275. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  89276. /**
  89277. * Lambda to Update a vec3 of float in a uniform buffer.
  89278. * This is dynamic to allow compat with webgl 1 and 2.
  89279. * You will need to pass the name of the uniform as well as the value.
  89280. */
  89281. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  89282. /**
  89283. * Lambda to Update a vec4 of float in a uniform buffer.
  89284. * This is dynamic to allow compat with webgl 1 and 2.
  89285. * You will need to pass the name of the uniform as well as the value.
  89286. */
  89287. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  89288. /**
  89289. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  89290. * This is dynamic to allow compat with webgl 1 and 2.
  89291. * You will need to pass the name of the uniform as well as the value.
  89292. */
  89293. updateMatrix: (name: string, mat: Matrix) => void;
  89294. /**
  89295. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  89296. * This is dynamic to allow compat with webgl 1 and 2.
  89297. * You will need to pass the name of the uniform as well as the value.
  89298. */
  89299. updateVector3: (name: string, vector: Vector3) => void;
  89300. /**
  89301. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  89302. * This is dynamic to allow compat with webgl 1 and 2.
  89303. * You will need to pass the name of the uniform as well as the value.
  89304. */
  89305. updateVector4: (name: string, vector: Vector4) => void;
  89306. /**
  89307. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  89308. * This is dynamic to allow compat with webgl 1 and 2.
  89309. * You will need to pass the name of the uniform as well as the value.
  89310. */
  89311. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  89312. /**
  89313. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  89314. * This is dynamic to allow compat with webgl 1 and 2.
  89315. * You will need to pass the name of the uniform as well as the value.
  89316. */
  89317. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  89318. /**
  89319. * Instantiates a new Uniform buffer objects.
  89320. *
  89321. * Handles blocks of uniform on the GPU.
  89322. *
  89323. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89324. *
  89325. * For more information, please refer to :
  89326. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89327. * @param engine Define the engine the buffer is associated with
  89328. * @param data Define the data contained in the buffer
  89329. * @param dynamic Define if the buffer is updatable
  89330. */
  89331. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  89332. /**
  89333. * Indicates if the buffer is using the WebGL2 UBO implementation,
  89334. * or just falling back on setUniformXXX calls.
  89335. */
  89336. get useUbo(): boolean;
  89337. /**
  89338. * Indicates if the WebGL underlying uniform buffer is in sync
  89339. * with the javascript cache data.
  89340. */
  89341. get isSync(): boolean;
  89342. /**
  89343. * Indicates if the WebGL underlying uniform buffer is dynamic.
  89344. * Also, a dynamic UniformBuffer will disable cache verification and always
  89345. * update the underlying WebGL uniform buffer to the GPU.
  89346. * @returns if Dynamic, otherwise false
  89347. */
  89348. isDynamic(): boolean;
  89349. /**
  89350. * The data cache on JS side.
  89351. * @returns the underlying data as a float array
  89352. */
  89353. getData(): Float32Array;
  89354. /**
  89355. * The underlying WebGL Uniform buffer.
  89356. * @returns the webgl buffer
  89357. */
  89358. getBuffer(): Nullable<DataBuffer>;
  89359. /**
  89360. * std140 layout specifies how to align data within an UBO structure.
  89361. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  89362. * for specs.
  89363. */
  89364. private _fillAlignment;
  89365. /**
  89366. * Adds an uniform in the buffer.
  89367. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  89368. * for the layout to be correct !
  89369. * @param name Name of the uniform, as used in the uniform block in the shader.
  89370. * @param size Data size, or data directly.
  89371. */
  89372. addUniform(name: string, size: number | number[]): void;
  89373. /**
  89374. * Adds a Matrix 4x4 to the uniform buffer.
  89375. * @param name Name of the uniform, as used in the uniform block in the shader.
  89376. * @param mat A 4x4 matrix.
  89377. */
  89378. addMatrix(name: string, mat: Matrix): void;
  89379. /**
  89380. * Adds a vec2 to the uniform buffer.
  89381. * @param name Name of the uniform, as used in the uniform block in the shader.
  89382. * @param x Define the x component value of the vec2
  89383. * @param y Define the y component value of the vec2
  89384. */
  89385. addFloat2(name: string, x: number, y: number): void;
  89386. /**
  89387. * Adds a vec3 to the uniform buffer.
  89388. * @param name Name of the uniform, as used in the uniform block in the shader.
  89389. * @param x Define the x component value of the vec3
  89390. * @param y Define the y component value of the vec3
  89391. * @param z Define the z component value of the vec3
  89392. */
  89393. addFloat3(name: string, x: number, y: number, z: number): void;
  89394. /**
  89395. * Adds a vec3 to the uniform buffer.
  89396. * @param name Name of the uniform, as used in the uniform block in the shader.
  89397. * @param color Define the vec3 from a Color
  89398. */
  89399. addColor3(name: string, color: Color3): void;
  89400. /**
  89401. * Adds a vec4 to the uniform buffer.
  89402. * @param name Name of the uniform, as used in the uniform block in the shader.
  89403. * @param color Define the rgb components from a Color
  89404. * @param alpha Define the a component of the vec4
  89405. */
  89406. addColor4(name: string, color: Color3, alpha: number): void;
  89407. /**
  89408. * Adds a vec3 to the uniform buffer.
  89409. * @param name Name of the uniform, as used in the uniform block in the shader.
  89410. * @param vector Define the vec3 components from a Vector
  89411. */
  89412. addVector3(name: string, vector: Vector3): void;
  89413. /**
  89414. * Adds a Matrix 3x3 to the uniform buffer.
  89415. * @param name Name of the uniform, as used in the uniform block in the shader.
  89416. */
  89417. addMatrix3x3(name: string): void;
  89418. /**
  89419. * Adds a Matrix 2x2 to the uniform buffer.
  89420. * @param name Name of the uniform, as used in the uniform block in the shader.
  89421. */
  89422. addMatrix2x2(name: string): void;
  89423. /**
  89424. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  89425. */
  89426. create(): void;
  89427. /** @hidden */
  89428. _rebuild(): void;
  89429. /**
  89430. * Updates the WebGL Uniform Buffer on the GPU.
  89431. * If the `dynamic` flag is set to true, no cache comparison is done.
  89432. * Otherwise, the buffer will be updated only if the cache differs.
  89433. */
  89434. update(): void;
  89435. /**
  89436. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  89437. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89438. * @param data Define the flattened data
  89439. * @param size Define the size of the data.
  89440. */
  89441. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  89442. private _valueCache;
  89443. private _cacheMatrix;
  89444. private _updateMatrix3x3ForUniform;
  89445. private _updateMatrix3x3ForEffect;
  89446. private _updateMatrix2x2ForEffect;
  89447. private _updateMatrix2x2ForUniform;
  89448. private _updateFloatForEffect;
  89449. private _updateFloatForUniform;
  89450. private _updateFloat2ForEffect;
  89451. private _updateFloat2ForUniform;
  89452. private _updateFloat3ForEffect;
  89453. private _updateFloat3ForUniform;
  89454. private _updateFloat4ForEffect;
  89455. private _updateFloat4ForUniform;
  89456. private _updateMatrixForEffect;
  89457. private _updateMatrixForUniform;
  89458. private _updateVector3ForEffect;
  89459. private _updateVector3ForUniform;
  89460. private _updateVector4ForEffect;
  89461. private _updateVector4ForUniform;
  89462. private _updateColor3ForEffect;
  89463. private _updateColor3ForUniform;
  89464. private _updateColor4ForEffect;
  89465. private _updateColor4ForUniform;
  89466. /**
  89467. * Sets a sampler uniform on the effect.
  89468. * @param name Define the name of the sampler.
  89469. * @param texture Define the texture to set in the sampler
  89470. */
  89471. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  89472. /**
  89473. * Directly updates the value of the uniform in the cache AND on the GPU.
  89474. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89475. * @param data Define the flattened data
  89476. */
  89477. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  89478. /**
  89479. * Binds this uniform buffer to an effect.
  89480. * @param effect Define the effect to bind the buffer to
  89481. * @param name Name of the uniform block in the shader.
  89482. */
  89483. bindToEffect(effect: Effect, name: string): void;
  89484. /**
  89485. * Disposes the uniform buffer.
  89486. */
  89487. dispose(): void;
  89488. }
  89489. }
  89490. declare module BABYLON {
  89491. /**
  89492. * Manages the defines for the Material
  89493. */
  89494. export class MaterialDefines {
  89495. /** @hidden */
  89496. protected _keys: string[];
  89497. private _isDirty;
  89498. /** @hidden */
  89499. _renderId: number;
  89500. /** @hidden */
  89501. _areLightsDirty: boolean;
  89502. /** @hidden */
  89503. _areLightsDisposed: boolean;
  89504. /** @hidden */
  89505. _areAttributesDirty: boolean;
  89506. /** @hidden */
  89507. _areTexturesDirty: boolean;
  89508. /** @hidden */
  89509. _areFresnelDirty: boolean;
  89510. /** @hidden */
  89511. _areMiscDirty: boolean;
  89512. /** @hidden */
  89513. _arePrePassDirty: boolean;
  89514. /** @hidden */
  89515. _areImageProcessingDirty: boolean;
  89516. /** @hidden */
  89517. _normals: boolean;
  89518. /** @hidden */
  89519. _uvs: boolean;
  89520. /** @hidden */
  89521. _needNormals: boolean;
  89522. /** @hidden */
  89523. _needUVs: boolean;
  89524. [id: string]: any;
  89525. /**
  89526. * Specifies if the material needs to be re-calculated
  89527. */
  89528. get isDirty(): boolean;
  89529. /**
  89530. * Marks the material to indicate that it has been re-calculated
  89531. */
  89532. markAsProcessed(): void;
  89533. /**
  89534. * Marks the material to indicate that it needs to be re-calculated
  89535. */
  89536. markAsUnprocessed(): void;
  89537. /**
  89538. * Marks the material to indicate all of its defines need to be re-calculated
  89539. */
  89540. markAllAsDirty(): void;
  89541. /**
  89542. * Marks the material to indicate that image processing needs to be re-calculated
  89543. */
  89544. markAsImageProcessingDirty(): void;
  89545. /**
  89546. * Marks the material to indicate the lights need to be re-calculated
  89547. * @param disposed Defines whether the light is dirty due to dispose or not
  89548. */
  89549. markAsLightDirty(disposed?: boolean): void;
  89550. /**
  89551. * Marks the attribute state as changed
  89552. */
  89553. markAsAttributesDirty(): void;
  89554. /**
  89555. * Marks the texture state as changed
  89556. */
  89557. markAsTexturesDirty(): void;
  89558. /**
  89559. * Marks the fresnel state as changed
  89560. */
  89561. markAsFresnelDirty(): void;
  89562. /**
  89563. * Marks the misc state as changed
  89564. */
  89565. markAsMiscDirty(): void;
  89566. /**
  89567. * Marks the prepass state as changed
  89568. */
  89569. markAsPrePassDirty(): void;
  89570. /**
  89571. * Rebuilds the material defines
  89572. */
  89573. rebuild(): void;
  89574. /**
  89575. * Specifies if two material defines are equal
  89576. * @param other - A material define instance to compare to
  89577. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  89578. */
  89579. isEqual(other: MaterialDefines): boolean;
  89580. /**
  89581. * Clones this instance's defines to another instance
  89582. * @param other - material defines to clone values to
  89583. */
  89584. cloneTo(other: MaterialDefines): void;
  89585. /**
  89586. * Resets the material define values
  89587. */
  89588. reset(): void;
  89589. /**
  89590. * Converts the material define values to a string
  89591. * @returns - String of material define information
  89592. */
  89593. toString(): string;
  89594. }
  89595. }
  89596. declare module BABYLON {
  89597. /**
  89598. * Enum that determines the text-wrapping mode to use.
  89599. */
  89600. export enum InspectableType {
  89601. /**
  89602. * Checkbox for booleans
  89603. */
  89604. Checkbox = 0,
  89605. /**
  89606. * Sliders for numbers
  89607. */
  89608. Slider = 1,
  89609. /**
  89610. * Vector3
  89611. */
  89612. Vector3 = 2,
  89613. /**
  89614. * Quaternions
  89615. */
  89616. Quaternion = 3,
  89617. /**
  89618. * Color3
  89619. */
  89620. Color3 = 4,
  89621. /**
  89622. * String
  89623. */
  89624. String = 5
  89625. }
  89626. /**
  89627. * Interface used to define custom inspectable properties.
  89628. * This interface is used by the inspector to display custom property grids
  89629. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89630. */
  89631. export interface IInspectable {
  89632. /**
  89633. * Gets the label to display
  89634. */
  89635. label: string;
  89636. /**
  89637. * Gets the name of the property to edit
  89638. */
  89639. propertyName: string;
  89640. /**
  89641. * Gets the type of the editor to use
  89642. */
  89643. type: InspectableType;
  89644. /**
  89645. * Gets the minimum value of the property when using in "slider" mode
  89646. */
  89647. min?: number;
  89648. /**
  89649. * Gets the maximum value of the property when using in "slider" mode
  89650. */
  89651. max?: number;
  89652. /**
  89653. * Gets the setp to use when using in "slider" mode
  89654. */
  89655. step?: number;
  89656. }
  89657. }
  89658. declare module BABYLON {
  89659. /**
  89660. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  89661. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  89662. * 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.
  89663. */
  89664. export abstract class Light extends Node {
  89665. /**
  89666. * Falloff Default: light is falling off following the material specification:
  89667. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  89668. */
  89669. static readonly FALLOFF_DEFAULT: number;
  89670. /**
  89671. * Falloff Physical: light is falling off following the inverse squared distance law.
  89672. */
  89673. static readonly FALLOFF_PHYSICAL: number;
  89674. /**
  89675. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  89676. * to enhance interoperability with other engines.
  89677. */
  89678. static readonly FALLOFF_GLTF: number;
  89679. /**
  89680. * Falloff Standard: light is falling off like in the standard material
  89681. * to enhance interoperability with other materials.
  89682. */
  89683. static readonly FALLOFF_STANDARD: number;
  89684. /**
  89685. * If every light affecting the material is in this lightmapMode,
  89686. * material.lightmapTexture adds or multiplies
  89687. * (depends on material.useLightmapAsShadowmap)
  89688. * after every other light calculations.
  89689. */
  89690. static readonly LIGHTMAP_DEFAULT: number;
  89691. /**
  89692. * material.lightmapTexture as only diffuse lighting from this light
  89693. * adds only specular lighting from this light
  89694. * adds dynamic shadows
  89695. */
  89696. static readonly LIGHTMAP_SPECULAR: number;
  89697. /**
  89698. * material.lightmapTexture as only lighting
  89699. * no light calculation from this light
  89700. * only adds dynamic shadows from this light
  89701. */
  89702. static readonly LIGHTMAP_SHADOWSONLY: number;
  89703. /**
  89704. * Each light type uses the default quantity according to its type:
  89705. * point/spot lights use luminous intensity
  89706. * directional lights use illuminance
  89707. */
  89708. static readonly INTENSITYMODE_AUTOMATIC: number;
  89709. /**
  89710. * lumen (lm)
  89711. */
  89712. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  89713. /**
  89714. * candela (lm/sr)
  89715. */
  89716. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  89717. /**
  89718. * lux (lm/m^2)
  89719. */
  89720. static readonly INTENSITYMODE_ILLUMINANCE: number;
  89721. /**
  89722. * nit (cd/m^2)
  89723. */
  89724. static readonly INTENSITYMODE_LUMINANCE: number;
  89725. /**
  89726. * Light type const id of the point light.
  89727. */
  89728. static readonly LIGHTTYPEID_POINTLIGHT: number;
  89729. /**
  89730. * Light type const id of the directional light.
  89731. */
  89732. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  89733. /**
  89734. * Light type const id of the spot light.
  89735. */
  89736. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  89737. /**
  89738. * Light type const id of the hemispheric light.
  89739. */
  89740. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  89741. /**
  89742. * Diffuse gives the basic color to an object.
  89743. */
  89744. diffuse: Color3;
  89745. /**
  89746. * Specular produces a highlight color on an object.
  89747. * Note: This is note affecting PBR materials.
  89748. */
  89749. specular: Color3;
  89750. /**
  89751. * Defines the falloff type for this light. This lets overrriding how punctual light are
  89752. * falling off base on range or angle.
  89753. * This can be set to any values in Light.FALLOFF_x.
  89754. *
  89755. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  89756. * other types of materials.
  89757. */
  89758. falloffType: number;
  89759. /**
  89760. * Strength of the light.
  89761. * Note: By default it is define in the framework own unit.
  89762. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  89763. */
  89764. intensity: number;
  89765. private _range;
  89766. protected _inverseSquaredRange: number;
  89767. /**
  89768. * Defines how far from the source the light is impacting in scene units.
  89769. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  89770. */
  89771. get range(): number;
  89772. /**
  89773. * Defines how far from the source the light is impacting in scene units.
  89774. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  89775. */
  89776. set range(value: number);
  89777. /**
  89778. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  89779. * of light.
  89780. */
  89781. private _photometricScale;
  89782. private _intensityMode;
  89783. /**
  89784. * Gets the photometric scale used to interpret the intensity.
  89785. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  89786. */
  89787. get intensityMode(): number;
  89788. /**
  89789. * Sets the photometric scale used to interpret the intensity.
  89790. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  89791. */
  89792. set intensityMode(value: number);
  89793. private _radius;
  89794. /**
  89795. * Gets the light radius used by PBR Materials to simulate soft area lights.
  89796. */
  89797. get radius(): number;
  89798. /**
  89799. * sets the light radius used by PBR Materials to simulate soft area lights.
  89800. */
  89801. set radius(value: number);
  89802. private _renderPriority;
  89803. /**
  89804. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  89805. * exceeding the number allowed of the materials.
  89806. */
  89807. renderPriority: number;
  89808. private _shadowEnabled;
  89809. /**
  89810. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  89811. * the current shadow generator.
  89812. */
  89813. get shadowEnabled(): boolean;
  89814. /**
  89815. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  89816. * the current shadow generator.
  89817. */
  89818. set shadowEnabled(value: boolean);
  89819. private _includedOnlyMeshes;
  89820. /**
  89821. * Gets the only meshes impacted by this light.
  89822. */
  89823. get includedOnlyMeshes(): AbstractMesh[];
  89824. /**
  89825. * Sets the only meshes impacted by this light.
  89826. */
  89827. set includedOnlyMeshes(value: AbstractMesh[]);
  89828. private _excludedMeshes;
  89829. /**
  89830. * Gets the meshes not impacted by this light.
  89831. */
  89832. get excludedMeshes(): AbstractMesh[];
  89833. /**
  89834. * Sets the meshes not impacted by this light.
  89835. */
  89836. set excludedMeshes(value: AbstractMesh[]);
  89837. private _excludeWithLayerMask;
  89838. /**
  89839. * Gets the layer id use to find what meshes are not impacted by the light.
  89840. * Inactive if 0
  89841. */
  89842. get excludeWithLayerMask(): number;
  89843. /**
  89844. * Sets the layer id use to find what meshes are not impacted by the light.
  89845. * Inactive if 0
  89846. */
  89847. set excludeWithLayerMask(value: number);
  89848. private _includeOnlyWithLayerMask;
  89849. /**
  89850. * Gets the layer id use to find what meshes are impacted by the light.
  89851. * Inactive if 0
  89852. */
  89853. get includeOnlyWithLayerMask(): number;
  89854. /**
  89855. * Sets the layer id use to find what meshes are impacted by the light.
  89856. * Inactive if 0
  89857. */
  89858. set includeOnlyWithLayerMask(value: number);
  89859. private _lightmapMode;
  89860. /**
  89861. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  89862. */
  89863. get lightmapMode(): number;
  89864. /**
  89865. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  89866. */
  89867. set lightmapMode(value: number);
  89868. /**
  89869. * Shadow generator associted to the light.
  89870. * @hidden Internal use only.
  89871. */
  89872. _shadowGenerator: Nullable<IShadowGenerator>;
  89873. /**
  89874. * @hidden Internal use only.
  89875. */
  89876. _excludedMeshesIds: string[];
  89877. /**
  89878. * @hidden Internal use only.
  89879. */
  89880. _includedOnlyMeshesIds: string[];
  89881. /**
  89882. * The current light unifom buffer.
  89883. * @hidden Internal use only.
  89884. */
  89885. _uniformBuffer: UniformBuffer;
  89886. /** @hidden */
  89887. _renderId: number;
  89888. /**
  89889. * Creates a Light object in the scene.
  89890. * Documentation : https://doc.babylonjs.com/babylon101/lights
  89891. * @param name The firendly name of the light
  89892. * @param scene The scene the light belongs too
  89893. */
  89894. constructor(name: string, scene: Scene);
  89895. protected abstract _buildUniformLayout(): void;
  89896. /**
  89897. * Sets the passed Effect "effect" with the Light information.
  89898. * @param effect The effect to update
  89899. * @param lightIndex The index of the light in the effect to update
  89900. * @returns The light
  89901. */
  89902. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  89903. /**
  89904. * Sets the passed Effect "effect" with the Light textures.
  89905. * @param effect The effect to update
  89906. * @param lightIndex The index of the light in the effect to update
  89907. * @returns The light
  89908. */
  89909. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  89910. /**
  89911. * Binds the lights information from the scene to the effect for the given mesh.
  89912. * @param lightIndex Light index
  89913. * @param scene The scene where the light belongs to
  89914. * @param effect The effect we are binding the data to
  89915. * @param useSpecular Defines if specular is supported
  89916. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  89917. */
  89918. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  89919. /**
  89920. * Sets the passed Effect "effect" with the Light information.
  89921. * @param effect The effect to update
  89922. * @param lightDataUniformName The uniform used to store light data (position or direction)
  89923. * @returns The light
  89924. */
  89925. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  89926. /**
  89927. * Returns the string "Light".
  89928. * @returns the class name
  89929. */
  89930. getClassName(): string;
  89931. /** @hidden */
  89932. readonly _isLight: boolean;
  89933. /**
  89934. * Converts the light information to a readable string for debug purpose.
  89935. * @param fullDetails Supports for multiple levels of logging within scene loading
  89936. * @returns the human readable light info
  89937. */
  89938. toString(fullDetails?: boolean): string;
  89939. /** @hidden */
  89940. protected _syncParentEnabledState(): void;
  89941. /**
  89942. * Set the enabled state of this node.
  89943. * @param value - the new enabled state
  89944. */
  89945. setEnabled(value: boolean): void;
  89946. /**
  89947. * Returns the Light associated shadow generator if any.
  89948. * @return the associated shadow generator.
  89949. */
  89950. getShadowGenerator(): Nullable<IShadowGenerator>;
  89951. /**
  89952. * Returns a Vector3, the absolute light position in the World.
  89953. * @returns the world space position of the light
  89954. */
  89955. getAbsolutePosition(): Vector3;
  89956. /**
  89957. * Specifies if the light will affect the passed mesh.
  89958. * @param mesh The mesh to test against the light
  89959. * @return true the mesh is affected otherwise, false.
  89960. */
  89961. canAffectMesh(mesh: AbstractMesh): boolean;
  89962. /**
  89963. * Sort function to order lights for rendering.
  89964. * @param a First Light object to compare to second.
  89965. * @param b Second Light object to compare first.
  89966. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  89967. */
  89968. static CompareLightsPriority(a: Light, b: Light): number;
  89969. /**
  89970. * Releases resources associated with this node.
  89971. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89972. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89973. */
  89974. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89975. /**
  89976. * Returns the light type ID (integer).
  89977. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  89978. */
  89979. getTypeID(): number;
  89980. /**
  89981. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  89982. * @returns the scaled intensity in intensity mode unit
  89983. */
  89984. getScaledIntensity(): number;
  89985. /**
  89986. * Returns a new Light object, named "name", from the current one.
  89987. * @param name The name of the cloned light
  89988. * @param newParent The parent of this light, if it has one
  89989. * @returns the new created light
  89990. */
  89991. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  89992. /**
  89993. * Serializes the current light into a Serialization object.
  89994. * @returns the serialized object.
  89995. */
  89996. serialize(): any;
  89997. /**
  89998. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  89999. * This new light is named "name" and added to the passed scene.
  90000. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90001. * @param name The friendly name of the light
  90002. * @param scene The scene the new light will belong to
  90003. * @returns the constructor function
  90004. */
  90005. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90006. /**
  90007. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90008. * @param parsedLight The JSON representation of the light
  90009. * @param scene The scene to create the parsed light in
  90010. * @returns the created light after parsing
  90011. */
  90012. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90013. private _hookArrayForExcluded;
  90014. private _hookArrayForIncludedOnly;
  90015. private _resyncMeshes;
  90016. /**
  90017. * Forces the meshes to update their light related information in their rendering used effects
  90018. * @hidden Internal Use Only
  90019. */
  90020. _markMeshesAsLightDirty(): void;
  90021. /**
  90022. * Recomputes the cached photometric scale if needed.
  90023. */
  90024. private _computePhotometricScale;
  90025. /**
  90026. * Returns the Photometric Scale according to the light type and intensity mode.
  90027. */
  90028. private _getPhotometricScale;
  90029. /**
  90030. * Reorder the light in the scene according to their defined priority.
  90031. * @hidden Internal Use Only
  90032. */
  90033. _reorderLightsInScene(): void;
  90034. /**
  90035. * Prepares the list of defines specific to the light type.
  90036. * @param defines the list of defines
  90037. * @param lightIndex defines the index of the light for the effect
  90038. */
  90039. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90040. }
  90041. }
  90042. declare module BABYLON {
  90043. /** Defines supported spaces */
  90044. export enum Space {
  90045. /** Local (object) space */
  90046. LOCAL = 0,
  90047. /** World space */
  90048. WORLD = 1,
  90049. /** Bone space */
  90050. BONE = 2
  90051. }
  90052. /** Defines the 3 main axes */
  90053. export class Axis {
  90054. /** X axis */
  90055. static X: Vector3;
  90056. /** Y axis */
  90057. static Y: Vector3;
  90058. /** Z axis */
  90059. static Z: Vector3;
  90060. }
  90061. /**
  90062. * Defines cartesian components.
  90063. */
  90064. export enum Coordinate {
  90065. /** X axis */
  90066. X = 0,
  90067. /** Y axis */
  90068. Y = 1,
  90069. /** Z axis */
  90070. Z = 2
  90071. }
  90072. }
  90073. declare module BABYLON {
  90074. /**
  90075. * Interface describing all the common properties and methods a shadow light needs to implement.
  90076. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  90077. * as well as binding the different shadow properties to the effects.
  90078. */
  90079. export interface IShadowLight extends Light {
  90080. /**
  90081. * The light id in the scene (used in scene.findLighById for instance)
  90082. */
  90083. id: string;
  90084. /**
  90085. * The position the shdow will be casted from.
  90086. */
  90087. position: Vector3;
  90088. /**
  90089. * In 2d mode (needCube being false), the direction used to cast the shadow.
  90090. */
  90091. direction: Vector3;
  90092. /**
  90093. * The transformed position. Position of the light in world space taking parenting in account.
  90094. */
  90095. transformedPosition: Vector3;
  90096. /**
  90097. * The transformed direction. Direction of the light in world space taking parenting in account.
  90098. */
  90099. transformedDirection: Vector3;
  90100. /**
  90101. * The friendly name of the light in the scene.
  90102. */
  90103. name: string;
  90104. /**
  90105. * Defines the shadow projection clipping minimum z value.
  90106. */
  90107. shadowMinZ: number;
  90108. /**
  90109. * Defines the shadow projection clipping maximum z value.
  90110. */
  90111. shadowMaxZ: number;
  90112. /**
  90113. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  90114. * @returns true if the information has been computed, false if it does not need to (no parenting)
  90115. */
  90116. computeTransformedInformation(): boolean;
  90117. /**
  90118. * Gets the scene the light belongs to.
  90119. * @returns The scene
  90120. */
  90121. getScene(): Scene;
  90122. /**
  90123. * Callback defining a custom Projection Matrix Builder.
  90124. * This can be used to override the default projection matrix computation.
  90125. */
  90126. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  90127. /**
  90128. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  90129. * @param matrix The materix to updated with the projection information
  90130. * @param viewMatrix The transform matrix of the light
  90131. * @param renderList The list of mesh to render in the map
  90132. * @returns The current light
  90133. */
  90134. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  90135. /**
  90136. * Gets the current depth scale used in ESM.
  90137. * @returns The scale
  90138. */
  90139. getDepthScale(): number;
  90140. /**
  90141. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  90142. * @returns true if a cube texture needs to be use
  90143. */
  90144. needCube(): boolean;
  90145. /**
  90146. * Detects if the projection matrix requires to be recomputed this frame.
  90147. * @returns true if it requires to be recomputed otherwise, false.
  90148. */
  90149. needProjectionMatrixCompute(): boolean;
  90150. /**
  90151. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  90152. */
  90153. forceProjectionMatrixCompute(): void;
  90154. /**
  90155. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  90156. * @param faceIndex The index of the face we are computed the direction to generate shadow
  90157. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  90158. */
  90159. getShadowDirection(faceIndex?: number): Vector3;
  90160. /**
  90161. * Gets the minZ used for shadow according to both the scene and the light.
  90162. * @param activeCamera The camera we are returning the min for
  90163. * @returns the depth min z
  90164. */
  90165. getDepthMinZ(activeCamera: Camera): number;
  90166. /**
  90167. * Gets the maxZ used for shadow according to both the scene and the light.
  90168. * @param activeCamera The camera we are returning the max for
  90169. * @returns the depth max z
  90170. */
  90171. getDepthMaxZ(activeCamera: Camera): number;
  90172. }
  90173. /**
  90174. * Base implementation IShadowLight
  90175. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  90176. */
  90177. export abstract class ShadowLight extends Light implements IShadowLight {
  90178. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  90179. protected _position: Vector3;
  90180. protected _setPosition(value: Vector3): void;
  90181. /**
  90182. * Sets the position the shadow will be casted from. Also use as the light position for both
  90183. * point and spot lights.
  90184. */
  90185. get position(): Vector3;
  90186. /**
  90187. * Sets the position the shadow will be casted from. Also use as the light position for both
  90188. * point and spot lights.
  90189. */
  90190. set position(value: Vector3);
  90191. protected _direction: Vector3;
  90192. protected _setDirection(value: Vector3): void;
  90193. /**
  90194. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  90195. * Also use as the light direction on spot and directional lights.
  90196. */
  90197. get direction(): Vector3;
  90198. /**
  90199. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  90200. * Also use as the light direction on spot and directional lights.
  90201. */
  90202. set direction(value: Vector3);
  90203. protected _shadowMinZ: number;
  90204. /**
  90205. * Gets the shadow projection clipping minimum z value.
  90206. */
  90207. get shadowMinZ(): number;
  90208. /**
  90209. * Sets the shadow projection clipping minimum z value.
  90210. */
  90211. set shadowMinZ(value: number);
  90212. protected _shadowMaxZ: number;
  90213. /**
  90214. * Sets the shadow projection clipping maximum z value.
  90215. */
  90216. get shadowMaxZ(): number;
  90217. /**
  90218. * Gets the shadow projection clipping maximum z value.
  90219. */
  90220. set shadowMaxZ(value: number);
  90221. /**
  90222. * Callback defining a custom Projection Matrix Builder.
  90223. * This can be used to override the default projection matrix computation.
  90224. */
  90225. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  90226. /**
  90227. * The transformed position. Position of the light in world space taking parenting in account.
  90228. */
  90229. transformedPosition: Vector3;
  90230. /**
  90231. * The transformed direction. Direction of the light in world space taking parenting in account.
  90232. */
  90233. transformedDirection: Vector3;
  90234. private _needProjectionMatrixCompute;
  90235. /**
  90236. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  90237. * @returns true if the information has been computed, false if it does not need to (no parenting)
  90238. */
  90239. computeTransformedInformation(): boolean;
  90240. /**
  90241. * Return the depth scale used for the shadow map.
  90242. * @returns the depth scale.
  90243. */
  90244. getDepthScale(): number;
  90245. /**
  90246. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  90247. * @param faceIndex The index of the face we are computed the direction to generate shadow
  90248. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  90249. */
  90250. getShadowDirection(faceIndex?: number): Vector3;
  90251. /**
  90252. * Returns the ShadowLight absolute position in the World.
  90253. * @returns the position vector in world space
  90254. */
  90255. getAbsolutePosition(): Vector3;
  90256. /**
  90257. * Sets the ShadowLight direction toward the passed target.
  90258. * @param target The point to target in local space
  90259. * @returns the updated ShadowLight direction
  90260. */
  90261. setDirectionToTarget(target: Vector3): Vector3;
  90262. /**
  90263. * Returns the light rotation in euler definition.
  90264. * @returns the x y z rotation in local space.
  90265. */
  90266. getRotation(): Vector3;
  90267. /**
  90268. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  90269. * @returns true if a cube texture needs to be use
  90270. */
  90271. needCube(): boolean;
  90272. /**
  90273. * Detects if the projection matrix requires to be recomputed this frame.
  90274. * @returns true if it requires to be recomputed otherwise, false.
  90275. */
  90276. needProjectionMatrixCompute(): boolean;
  90277. /**
  90278. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  90279. */
  90280. forceProjectionMatrixCompute(): void;
  90281. /** @hidden */
  90282. _initCache(): void;
  90283. /** @hidden */
  90284. _isSynchronized(): boolean;
  90285. /**
  90286. * Computes the world matrix of the node
  90287. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90288. * @returns the world matrix
  90289. */
  90290. computeWorldMatrix(force?: boolean): Matrix;
  90291. /**
  90292. * Gets the minZ used for shadow according to both the scene and the light.
  90293. * @param activeCamera The camera we are returning the min for
  90294. * @returns the depth min z
  90295. */
  90296. getDepthMinZ(activeCamera: Camera): number;
  90297. /**
  90298. * Gets the maxZ used for shadow according to both the scene and the light.
  90299. * @param activeCamera The camera we are returning the max for
  90300. * @returns the depth max z
  90301. */
  90302. getDepthMaxZ(activeCamera: Camera): number;
  90303. /**
  90304. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  90305. * @param matrix The materix to updated with the projection information
  90306. * @param viewMatrix The transform matrix of the light
  90307. * @param renderList The list of mesh to render in the map
  90308. * @returns The current light
  90309. */
  90310. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  90311. }
  90312. }
  90313. declare module BABYLON {
  90314. /**
  90315. * Configuration needed for prepass-capable materials
  90316. */
  90317. export class PrePassConfiguration {
  90318. /**
  90319. * Previous world matrices of meshes carrying this material
  90320. * Used for computing velocity
  90321. */
  90322. previousWorldMatrices: {
  90323. [index: number]: Matrix;
  90324. };
  90325. /**
  90326. * Previous view project matrix
  90327. * Used for computing velocity
  90328. */
  90329. previousViewProjection: Matrix;
  90330. /**
  90331. * Previous bones of meshes carrying this material
  90332. * Used for computing velocity
  90333. */
  90334. previousBones: {
  90335. [index: number]: Float32Array;
  90336. };
  90337. /**
  90338. * Add the required uniforms to the current list.
  90339. * @param uniforms defines the current uniform list.
  90340. */
  90341. static AddUniforms(uniforms: string[]): void;
  90342. /**
  90343. * Add the required samplers to the current list.
  90344. * @param samplers defines the current sampler list.
  90345. */
  90346. static AddSamplers(samplers: string[]): void;
  90347. /**
  90348. * Binds the material data.
  90349. * @param effect defines the effect to update
  90350. * @param scene defines the scene the material belongs to.
  90351. * @param mesh The mesh
  90352. * @param world World matrix of this mesh
  90353. * @param isFrozen Is the material frozen
  90354. */
  90355. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  90356. }
  90357. }
  90358. declare module BABYLON {
  90359. /**
  90360. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  90361. * This is the base of the follow, arc rotate cameras and Free camera
  90362. * @see https://doc.babylonjs.com/features/cameras
  90363. */
  90364. export class TargetCamera extends Camera {
  90365. private static _RigCamTransformMatrix;
  90366. private static _TargetTransformMatrix;
  90367. private static _TargetFocalPoint;
  90368. private _tmpUpVector;
  90369. private _tmpTargetVector;
  90370. /**
  90371. * Define the current direction the camera is moving to
  90372. */
  90373. cameraDirection: Vector3;
  90374. /**
  90375. * Define the current rotation the camera is rotating to
  90376. */
  90377. cameraRotation: Vector2;
  90378. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  90379. ignoreParentScaling: boolean;
  90380. /**
  90381. * When set, the up vector of the camera will be updated by the rotation of the camera
  90382. */
  90383. updateUpVectorFromRotation: boolean;
  90384. private _tmpQuaternion;
  90385. /**
  90386. * Define the current rotation of the camera
  90387. */
  90388. rotation: Vector3;
  90389. /**
  90390. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  90391. */
  90392. rotationQuaternion: Quaternion;
  90393. /**
  90394. * Define the current speed of the camera
  90395. */
  90396. speed: number;
  90397. /**
  90398. * Add constraint to the camera to prevent it to move freely in all directions and
  90399. * around all axis.
  90400. */
  90401. noRotationConstraint: boolean;
  90402. /**
  90403. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  90404. * panning
  90405. */
  90406. invertRotation: boolean;
  90407. /**
  90408. * Speed multiplier for inverse camera panning
  90409. */
  90410. inverseRotationSpeed: number;
  90411. /**
  90412. * Define the current target of the camera as an object or a position.
  90413. */
  90414. lockedTarget: any;
  90415. /** @hidden */
  90416. _currentTarget: Vector3;
  90417. /** @hidden */
  90418. _initialFocalDistance: number;
  90419. /** @hidden */
  90420. _viewMatrix: Matrix;
  90421. /** @hidden */
  90422. _camMatrix: Matrix;
  90423. /** @hidden */
  90424. _cameraTransformMatrix: Matrix;
  90425. /** @hidden */
  90426. _cameraRotationMatrix: Matrix;
  90427. /** @hidden */
  90428. _referencePoint: Vector3;
  90429. /** @hidden */
  90430. _transformedReferencePoint: Vector3;
  90431. /** @hidden */
  90432. _reset: () => void;
  90433. private _defaultUp;
  90434. /**
  90435. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  90436. * This is the base of the follow, arc rotate cameras and Free camera
  90437. * @see https://doc.babylonjs.com/features/cameras
  90438. * @param name Defines the name of the camera in the scene
  90439. * @param position Defines the start position of the camera in the scene
  90440. * @param scene Defines the scene the camera belongs to
  90441. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  90442. */
  90443. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90444. /**
  90445. * Gets the position in front of the camera at a given distance.
  90446. * @param distance The distance from the camera we want the position to be
  90447. * @returns the position
  90448. */
  90449. getFrontPosition(distance: number): Vector3;
  90450. /** @hidden */
  90451. _getLockedTargetPosition(): Nullable<Vector3>;
  90452. private _storedPosition;
  90453. private _storedRotation;
  90454. private _storedRotationQuaternion;
  90455. /**
  90456. * Store current camera state of the camera (fov, position, rotation, etc..)
  90457. * @returns the camera
  90458. */
  90459. storeState(): Camera;
  90460. /**
  90461. * Restored camera state. You must call storeState() first
  90462. * @returns whether it was successful or not
  90463. * @hidden
  90464. */
  90465. _restoreStateValues(): boolean;
  90466. /** @hidden */
  90467. _initCache(): void;
  90468. /** @hidden */
  90469. _updateCache(ignoreParentClass?: boolean): void;
  90470. /** @hidden */
  90471. _isSynchronizedViewMatrix(): boolean;
  90472. /** @hidden */
  90473. _computeLocalCameraSpeed(): number;
  90474. /**
  90475. * Defines the target the camera should look at.
  90476. * @param target Defines the new target as a Vector or a mesh
  90477. */
  90478. setTarget(target: Vector3): void;
  90479. /**
  90480. * Defines the target point of the camera.
  90481. * The camera looks towards it form the radius distance.
  90482. */
  90483. get target(): Vector3;
  90484. set target(value: Vector3);
  90485. /**
  90486. * Return the current target position of the camera. This value is expressed in local space.
  90487. * @returns the target position
  90488. */
  90489. getTarget(): Vector3;
  90490. /** @hidden */
  90491. _decideIfNeedsToMove(): boolean;
  90492. /** @hidden */
  90493. _updatePosition(): void;
  90494. /** @hidden */
  90495. _checkInputs(): void;
  90496. protected _updateCameraRotationMatrix(): void;
  90497. /**
  90498. * 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)
  90499. * @returns the current camera
  90500. */
  90501. private _rotateUpVectorWithCameraRotationMatrix;
  90502. private _cachedRotationZ;
  90503. private _cachedQuaternionRotationZ;
  90504. /** @hidden */
  90505. _getViewMatrix(): Matrix;
  90506. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  90507. /**
  90508. * @hidden
  90509. */
  90510. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90511. /**
  90512. * @hidden
  90513. */
  90514. _updateRigCameras(): void;
  90515. private _getRigCamPositionAndTarget;
  90516. /**
  90517. * Gets the current object class name.
  90518. * @return the class name
  90519. */
  90520. getClassName(): string;
  90521. }
  90522. }
  90523. declare module BABYLON {
  90524. /**
  90525. * @ignore
  90526. * This is a list of all the different input types that are available in the application.
  90527. * Fo instance: ArcRotateCameraGamepadInput...
  90528. */
  90529. export var CameraInputTypes: {};
  90530. /**
  90531. * This is the contract to implement in order to create a new input class.
  90532. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  90533. */
  90534. export interface ICameraInput<TCamera extends Camera> {
  90535. /**
  90536. * Defines the camera the input is attached to.
  90537. */
  90538. camera: Nullable<TCamera>;
  90539. /**
  90540. * Gets the class name of the current intput.
  90541. * @returns the class name
  90542. */
  90543. getClassName(): string;
  90544. /**
  90545. * Get the friendly name associated with the input class.
  90546. * @returns the input friendly name
  90547. */
  90548. getSimpleName(): string;
  90549. /**
  90550. * Attach the input controls to a specific dom element to get the input from.
  90551. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90552. */
  90553. attachControl(noPreventDefault?: boolean): void;
  90554. /**
  90555. * Detach the current controls from the specified dom element.
  90556. */
  90557. detachControl(): void;
  90558. /**
  90559. * Update the current camera state depending on the inputs that have been used this frame.
  90560. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  90561. */
  90562. checkInputs?: () => void;
  90563. }
  90564. /**
  90565. * Represents a map of input types to input instance or input index to input instance.
  90566. */
  90567. export interface CameraInputsMap<TCamera extends Camera> {
  90568. /**
  90569. * Accessor to the input by input type.
  90570. */
  90571. [name: string]: ICameraInput<TCamera>;
  90572. /**
  90573. * Accessor to the input by input index.
  90574. */
  90575. [idx: number]: ICameraInput<TCamera>;
  90576. }
  90577. /**
  90578. * This represents the input manager used within a camera.
  90579. * It helps dealing with all the different kind of input attached to a camera.
  90580. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  90581. */
  90582. export class CameraInputsManager<TCamera extends Camera> {
  90583. /**
  90584. * Defines the list of inputs attahed to the camera.
  90585. */
  90586. attached: CameraInputsMap<TCamera>;
  90587. /**
  90588. * Defines the dom element the camera is collecting inputs from.
  90589. * This is null if the controls have not been attached.
  90590. */
  90591. attachedToElement: boolean;
  90592. /**
  90593. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90594. */
  90595. noPreventDefault: boolean;
  90596. /**
  90597. * Defined the camera the input manager belongs to.
  90598. */
  90599. camera: TCamera;
  90600. /**
  90601. * Update the current camera state depending on the inputs that have been used this frame.
  90602. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  90603. */
  90604. checkInputs: () => void;
  90605. /**
  90606. * Instantiate a new Camera Input Manager.
  90607. * @param camera Defines the camera the input manager blongs to
  90608. */
  90609. constructor(camera: TCamera);
  90610. /**
  90611. * Add an input method to a camera
  90612. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  90613. * @param input camera input method
  90614. */
  90615. add(input: ICameraInput<TCamera>): void;
  90616. /**
  90617. * Remove a specific input method from a camera
  90618. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  90619. * @param inputToRemove camera input method
  90620. */
  90621. remove(inputToRemove: ICameraInput<TCamera>): void;
  90622. /**
  90623. * Remove a specific input type from a camera
  90624. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  90625. * @param inputType the type of the input to remove
  90626. */
  90627. removeByType(inputType: string): void;
  90628. private _addCheckInputs;
  90629. /**
  90630. * Attach the input controls to the currently attached dom element to listen the events from.
  90631. * @param input Defines the input to attach
  90632. */
  90633. attachInput(input: ICameraInput<TCamera>): void;
  90634. /**
  90635. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  90636. * @param element Defines the dom element to collect the events from
  90637. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90638. */
  90639. attachElement(noPreventDefault?: boolean): void;
  90640. /**
  90641. * Detach the current manager inputs controls from a specific dom element.
  90642. * @param element Defines the dom element to collect the events from
  90643. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  90644. */
  90645. detachElement(disconnect?: boolean): void;
  90646. /**
  90647. * Rebuild the dynamic inputCheck function from the current list of
  90648. * defined inputs in the manager.
  90649. */
  90650. rebuildInputCheck(): void;
  90651. /**
  90652. * Remove all attached input methods from a camera
  90653. */
  90654. clear(): void;
  90655. /**
  90656. * Serialize the current input manager attached to a camera.
  90657. * This ensures than once parsed,
  90658. * the input associated to the camera will be identical to the current ones
  90659. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  90660. */
  90661. serialize(serializedCamera: any): void;
  90662. /**
  90663. * Parses an input manager serialized JSON to restore the previous list of inputs
  90664. * and states associated to a camera.
  90665. * @param parsedCamera Defines the JSON to parse
  90666. */
  90667. parse(parsedCamera: any): void;
  90668. }
  90669. }
  90670. declare module BABYLON {
  90671. /**
  90672. * Gather the list of keyboard event types as constants.
  90673. */
  90674. export class KeyboardEventTypes {
  90675. /**
  90676. * The keydown event is fired when a key becomes active (pressed).
  90677. */
  90678. static readonly KEYDOWN: number;
  90679. /**
  90680. * The keyup event is fired when a key has been released.
  90681. */
  90682. static readonly KEYUP: number;
  90683. }
  90684. /**
  90685. * This class is used to store keyboard related info for the onKeyboardObservable event.
  90686. */
  90687. export class KeyboardInfo {
  90688. /**
  90689. * Defines the type of event (KeyboardEventTypes)
  90690. */
  90691. type: number;
  90692. /**
  90693. * Defines the related dom event
  90694. */
  90695. event: KeyboardEvent;
  90696. /**
  90697. * Instantiates a new keyboard info.
  90698. * This class is used to store keyboard related info for the onKeyboardObservable event.
  90699. * @param type Defines the type of event (KeyboardEventTypes)
  90700. * @param event Defines the related dom event
  90701. */
  90702. constructor(
  90703. /**
  90704. * Defines the type of event (KeyboardEventTypes)
  90705. */
  90706. type: number,
  90707. /**
  90708. * Defines the related dom event
  90709. */
  90710. event: KeyboardEvent);
  90711. }
  90712. /**
  90713. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  90714. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  90715. */
  90716. export class KeyboardInfoPre extends KeyboardInfo {
  90717. /**
  90718. * Defines the type of event (KeyboardEventTypes)
  90719. */
  90720. type: number;
  90721. /**
  90722. * Defines the related dom event
  90723. */
  90724. event: KeyboardEvent;
  90725. /**
  90726. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  90727. */
  90728. skipOnPointerObservable: boolean;
  90729. /**
  90730. * Instantiates a new keyboard pre info.
  90731. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  90732. * @param type Defines the type of event (KeyboardEventTypes)
  90733. * @param event Defines the related dom event
  90734. */
  90735. constructor(
  90736. /**
  90737. * Defines the type of event (KeyboardEventTypes)
  90738. */
  90739. type: number,
  90740. /**
  90741. * Defines the related dom event
  90742. */
  90743. event: KeyboardEvent);
  90744. }
  90745. }
  90746. declare module BABYLON {
  90747. /**
  90748. * Manage the keyboard inputs to control the movement of a free camera.
  90749. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  90750. */
  90751. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  90752. /**
  90753. * Defines the camera the input is attached to.
  90754. */
  90755. camera: FreeCamera;
  90756. /**
  90757. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  90758. */
  90759. keysUp: number[];
  90760. /**
  90761. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  90762. */
  90763. keysUpward: number[];
  90764. /**
  90765. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  90766. */
  90767. keysDown: number[];
  90768. /**
  90769. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  90770. */
  90771. keysDownward: number[];
  90772. /**
  90773. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  90774. */
  90775. keysLeft: number[];
  90776. /**
  90777. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  90778. */
  90779. keysRight: number[];
  90780. private _keys;
  90781. private _onCanvasBlurObserver;
  90782. private _onKeyboardObserver;
  90783. private _engine;
  90784. private _scene;
  90785. /**
  90786. * Attach the input controls to a specific dom element to get the input from.
  90787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90788. */
  90789. attachControl(noPreventDefault?: boolean): void;
  90790. /**
  90791. * Detach the current controls from the specified dom element.
  90792. */
  90793. detachControl(): void;
  90794. /**
  90795. * Update the current camera state depending on the inputs that have been used this frame.
  90796. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  90797. */
  90798. checkInputs(): void;
  90799. /**
  90800. * Gets the class name of the current intput.
  90801. * @returns the class name
  90802. */
  90803. getClassName(): string;
  90804. /** @hidden */
  90805. _onLostFocus(): void;
  90806. /**
  90807. * Get the friendly name associated with the input class.
  90808. * @returns the input friendly name
  90809. */
  90810. getSimpleName(): string;
  90811. }
  90812. }
  90813. declare module BABYLON {
  90814. /**
  90815. * Interface used to define Action
  90816. */
  90817. export interface IAction {
  90818. /**
  90819. * Trigger for the action
  90820. */
  90821. trigger: number;
  90822. /** Options of the trigger */
  90823. triggerOptions: any;
  90824. /**
  90825. * Gets the trigger parameters
  90826. * @returns the trigger parameters
  90827. */
  90828. getTriggerParameter(): any;
  90829. /**
  90830. * Internal only - executes current action event
  90831. * @hidden
  90832. */
  90833. _executeCurrent(evt?: ActionEvent): void;
  90834. /**
  90835. * Serialize placeholder for child classes
  90836. * @param parent of child
  90837. * @returns the serialized object
  90838. */
  90839. serialize(parent: any): any;
  90840. /**
  90841. * Internal only
  90842. * @hidden
  90843. */
  90844. _prepare(): void;
  90845. /**
  90846. * Internal only - manager for action
  90847. * @hidden
  90848. */
  90849. _actionManager: Nullable<AbstractActionManager>;
  90850. /**
  90851. * Adds action to chain of actions, may be a DoNothingAction
  90852. * @param action defines the next action to execute
  90853. * @returns The action passed in
  90854. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90855. */
  90856. then(action: IAction): IAction;
  90857. }
  90858. /**
  90859. * The action to be carried out following a trigger
  90860. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90861. */
  90862. export class Action implements IAction {
  90863. /** the trigger, with or without parameters, for the action */
  90864. triggerOptions: any;
  90865. /**
  90866. * Trigger for the action
  90867. */
  90868. trigger: number;
  90869. /**
  90870. * Internal only - manager for action
  90871. * @hidden
  90872. */
  90873. _actionManager: ActionManager;
  90874. private _nextActiveAction;
  90875. private _child;
  90876. private _condition?;
  90877. private _triggerParameter;
  90878. /**
  90879. * An event triggered prior to action being executed.
  90880. */
  90881. onBeforeExecuteObservable: Observable<Action>;
  90882. /**
  90883. * Creates a new Action
  90884. * @param triggerOptions the trigger, with or without parameters, for the action
  90885. * @param condition an optional determinant of action
  90886. */
  90887. constructor(
  90888. /** the trigger, with or without parameters, for the action */
  90889. triggerOptions: any, condition?: Condition);
  90890. /**
  90891. * Internal only
  90892. * @hidden
  90893. */
  90894. _prepare(): void;
  90895. /**
  90896. * Gets the trigger parameters
  90897. * @returns the trigger parameters
  90898. */
  90899. getTriggerParameter(): any;
  90900. /**
  90901. * Internal only - executes current action event
  90902. * @hidden
  90903. */
  90904. _executeCurrent(evt?: ActionEvent): void;
  90905. /**
  90906. * Execute placeholder for child classes
  90907. * @param evt optional action event
  90908. */
  90909. execute(evt?: ActionEvent): void;
  90910. /**
  90911. * Skips to next active action
  90912. */
  90913. skipToNextActiveAction(): void;
  90914. /**
  90915. * Adds action to chain of actions, may be a DoNothingAction
  90916. * @param action defines the next action to execute
  90917. * @returns The action passed in
  90918. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90919. */
  90920. then(action: Action): Action;
  90921. /**
  90922. * Internal only
  90923. * @hidden
  90924. */
  90925. _getProperty(propertyPath: string): string;
  90926. /**
  90927. * Internal only
  90928. * @hidden
  90929. */
  90930. _getEffectiveTarget(target: any, propertyPath: string): any;
  90931. /**
  90932. * Serialize placeholder for child classes
  90933. * @param parent of child
  90934. * @returns the serialized object
  90935. */
  90936. serialize(parent: any): any;
  90937. /**
  90938. * Internal only called by serialize
  90939. * @hidden
  90940. */
  90941. protected _serialize(serializedAction: any, parent?: any): any;
  90942. /**
  90943. * Internal only
  90944. * @hidden
  90945. */
  90946. static _SerializeValueAsString: (value: any) => string;
  90947. /**
  90948. * Internal only
  90949. * @hidden
  90950. */
  90951. static _GetTargetProperty: (target: Scene | Node) => {
  90952. name: string;
  90953. targetType: string;
  90954. value: string;
  90955. };
  90956. }
  90957. }
  90958. declare module BABYLON {
  90959. /**
  90960. * A Condition applied to an Action
  90961. */
  90962. export class Condition {
  90963. /**
  90964. * Internal only - manager for action
  90965. * @hidden
  90966. */
  90967. _actionManager: ActionManager;
  90968. /**
  90969. * Internal only
  90970. * @hidden
  90971. */
  90972. _evaluationId: number;
  90973. /**
  90974. * Internal only
  90975. * @hidden
  90976. */
  90977. _currentResult: boolean;
  90978. /**
  90979. * Creates a new Condition
  90980. * @param actionManager the manager of the action the condition is applied to
  90981. */
  90982. constructor(actionManager: ActionManager);
  90983. /**
  90984. * Check if the current condition is valid
  90985. * @returns a boolean
  90986. */
  90987. isValid(): boolean;
  90988. /**
  90989. * Internal only
  90990. * @hidden
  90991. */
  90992. _getProperty(propertyPath: string): string;
  90993. /**
  90994. * Internal only
  90995. * @hidden
  90996. */
  90997. _getEffectiveTarget(target: any, propertyPath: string): any;
  90998. /**
  90999. * Serialize placeholder for child classes
  91000. * @returns the serialized object
  91001. */
  91002. serialize(): any;
  91003. /**
  91004. * Internal only
  91005. * @hidden
  91006. */
  91007. protected _serialize(serializedCondition: any): any;
  91008. }
  91009. /**
  91010. * Defines specific conditional operators as extensions of Condition
  91011. */
  91012. export class ValueCondition extends Condition {
  91013. /** path to specify the property of the target the conditional operator uses */
  91014. propertyPath: string;
  91015. /** the value compared by the conditional operator against the current value of the property */
  91016. value: any;
  91017. /** the conditional operator, default ValueCondition.IsEqual */
  91018. operator: number;
  91019. /**
  91020. * Internal only
  91021. * @hidden
  91022. */
  91023. private static _IsEqual;
  91024. /**
  91025. * Internal only
  91026. * @hidden
  91027. */
  91028. private static _IsDifferent;
  91029. /**
  91030. * Internal only
  91031. * @hidden
  91032. */
  91033. private static _IsGreater;
  91034. /**
  91035. * Internal only
  91036. * @hidden
  91037. */
  91038. private static _IsLesser;
  91039. /**
  91040. * returns the number for IsEqual
  91041. */
  91042. static get IsEqual(): number;
  91043. /**
  91044. * Returns the number for IsDifferent
  91045. */
  91046. static get IsDifferent(): number;
  91047. /**
  91048. * Returns the number for IsGreater
  91049. */
  91050. static get IsGreater(): number;
  91051. /**
  91052. * Returns the number for IsLesser
  91053. */
  91054. static get IsLesser(): number;
  91055. /**
  91056. * Internal only The action manager for the condition
  91057. * @hidden
  91058. */
  91059. _actionManager: ActionManager;
  91060. /**
  91061. * Internal only
  91062. * @hidden
  91063. */
  91064. private _target;
  91065. /**
  91066. * Internal only
  91067. * @hidden
  91068. */
  91069. private _effectiveTarget;
  91070. /**
  91071. * Internal only
  91072. * @hidden
  91073. */
  91074. private _property;
  91075. /**
  91076. * Creates a new ValueCondition
  91077. * @param actionManager manager for the action the condition applies to
  91078. * @param target for the action
  91079. * @param propertyPath path to specify the property of the target the conditional operator uses
  91080. * @param value the value compared by the conditional operator against the current value of the property
  91081. * @param operator the conditional operator, default ValueCondition.IsEqual
  91082. */
  91083. constructor(actionManager: ActionManager, target: any,
  91084. /** path to specify the property of the target the conditional operator uses */
  91085. propertyPath: string,
  91086. /** the value compared by the conditional operator against the current value of the property */
  91087. value: any,
  91088. /** the conditional operator, default ValueCondition.IsEqual */
  91089. operator?: number);
  91090. /**
  91091. * Compares the given value with the property value for the specified conditional operator
  91092. * @returns the result of the comparison
  91093. */
  91094. isValid(): boolean;
  91095. /**
  91096. * Serialize the ValueCondition into a JSON compatible object
  91097. * @returns serialization object
  91098. */
  91099. serialize(): any;
  91100. /**
  91101. * Gets the name of the conditional operator for the ValueCondition
  91102. * @param operator the conditional operator
  91103. * @returns the name
  91104. */
  91105. static GetOperatorName(operator: number): string;
  91106. }
  91107. /**
  91108. * Defines a predicate condition as an extension of Condition
  91109. */
  91110. export class PredicateCondition extends Condition {
  91111. /** defines the predicate function used to validate the condition */
  91112. predicate: () => boolean;
  91113. /**
  91114. * Internal only - manager for action
  91115. * @hidden
  91116. */
  91117. _actionManager: ActionManager;
  91118. /**
  91119. * Creates a new PredicateCondition
  91120. * @param actionManager manager for the action the condition applies to
  91121. * @param predicate defines the predicate function used to validate the condition
  91122. */
  91123. constructor(actionManager: ActionManager,
  91124. /** defines the predicate function used to validate the condition */
  91125. predicate: () => boolean);
  91126. /**
  91127. * @returns the validity of the predicate condition
  91128. */
  91129. isValid(): boolean;
  91130. }
  91131. /**
  91132. * Defines a state condition as an extension of Condition
  91133. */
  91134. export class StateCondition extends Condition {
  91135. /** Value to compare with target state */
  91136. value: string;
  91137. /**
  91138. * Internal only - manager for action
  91139. * @hidden
  91140. */
  91141. _actionManager: ActionManager;
  91142. /**
  91143. * Internal only
  91144. * @hidden
  91145. */
  91146. private _target;
  91147. /**
  91148. * Creates a new StateCondition
  91149. * @param actionManager manager for the action the condition applies to
  91150. * @param target of the condition
  91151. * @param value to compare with target state
  91152. */
  91153. constructor(actionManager: ActionManager, target: any,
  91154. /** Value to compare with target state */
  91155. value: string);
  91156. /**
  91157. * Gets a boolean indicating if the current condition is met
  91158. * @returns the validity of the state
  91159. */
  91160. isValid(): boolean;
  91161. /**
  91162. * Serialize the StateCondition into a JSON compatible object
  91163. * @returns serialization object
  91164. */
  91165. serialize(): any;
  91166. }
  91167. }
  91168. declare module BABYLON {
  91169. /**
  91170. * This defines an action responsible to toggle a boolean once triggered.
  91171. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91172. */
  91173. export class SwitchBooleanAction extends Action {
  91174. /**
  91175. * The path to the boolean property in the target object
  91176. */
  91177. propertyPath: string;
  91178. private _target;
  91179. private _effectiveTarget;
  91180. private _property;
  91181. /**
  91182. * Instantiate the action
  91183. * @param triggerOptions defines the trigger options
  91184. * @param target defines the object containing the boolean
  91185. * @param propertyPath defines the path to the boolean property in the target object
  91186. * @param condition defines the trigger related conditions
  91187. */
  91188. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  91189. /** @hidden */
  91190. _prepare(): void;
  91191. /**
  91192. * Execute the action toggle the boolean value.
  91193. */
  91194. execute(): void;
  91195. /**
  91196. * Serializes the actions and its related information.
  91197. * @param parent defines the object to serialize in
  91198. * @returns the serialized object
  91199. */
  91200. serialize(parent: any): any;
  91201. }
  91202. /**
  91203. * This defines an action responsible to set a the state field of the target
  91204. * to a desired value once triggered.
  91205. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91206. */
  91207. export class SetStateAction extends Action {
  91208. /**
  91209. * The value to store in the state field.
  91210. */
  91211. value: string;
  91212. private _target;
  91213. /**
  91214. * Instantiate the action
  91215. * @param triggerOptions defines the trigger options
  91216. * @param target defines the object containing the state property
  91217. * @param value defines the value to store in the state field
  91218. * @param condition defines the trigger related conditions
  91219. */
  91220. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  91221. /**
  91222. * Execute the action and store the value on the target state property.
  91223. */
  91224. execute(): void;
  91225. /**
  91226. * Serializes the actions and its related information.
  91227. * @param parent defines the object to serialize in
  91228. * @returns the serialized object
  91229. */
  91230. serialize(parent: any): any;
  91231. }
  91232. /**
  91233. * This defines an action responsible to set a property of the target
  91234. * to a desired value once triggered.
  91235. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91236. */
  91237. export class SetValueAction extends Action {
  91238. /**
  91239. * The path of the property to set in the target.
  91240. */
  91241. propertyPath: string;
  91242. /**
  91243. * The value to set in the property
  91244. */
  91245. value: any;
  91246. private _target;
  91247. private _effectiveTarget;
  91248. private _property;
  91249. /**
  91250. * Instantiate the action
  91251. * @param triggerOptions defines the trigger options
  91252. * @param target defines the object containing the property
  91253. * @param propertyPath defines the path of the property to set in the target
  91254. * @param value defines the value to set in the property
  91255. * @param condition defines the trigger related conditions
  91256. */
  91257. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91258. /** @hidden */
  91259. _prepare(): void;
  91260. /**
  91261. * Execute the action and set the targetted property to the desired value.
  91262. */
  91263. execute(): void;
  91264. /**
  91265. * Serializes the actions and its related information.
  91266. * @param parent defines the object to serialize in
  91267. * @returns the serialized object
  91268. */
  91269. serialize(parent: any): any;
  91270. }
  91271. /**
  91272. * This defines an action responsible to increment the target value
  91273. * to a desired value once triggered.
  91274. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91275. */
  91276. export class IncrementValueAction extends Action {
  91277. /**
  91278. * The path of the property to increment in the target.
  91279. */
  91280. propertyPath: string;
  91281. /**
  91282. * The value we should increment the property by.
  91283. */
  91284. value: any;
  91285. private _target;
  91286. private _effectiveTarget;
  91287. private _property;
  91288. /**
  91289. * Instantiate the action
  91290. * @param triggerOptions defines the trigger options
  91291. * @param target defines the object containing the property
  91292. * @param propertyPath defines the path of the property to increment in the target
  91293. * @param value defines the value value we should increment the property by
  91294. * @param condition defines the trigger related conditions
  91295. */
  91296. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91297. /** @hidden */
  91298. _prepare(): void;
  91299. /**
  91300. * Execute the action and increment the target of the value amount.
  91301. */
  91302. execute(): void;
  91303. /**
  91304. * Serializes the actions and its related information.
  91305. * @param parent defines the object to serialize in
  91306. * @returns the serialized object
  91307. */
  91308. serialize(parent: any): any;
  91309. }
  91310. /**
  91311. * This defines an action responsible to start an animation once triggered.
  91312. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91313. */
  91314. export class PlayAnimationAction extends Action {
  91315. /**
  91316. * Where the animation should start (animation frame)
  91317. */
  91318. from: number;
  91319. /**
  91320. * Where the animation should stop (animation frame)
  91321. */
  91322. to: number;
  91323. /**
  91324. * Define if the animation should loop or stop after the first play.
  91325. */
  91326. loop?: boolean;
  91327. private _target;
  91328. /**
  91329. * Instantiate the action
  91330. * @param triggerOptions defines the trigger options
  91331. * @param target defines the target animation or animation name
  91332. * @param from defines from where the animation should start (animation frame)
  91333. * @param end defines where the animation should stop (animation frame)
  91334. * @param loop defines if the animation should loop or stop after the first play
  91335. * @param condition defines the trigger related conditions
  91336. */
  91337. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  91338. /** @hidden */
  91339. _prepare(): void;
  91340. /**
  91341. * Execute the action and play the animation.
  91342. */
  91343. execute(): void;
  91344. /**
  91345. * Serializes the actions and its related information.
  91346. * @param parent defines the object to serialize in
  91347. * @returns the serialized object
  91348. */
  91349. serialize(parent: any): any;
  91350. }
  91351. /**
  91352. * This defines an action responsible to stop an animation once triggered.
  91353. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91354. */
  91355. export class StopAnimationAction extends Action {
  91356. private _target;
  91357. /**
  91358. * Instantiate the action
  91359. * @param triggerOptions defines the trigger options
  91360. * @param target defines the target animation or animation name
  91361. * @param condition defines the trigger related conditions
  91362. */
  91363. constructor(triggerOptions: any, target: any, condition?: Condition);
  91364. /** @hidden */
  91365. _prepare(): void;
  91366. /**
  91367. * Execute the action and stop the animation.
  91368. */
  91369. execute(): void;
  91370. /**
  91371. * Serializes the actions and its related information.
  91372. * @param parent defines the object to serialize in
  91373. * @returns the serialized object
  91374. */
  91375. serialize(parent: any): any;
  91376. }
  91377. /**
  91378. * This defines an action responsible that does nothing once triggered.
  91379. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91380. */
  91381. export class DoNothingAction extends Action {
  91382. /**
  91383. * Instantiate the action
  91384. * @param triggerOptions defines the trigger options
  91385. * @param condition defines the trigger related conditions
  91386. */
  91387. constructor(triggerOptions?: any, condition?: Condition);
  91388. /**
  91389. * Execute the action and do nothing.
  91390. */
  91391. execute(): void;
  91392. /**
  91393. * Serializes the actions and its related information.
  91394. * @param parent defines the object to serialize in
  91395. * @returns the serialized object
  91396. */
  91397. serialize(parent: any): any;
  91398. }
  91399. /**
  91400. * This defines an action responsible to trigger several actions once triggered.
  91401. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91402. */
  91403. export class CombineAction extends Action {
  91404. /**
  91405. * The list of aggregated animations to run.
  91406. */
  91407. children: Action[];
  91408. /**
  91409. * Instantiate the action
  91410. * @param triggerOptions defines the trigger options
  91411. * @param children defines the list of aggregated animations to run
  91412. * @param condition defines the trigger related conditions
  91413. */
  91414. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  91415. /** @hidden */
  91416. _prepare(): void;
  91417. /**
  91418. * Execute the action and executes all the aggregated actions.
  91419. */
  91420. execute(evt: ActionEvent): void;
  91421. /**
  91422. * Serializes the actions and its related information.
  91423. * @param parent defines the object to serialize in
  91424. * @returns the serialized object
  91425. */
  91426. serialize(parent: any): any;
  91427. }
  91428. /**
  91429. * This defines an action responsible to run code (external event) once triggered.
  91430. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91431. */
  91432. export class ExecuteCodeAction extends Action {
  91433. /**
  91434. * The callback function to run.
  91435. */
  91436. func: (evt: ActionEvent) => void;
  91437. /**
  91438. * Instantiate the action
  91439. * @param triggerOptions defines the trigger options
  91440. * @param func defines the callback function to run
  91441. * @param condition defines the trigger related conditions
  91442. */
  91443. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  91444. /**
  91445. * Execute the action and run the attached code.
  91446. */
  91447. execute(evt: ActionEvent): void;
  91448. }
  91449. /**
  91450. * This defines an action responsible to set the parent property of the target once triggered.
  91451. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91452. */
  91453. export class SetParentAction extends Action {
  91454. private _parent;
  91455. private _target;
  91456. /**
  91457. * Instantiate the action
  91458. * @param triggerOptions defines the trigger options
  91459. * @param target defines the target containing the parent property
  91460. * @param parent defines from where the animation should start (animation frame)
  91461. * @param condition defines the trigger related conditions
  91462. */
  91463. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  91464. /** @hidden */
  91465. _prepare(): void;
  91466. /**
  91467. * Execute the action and set the parent property.
  91468. */
  91469. execute(): void;
  91470. /**
  91471. * Serializes the actions and its related information.
  91472. * @param parent defines the object to serialize in
  91473. * @returns the serialized object
  91474. */
  91475. serialize(parent: any): any;
  91476. }
  91477. }
  91478. declare module BABYLON {
  91479. /**
  91480. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  91481. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  91482. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91483. */
  91484. export class ActionManager extends AbstractActionManager {
  91485. /**
  91486. * Nothing
  91487. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91488. */
  91489. static readonly NothingTrigger: number;
  91490. /**
  91491. * On pick
  91492. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91493. */
  91494. static readonly OnPickTrigger: number;
  91495. /**
  91496. * On left pick
  91497. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91498. */
  91499. static readonly OnLeftPickTrigger: number;
  91500. /**
  91501. * On right pick
  91502. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91503. */
  91504. static readonly OnRightPickTrigger: number;
  91505. /**
  91506. * On center pick
  91507. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91508. */
  91509. static readonly OnCenterPickTrigger: number;
  91510. /**
  91511. * On pick down
  91512. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91513. */
  91514. static readonly OnPickDownTrigger: number;
  91515. /**
  91516. * On double pick
  91517. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91518. */
  91519. static readonly OnDoublePickTrigger: number;
  91520. /**
  91521. * On pick up
  91522. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91523. */
  91524. static readonly OnPickUpTrigger: number;
  91525. /**
  91526. * On pick out.
  91527. * This trigger will only be raised if you also declared a OnPickDown
  91528. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91529. */
  91530. static readonly OnPickOutTrigger: number;
  91531. /**
  91532. * On long press
  91533. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91534. */
  91535. static readonly OnLongPressTrigger: number;
  91536. /**
  91537. * On pointer over
  91538. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91539. */
  91540. static readonly OnPointerOverTrigger: number;
  91541. /**
  91542. * On pointer out
  91543. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91544. */
  91545. static readonly OnPointerOutTrigger: number;
  91546. /**
  91547. * On every frame
  91548. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91549. */
  91550. static readonly OnEveryFrameTrigger: number;
  91551. /**
  91552. * On intersection enter
  91553. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91554. */
  91555. static readonly OnIntersectionEnterTrigger: number;
  91556. /**
  91557. * On intersection exit
  91558. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91559. */
  91560. static readonly OnIntersectionExitTrigger: number;
  91561. /**
  91562. * On key down
  91563. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91564. */
  91565. static readonly OnKeyDownTrigger: number;
  91566. /**
  91567. * On key up
  91568. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91569. */
  91570. static readonly OnKeyUpTrigger: number;
  91571. private _scene;
  91572. /**
  91573. * Creates a new action manager
  91574. * @param scene defines the hosting scene
  91575. */
  91576. constructor(scene: Scene);
  91577. /**
  91578. * Releases all associated resources
  91579. */
  91580. dispose(): void;
  91581. /**
  91582. * Gets hosting scene
  91583. * @returns the hosting scene
  91584. */
  91585. getScene(): Scene;
  91586. /**
  91587. * Does this action manager handles actions of any of the given triggers
  91588. * @param triggers defines the triggers to be tested
  91589. * @return a boolean indicating whether one (or more) of the triggers is handled
  91590. */
  91591. hasSpecificTriggers(triggers: number[]): boolean;
  91592. /**
  91593. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91594. * speed.
  91595. * @param triggerA defines the trigger to be tested
  91596. * @param triggerB defines the trigger to be tested
  91597. * @return a boolean indicating whether one (or more) of the triggers is handled
  91598. */
  91599. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91600. /**
  91601. * Does this action manager handles actions of a given trigger
  91602. * @param trigger defines the trigger to be tested
  91603. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91604. * @return whether the trigger is handled
  91605. */
  91606. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91607. /**
  91608. * Does this action manager has pointer triggers
  91609. */
  91610. get hasPointerTriggers(): boolean;
  91611. /**
  91612. * Does this action manager has pick triggers
  91613. */
  91614. get hasPickTriggers(): boolean;
  91615. /**
  91616. * Registers an action to this action manager
  91617. * @param action defines the action to be registered
  91618. * @return the action amended (prepared) after registration
  91619. */
  91620. registerAction(action: IAction): Nullable<IAction>;
  91621. /**
  91622. * Unregisters an action to this action manager
  91623. * @param action defines the action to be unregistered
  91624. * @return a boolean indicating whether the action has been unregistered
  91625. */
  91626. unregisterAction(action: IAction): Boolean;
  91627. /**
  91628. * Process a specific trigger
  91629. * @param trigger defines the trigger to process
  91630. * @param evt defines the event details to be processed
  91631. */
  91632. processTrigger(trigger: number, evt?: IActionEvent): void;
  91633. /** @hidden */
  91634. _getEffectiveTarget(target: any, propertyPath: string): any;
  91635. /** @hidden */
  91636. _getProperty(propertyPath: string): string;
  91637. /**
  91638. * Serialize this manager to a JSON object
  91639. * @param name defines the property name to store this manager
  91640. * @returns a JSON representation of this manager
  91641. */
  91642. serialize(name: string): any;
  91643. /**
  91644. * Creates a new ActionManager from a JSON data
  91645. * @param parsedActions defines the JSON data to read from
  91646. * @param object defines the hosting mesh
  91647. * @param scene defines the hosting scene
  91648. */
  91649. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91650. /**
  91651. * Get a trigger name by index
  91652. * @param trigger defines the trigger index
  91653. * @returns a trigger name
  91654. */
  91655. static GetTriggerName(trigger: number): string;
  91656. }
  91657. }
  91658. declare module BABYLON {
  91659. /**
  91660. * Class representing a ray with position and direction
  91661. */
  91662. export class Ray {
  91663. /** origin point */
  91664. origin: Vector3;
  91665. /** direction */
  91666. direction: Vector3;
  91667. /** length of the ray */
  91668. length: number;
  91669. private static readonly _TmpVector3;
  91670. private _tmpRay;
  91671. /**
  91672. * Creates a new ray
  91673. * @param origin origin point
  91674. * @param direction direction
  91675. * @param length length of the ray
  91676. */
  91677. constructor(
  91678. /** origin point */
  91679. origin: Vector3,
  91680. /** direction */
  91681. direction: Vector3,
  91682. /** length of the ray */
  91683. length?: number);
  91684. /**
  91685. * Checks if the ray intersects a box
  91686. * This does not account for the ray lenght by design to improve perfs.
  91687. * @param minimum bound of the box
  91688. * @param maximum bound of the box
  91689. * @param intersectionTreshold extra extend to be added to the box in all direction
  91690. * @returns if the box was hit
  91691. */
  91692. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  91693. /**
  91694. * Checks if the ray intersects a box
  91695. * This does not account for the ray lenght by design to improve perfs.
  91696. * @param box the bounding box to check
  91697. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  91698. * @returns if the box was hit
  91699. */
  91700. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  91701. /**
  91702. * If the ray hits a sphere
  91703. * @param sphere the bounding sphere to check
  91704. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  91705. * @returns true if it hits the sphere
  91706. */
  91707. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  91708. /**
  91709. * If the ray hits a triange
  91710. * @param vertex0 triangle vertex
  91711. * @param vertex1 triangle vertex
  91712. * @param vertex2 triangle vertex
  91713. * @returns intersection information if hit
  91714. */
  91715. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  91716. /**
  91717. * Checks if ray intersects a plane
  91718. * @param plane the plane to check
  91719. * @returns the distance away it was hit
  91720. */
  91721. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  91722. /**
  91723. * Calculate the intercept of a ray on a given axis
  91724. * @param axis to check 'x' | 'y' | 'z'
  91725. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  91726. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  91727. */
  91728. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  91729. /**
  91730. * Checks if ray intersects a mesh
  91731. * @param mesh the mesh to check
  91732. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91733. * @returns picking info of the intersecton
  91734. */
  91735. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  91736. /**
  91737. * Checks if ray intersects a mesh
  91738. * @param meshes the meshes to check
  91739. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91740. * @param results array to store result in
  91741. * @returns Array of picking infos
  91742. */
  91743. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  91744. private _comparePickingInfo;
  91745. private static smallnum;
  91746. private static rayl;
  91747. /**
  91748. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  91749. * @param sega the first point of the segment to test the intersection against
  91750. * @param segb the second point of the segment to test the intersection against
  91751. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  91752. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  91753. */
  91754. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  91755. /**
  91756. * Update the ray from viewport position
  91757. * @param x position
  91758. * @param y y position
  91759. * @param viewportWidth viewport width
  91760. * @param viewportHeight viewport height
  91761. * @param world world matrix
  91762. * @param view view matrix
  91763. * @param projection projection matrix
  91764. * @returns this ray updated
  91765. */
  91766. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91767. /**
  91768. * Creates a ray with origin and direction of 0,0,0
  91769. * @returns the new ray
  91770. */
  91771. static Zero(): Ray;
  91772. /**
  91773. * Creates a new ray from screen space and viewport
  91774. * @param x position
  91775. * @param y y position
  91776. * @param viewportWidth viewport width
  91777. * @param viewportHeight viewport height
  91778. * @param world world matrix
  91779. * @param view view matrix
  91780. * @param projection projection matrix
  91781. * @returns new ray
  91782. */
  91783. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91784. /**
  91785. * 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
  91786. * transformed to the given world matrix.
  91787. * @param origin The origin point
  91788. * @param end The end point
  91789. * @param world a matrix to transform the ray to. Default is the identity matrix.
  91790. * @returns the new ray
  91791. */
  91792. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  91793. /**
  91794. * Transforms a ray by a matrix
  91795. * @param ray ray to transform
  91796. * @param matrix matrix to apply
  91797. * @returns the resulting new ray
  91798. */
  91799. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  91800. /**
  91801. * Transforms a ray by a matrix
  91802. * @param ray ray to transform
  91803. * @param matrix matrix to apply
  91804. * @param result ray to store result in
  91805. */
  91806. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  91807. /**
  91808. * Unproject a ray from screen space to object space
  91809. * @param sourceX defines the screen space x coordinate to use
  91810. * @param sourceY defines the screen space y coordinate to use
  91811. * @param viewportWidth defines the current width of the viewport
  91812. * @param viewportHeight defines the current height of the viewport
  91813. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  91814. * @param view defines the view matrix to use
  91815. * @param projection defines the projection matrix to use
  91816. */
  91817. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  91818. }
  91819. /**
  91820. * Type used to define predicate used to select faces when a mesh intersection is detected
  91821. */
  91822. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  91823. interface Scene {
  91824. /** @hidden */
  91825. _tempPickingRay: Nullable<Ray>;
  91826. /** @hidden */
  91827. _cachedRayForTransform: Ray;
  91828. /** @hidden */
  91829. _pickWithRayInverseMatrix: Matrix;
  91830. /** @hidden */
  91831. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91832. /** @hidden */
  91833. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91834. /** @hidden */
  91835. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  91836. }
  91837. }
  91838. declare module BABYLON {
  91839. /**
  91840. * Groups all the scene component constants in one place to ease maintenance.
  91841. * @hidden
  91842. */
  91843. export class SceneComponentConstants {
  91844. static readonly NAME_EFFECTLAYER: string;
  91845. static readonly NAME_LAYER: string;
  91846. static readonly NAME_LENSFLARESYSTEM: string;
  91847. static readonly NAME_BOUNDINGBOXRENDERER: string;
  91848. static readonly NAME_PARTICLESYSTEM: string;
  91849. static readonly NAME_GAMEPAD: string;
  91850. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  91851. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  91852. static readonly NAME_PREPASSRENDERER: string;
  91853. static readonly NAME_DEPTHRENDERER: string;
  91854. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  91855. static readonly NAME_SPRITE: string;
  91856. static readonly NAME_SUBSURFACE: string;
  91857. static readonly NAME_OUTLINERENDERER: string;
  91858. static readonly NAME_PROCEDURALTEXTURE: string;
  91859. static readonly NAME_SHADOWGENERATOR: string;
  91860. static readonly NAME_OCTREE: string;
  91861. static readonly NAME_PHYSICSENGINE: string;
  91862. static readonly NAME_AUDIO: string;
  91863. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  91864. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91865. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  91866. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91867. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  91868. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  91869. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  91870. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  91871. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  91872. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  91873. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  91874. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  91875. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  91876. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  91877. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  91878. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  91879. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  91880. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  91881. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  91882. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  91883. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  91884. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  91885. static readonly STEP_AFTERRENDER_AUDIO: number;
  91886. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  91887. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  91888. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  91889. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  91890. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  91891. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  91892. static readonly STEP_POINTERMOVE_SPRITE: number;
  91893. static readonly STEP_POINTERDOWN_SPRITE: number;
  91894. static readonly STEP_POINTERUP_SPRITE: number;
  91895. }
  91896. /**
  91897. * This represents a scene component.
  91898. *
  91899. * This is used to decouple the dependency the scene is having on the different workloads like
  91900. * layers, post processes...
  91901. */
  91902. export interface ISceneComponent {
  91903. /**
  91904. * The name of the component. Each component must have a unique name.
  91905. */
  91906. name: string;
  91907. /**
  91908. * The scene the component belongs to.
  91909. */
  91910. scene: Scene;
  91911. /**
  91912. * Register the component to one instance of a scene.
  91913. */
  91914. register(): void;
  91915. /**
  91916. * Rebuilds the elements related to this component in case of
  91917. * context lost for instance.
  91918. */
  91919. rebuild(): void;
  91920. /**
  91921. * Disposes the component and the associated ressources.
  91922. */
  91923. dispose(): void;
  91924. }
  91925. /**
  91926. * This represents a SERIALIZABLE scene component.
  91927. *
  91928. * This extends Scene Component to add Serialization methods on top.
  91929. */
  91930. export interface ISceneSerializableComponent extends ISceneComponent {
  91931. /**
  91932. * Adds all the elements from the container to the scene
  91933. * @param container the container holding the elements
  91934. */
  91935. addFromContainer(container: AbstractScene): void;
  91936. /**
  91937. * Removes all the elements in the container from the scene
  91938. * @param container contains the elements to remove
  91939. * @param dispose if the removed element should be disposed (default: false)
  91940. */
  91941. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  91942. /**
  91943. * Serializes the component data to the specified json object
  91944. * @param serializationObject The object to serialize to
  91945. */
  91946. serialize(serializationObject: any): void;
  91947. }
  91948. /**
  91949. * Strong typing of a Mesh related stage step action
  91950. */
  91951. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  91952. /**
  91953. * Strong typing of a Evaluate Sub Mesh related stage step action
  91954. */
  91955. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  91956. /**
  91957. * Strong typing of a pre active Mesh related stage step action
  91958. */
  91959. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  91960. /**
  91961. * Strong typing of a Camera related stage step action
  91962. */
  91963. export type CameraStageAction = (camera: Camera) => void;
  91964. /**
  91965. * Strong typing of a Camera Frame buffer related stage step action
  91966. */
  91967. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  91968. /**
  91969. * Strong typing of a Render Target related stage step action
  91970. */
  91971. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  91972. /**
  91973. * Strong typing of a RenderingGroup related stage step action
  91974. */
  91975. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  91976. /**
  91977. * Strong typing of a Mesh Render related stage step action
  91978. */
  91979. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  91980. /**
  91981. * Strong typing of a simple stage step action
  91982. */
  91983. export type SimpleStageAction = () => void;
  91984. /**
  91985. * Strong typing of a render target action.
  91986. */
  91987. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  91988. /**
  91989. * Strong typing of a pointer move action.
  91990. */
  91991. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  91992. /**
  91993. * Strong typing of a pointer up/down action.
  91994. */
  91995. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  91996. /**
  91997. * Representation of a stage in the scene (Basically a list of ordered steps)
  91998. * @hidden
  91999. */
  92000. export class Stage<T extends Function> extends Array<{
  92001. index: number;
  92002. component: ISceneComponent;
  92003. action: T;
  92004. }> {
  92005. /**
  92006. * Hide ctor from the rest of the world.
  92007. * @param items The items to add.
  92008. */
  92009. private constructor();
  92010. /**
  92011. * Creates a new Stage.
  92012. * @returns A new instance of a Stage
  92013. */
  92014. static Create<T extends Function>(): Stage<T>;
  92015. /**
  92016. * Registers a step in an ordered way in the targeted stage.
  92017. * @param index Defines the position to register the step in
  92018. * @param component Defines the component attached to the step
  92019. * @param action Defines the action to launch during the step
  92020. */
  92021. registerStep(index: number, component: ISceneComponent, action: T): void;
  92022. /**
  92023. * Clears all the steps from the stage.
  92024. */
  92025. clear(): void;
  92026. }
  92027. }
  92028. declare module BABYLON {
  92029. interface Scene {
  92030. /** @hidden */
  92031. _pointerOverSprite: Nullable<Sprite>;
  92032. /** @hidden */
  92033. _pickedDownSprite: Nullable<Sprite>;
  92034. /** @hidden */
  92035. _tempSpritePickingRay: Nullable<Ray>;
  92036. /**
  92037. * All of the sprite managers added to this scene
  92038. * @see https://doc.babylonjs.com/babylon101/sprites
  92039. */
  92040. spriteManagers: Array<ISpriteManager>;
  92041. /**
  92042. * An event triggered when sprites rendering is about to start
  92043. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  92044. */
  92045. onBeforeSpritesRenderingObservable: Observable<Scene>;
  92046. /**
  92047. * An event triggered when sprites rendering is done
  92048. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  92049. */
  92050. onAfterSpritesRenderingObservable: Observable<Scene>;
  92051. /** @hidden */
  92052. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92053. /** Launch a ray to try to pick a sprite in the scene
  92054. * @param x position on screen
  92055. * @param y position on screen
  92056. * @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
  92057. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92058. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92059. * @returns a PickingInfo
  92060. */
  92061. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92062. /** Use the given ray to pick a sprite in the scene
  92063. * @param ray The ray (in world space) to use to pick meshes
  92064. * @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
  92065. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92066. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  92067. * @returns a PickingInfo
  92068. */
  92069. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92070. /** @hidden */
  92071. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92072. /** Launch a ray to try to pick sprites in the scene
  92073. * @param x position on screen
  92074. * @param y position on screen
  92075. * @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
  92076. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92077. * @returns a PickingInfo array
  92078. */
  92079. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92080. /** Use the given ray to pick sprites in the scene
  92081. * @param ray The ray (in world space) to use to pick meshes
  92082. * @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
  92083. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  92084. * @returns a PickingInfo array
  92085. */
  92086. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92087. /**
  92088. * Force the sprite under the pointer
  92089. * @param sprite defines the sprite to use
  92090. */
  92091. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  92092. /**
  92093. * Gets the sprite under the pointer
  92094. * @returns a Sprite or null if no sprite is under the pointer
  92095. */
  92096. getPointerOverSprite(): Nullable<Sprite>;
  92097. }
  92098. /**
  92099. * Defines the sprite scene component responsible to manage sprites
  92100. * in a given scene.
  92101. */
  92102. export class SpriteSceneComponent implements ISceneComponent {
  92103. /**
  92104. * The component name helpfull to identify the component in the list of scene components.
  92105. */
  92106. readonly name: string;
  92107. /**
  92108. * The scene the component belongs to.
  92109. */
  92110. scene: Scene;
  92111. /** @hidden */
  92112. private _spritePredicate;
  92113. /**
  92114. * Creates a new instance of the component for the given scene
  92115. * @param scene Defines the scene to register the component in
  92116. */
  92117. constructor(scene: Scene);
  92118. /**
  92119. * Registers the component in a given scene
  92120. */
  92121. register(): void;
  92122. /**
  92123. * Rebuilds the elements related to this component in case of
  92124. * context lost for instance.
  92125. */
  92126. rebuild(): void;
  92127. /**
  92128. * Disposes the component and the associated ressources.
  92129. */
  92130. dispose(): void;
  92131. private _pickSpriteButKeepRay;
  92132. private _pointerMove;
  92133. private _pointerDown;
  92134. private _pointerUp;
  92135. }
  92136. }
  92137. declare module BABYLON {
  92138. /**
  92139. * Class used to provide helper for timing
  92140. */
  92141. export class TimingTools {
  92142. /**
  92143. * Polyfill for setImmediate
  92144. * @param action defines the action to execute after the current execution block
  92145. */
  92146. static SetImmediate(action: () => void): void;
  92147. }
  92148. }
  92149. declare module BABYLON {
  92150. /**
  92151. * Class used to enable instatition of objects by class name
  92152. */
  92153. export class InstantiationTools {
  92154. /**
  92155. * Use this object to register external classes like custom textures or material
  92156. * to allow the laoders to instantiate them
  92157. */
  92158. static RegisteredExternalClasses: {
  92159. [key: string]: Object;
  92160. };
  92161. /**
  92162. * Tries to instantiate a new object from a given class name
  92163. * @param className defines the class name to instantiate
  92164. * @returns the new object or null if the system was not able to do the instantiation
  92165. */
  92166. static Instantiate(className: string): any;
  92167. }
  92168. }
  92169. declare module BABYLON {
  92170. /**
  92171. * Class used to host copy specific utilities
  92172. */
  92173. export class CopyTools {
  92174. /**
  92175. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  92176. * @param texture defines the texture to read pixels from
  92177. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  92178. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  92179. * @returns The base64 encoded string or null
  92180. */
  92181. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  92182. }
  92183. }
  92184. declare module BABYLON {
  92185. /**
  92186. * Define options used to create a depth texture
  92187. */
  92188. export class DepthTextureCreationOptions {
  92189. /** Specifies whether or not a stencil should be allocated in the texture */
  92190. generateStencil?: boolean;
  92191. /** Specifies whether or not bilinear filtering is enable on the texture */
  92192. bilinearFiltering?: boolean;
  92193. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  92194. comparisonFunction?: number;
  92195. /** Specifies if the created texture is a cube texture */
  92196. isCube?: boolean;
  92197. }
  92198. }
  92199. declare module BABYLON {
  92200. interface ThinEngine {
  92201. /**
  92202. * Creates a depth stencil cube texture.
  92203. * This is only available in WebGL 2.
  92204. * @param size The size of face edge in the cube texture.
  92205. * @param options The options defining the cube texture.
  92206. * @returns The cube texture
  92207. */
  92208. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  92209. /**
  92210. * Creates a cube texture
  92211. * @param rootUrl defines the url where the files to load is located
  92212. * @param scene defines the current scene
  92213. * @param files defines the list of files to load (1 per face)
  92214. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  92215. * @param onLoad defines an optional callback raised when the texture is loaded
  92216. * @param onError defines an optional callback raised if there is an issue to load the texture
  92217. * @param format defines the format of the data
  92218. * @param forcedExtension defines the extension to use to pick the right loader
  92219. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  92220. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  92221. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  92222. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  92223. * @param loaderOptions options to be passed to the loader
  92224. * @returns the cube texture as an InternalTexture
  92225. */
  92226. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any): InternalTexture;
  92227. /**
  92228. * Creates a cube texture
  92229. * @param rootUrl defines the url where the files to load is located
  92230. * @param scene defines the current scene
  92231. * @param files defines the list of files to load (1 per face)
  92232. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  92233. * @param onLoad defines an optional callback raised when the texture is loaded
  92234. * @param onError defines an optional callback raised if there is an issue to load the texture
  92235. * @param format defines the format of the data
  92236. * @param forcedExtension defines the extension to use to pick the right loader
  92237. * @returns the cube texture as an InternalTexture
  92238. */
  92239. 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;
  92240. /**
  92241. * Creates a cube texture
  92242. * @param rootUrl defines the url where the files to load is located
  92243. * @param scene defines the current scene
  92244. * @param files defines the list of files to load (1 per face)
  92245. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  92246. * @param onLoad defines an optional callback raised when the texture is loaded
  92247. * @param onError defines an optional callback raised if there is an issue to load the texture
  92248. * @param format defines the format of the data
  92249. * @param forcedExtension defines the extension to use to pick the right loader
  92250. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  92251. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  92252. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  92253. * @returns the cube texture as an InternalTexture
  92254. */
  92255. 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;
  92256. /** @hidden */
  92257. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  92258. /** @hidden */
  92259. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  92260. /** @hidden */
  92261. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  92262. /** @hidden */
  92263. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  92264. /**
  92265. * @hidden
  92266. */
  92267. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  92268. }
  92269. }
  92270. declare module BABYLON {
  92271. /**
  92272. * Class for creating a cube texture
  92273. */
  92274. export class CubeTexture extends BaseTexture {
  92275. private _delayedOnLoad;
  92276. /**
  92277. * Observable triggered once the texture has been loaded.
  92278. */
  92279. onLoadObservable: Observable<CubeTexture>;
  92280. /**
  92281. * The url of the texture
  92282. */
  92283. url: string;
  92284. /**
  92285. * Gets or sets the center of the bounding box associated with the cube texture.
  92286. * It must define where the camera used to render the texture was set
  92287. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  92288. */
  92289. boundingBoxPosition: Vector3;
  92290. private _boundingBoxSize;
  92291. /**
  92292. * Gets or sets the size of the bounding box associated with the cube texture
  92293. * When defined, the cubemap will switch to local mode
  92294. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  92295. * @example https://www.babylonjs-playground.com/#RNASML
  92296. */
  92297. set boundingBoxSize(value: Vector3);
  92298. /**
  92299. * Returns the bounding box size
  92300. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  92301. */
  92302. get boundingBoxSize(): Vector3;
  92303. protected _rotationY: number;
  92304. /**
  92305. * Sets texture matrix rotation angle around Y axis in radians.
  92306. */
  92307. set rotationY(value: number);
  92308. /**
  92309. * Gets texture matrix rotation angle around Y axis radians.
  92310. */
  92311. get rotationY(): number;
  92312. /**
  92313. * Are mip maps generated for this texture or not.
  92314. */
  92315. get noMipmap(): boolean;
  92316. private _noMipmap;
  92317. private _files;
  92318. protected _forcedExtension: Nullable<string>;
  92319. private _extensions;
  92320. private _textureMatrix;
  92321. private _format;
  92322. private _createPolynomials;
  92323. private _loaderOptions;
  92324. /**
  92325. * Creates a cube texture from an array of image urls
  92326. * @param files defines an array of image urls
  92327. * @param scene defines the hosting scene
  92328. * @param noMipmap specifies if mip maps are not used
  92329. * @returns a cube texture
  92330. */
  92331. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  92332. /**
  92333. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  92334. * @param url defines the url of the prefiltered texture
  92335. * @param scene defines the scene the texture is attached to
  92336. * @param forcedExtension defines the extension of the file if different from the url
  92337. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  92338. * @return the prefiltered texture
  92339. */
  92340. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  92341. /**
  92342. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  92343. * as prefiltered data.
  92344. * @param rootUrl defines the url of the texture or the root name of the six images
  92345. * @param null defines the scene or engine the texture is attached to
  92346. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  92347. * @param noMipmap defines if mipmaps should be created or not
  92348. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  92349. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  92350. * @param onError defines a callback triggered in case of error during load
  92351. * @param format defines the internal format to use for the texture once loaded
  92352. * @param prefiltered defines whether or not the texture is created from prefiltered data
  92353. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  92354. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  92355. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  92356. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  92357. * @param loaderOptions options to be passed to the loader
  92358. * @return the cube texture
  92359. */
  92360. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, loaderOptions?: any);
  92361. /**
  92362. * Get the current class name of the texture useful for serialization or dynamic coding.
  92363. * @returns "CubeTexture"
  92364. */
  92365. getClassName(): string;
  92366. /**
  92367. * Update the url (and optional buffer) of this texture if url was null during construction.
  92368. * @param url the url of the texture
  92369. * @param forcedExtension defines the extension to use
  92370. * @param onLoad callback called when the texture is loaded (defaults to null)
  92371. * @param prefiltered Defines whether the updated texture is prefiltered or not
  92372. */
  92373. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  92374. /**
  92375. * Delays loading of the cube texture
  92376. * @param forcedExtension defines the extension to use
  92377. */
  92378. delayLoad(forcedExtension?: string): void;
  92379. /**
  92380. * Returns the reflection texture matrix
  92381. * @returns the reflection texture matrix
  92382. */
  92383. getReflectionTextureMatrix(): Matrix;
  92384. /**
  92385. * Sets the reflection texture matrix
  92386. * @param value Reflection texture matrix
  92387. */
  92388. setReflectionTextureMatrix(value: Matrix): void;
  92389. /**
  92390. * Parses text to create a cube texture
  92391. * @param parsedTexture define the serialized text to read from
  92392. * @param scene defines the hosting scene
  92393. * @param rootUrl defines the root url of the cube texture
  92394. * @returns a cube texture
  92395. */
  92396. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  92397. /**
  92398. * Makes a clone, or deep copy, of the cube texture
  92399. * @returns a new cube texture
  92400. */
  92401. clone(): CubeTexture;
  92402. }
  92403. }
  92404. declare module BABYLON {
  92405. /**
  92406. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  92407. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  92408. * 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;
  92409. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  92410. */
  92411. export class ColorCurves {
  92412. private _dirty;
  92413. private _tempColor;
  92414. private _globalCurve;
  92415. private _highlightsCurve;
  92416. private _midtonesCurve;
  92417. private _shadowsCurve;
  92418. private _positiveCurve;
  92419. private _negativeCurve;
  92420. private _globalHue;
  92421. private _globalDensity;
  92422. private _globalSaturation;
  92423. private _globalExposure;
  92424. /**
  92425. * Gets the global Hue value.
  92426. * 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).
  92427. */
  92428. get globalHue(): number;
  92429. /**
  92430. * Sets the global Hue value.
  92431. * 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).
  92432. */
  92433. set globalHue(value: number);
  92434. /**
  92435. * Gets the global Density value.
  92436. * 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.
  92437. * Values less than zero provide a filter of opposite hue.
  92438. */
  92439. get globalDensity(): number;
  92440. /**
  92441. * Sets the global Density value.
  92442. * 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.
  92443. * Values less than zero provide a filter of opposite hue.
  92444. */
  92445. set globalDensity(value: number);
  92446. /**
  92447. * Gets the global Saturation value.
  92448. * 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.
  92449. */
  92450. get globalSaturation(): number;
  92451. /**
  92452. * Sets the global Saturation value.
  92453. * 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.
  92454. */
  92455. set globalSaturation(value: number);
  92456. /**
  92457. * Gets the global Exposure value.
  92458. * 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.
  92459. */
  92460. get globalExposure(): number;
  92461. /**
  92462. * Sets the global Exposure value.
  92463. * 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.
  92464. */
  92465. set globalExposure(value: number);
  92466. private _highlightsHue;
  92467. private _highlightsDensity;
  92468. private _highlightsSaturation;
  92469. private _highlightsExposure;
  92470. /**
  92471. * Gets the highlights Hue value.
  92472. * 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).
  92473. */
  92474. get highlightsHue(): number;
  92475. /**
  92476. * Sets the highlights Hue value.
  92477. * 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).
  92478. */
  92479. set highlightsHue(value: number);
  92480. /**
  92481. * Gets the highlights Density value.
  92482. * 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.
  92483. * Values less than zero provide a filter of opposite hue.
  92484. */
  92485. get highlightsDensity(): number;
  92486. /**
  92487. * Sets the highlights Density value.
  92488. * 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.
  92489. * Values less than zero provide a filter of opposite hue.
  92490. */
  92491. set highlightsDensity(value: number);
  92492. /**
  92493. * Gets the highlights Saturation value.
  92494. * 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.
  92495. */
  92496. get highlightsSaturation(): number;
  92497. /**
  92498. * Sets the highlights Saturation value.
  92499. * 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.
  92500. */
  92501. set highlightsSaturation(value: number);
  92502. /**
  92503. * Gets the highlights Exposure value.
  92504. * 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.
  92505. */
  92506. get highlightsExposure(): number;
  92507. /**
  92508. * Sets the highlights Exposure value.
  92509. * 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.
  92510. */
  92511. set highlightsExposure(value: number);
  92512. private _midtonesHue;
  92513. private _midtonesDensity;
  92514. private _midtonesSaturation;
  92515. private _midtonesExposure;
  92516. /**
  92517. * Gets the midtones Hue value.
  92518. * 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).
  92519. */
  92520. get midtonesHue(): number;
  92521. /**
  92522. * Sets the midtones Hue value.
  92523. * 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).
  92524. */
  92525. set midtonesHue(value: number);
  92526. /**
  92527. * Gets the midtones Density value.
  92528. * 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.
  92529. * Values less than zero provide a filter of opposite hue.
  92530. */
  92531. get midtonesDensity(): number;
  92532. /**
  92533. * Sets the midtones Density value.
  92534. * 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.
  92535. * Values less than zero provide a filter of opposite hue.
  92536. */
  92537. set midtonesDensity(value: number);
  92538. /**
  92539. * Gets the midtones Saturation value.
  92540. * 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.
  92541. */
  92542. get midtonesSaturation(): number;
  92543. /**
  92544. * Sets the midtones Saturation value.
  92545. * 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.
  92546. */
  92547. set midtonesSaturation(value: number);
  92548. /**
  92549. * Gets the midtones Exposure value.
  92550. * 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.
  92551. */
  92552. get midtonesExposure(): number;
  92553. /**
  92554. * Sets the midtones Exposure value.
  92555. * 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.
  92556. */
  92557. set midtonesExposure(value: number);
  92558. private _shadowsHue;
  92559. private _shadowsDensity;
  92560. private _shadowsSaturation;
  92561. private _shadowsExposure;
  92562. /**
  92563. * Gets the shadows Hue value.
  92564. * 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).
  92565. */
  92566. get shadowsHue(): number;
  92567. /**
  92568. * Sets the shadows Hue value.
  92569. * 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).
  92570. */
  92571. set shadowsHue(value: number);
  92572. /**
  92573. * Gets the shadows Density value.
  92574. * 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.
  92575. * Values less than zero provide a filter of opposite hue.
  92576. */
  92577. get shadowsDensity(): number;
  92578. /**
  92579. * Sets the shadows Density value.
  92580. * 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.
  92581. * Values less than zero provide a filter of opposite hue.
  92582. */
  92583. set shadowsDensity(value: number);
  92584. /**
  92585. * Gets the shadows Saturation value.
  92586. * 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.
  92587. */
  92588. get shadowsSaturation(): number;
  92589. /**
  92590. * Sets the shadows Saturation value.
  92591. * 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.
  92592. */
  92593. set shadowsSaturation(value: number);
  92594. /**
  92595. * Gets the shadows Exposure value.
  92596. * 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.
  92597. */
  92598. get shadowsExposure(): number;
  92599. /**
  92600. * Sets the shadows Exposure value.
  92601. * 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.
  92602. */
  92603. set shadowsExposure(value: number);
  92604. /**
  92605. * Returns the class name
  92606. * @returns The class name
  92607. */
  92608. getClassName(): string;
  92609. /**
  92610. * Binds the color curves to the shader.
  92611. * @param colorCurves The color curve to bind
  92612. * @param effect The effect to bind to
  92613. * @param positiveUniform The positive uniform shader parameter
  92614. * @param neutralUniform The neutral uniform shader parameter
  92615. * @param negativeUniform The negative uniform shader parameter
  92616. */
  92617. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  92618. /**
  92619. * Prepare the list of uniforms associated with the ColorCurves effects.
  92620. * @param uniformsList The list of uniforms used in the effect
  92621. */
  92622. static PrepareUniforms(uniformsList: string[]): void;
  92623. /**
  92624. * Returns color grading data based on a hue, density, saturation and exposure value.
  92625. * @param filterHue The hue of the color filter.
  92626. * @param filterDensity The density of the color filter.
  92627. * @param saturation The saturation.
  92628. * @param exposure The exposure.
  92629. * @param result The result data container.
  92630. */
  92631. private getColorGradingDataToRef;
  92632. /**
  92633. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  92634. * @param value The input slider value in range [-100,100].
  92635. * @returns Adjusted value.
  92636. */
  92637. private static applyColorGradingSliderNonlinear;
  92638. /**
  92639. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  92640. * @param hue The hue (H) input.
  92641. * @param saturation The saturation (S) input.
  92642. * @param brightness The brightness (B) input.
  92643. * @result An RGBA color represented as Vector4.
  92644. */
  92645. private static fromHSBToRef;
  92646. /**
  92647. * Returns a value clamped between min and max
  92648. * @param value The value to clamp
  92649. * @param min The minimum of value
  92650. * @param max The maximum of value
  92651. * @returns The clamped value.
  92652. */
  92653. private static clamp;
  92654. /**
  92655. * Clones the current color curve instance.
  92656. * @return The cloned curves
  92657. */
  92658. clone(): ColorCurves;
  92659. /**
  92660. * Serializes the current color curve instance to a json representation.
  92661. * @return a JSON representation
  92662. */
  92663. serialize(): any;
  92664. /**
  92665. * Parses the color curve from a json representation.
  92666. * @param source the JSON source to parse
  92667. * @return The parsed curves
  92668. */
  92669. static Parse(source: any): ColorCurves;
  92670. }
  92671. }
  92672. declare module BABYLON {
  92673. /**
  92674. * Interface to follow in your material defines to integrate easily the
  92675. * Image proccessing functions.
  92676. * @hidden
  92677. */
  92678. export interface IImageProcessingConfigurationDefines {
  92679. IMAGEPROCESSING: boolean;
  92680. VIGNETTE: boolean;
  92681. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92682. VIGNETTEBLENDMODEOPAQUE: boolean;
  92683. TONEMAPPING: boolean;
  92684. TONEMAPPING_ACES: boolean;
  92685. CONTRAST: boolean;
  92686. EXPOSURE: boolean;
  92687. COLORCURVES: boolean;
  92688. COLORGRADING: boolean;
  92689. COLORGRADING3D: boolean;
  92690. SAMPLER3DGREENDEPTH: boolean;
  92691. SAMPLER3DBGRMAP: boolean;
  92692. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92693. }
  92694. /**
  92695. * @hidden
  92696. */
  92697. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  92698. IMAGEPROCESSING: boolean;
  92699. VIGNETTE: boolean;
  92700. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92701. VIGNETTEBLENDMODEOPAQUE: boolean;
  92702. TONEMAPPING: boolean;
  92703. TONEMAPPING_ACES: boolean;
  92704. CONTRAST: boolean;
  92705. COLORCURVES: boolean;
  92706. COLORGRADING: boolean;
  92707. COLORGRADING3D: boolean;
  92708. SAMPLER3DGREENDEPTH: boolean;
  92709. SAMPLER3DBGRMAP: boolean;
  92710. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92711. EXPOSURE: boolean;
  92712. constructor();
  92713. }
  92714. /**
  92715. * This groups together the common properties used for image processing either in direct forward pass
  92716. * or through post processing effect depending on the use of the image processing pipeline in your scene
  92717. * or not.
  92718. */
  92719. export class ImageProcessingConfiguration {
  92720. /**
  92721. * Default tone mapping applied in BabylonJS.
  92722. */
  92723. static readonly TONEMAPPING_STANDARD: number;
  92724. /**
  92725. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  92726. * to other engines rendering to increase portability.
  92727. */
  92728. static readonly TONEMAPPING_ACES: number;
  92729. /**
  92730. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  92731. */
  92732. colorCurves: Nullable<ColorCurves>;
  92733. private _colorCurvesEnabled;
  92734. /**
  92735. * Gets wether the color curves effect is enabled.
  92736. */
  92737. get colorCurvesEnabled(): boolean;
  92738. /**
  92739. * Sets wether the color curves effect is enabled.
  92740. */
  92741. set colorCurvesEnabled(value: boolean);
  92742. private _colorGradingTexture;
  92743. /**
  92744. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92745. */
  92746. get colorGradingTexture(): Nullable<BaseTexture>;
  92747. /**
  92748. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92749. */
  92750. set colorGradingTexture(value: Nullable<BaseTexture>);
  92751. private _colorGradingEnabled;
  92752. /**
  92753. * Gets wether the color grading effect is enabled.
  92754. */
  92755. get colorGradingEnabled(): boolean;
  92756. /**
  92757. * Sets wether the color grading effect is enabled.
  92758. */
  92759. set colorGradingEnabled(value: boolean);
  92760. private _colorGradingWithGreenDepth;
  92761. /**
  92762. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  92763. */
  92764. get colorGradingWithGreenDepth(): boolean;
  92765. /**
  92766. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  92767. */
  92768. set colorGradingWithGreenDepth(value: boolean);
  92769. private _colorGradingBGR;
  92770. /**
  92771. * Gets wether the color grading texture contains BGR values.
  92772. */
  92773. get colorGradingBGR(): boolean;
  92774. /**
  92775. * Sets wether the color grading texture contains BGR values.
  92776. */
  92777. set colorGradingBGR(value: boolean);
  92778. /** @hidden */
  92779. _exposure: number;
  92780. /**
  92781. * Gets the Exposure used in the effect.
  92782. */
  92783. get exposure(): number;
  92784. /**
  92785. * Sets the Exposure used in the effect.
  92786. */
  92787. set exposure(value: number);
  92788. private _toneMappingEnabled;
  92789. /**
  92790. * Gets wether the tone mapping effect is enabled.
  92791. */
  92792. get toneMappingEnabled(): boolean;
  92793. /**
  92794. * Sets wether the tone mapping effect is enabled.
  92795. */
  92796. set toneMappingEnabled(value: boolean);
  92797. private _toneMappingType;
  92798. /**
  92799. * Gets the type of tone mapping effect.
  92800. */
  92801. get toneMappingType(): number;
  92802. /**
  92803. * Sets the type of tone mapping effect used in BabylonJS.
  92804. */
  92805. set toneMappingType(value: number);
  92806. protected _contrast: number;
  92807. /**
  92808. * Gets the contrast used in the effect.
  92809. */
  92810. get contrast(): number;
  92811. /**
  92812. * Sets the contrast used in the effect.
  92813. */
  92814. set contrast(value: number);
  92815. /**
  92816. * Vignette stretch size.
  92817. */
  92818. vignetteStretch: number;
  92819. /**
  92820. * Vignette centre X Offset.
  92821. */
  92822. vignetteCentreX: number;
  92823. /**
  92824. * Vignette centre Y Offset.
  92825. */
  92826. vignetteCentreY: number;
  92827. /**
  92828. * Vignette weight or intensity of the vignette effect.
  92829. */
  92830. vignetteWeight: number;
  92831. /**
  92832. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  92833. * if vignetteEnabled is set to true.
  92834. */
  92835. vignetteColor: Color4;
  92836. /**
  92837. * Camera field of view used by the Vignette effect.
  92838. */
  92839. vignetteCameraFov: number;
  92840. private _vignetteBlendMode;
  92841. /**
  92842. * Gets the vignette blend mode allowing different kind of effect.
  92843. */
  92844. get vignetteBlendMode(): number;
  92845. /**
  92846. * Sets the vignette blend mode allowing different kind of effect.
  92847. */
  92848. set vignetteBlendMode(value: number);
  92849. private _vignetteEnabled;
  92850. /**
  92851. * Gets wether the vignette effect is enabled.
  92852. */
  92853. get vignetteEnabled(): boolean;
  92854. /**
  92855. * Sets wether the vignette effect is enabled.
  92856. */
  92857. set vignetteEnabled(value: boolean);
  92858. private _applyByPostProcess;
  92859. /**
  92860. * Gets wether the image processing is applied through a post process or not.
  92861. */
  92862. get applyByPostProcess(): boolean;
  92863. /**
  92864. * Sets wether the image processing is applied through a post process or not.
  92865. */
  92866. set applyByPostProcess(value: boolean);
  92867. private _isEnabled;
  92868. /**
  92869. * Gets wether the image processing is enabled or not.
  92870. */
  92871. get isEnabled(): boolean;
  92872. /**
  92873. * Sets wether the image processing is enabled or not.
  92874. */
  92875. set isEnabled(value: boolean);
  92876. /**
  92877. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  92878. */
  92879. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  92880. /**
  92881. * Method called each time the image processing information changes requires to recompile the effect.
  92882. */
  92883. protected _updateParameters(): void;
  92884. /**
  92885. * Gets the current class name.
  92886. * @return "ImageProcessingConfiguration"
  92887. */
  92888. getClassName(): string;
  92889. /**
  92890. * Prepare the list of uniforms associated with the Image Processing effects.
  92891. * @param uniforms The list of uniforms used in the effect
  92892. * @param defines the list of defines currently in use
  92893. */
  92894. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  92895. /**
  92896. * Prepare the list of samplers associated with the Image Processing effects.
  92897. * @param samplersList The list of uniforms used in the effect
  92898. * @param defines the list of defines currently in use
  92899. */
  92900. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  92901. /**
  92902. * Prepare the list of defines associated to the shader.
  92903. * @param defines the list of defines to complete
  92904. * @param forPostProcess Define if we are currently in post process mode or not
  92905. */
  92906. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  92907. /**
  92908. * Returns true if all the image processing information are ready.
  92909. * @returns True if ready, otherwise, false
  92910. */
  92911. isReady(): boolean;
  92912. /**
  92913. * Binds the image processing to the shader.
  92914. * @param effect The effect to bind to
  92915. * @param overrideAspectRatio Override the aspect ratio of the effect
  92916. */
  92917. bind(effect: Effect, overrideAspectRatio?: number): void;
  92918. /**
  92919. * Clones the current image processing instance.
  92920. * @return The cloned image processing
  92921. */
  92922. clone(): ImageProcessingConfiguration;
  92923. /**
  92924. * Serializes the current image processing instance to a json representation.
  92925. * @return a JSON representation
  92926. */
  92927. serialize(): any;
  92928. /**
  92929. * Parses the image processing from a json representation.
  92930. * @param source the JSON source to parse
  92931. * @return The parsed image processing
  92932. */
  92933. static Parse(source: any): ImageProcessingConfiguration;
  92934. private static _VIGNETTEMODE_MULTIPLY;
  92935. private static _VIGNETTEMODE_OPAQUE;
  92936. /**
  92937. * Used to apply the vignette as a mix with the pixel color.
  92938. */
  92939. static get VIGNETTEMODE_MULTIPLY(): number;
  92940. /**
  92941. * Used to apply the vignette as a replacement of the pixel color.
  92942. */
  92943. static get VIGNETTEMODE_OPAQUE(): number;
  92944. }
  92945. }
  92946. declare module BABYLON {
  92947. /** @hidden */
  92948. export var postprocessVertexShader: {
  92949. name: string;
  92950. shader: string;
  92951. };
  92952. }
  92953. declare module BABYLON {
  92954. /**
  92955. * Type used to define a render target texture size (either with a number or with a rect width and height)
  92956. */
  92957. export type RenderTargetTextureSize = number | {
  92958. width: number;
  92959. height: number;
  92960. layers?: number;
  92961. };
  92962. interface ThinEngine {
  92963. /**
  92964. * Creates a new render target texture
  92965. * @param size defines the size of the texture
  92966. * @param options defines the options used to create the texture
  92967. * @returns a new render target texture stored in an InternalTexture
  92968. */
  92969. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  92970. /**
  92971. * Creates a depth stencil texture.
  92972. * This is only available in WebGL 2 or with the depth texture extension available.
  92973. * @param size The size of face edge in the texture.
  92974. * @param options The options defining the texture.
  92975. * @returns The texture
  92976. */
  92977. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  92978. /** @hidden */
  92979. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  92980. }
  92981. }
  92982. declare module BABYLON {
  92983. /**
  92984. * Defines the kind of connection point for node based material
  92985. */
  92986. export enum NodeMaterialBlockConnectionPointTypes {
  92987. /** Float */
  92988. Float = 1,
  92989. /** Int */
  92990. Int = 2,
  92991. /** Vector2 */
  92992. Vector2 = 4,
  92993. /** Vector3 */
  92994. Vector3 = 8,
  92995. /** Vector4 */
  92996. Vector4 = 16,
  92997. /** Color3 */
  92998. Color3 = 32,
  92999. /** Color4 */
  93000. Color4 = 64,
  93001. /** Matrix */
  93002. Matrix = 128,
  93003. /** Custom object */
  93004. Object = 256,
  93005. /** Detect type based on connection */
  93006. AutoDetect = 1024,
  93007. /** Output type that will be defined by input type */
  93008. BasedOnInput = 2048
  93009. }
  93010. }
  93011. declare module BABYLON {
  93012. /**
  93013. * Enum used to define the target of a block
  93014. */
  93015. export enum NodeMaterialBlockTargets {
  93016. /** Vertex shader */
  93017. Vertex = 1,
  93018. /** Fragment shader */
  93019. Fragment = 2,
  93020. /** Neutral */
  93021. Neutral = 4,
  93022. /** Vertex and Fragment */
  93023. VertexAndFragment = 3
  93024. }
  93025. }
  93026. declare module BABYLON {
  93027. /**
  93028. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  93029. */
  93030. export enum NodeMaterialBlockConnectionPointMode {
  93031. /** Value is an uniform */
  93032. Uniform = 0,
  93033. /** Value is a mesh attribute */
  93034. Attribute = 1,
  93035. /** Value is a varying between vertex and fragment shaders */
  93036. Varying = 2,
  93037. /** Mode is undefined */
  93038. Undefined = 3
  93039. }
  93040. }
  93041. declare module BABYLON {
  93042. /**
  93043. * Enum used to define system values e.g. values automatically provided by the system
  93044. */
  93045. export enum NodeMaterialSystemValues {
  93046. /** World */
  93047. World = 1,
  93048. /** View */
  93049. View = 2,
  93050. /** Projection */
  93051. Projection = 3,
  93052. /** ViewProjection */
  93053. ViewProjection = 4,
  93054. /** WorldView */
  93055. WorldView = 5,
  93056. /** WorldViewProjection */
  93057. WorldViewProjection = 6,
  93058. /** CameraPosition */
  93059. CameraPosition = 7,
  93060. /** Fog Color */
  93061. FogColor = 8,
  93062. /** Delta time */
  93063. DeltaTime = 9
  93064. }
  93065. }
  93066. declare module BABYLON {
  93067. /**
  93068. * Represents a camera frustum
  93069. */
  93070. export class Frustum {
  93071. /**
  93072. * Gets the planes representing the frustum
  93073. * @param transform matrix to be applied to the returned planes
  93074. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  93075. */
  93076. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  93077. /**
  93078. * Gets the near frustum plane transformed by the transform matrix
  93079. * @param transform transformation matrix to be applied to the resulting frustum plane
  93080. * @param frustumPlane the resuling frustum plane
  93081. */
  93082. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93083. /**
  93084. * Gets the far frustum plane transformed by the transform matrix
  93085. * @param transform transformation matrix to be applied to the resulting frustum plane
  93086. * @param frustumPlane the resuling frustum plane
  93087. */
  93088. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93089. /**
  93090. * Gets the left frustum plane transformed by the transform matrix
  93091. * @param transform transformation matrix to be applied to the resulting frustum plane
  93092. * @param frustumPlane the resuling frustum plane
  93093. */
  93094. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93095. /**
  93096. * Gets the right frustum plane transformed by the transform matrix
  93097. * @param transform transformation matrix to be applied to the resulting frustum plane
  93098. * @param frustumPlane the resuling frustum plane
  93099. */
  93100. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93101. /**
  93102. * Gets the top frustum plane transformed by the transform matrix
  93103. * @param transform transformation matrix to be applied to the resulting frustum plane
  93104. * @param frustumPlane the resuling frustum plane
  93105. */
  93106. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93107. /**
  93108. * Gets the bottom frustum plane transformed by the transform matrix
  93109. * @param transform transformation matrix to be applied to the resulting frustum plane
  93110. * @param frustumPlane the resuling frustum plane
  93111. */
  93112. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93113. /**
  93114. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  93115. * @param transform transformation matrix to be applied to the resulting frustum planes
  93116. * @param frustumPlanes the resuling frustum planes
  93117. */
  93118. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  93119. }
  93120. }
  93121. declare module BABYLON {
  93122. /**
  93123. * Contains position and normal vectors for a vertex
  93124. */
  93125. export class PositionNormalVertex {
  93126. /** the position of the vertex (defaut: 0,0,0) */
  93127. position: Vector3;
  93128. /** the normal of the vertex (defaut: 0,1,0) */
  93129. normal: Vector3;
  93130. /**
  93131. * Creates a PositionNormalVertex
  93132. * @param position the position of the vertex (defaut: 0,0,0)
  93133. * @param normal the normal of the vertex (defaut: 0,1,0)
  93134. */
  93135. constructor(
  93136. /** the position of the vertex (defaut: 0,0,0) */
  93137. position?: Vector3,
  93138. /** the normal of the vertex (defaut: 0,1,0) */
  93139. normal?: Vector3);
  93140. /**
  93141. * Clones the PositionNormalVertex
  93142. * @returns the cloned PositionNormalVertex
  93143. */
  93144. clone(): PositionNormalVertex;
  93145. }
  93146. /**
  93147. * Contains position, normal and uv vectors for a vertex
  93148. */
  93149. export class PositionNormalTextureVertex {
  93150. /** the position of the vertex (defaut: 0,0,0) */
  93151. position: Vector3;
  93152. /** the normal of the vertex (defaut: 0,1,0) */
  93153. normal: Vector3;
  93154. /** the uv of the vertex (default: 0,0) */
  93155. uv: Vector2;
  93156. /**
  93157. * Creates a PositionNormalTextureVertex
  93158. * @param position the position of the vertex (defaut: 0,0,0)
  93159. * @param normal the normal of the vertex (defaut: 0,1,0)
  93160. * @param uv the uv of the vertex (default: 0,0)
  93161. */
  93162. constructor(
  93163. /** the position of the vertex (defaut: 0,0,0) */
  93164. position?: Vector3,
  93165. /** the normal of the vertex (defaut: 0,1,0) */
  93166. normal?: Vector3,
  93167. /** the uv of the vertex (default: 0,0) */
  93168. uv?: Vector2);
  93169. /**
  93170. * Clones the PositionNormalTextureVertex
  93171. * @returns the cloned PositionNormalTextureVertex
  93172. */
  93173. clone(): PositionNormalTextureVertex;
  93174. }
  93175. }
  93176. declare module BABYLON {
  93177. /**
  93178. * Enum defining the type of animations supported by InputBlock
  93179. */
  93180. export enum AnimatedInputBlockTypes {
  93181. /** No animation */
  93182. None = 0,
  93183. /** Time based animation. Will only work for floats */
  93184. Time = 1
  93185. }
  93186. }
  93187. declare module BABYLON {
  93188. /**
  93189. * Block used to expose an input value
  93190. */
  93191. export class InputBlock extends NodeMaterialBlock {
  93192. private _mode;
  93193. private _associatedVariableName;
  93194. private _storedValue;
  93195. private _valueCallback;
  93196. private _type;
  93197. private _animationType;
  93198. /** Gets or set a value used to limit the range of float values */
  93199. min: number;
  93200. /** Gets or set a value used to limit the range of float values */
  93201. max: number;
  93202. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  93203. isBoolean: boolean;
  93204. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  93205. matrixMode: number;
  93206. /** @hidden */
  93207. _systemValue: Nullable<NodeMaterialSystemValues>;
  93208. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  93209. isConstant: boolean;
  93210. /** Gets or sets the group to use to display this block in the Inspector */
  93211. groupInInspector: string;
  93212. /** Gets an observable raised when the value is changed */
  93213. onValueChangedObservable: Observable<InputBlock>;
  93214. /**
  93215. * Gets or sets the connection point type (default is float)
  93216. */
  93217. get type(): NodeMaterialBlockConnectionPointTypes;
  93218. /**
  93219. * Creates a new InputBlock
  93220. * @param name defines the block name
  93221. * @param target defines the target of that block (Vertex by default)
  93222. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  93223. */
  93224. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  93225. /**
  93226. * Validates if a name is a reserve word.
  93227. * @param newName the new name to be given to the node.
  93228. * @returns false if the name is a reserve word, else true.
  93229. */
  93230. validateBlockName(newName: string): boolean;
  93231. /**
  93232. * Gets the output component
  93233. */
  93234. get output(): NodeMaterialConnectionPoint;
  93235. /**
  93236. * Set the source of this connection point to a vertex attribute
  93237. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  93238. * @returns the current connection point
  93239. */
  93240. setAsAttribute(attributeName?: string): InputBlock;
  93241. /**
  93242. * Set the source of this connection point to a system value
  93243. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  93244. * @returns the current connection point
  93245. */
  93246. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  93247. /**
  93248. * Gets or sets the value of that point.
  93249. * Please note that this value will be ignored if valueCallback is defined
  93250. */
  93251. get value(): any;
  93252. set value(value: any);
  93253. /**
  93254. * Gets or sets a callback used to get the value of that point.
  93255. * Please note that setting this value will force the connection point to ignore the value property
  93256. */
  93257. get valueCallback(): () => any;
  93258. set valueCallback(value: () => any);
  93259. /**
  93260. * Gets or sets the associated variable name in the shader
  93261. */
  93262. get associatedVariableName(): string;
  93263. set associatedVariableName(value: string);
  93264. /** Gets or sets the type of animation applied to the input */
  93265. get animationType(): AnimatedInputBlockTypes;
  93266. set animationType(value: AnimatedInputBlockTypes);
  93267. /**
  93268. * Gets a boolean indicating that this connection point not defined yet
  93269. */
  93270. get isUndefined(): boolean;
  93271. /**
  93272. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  93273. * In this case the connection point name must be the name of the uniform to use.
  93274. * Can only be set on inputs
  93275. */
  93276. get isUniform(): boolean;
  93277. set isUniform(value: boolean);
  93278. /**
  93279. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  93280. * In this case the connection point name must be the name of the attribute to use
  93281. * Can only be set on inputs
  93282. */
  93283. get isAttribute(): boolean;
  93284. set isAttribute(value: boolean);
  93285. /**
  93286. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  93287. * Can only be set on exit points
  93288. */
  93289. get isVarying(): boolean;
  93290. set isVarying(value: boolean);
  93291. /**
  93292. * Gets a boolean indicating that the current connection point is a system value
  93293. */
  93294. get isSystemValue(): boolean;
  93295. /**
  93296. * Gets or sets the current well known value or null if not defined as a system value
  93297. */
  93298. get systemValue(): Nullable<NodeMaterialSystemValues>;
  93299. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  93300. /**
  93301. * Gets the current class name
  93302. * @returns the class name
  93303. */
  93304. getClassName(): string;
  93305. /**
  93306. * Animate the input if animationType !== None
  93307. * @param scene defines the rendering scene
  93308. */
  93309. animate(scene: Scene): void;
  93310. private _emitDefine;
  93311. initialize(state: NodeMaterialBuildState): void;
  93312. /**
  93313. * Set the input block to its default value (based on its type)
  93314. */
  93315. setDefaultValue(): void;
  93316. private _emitConstant;
  93317. /** @hidden */
  93318. get _noContextSwitch(): boolean;
  93319. private _emit;
  93320. /** @hidden */
  93321. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  93322. /** @hidden */
  93323. _transmit(effect: Effect, scene: Scene): void;
  93324. protected _buildBlock(state: NodeMaterialBuildState): void;
  93325. protected _dumpPropertiesCode(): string;
  93326. dispose(): void;
  93327. serialize(): any;
  93328. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  93329. }
  93330. }
  93331. declare module BABYLON {
  93332. /**
  93333. * Enum used to define the compatibility state between two connection points
  93334. */
  93335. export enum NodeMaterialConnectionPointCompatibilityStates {
  93336. /** Points are compatibles */
  93337. Compatible = 0,
  93338. /** Points are incompatible because of their types */
  93339. TypeIncompatible = 1,
  93340. /** Points are incompatible because of their targets (vertex vs fragment) */
  93341. TargetIncompatible = 2
  93342. }
  93343. /**
  93344. * Defines the direction of a connection point
  93345. */
  93346. export enum NodeMaterialConnectionPointDirection {
  93347. /** Input */
  93348. Input = 0,
  93349. /** Output */
  93350. Output = 1
  93351. }
  93352. /**
  93353. * Defines a connection point for a block
  93354. */
  93355. export class NodeMaterialConnectionPoint {
  93356. /**
  93357. * Checks if two types are equivalent
  93358. * @param type1 type 1 to check
  93359. * @param type2 type 2 to check
  93360. * @returns true if both types are equivalent, else false
  93361. */
  93362. static AreEquivalentTypes(type1: number, type2: number): boolean;
  93363. /** @hidden */
  93364. _ownerBlock: NodeMaterialBlock;
  93365. /** @hidden */
  93366. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  93367. private _endpoints;
  93368. private _associatedVariableName;
  93369. private _direction;
  93370. /** @hidden */
  93371. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  93372. /** @hidden */
  93373. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  93374. /** @hidden */
  93375. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  93376. private _type;
  93377. /** @hidden */
  93378. _enforceAssociatedVariableName: boolean;
  93379. /** Gets the direction of the point */
  93380. get direction(): NodeMaterialConnectionPointDirection;
  93381. /** Indicates that this connection point needs dual validation before being connected to another point */
  93382. needDualDirectionValidation: boolean;
  93383. /**
  93384. * Gets or sets the additional types supported by this connection point
  93385. */
  93386. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  93387. /**
  93388. * Gets or sets the additional types excluded by this connection point
  93389. */
  93390. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  93391. /**
  93392. * Observable triggered when this point is connected
  93393. */
  93394. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  93395. /**
  93396. * Gets or sets the associated variable name in the shader
  93397. */
  93398. get associatedVariableName(): string;
  93399. set associatedVariableName(value: string);
  93400. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  93401. get innerType(): NodeMaterialBlockConnectionPointTypes;
  93402. /**
  93403. * Gets or sets the connection point type (default is float)
  93404. */
  93405. get type(): NodeMaterialBlockConnectionPointTypes;
  93406. set type(value: NodeMaterialBlockConnectionPointTypes);
  93407. /**
  93408. * Gets or sets the connection point name
  93409. */
  93410. name: string;
  93411. /**
  93412. * Gets or sets the connection point name
  93413. */
  93414. displayName: string;
  93415. /**
  93416. * Gets or sets a boolean indicating that this connection point can be omitted
  93417. */
  93418. isOptional: boolean;
  93419. /**
  93420. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  93421. */
  93422. isExposedOnFrame: boolean;
  93423. /**
  93424. * Gets or sets number indicating the position that the port is exposed to on a frame
  93425. */
  93426. exposedPortPosition: number;
  93427. /**
  93428. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  93429. */
  93430. define: string;
  93431. /** @hidden */
  93432. _prioritizeVertex: boolean;
  93433. private _target;
  93434. /** Gets or sets the target of that connection point */
  93435. get target(): NodeMaterialBlockTargets;
  93436. set target(value: NodeMaterialBlockTargets);
  93437. /**
  93438. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  93439. */
  93440. get isConnected(): boolean;
  93441. /**
  93442. * Gets a boolean indicating that the current point is connected to an input block
  93443. */
  93444. get isConnectedToInputBlock(): boolean;
  93445. /**
  93446. * Gets a the connected input block (if any)
  93447. */
  93448. get connectInputBlock(): Nullable<InputBlock>;
  93449. /** Get the other side of the connection (if any) */
  93450. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  93451. /** Get the block that owns this connection point */
  93452. get ownerBlock(): NodeMaterialBlock;
  93453. /** Get the block connected on the other side of this connection (if any) */
  93454. get sourceBlock(): Nullable<NodeMaterialBlock>;
  93455. /** Get the block connected on the endpoints of this connection (if any) */
  93456. get connectedBlocks(): Array<NodeMaterialBlock>;
  93457. /** Gets the list of connected endpoints */
  93458. get endpoints(): NodeMaterialConnectionPoint[];
  93459. /** Gets a boolean indicating if that output point is connected to at least one input */
  93460. get hasEndpoints(): boolean;
  93461. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  93462. get isConnectedInVertexShader(): boolean;
  93463. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  93464. get isConnectedInFragmentShader(): boolean;
  93465. /**
  93466. * Creates a block suitable to be used as an input for this input point.
  93467. * If null is returned, a block based on the point type will be created.
  93468. * @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
  93469. */
  93470. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  93471. /**
  93472. * Creates a new connection point
  93473. * @param name defines the connection point name
  93474. * @param ownerBlock defines the block hosting this connection point
  93475. * @param direction defines the direction of the connection point
  93476. */
  93477. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  93478. /**
  93479. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  93480. * @returns the class name
  93481. */
  93482. getClassName(): string;
  93483. /**
  93484. * Gets a boolean indicating if the current point can be connected to another point
  93485. * @param connectionPoint defines the other connection point
  93486. * @returns a boolean
  93487. */
  93488. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  93489. /**
  93490. * Gets a number indicating if the current point can be connected to another point
  93491. * @param connectionPoint defines the other connection point
  93492. * @returns a number defining the compatibility state
  93493. */
  93494. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  93495. /**
  93496. * Connect this point to another connection point
  93497. * @param connectionPoint defines the other connection point
  93498. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  93499. * @returns the current connection point
  93500. */
  93501. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  93502. /**
  93503. * Disconnect this point from one of his endpoint
  93504. * @param endpoint defines the other connection point
  93505. * @returns the current connection point
  93506. */
  93507. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  93508. /**
  93509. * Serializes this point in a JSON representation
  93510. * @param isInput defines if the connection point is an input (default is true)
  93511. * @returns the serialized point object
  93512. */
  93513. serialize(isInput?: boolean): any;
  93514. /**
  93515. * Release resources
  93516. */
  93517. dispose(): void;
  93518. }
  93519. }
  93520. declare module BABYLON {
  93521. /**
  93522. * Enum used to define the material modes
  93523. */
  93524. export enum NodeMaterialModes {
  93525. /** Regular material */
  93526. Material = 0,
  93527. /** For post process */
  93528. PostProcess = 1,
  93529. /** For particle system */
  93530. Particle = 2,
  93531. /** For procedural texture */
  93532. ProceduralTexture = 3
  93533. }
  93534. }
  93535. declare module BABYLON {
  93536. /** @hidden */
  93537. export var helperFunctions: {
  93538. name: string;
  93539. shader: string;
  93540. };
  93541. }
  93542. declare module BABYLON {
  93543. /**
  93544. * Block used to read a texture from a sampler
  93545. */
  93546. export class TextureBlock extends NodeMaterialBlock {
  93547. private _defineName;
  93548. private _linearDefineName;
  93549. private _gammaDefineName;
  93550. private _tempTextureRead;
  93551. private _samplerName;
  93552. private _transformedUVName;
  93553. private _textureTransformName;
  93554. private _textureInfoName;
  93555. private _mainUVName;
  93556. private _mainUVDefineName;
  93557. private _fragmentOnly;
  93558. /**
  93559. * Gets or sets the texture associated with the node
  93560. */
  93561. texture: Nullable<Texture>;
  93562. /**
  93563. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  93564. */
  93565. convertToGammaSpace: boolean;
  93566. /**
  93567. * Gets or sets a boolean indicating if content needs to be converted to linear space
  93568. */
  93569. convertToLinearSpace: boolean;
  93570. /**
  93571. * Create a new TextureBlock
  93572. * @param name defines the block name
  93573. */
  93574. constructor(name: string, fragmentOnly?: boolean);
  93575. /**
  93576. * Gets the current class name
  93577. * @returns the class name
  93578. */
  93579. getClassName(): string;
  93580. /**
  93581. * Gets the uv input component
  93582. */
  93583. get uv(): NodeMaterialConnectionPoint;
  93584. /**
  93585. * Gets the rgba output component
  93586. */
  93587. get rgba(): NodeMaterialConnectionPoint;
  93588. /**
  93589. * Gets the rgb output component
  93590. */
  93591. get rgb(): NodeMaterialConnectionPoint;
  93592. /**
  93593. * Gets the r output component
  93594. */
  93595. get r(): NodeMaterialConnectionPoint;
  93596. /**
  93597. * Gets the g output component
  93598. */
  93599. get g(): NodeMaterialConnectionPoint;
  93600. /**
  93601. * Gets the b output component
  93602. */
  93603. get b(): NodeMaterialConnectionPoint;
  93604. /**
  93605. * Gets the a output component
  93606. */
  93607. get a(): NodeMaterialConnectionPoint;
  93608. get target(): NodeMaterialBlockTargets;
  93609. autoConfigure(material: NodeMaterial): void;
  93610. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  93611. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  93612. isReady(): boolean;
  93613. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  93614. private get _isMixed();
  93615. private _injectVertexCode;
  93616. private _writeTextureRead;
  93617. private _writeOutput;
  93618. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  93619. protected _dumpPropertiesCode(): string;
  93620. serialize(): any;
  93621. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  93622. }
  93623. }
  93624. declare module BABYLON {
  93625. /** @hidden */
  93626. export var reflectionFunction: {
  93627. name: string;
  93628. shader: string;
  93629. };
  93630. }
  93631. declare module BABYLON {
  93632. /**
  93633. * Base block used to read a reflection texture from a sampler
  93634. */
  93635. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  93636. /** @hidden */
  93637. _define3DName: string;
  93638. /** @hidden */
  93639. _defineCubicName: string;
  93640. /** @hidden */
  93641. _defineExplicitName: string;
  93642. /** @hidden */
  93643. _defineProjectionName: string;
  93644. /** @hidden */
  93645. _defineLocalCubicName: string;
  93646. /** @hidden */
  93647. _defineSphericalName: string;
  93648. /** @hidden */
  93649. _definePlanarName: string;
  93650. /** @hidden */
  93651. _defineEquirectangularName: string;
  93652. /** @hidden */
  93653. _defineMirroredEquirectangularFixedName: string;
  93654. /** @hidden */
  93655. _defineEquirectangularFixedName: string;
  93656. /** @hidden */
  93657. _defineSkyboxName: string;
  93658. /** @hidden */
  93659. _defineOppositeZ: string;
  93660. /** @hidden */
  93661. _cubeSamplerName: string;
  93662. /** @hidden */
  93663. _2DSamplerName: string;
  93664. protected _positionUVWName: string;
  93665. protected _directionWName: string;
  93666. protected _reflectionVectorName: string;
  93667. /** @hidden */
  93668. _reflectionCoordsName: string;
  93669. /** @hidden */
  93670. _reflectionMatrixName: string;
  93671. protected _reflectionColorName: string;
  93672. /**
  93673. * Gets or sets the texture associated with the node
  93674. */
  93675. texture: Nullable<BaseTexture>;
  93676. /**
  93677. * Create a new ReflectionTextureBaseBlock
  93678. * @param name defines the block name
  93679. */
  93680. constructor(name: string);
  93681. /**
  93682. * Gets the current class name
  93683. * @returns the class name
  93684. */
  93685. getClassName(): string;
  93686. /**
  93687. * Gets the world position input component
  93688. */
  93689. abstract get position(): NodeMaterialConnectionPoint;
  93690. /**
  93691. * Gets the world position input component
  93692. */
  93693. abstract get worldPosition(): NodeMaterialConnectionPoint;
  93694. /**
  93695. * Gets the world normal input component
  93696. */
  93697. abstract get worldNormal(): NodeMaterialConnectionPoint;
  93698. /**
  93699. * Gets the world input component
  93700. */
  93701. abstract get world(): NodeMaterialConnectionPoint;
  93702. /**
  93703. * Gets the camera (or eye) position component
  93704. */
  93705. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  93706. /**
  93707. * Gets the view input component
  93708. */
  93709. abstract get view(): NodeMaterialConnectionPoint;
  93710. protected _getTexture(): Nullable<BaseTexture>;
  93711. autoConfigure(material: NodeMaterial): void;
  93712. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  93713. isReady(): boolean;
  93714. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  93715. /**
  93716. * Gets the code to inject in the vertex shader
  93717. * @param state current state of the node material building
  93718. * @returns the shader code
  93719. */
  93720. handleVertexSide(state: NodeMaterialBuildState): string;
  93721. /**
  93722. * Handles the inits for the fragment code path
  93723. * @param state node material build state
  93724. */
  93725. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  93726. /**
  93727. * Generates the reflection coords code for the fragment code path
  93728. * @param worldNormalVarName name of the world normal variable
  93729. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  93730. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  93731. * @returns the shader code
  93732. */
  93733. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  93734. /**
  93735. * Generates the reflection color code for the fragment code path
  93736. * @param lodVarName name of the lod variable
  93737. * @param swizzleLookupTexture swizzle to use for the final color variable
  93738. * @returns the shader code
  93739. */
  93740. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  93741. /**
  93742. * Generates the code corresponding to the connected output points
  93743. * @param state node material build state
  93744. * @param varName name of the variable to output
  93745. * @returns the shader code
  93746. */
  93747. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  93748. protected _buildBlock(state: NodeMaterialBuildState): this;
  93749. protected _dumpPropertiesCode(): string;
  93750. serialize(): any;
  93751. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  93752. }
  93753. }
  93754. declare module BABYLON {
  93755. /**
  93756. * Defines a connection point to be used for points with a custom object type
  93757. */
  93758. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  93759. private _blockType;
  93760. private _blockName;
  93761. private _nameForCheking?;
  93762. /**
  93763. * Creates a new connection point
  93764. * @param name defines the connection point name
  93765. * @param ownerBlock defines the block hosting this connection point
  93766. * @param direction defines the direction of the connection point
  93767. */
  93768. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  93769. /**
  93770. * Gets a number indicating if the current point can be connected to another point
  93771. * @param connectionPoint defines the other connection point
  93772. * @returns a number defining the compatibility state
  93773. */
  93774. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  93775. /**
  93776. * Creates a block suitable to be used as an input for this input point.
  93777. * If null is returned, a block based on the point type will be created.
  93778. * @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
  93779. */
  93780. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  93781. }
  93782. }
  93783. declare module BABYLON {
  93784. /**
  93785. * Enum defining the type of properties that can be edited in the property pages in the NME
  93786. */
  93787. export enum PropertyTypeForEdition {
  93788. /** property is a boolean */
  93789. Boolean = 0,
  93790. /** property is a float */
  93791. Float = 1,
  93792. /** property is a Vector2 */
  93793. Vector2 = 2,
  93794. /** property is a list of values */
  93795. List = 3
  93796. }
  93797. /**
  93798. * Interface that defines an option in a variable of type list
  93799. */
  93800. export interface IEditablePropertyListOption {
  93801. /** label of the option */
  93802. "label": string;
  93803. /** value of the option */
  93804. "value": number;
  93805. }
  93806. /**
  93807. * Interface that defines the options available for an editable property
  93808. */
  93809. export interface IEditablePropertyOption {
  93810. /** min value */
  93811. "min"?: number;
  93812. /** max value */
  93813. "max"?: number;
  93814. /** notifiers: indicates which actions to take when the property is changed */
  93815. "notifiers"?: {
  93816. /** the material should be rebuilt */
  93817. "rebuild"?: boolean;
  93818. /** the preview should be updated */
  93819. "update"?: boolean;
  93820. };
  93821. /** list of the options for a variable of type list */
  93822. "options"?: IEditablePropertyListOption[];
  93823. }
  93824. /**
  93825. * Interface that describes an editable property
  93826. */
  93827. export interface IPropertyDescriptionForEdition {
  93828. /** name of the property */
  93829. "propertyName": string;
  93830. /** display name of the property */
  93831. "displayName": string;
  93832. /** type of the property */
  93833. "type": PropertyTypeForEdition;
  93834. /** group of the property - all properties with the same group value will be displayed in a specific section */
  93835. "groupName": string;
  93836. /** options for the property */
  93837. "options": IEditablePropertyOption;
  93838. }
  93839. /**
  93840. * Decorator that flags a property in a node material block as being editable
  93841. */
  93842. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  93843. }
  93844. declare module BABYLON {
  93845. /**
  93846. * Block used to implement the refraction part of the sub surface module of the PBR material
  93847. */
  93848. export class RefractionBlock extends NodeMaterialBlock {
  93849. /** @hidden */
  93850. _define3DName: string;
  93851. /** @hidden */
  93852. _refractionMatrixName: string;
  93853. /** @hidden */
  93854. _defineLODRefractionAlpha: string;
  93855. /** @hidden */
  93856. _defineLinearSpecularRefraction: string;
  93857. /** @hidden */
  93858. _defineOppositeZ: string;
  93859. /** @hidden */
  93860. _cubeSamplerName: string;
  93861. /** @hidden */
  93862. _2DSamplerName: string;
  93863. /** @hidden */
  93864. _vRefractionMicrosurfaceInfosName: string;
  93865. /** @hidden */
  93866. _vRefractionInfosName: string;
  93867. private _scene;
  93868. /**
  93869. * The properties below are set by the main PBR block prior to calling methods of this class.
  93870. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  93871. * It's less burden on the user side in the editor part.
  93872. */
  93873. /** @hidden */
  93874. viewConnectionPoint: NodeMaterialConnectionPoint;
  93875. /** @hidden */
  93876. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  93877. /**
  93878. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  93879. * Materials half opaque for instance using refraction could benefit from this control.
  93880. */
  93881. linkRefractionWithTransparency: boolean;
  93882. /**
  93883. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  93884. */
  93885. invertRefractionY: boolean;
  93886. /**
  93887. * Gets or sets the texture associated with the node
  93888. */
  93889. texture: Nullable<BaseTexture>;
  93890. /**
  93891. * Create a new RefractionBlock
  93892. * @param name defines the block name
  93893. */
  93894. constructor(name: string);
  93895. /**
  93896. * Gets the current class name
  93897. * @returns the class name
  93898. */
  93899. getClassName(): string;
  93900. /**
  93901. * Gets the intensity input component
  93902. */
  93903. get intensity(): NodeMaterialConnectionPoint;
  93904. /**
  93905. * Gets the tint at distance input component
  93906. */
  93907. get tintAtDistance(): NodeMaterialConnectionPoint;
  93908. /**
  93909. * Gets the view input component
  93910. */
  93911. get view(): NodeMaterialConnectionPoint;
  93912. /**
  93913. * Gets the refraction object output component
  93914. */
  93915. get refraction(): NodeMaterialConnectionPoint;
  93916. /**
  93917. * Returns true if the block has a texture
  93918. */
  93919. get hasTexture(): boolean;
  93920. protected _getTexture(): Nullable<BaseTexture>;
  93921. autoConfigure(material: NodeMaterial): void;
  93922. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  93923. isReady(): boolean;
  93924. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  93925. /**
  93926. * Gets the main code of the block (fragment side)
  93927. * @param state current state of the node material building
  93928. * @returns the shader code
  93929. */
  93930. getCode(state: NodeMaterialBuildState): string;
  93931. protected _buildBlock(state: NodeMaterialBuildState): this;
  93932. protected _dumpPropertiesCode(): string;
  93933. serialize(): any;
  93934. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  93935. }
  93936. }
  93937. declare module BABYLON {
  93938. /**
  93939. * Base block used as input for post process
  93940. */
  93941. export class CurrentScreenBlock extends NodeMaterialBlock {
  93942. private _samplerName;
  93943. private _linearDefineName;
  93944. private _gammaDefineName;
  93945. private _mainUVName;
  93946. private _tempTextureRead;
  93947. /**
  93948. * Gets or sets the texture associated with the node
  93949. */
  93950. texture: Nullable<BaseTexture>;
  93951. /**
  93952. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  93953. */
  93954. convertToGammaSpace: boolean;
  93955. /**
  93956. * Gets or sets a boolean indicating if content needs to be converted to linear space
  93957. */
  93958. convertToLinearSpace: boolean;
  93959. /**
  93960. * Create a new CurrentScreenBlock
  93961. * @param name defines the block name
  93962. */
  93963. constructor(name: string);
  93964. /**
  93965. * Gets the current class name
  93966. * @returns the class name
  93967. */
  93968. getClassName(): string;
  93969. /**
  93970. * Gets the uv input component
  93971. */
  93972. get uv(): NodeMaterialConnectionPoint;
  93973. /**
  93974. * Gets the rgba output component
  93975. */
  93976. get rgba(): NodeMaterialConnectionPoint;
  93977. /**
  93978. * Gets the rgb output component
  93979. */
  93980. get rgb(): NodeMaterialConnectionPoint;
  93981. /**
  93982. * Gets the r output component
  93983. */
  93984. get r(): NodeMaterialConnectionPoint;
  93985. /**
  93986. * Gets the g output component
  93987. */
  93988. get g(): NodeMaterialConnectionPoint;
  93989. /**
  93990. * Gets the b output component
  93991. */
  93992. get b(): NodeMaterialConnectionPoint;
  93993. /**
  93994. * Gets the a output component
  93995. */
  93996. get a(): NodeMaterialConnectionPoint;
  93997. /**
  93998. * Initialize the block and prepare the context for build
  93999. * @param state defines the state that will be used for the build
  94000. */
  94001. initialize(state: NodeMaterialBuildState): void;
  94002. get target(): NodeMaterialBlockTargets;
  94003. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  94004. isReady(): boolean;
  94005. private _injectVertexCode;
  94006. private _writeTextureRead;
  94007. private _writeOutput;
  94008. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  94009. serialize(): any;
  94010. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94011. }
  94012. }
  94013. declare module BABYLON {
  94014. /**
  94015. * Base block used for the particle texture
  94016. */
  94017. export class ParticleTextureBlock extends NodeMaterialBlock {
  94018. private _samplerName;
  94019. private _linearDefineName;
  94020. private _gammaDefineName;
  94021. private _tempTextureRead;
  94022. /**
  94023. * Gets or sets the texture associated with the node
  94024. */
  94025. texture: Nullable<BaseTexture>;
  94026. /**
  94027. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  94028. */
  94029. convertToGammaSpace: boolean;
  94030. /**
  94031. * Gets or sets a boolean indicating if content needs to be converted to linear space
  94032. */
  94033. convertToLinearSpace: boolean;
  94034. /**
  94035. * Create a new ParticleTextureBlock
  94036. * @param name defines the block name
  94037. */
  94038. constructor(name: string);
  94039. /**
  94040. * Gets the current class name
  94041. * @returns the class name
  94042. */
  94043. getClassName(): string;
  94044. /**
  94045. * Gets the uv input component
  94046. */
  94047. get uv(): NodeMaterialConnectionPoint;
  94048. /**
  94049. * Gets the rgba output component
  94050. */
  94051. get rgba(): NodeMaterialConnectionPoint;
  94052. /**
  94053. * Gets the rgb output component
  94054. */
  94055. get rgb(): NodeMaterialConnectionPoint;
  94056. /**
  94057. * Gets the r output component
  94058. */
  94059. get r(): NodeMaterialConnectionPoint;
  94060. /**
  94061. * Gets the g output component
  94062. */
  94063. get g(): NodeMaterialConnectionPoint;
  94064. /**
  94065. * Gets the b output component
  94066. */
  94067. get b(): NodeMaterialConnectionPoint;
  94068. /**
  94069. * Gets the a output component
  94070. */
  94071. get a(): NodeMaterialConnectionPoint;
  94072. /**
  94073. * Initialize the block and prepare the context for build
  94074. * @param state defines the state that will be used for the build
  94075. */
  94076. initialize(state: NodeMaterialBuildState): void;
  94077. autoConfigure(material: NodeMaterial): void;
  94078. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  94079. isReady(): boolean;
  94080. private _writeOutput;
  94081. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  94082. serialize(): any;
  94083. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94084. }
  94085. }
  94086. declare module BABYLON {
  94087. /**
  94088. * Class used to store shared data between 2 NodeMaterialBuildState
  94089. */
  94090. export class NodeMaterialBuildStateSharedData {
  94091. /**
  94092. * Gets the list of emitted varyings
  94093. */
  94094. temps: string[];
  94095. /**
  94096. * Gets the list of emitted varyings
  94097. */
  94098. varyings: string[];
  94099. /**
  94100. * Gets the varying declaration string
  94101. */
  94102. varyingDeclaration: string;
  94103. /**
  94104. * Input blocks
  94105. */
  94106. inputBlocks: InputBlock[];
  94107. /**
  94108. * Input blocks
  94109. */
  94110. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  94111. /**
  94112. * Bindable blocks (Blocks that need to set data to the effect)
  94113. */
  94114. bindableBlocks: NodeMaterialBlock[];
  94115. /**
  94116. * List of blocks that can provide a compilation fallback
  94117. */
  94118. blocksWithFallbacks: NodeMaterialBlock[];
  94119. /**
  94120. * List of blocks that can provide a define update
  94121. */
  94122. blocksWithDefines: NodeMaterialBlock[];
  94123. /**
  94124. * List of blocks that can provide a repeatable content
  94125. */
  94126. repeatableContentBlocks: NodeMaterialBlock[];
  94127. /**
  94128. * List of blocks that can provide a dynamic list of uniforms
  94129. */
  94130. dynamicUniformBlocks: NodeMaterialBlock[];
  94131. /**
  94132. * List of blocks that can block the isReady function for the material
  94133. */
  94134. blockingBlocks: NodeMaterialBlock[];
  94135. /**
  94136. * Gets the list of animated inputs
  94137. */
  94138. animatedInputs: InputBlock[];
  94139. /**
  94140. * Build Id used to avoid multiple recompilations
  94141. */
  94142. buildId: number;
  94143. /** List of emitted variables */
  94144. variableNames: {
  94145. [key: string]: number;
  94146. };
  94147. /** List of emitted defines */
  94148. defineNames: {
  94149. [key: string]: number;
  94150. };
  94151. /** Should emit comments? */
  94152. emitComments: boolean;
  94153. /** Emit build activity */
  94154. verbose: boolean;
  94155. /** Gets or sets the hosting scene */
  94156. scene: Scene;
  94157. /**
  94158. * Gets the compilation hints emitted at compilation time
  94159. */
  94160. hints: {
  94161. needWorldViewMatrix: boolean;
  94162. needWorldViewProjectionMatrix: boolean;
  94163. needAlphaBlending: boolean;
  94164. needAlphaTesting: boolean;
  94165. };
  94166. /**
  94167. * List of compilation checks
  94168. */
  94169. checks: {
  94170. emitVertex: boolean;
  94171. emitFragment: boolean;
  94172. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  94173. };
  94174. /**
  94175. * Is vertex program allowed to be empty?
  94176. */
  94177. allowEmptyVertexProgram: boolean;
  94178. /** Creates a new shared data */
  94179. constructor();
  94180. /**
  94181. * Emits console errors and exceptions if there is a failing check
  94182. */
  94183. emitErrors(): void;
  94184. }
  94185. }
  94186. declare module BABYLON {
  94187. /**
  94188. * Class used to store node based material build state
  94189. */
  94190. export class NodeMaterialBuildState {
  94191. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  94192. supportUniformBuffers: boolean;
  94193. /**
  94194. * Gets the list of emitted attributes
  94195. */
  94196. attributes: string[];
  94197. /**
  94198. * Gets the list of emitted uniforms
  94199. */
  94200. uniforms: string[];
  94201. /**
  94202. * Gets the list of emitted constants
  94203. */
  94204. constants: string[];
  94205. /**
  94206. * Gets the list of emitted samplers
  94207. */
  94208. samplers: string[];
  94209. /**
  94210. * Gets the list of emitted functions
  94211. */
  94212. functions: {
  94213. [key: string]: string;
  94214. };
  94215. /**
  94216. * Gets the list of emitted extensions
  94217. */
  94218. extensions: {
  94219. [key: string]: string;
  94220. };
  94221. /**
  94222. * Gets the target of the compilation state
  94223. */
  94224. target: NodeMaterialBlockTargets;
  94225. /**
  94226. * Gets the list of emitted counters
  94227. */
  94228. counters: {
  94229. [key: string]: number;
  94230. };
  94231. /**
  94232. * Shared data between multiple NodeMaterialBuildState instances
  94233. */
  94234. sharedData: NodeMaterialBuildStateSharedData;
  94235. /** @hidden */
  94236. _vertexState: NodeMaterialBuildState;
  94237. /** @hidden */
  94238. _attributeDeclaration: string;
  94239. /** @hidden */
  94240. _uniformDeclaration: string;
  94241. /** @hidden */
  94242. _constantDeclaration: string;
  94243. /** @hidden */
  94244. _samplerDeclaration: string;
  94245. /** @hidden */
  94246. _varyingTransfer: string;
  94247. /** @hidden */
  94248. _injectAtEnd: string;
  94249. private _repeatableContentAnchorIndex;
  94250. /** @hidden */
  94251. _builtCompilationString: string;
  94252. /**
  94253. * Gets the emitted compilation strings
  94254. */
  94255. compilationString: string;
  94256. /**
  94257. * Finalize the compilation strings
  94258. * @param state defines the current compilation state
  94259. */
  94260. finalize(state: NodeMaterialBuildState): void;
  94261. /** @hidden */
  94262. get _repeatableContentAnchor(): string;
  94263. /** @hidden */
  94264. _getFreeVariableName(prefix: string): string;
  94265. /** @hidden */
  94266. _getFreeDefineName(prefix: string): string;
  94267. /** @hidden */
  94268. _excludeVariableName(name: string): void;
  94269. /** @hidden */
  94270. _emit2DSampler(name: string): void;
  94271. /** @hidden */
  94272. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  94273. /** @hidden */
  94274. _emitExtension(name: string, extension: string, define?: string): void;
  94275. /** @hidden */
  94276. _emitFunction(name: string, code: string, comments: string): void;
  94277. /** @hidden */
  94278. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  94279. replaceStrings?: {
  94280. search: RegExp;
  94281. replace: string;
  94282. }[];
  94283. repeatKey?: string;
  94284. }): string;
  94285. /** @hidden */
  94286. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  94287. repeatKey?: string;
  94288. removeAttributes?: boolean;
  94289. removeUniforms?: boolean;
  94290. removeVaryings?: boolean;
  94291. removeIfDef?: boolean;
  94292. replaceStrings?: {
  94293. search: RegExp;
  94294. replace: string;
  94295. }[];
  94296. }, storeKey?: string): void;
  94297. /** @hidden */
  94298. _registerTempVariable(name: string): boolean;
  94299. /** @hidden */
  94300. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  94301. /** @hidden */
  94302. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  94303. /** @hidden */
  94304. _emitFloat(value: number): string;
  94305. }
  94306. }
  94307. declare module BABYLON {
  94308. /**
  94309. * Helper class used to generate session unique ID
  94310. */
  94311. export class UniqueIdGenerator {
  94312. private static _UniqueIdCounter;
  94313. /**
  94314. * Gets an unique (relatively to the current scene) Id
  94315. */
  94316. static get UniqueId(): number;
  94317. }
  94318. }
  94319. declare module BABYLON {
  94320. /**
  94321. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  94322. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  94323. */
  94324. export class EffectFallbacks implements IEffectFallbacks {
  94325. private _defines;
  94326. private _currentRank;
  94327. private _maxRank;
  94328. private _mesh;
  94329. /**
  94330. * Removes the fallback from the bound mesh.
  94331. */
  94332. unBindMesh(): void;
  94333. /**
  94334. * Adds a fallback on the specified property.
  94335. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94336. * @param define The name of the define in the shader
  94337. */
  94338. addFallback(rank: number, define: string): void;
  94339. /**
  94340. * Sets the mesh to use CPU skinning when needing to fallback.
  94341. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94342. * @param mesh The mesh to use the fallbacks.
  94343. */
  94344. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  94345. /**
  94346. * Checks to see if more fallbacks are still availible.
  94347. */
  94348. get hasMoreFallbacks(): boolean;
  94349. /**
  94350. * Removes the defines that should be removed when falling back.
  94351. * @param currentDefines defines the current define statements for the shader.
  94352. * @param effect defines the current effect we try to compile
  94353. * @returns The resulting defines with defines of the current rank removed.
  94354. */
  94355. reduce(currentDefines: string, effect: Effect): string;
  94356. }
  94357. }
  94358. declare module BABYLON {
  94359. /**
  94360. * Defines a block that can be used inside a node based material
  94361. */
  94362. export class NodeMaterialBlock {
  94363. private _buildId;
  94364. private _buildTarget;
  94365. private _target;
  94366. private _isFinalMerger;
  94367. private _isInput;
  94368. private _name;
  94369. protected _isUnique: boolean;
  94370. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  94371. inputsAreExclusive: boolean;
  94372. /** @hidden */
  94373. _codeVariableName: string;
  94374. /** @hidden */
  94375. _inputs: NodeMaterialConnectionPoint[];
  94376. /** @hidden */
  94377. _outputs: NodeMaterialConnectionPoint[];
  94378. /** @hidden */
  94379. _preparationId: number;
  94380. /**
  94381. * Gets the name of the block
  94382. */
  94383. get name(): string;
  94384. /**
  94385. * Sets the name of the block. Will check if the name is valid.
  94386. */
  94387. set name(newName: string);
  94388. /**
  94389. * Gets or sets the unique id of the node
  94390. */
  94391. uniqueId: number;
  94392. /**
  94393. * Gets or sets the comments associated with this block
  94394. */
  94395. comments: string;
  94396. /**
  94397. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  94398. */
  94399. get isUnique(): boolean;
  94400. /**
  94401. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  94402. */
  94403. get isFinalMerger(): boolean;
  94404. /**
  94405. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  94406. */
  94407. get isInput(): boolean;
  94408. /**
  94409. * Gets or sets the build Id
  94410. */
  94411. get buildId(): number;
  94412. set buildId(value: number);
  94413. /**
  94414. * Gets or sets the target of the block
  94415. */
  94416. get target(): NodeMaterialBlockTargets;
  94417. set target(value: NodeMaterialBlockTargets);
  94418. /**
  94419. * Gets the list of input points
  94420. */
  94421. get inputs(): NodeMaterialConnectionPoint[];
  94422. /** Gets the list of output points */
  94423. get outputs(): NodeMaterialConnectionPoint[];
  94424. /**
  94425. * Find an input by its name
  94426. * @param name defines the name of the input to look for
  94427. * @returns the input or null if not found
  94428. */
  94429. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  94430. /**
  94431. * Find an output by its name
  94432. * @param name defines the name of the outputto look for
  94433. * @returns the output or null if not found
  94434. */
  94435. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  94436. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  94437. visibleInInspector: boolean;
  94438. /**
  94439. * Creates a new NodeMaterialBlock
  94440. * @param name defines the block name
  94441. * @param target defines the target of that block (Vertex by default)
  94442. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  94443. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  94444. */
  94445. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  94446. /**
  94447. * Initialize the block and prepare the context for build
  94448. * @param state defines the state that will be used for the build
  94449. */
  94450. initialize(state: NodeMaterialBuildState): void;
  94451. /**
  94452. * Bind data to effect. Will only be called for blocks with isBindable === true
  94453. * @param effect defines the effect to bind data to
  94454. * @param nodeMaterial defines the hosting NodeMaterial
  94455. * @param mesh defines the mesh that will be rendered
  94456. * @param subMesh defines the submesh that will be rendered
  94457. */
  94458. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  94459. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  94460. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  94461. protected _writeFloat(value: number): string;
  94462. /**
  94463. * Gets the current class name e.g. "NodeMaterialBlock"
  94464. * @returns the class name
  94465. */
  94466. getClassName(): string;
  94467. /**
  94468. * Register a new input. Must be called inside a block constructor
  94469. * @param name defines the connection point name
  94470. * @param type defines the connection point type
  94471. * @param isOptional defines a boolean indicating that this input can be omitted
  94472. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  94473. * @param point an already created connection point. If not provided, create a new one
  94474. * @returns the current block
  94475. */
  94476. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  94477. /**
  94478. * Register a new output. Must be called inside a block constructor
  94479. * @param name defines the connection point name
  94480. * @param type defines the connection point type
  94481. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  94482. * @param point an already created connection point. If not provided, create a new one
  94483. * @returns the current block
  94484. */
  94485. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  94486. /**
  94487. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  94488. * @param forOutput defines an optional connection point to check compatibility with
  94489. * @returns the first available input or null
  94490. */
  94491. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  94492. /**
  94493. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  94494. * @param forBlock defines an optional block to check compatibility with
  94495. * @returns the first available input or null
  94496. */
  94497. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  94498. /**
  94499. * Gets the sibling of the given output
  94500. * @param current defines the current output
  94501. * @returns the next output in the list or null
  94502. */
  94503. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  94504. /**
  94505. * Connect current block with another block
  94506. * @param other defines the block to connect with
  94507. * @param options define the various options to help pick the right connections
  94508. * @returns the current block
  94509. */
  94510. connectTo(other: NodeMaterialBlock, options?: {
  94511. input?: string;
  94512. output?: string;
  94513. outputSwizzle?: string;
  94514. }): this | undefined;
  94515. protected _buildBlock(state: NodeMaterialBuildState): void;
  94516. /**
  94517. * Add uniforms, samplers and uniform buffers at compilation time
  94518. * @param state defines the state to update
  94519. * @param nodeMaterial defines the node material requesting the update
  94520. * @param defines defines the material defines to update
  94521. * @param uniformBuffers defines the list of uniform buffer names
  94522. */
  94523. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  94524. /**
  94525. * Add potential fallbacks if shader compilation fails
  94526. * @param mesh defines the mesh to be rendered
  94527. * @param fallbacks defines the current prioritized list of fallbacks
  94528. */
  94529. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  94530. /**
  94531. * Initialize defines for shader compilation
  94532. * @param mesh defines the mesh to be rendered
  94533. * @param nodeMaterial defines the node material requesting the update
  94534. * @param defines defines the material defines to update
  94535. * @param useInstances specifies that instances should be used
  94536. */
  94537. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  94538. /**
  94539. * Update defines for shader compilation
  94540. * @param mesh defines the mesh to be rendered
  94541. * @param nodeMaterial defines the node material requesting the update
  94542. * @param defines defines the material defines to update
  94543. * @param useInstances specifies that instances should be used
  94544. * @param subMesh defines which submesh to render
  94545. */
  94546. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  94547. /**
  94548. * Lets the block try to connect some inputs automatically
  94549. * @param material defines the hosting NodeMaterial
  94550. */
  94551. autoConfigure(material: NodeMaterial): void;
  94552. /**
  94553. * Function called when a block is declared as repeatable content generator
  94554. * @param vertexShaderState defines the current compilation state for the vertex shader
  94555. * @param fragmentShaderState defines the current compilation state for the fragment shader
  94556. * @param mesh defines the mesh to be rendered
  94557. * @param defines defines the material defines to update
  94558. */
  94559. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  94560. /**
  94561. * Checks if the block is ready
  94562. * @param mesh defines the mesh to be rendered
  94563. * @param nodeMaterial defines the node material requesting the update
  94564. * @param defines defines the material defines to update
  94565. * @param useInstances specifies that instances should be used
  94566. * @returns true if the block is ready
  94567. */
  94568. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  94569. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  94570. private _processBuild;
  94571. /**
  94572. * Validates the new name for the block node.
  94573. * @param newName the new name to be given to the node.
  94574. * @returns false if the name is a reserve word, else true.
  94575. */
  94576. validateBlockName(newName: string): boolean;
  94577. /**
  94578. * Compile the current node and generate the shader code
  94579. * @param state defines the current compilation state (uniforms, samplers, current string)
  94580. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  94581. * @returns true if already built
  94582. */
  94583. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  94584. protected _inputRename(name: string): string;
  94585. protected _outputRename(name: string): string;
  94586. protected _dumpPropertiesCode(): string;
  94587. /** @hidden */
  94588. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  94589. /** @hidden */
  94590. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  94591. /**
  94592. * Clone the current block to a new identical block
  94593. * @param scene defines the hosting scene
  94594. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94595. * @returns a copy of the current block
  94596. */
  94597. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  94598. /**
  94599. * Serializes this block in a JSON representation
  94600. * @returns the serialized block object
  94601. */
  94602. serialize(): any;
  94603. /** @hidden */
  94604. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94605. private _deserializePortDisplayNamesAndExposedOnFrame;
  94606. /**
  94607. * Release resources
  94608. */
  94609. dispose(): void;
  94610. }
  94611. }
  94612. declare module BABYLON {
  94613. /**
  94614. * Base class of materials working in push mode in babylon JS
  94615. * @hidden
  94616. */
  94617. export class PushMaterial extends Material {
  94618. protected _activeEffect: Effect;
  94619. protected _normalMatrix: Matrix;
  94620. constructor(name: string, scene: Scene);
  94621. getEffect(): Effect;
  94622. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94623. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  94624. /**
  94625. * Binds the given world matrix to the active effect
  94626. *
  94627. * @param world the matrix to bind
  94628. */
  94629. bindOnlyWorldMatrix(world: Matrix): void;
  94630. /**
  94631. * Binds the given normal matrix to the active effect
  94632. *
  94633. * @param normalMatrix the matrix to bind
  94634. */
  94635. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  94636. bind(world: Matrix, mesh?: Mesh): void;
  94637. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  94638. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  94639. }
  94640. }
  94641. declare module BABYLON {
  94642. /**
  94643. * Root class for all node material optimizers
  94644. */
  94645. export class NodeMaterialOptimizer {
  94646. /**
  94647. * Function used to optimize a NodeMaterial graph
  94648. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  94649. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  94650. */
  94651. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  94652. }
  94653. }
  94654. declare module BABYLON {
  94655. /**
  94656. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  94657. */
  94658. export class TransformBlock extends NodeMaterialBlock {
  94659. /**
  94660. * Defines the value to use to complement W value to transform it to a Vector4
  94661. */
  94662. complementW: number;
  94663. /**
  94664. * Defines the value to use to complement z value to transform it to a Vector4
  94665. */
  94666. complementZ: number;
  94667. /**
  94668. * Creates a new TransformBlock
  94669. * @param name defines the block name
  94670. */
  94671. constructor(name: string);
  94672. /**
  94673. * Gets the current class name
  94674. * @returns the class name
  94675. */
  94676. getClassName(): string;
  94677. /**
  94678. * Gets the vector input
  94679. */
  94680. get vector(): NodeMaterialConnectionPoint;
  94681. /**
  94682. * Gets the output component
  94683. */
  94684. get output(): NodeMaterialConnectionPoint;
  94685. /**
  94686. * Gets the xyz output component
  94687. */
  94688. get xyz(): NodeMaterialConnectionPoint;
  94689. /**
  94690. * Gets the matrix transform input
  94691. */
  94692. get transform(): NodeMaterialConnectionPoint;
  94693. protected _buildBlock(state: NodeMaterialBuildState): this;
  94694. /**
  94695. * Update defines for shader compilation
  94696. * @param mesh defines the mesh to be rendered
  94697. * @param nodeMaterial defines the node material requesting the update
  94698. * @param defines defines the material defines to update
  94699. * @param useInstances specifies that instances should be used
  94700. * @param subMesh defines which submesh to render
  94701. */
  94702. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  94703. serialize(): any;
  94704. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94705. protected _dumpPropertiesCode(): string;
  94706. }
  94707. }
  94708. declare module BABYLON {
  94709. /**
  94710. * Block used to output the vertex position
  94711. */
  94712. export class VertexOutputBlock extends NodeMaterialBlock {
  94713. /**
  94714. * Creates a new VertexOutputBlock
  94715. * @param name defines the block name
  94716. */
  94717. constructor(name: string);
  94718. /**
  94719. * Gets the current class name
  94720. * @returns the class name
  94721. */
  94722. getClassName(): string;
  94723. /**
  94724. * Gets the vector input component
  94725. */
  94726. get vector(): NodeMaterialConnectionPoint;
  94727. protected _buildBlock(state: NodeMaterialBuildState): this;
  94728. }
  94729. }
  94730. declare module BABYLON {
  94731. /**
  94732. * Block used to output the final color
  94733. */
  94734. export class FragmentOutputBlock extends NodeMaterialBlock {
  94735. /**
  94736. * Create a new FragmentOutputBlock
  94737. * @param name defines the block name
  94738. */
  94739. constructor(name: string);
  94740. /**
  94741. * Gets the current class name
  94742. * @returns the class name
  94743. */
  94744. getClassName(): string;
  94745. /**
  94746. * Gets the rgba input component
  94747. */
  94748. get rgba(): NodeMaterialConnectionPoint;
  94749. /**
  94750. * Gets the rgb input component
  94751. */
  94752. get rgb(): NodeMaterialConnectionPoint;
  94753. /**
  94754. * Gets the a input component
  94755. */
  94756. get a(): NodeMaterialConnectionPoint;
  94757. protected _buildBlock(state: NodeMaterialBuildState): this;
  94758. }
  94759. }
  94760. declare module BABYLON {
  94761. /**
  94762. * Block used for the particle ramp gradient section
  94763. */
  94764. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  94765. /**
  94766. * Create a new ParticleRampGradientBlock
  94767. * @param name defines the block name
  94768. */
  94769. constructor(name: string);
  94770. /**
  94771. * Gets the current class name
  94772. * @returns the class name
  94773. */
  94774. getClassName(): string;
  94775. /**
  94776. * Gets the color input component
  94777. */
  94778. get color(): NodeMaterialConnectionPoint;
  94779. /**
  94780. * Gets the rampColor output component
  94781. */
  94782. get rampColor(): NodeMaterialConnectionPoint;
  94783. /**
  94784. * Initialize the block and prepare the context for build
  94785. * @param state defines the state that will be used for the build
  94786. */
  94787. initialize(state: NodeMaterialBuildState): void;
  94788. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  94789. }
  94790. }
  94791. declare module BABYLON {
  94792. /**
  94793. * Block used for the particle blend multiply section
  94794. */
  94795. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  94796. /**
  94797. * Create a new ParticleBlendMultiplyBlock
  94798. * @param name defines the block name
  94799. */
  94800. constructor(name: string);
  94801. /**
  94802. * Gets the current class name
  94803. * @returns the class name
  94804. */
  94805. getClassName(): string;
  94806. /**
  94807. * Gets the color input component
  94808. */
  94809. get color(): NodeMaterialConnectionPoint;
  94810. /**
  94811. * Gets the alphaTexture input component
  94812. */
  94813. get alphaTexture(): NodeMaterialConnectionPoint;
  94814. /**
  94815. * Gets the alphaColor input component
  94816. */
  94817. get alphaColor(): NodeMaterialConnectionPoint;
  94818. /**
  94819. * Gets the blendColor output component
  94820. */
  94821. get blendColor(): NodeMaterialConnectionPoint;
  94822. /**
  94823. * Initialize the block and prepare the context for build
  94824. * @param state defines the state that will be used for the build
  94825. */
  94826. initialize(state: NodeMaterialBuildState): void;
  94827. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  94828. }
  94829. }
  94830. declare module BABYLON {
  94831. /**
  94832. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  94833. */
  94834. export class VectorMergerBlock extends NodeMaterialBlock {
  94835. /**
  94836. * Create a new VectorMergerBlock
  94837. * @param name defines the block name
  94838. */
  94839. constructor(name: string);
  94840. /**
  94841. * Gets the current class name
  94842. * @returns the class name
  94843. */
  94844. getClassName(): string;
  94845. /**
  94846. * Gets the xyz component (input)
  94847. */
  94848. get xyzIn(): NodeMaterialConnectionPoint;
  94849. /**
  94850. * Gets the xy component (input)
  94851. */
  94852. get xyIn(): NodeMaterialConnectionPoint;
  94853. /**
  94854. * Gets the x component (input)
  94855. */
  94856. get x(): NodeMaterialConnectionPoint;
  94857. /**
  94858. * Gets the y component (input)
  94859. */
  94860. get y(): NodeMaterialConnectionPoint;
  94861. /**
  94862. * Gets the z component (input)
  94863. */
  94864. get z(): NodeMaterialConnectionPoint;
  94865. /**
  94866. * Gets the w component (input)
  94867. */
  94868. get w(): NodeMaterialConnectionPoint;
  94869. /**
  94870. * Gets the xyzw component (output)
  94871. */
  94872. get xyzw(): NodeMaterialConnectionPoint;
  94873. /**
  94874. * Gets the xyz component (output)
  94875. */
  94876. get xyzOut(): NodeMaterialConnectionPoint;
  94877. /**
  94878. * Gets the xy component (output)
  94879. */
  94880. get xyOut(): NodeMaterialConnectionPoint;
  94881. /**
  94882. * Gets the xy component (output)
  94883. * @deprecated Please use xyOut instead.
  94884. */
  94885. get xy(): NodeMaterialConnectionPoint;
  94886. /**
  94887. * Gets the xyz component (output)
  94888. * @deprecated Please use xyzOut instead.
  94889. */
  94890. get xyz(): NodeMaterialConnectionPoint;
  94891. protected _buildBlock(state: NodeMaterialBuildState): this;
  94892. }
  94893. }
  94894. declare module BABYLON {
  94895. /**
  94896. * Block used to remap a float from a range to a new one
  94897. */
  94898. export class RemapBlock extends NodeMaterialBlock {
  94899. /**
  94900. * Gets or sets the source range
  94901. */
  94902. sourceRange: Vector2;
  94903. /**
  94904. * Gets or sets the target range
  94905. */
  94906. targetRange: Vector2;
  94907. /**
  94908. * Creates a new RemapBlock
  94909. * @param name defines the block name
  94910. */
  94911. constructor(name: string);
  94912. /**
  94913. * Gets the current class name
  94914. * @returns the class name
  94915. */
  94916. getClassName(): string;
  94917. /**
  94918. * Gets the input component
  94919. */
  94920. get input(): NodeMaterialConnectionPoint;
  94921. /**
  94922. * Gets the source min input component
  94923. */
  94924. get sourceMin(): NodeMaterialConnectionPoint;
  94925. /**
  94926. * Gets the source max input component
  94927. */
  94928. get sourceMax(): NodeMaterialConnectionPoint;
  94929. /**
  94930. * Gets the target min input component
  94931. */
  94932. get targetMin(): NodeMaterialConnectionPoint;
  94933. /**
  94934. * Gets the target max input component
  94935. */
  94936. get targetMax(): NodeMaterialConnectionPoint;
  94937. /**
  94938. * Gets the output component
  94939. */
  94940. get output(): NodeMaterialConnectionPoint;
  94941. protected _buildBlock(state: NodeMaterialBuildState): this;
  94942. protected _dumpPropertiesCode(): string;
  94943. serialize(): any;
  94944. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94945. }
  94946. }
  94947. declare module BABYLON {
  94948. /**
  94949. * Block used to multiply 2 values
  94950. */
  94951. export class MultiplyBlock extends NodeMaterialBlock {
  94952. /**
  94953. * Creates a new MultiplyBlock
  94954. * @param name defines the block name
  94955. */
  94956. constructor(name: string);
  94957. /**
  94958. * Gets the current class name
  94959. * @returns the class name
  94960. */
  94961. getClassName(): string;
  94962. /**
  94963. * Gets the left operand input component
  94964. */
  94965. get left(): NodeMaterialConnectionPoint;
  94966. /**
  94967. * Gets the right operand input component
  94968. */
  94969. get right(): NodeMaterialConnectionPoint;
  94970. /**
  94971. * Gets the output component
  94972. */
  94973. get output(): NodeMaterialConnectionPoint;
  94974. protected _buildBlock(state: NodeMaterialBuildState): this;
  94975. }
  94976. }
  94977. declare module BABYLON {
  94978. /** Interface used by value gradients (color, factor, ...) */
  94979. export interface IValueGradient {
  94980. /**
  94981. * Gets or sets the gradient value (between 0 and 1)
  94982. */
  94983. gradient: number;
  94984. }
  94985. /** Class used to store color4 gradient */
  94986. export class ColorGradient implements IValueGradient {
  94987. /**
  94988. * Gets or sets the gradient value (between 0 and 1)
  94989. */
  94990. gradient: number;
  94991. /**
  94992. * Gets or sets first associated color
  94993. */
  94994. color1: Color4;
  94995. /**
  94996. * Gets or sets second associated color
  94997. */
  94998. color2?: Color4 | undefined;
  94999. /**
  95000. * Creates a new color4 gradient
  95001. * @param gradient gets or sets the gradient value (between 0 and 1)
  95002. * @param color1 gets or sets first associated color
  95003. * @param color2 gets or sets first second color
  95004. */
  95005. constructor(
  95006. /**
  95007. * Gets or sets the gradient value (between 0 and 1)
  95008. */
  95009. gradient: number,
  95010. /**
  95011. * Gets or sets first associated color
  95012. */
  95013. color1: Color4,
  95014. /**
  95015. * Gets or sets second associated color
  95016. */
  95017. color2?: Color4 | undefined);
  95018. /**
  95019. * Will get a color picked randomly between color1 and color2.
  95020. * If color2 is undefined then color1 will be used
  95021. * @param result defines the target Color4 to store the result in
  95022. */
  95023. getColorToRef(result: Color4): void;
  95024. }
  95025. /** Class used to store color 3 gradient */
  95026. export class Color3Gradient implements IValueGradient {
  95027. /**
  95028. * Gets or sets the gradient value (between 0 and 1)
  95029. */
  95030. gradient: number;
  95031. /**
  95032. * Gets or sets the associated color
  95033. */
  95034. color: Color3;
  95035. /**
  95036. * Creates a new color3 gradient
  95037. * @param gradient gets or sets the gradient value (between 0 and 1)
  95038. * @param color gets or sets associated color
  95039. */
  95040. constructor(
  95041. /**
  95042. * Gets or sets the gradient value (between 0 and 1)
  95043. */
  95044. gradient: number,
  95045. /**
  95046. * Gets or sets the associated color
  95047. */
  95048. color: Color3);
  95049. }
  95050. /** Class used to store factor gradient */
  95051. export class FactorGradient implements IValueGradient {
  95052. /**
  95053. * Gets or sets the gradient value (between 0 and 1)
  95054. */
  95055. gradient: number;
  95056. /**
  95057. * Gets or sets first associated factor
  95058. */
  95059. factor1: number;
  95060. /**
  95061. * Gets or sets second associated factor
  95062. */
  95063. factor2?: number | undefined;
  95064. /**
  95065. * Creates a new factor gradient
  95066. * @param gradient gets or sets the gradient value (between 0 and 1)
  95067. * @param factor1 gets or sets first associated factor
  95068. * @param factor2 gets or sets second associated factor
  95069. */
  95070. constructor(
  95071. /**
  95072. * Gets or sets the gradient value (between 0 and 1)
  95073. */
  95074. gradient: number,
  95075. /**
  95076. * Gets or sets first associated factor
  95077. */
  95078. factor1: number,
  95079. /**
  95080. * Gets or sets second associated factor
  95081. */
  95082. factor2?: number | undefined);
  95083. /**
  95084. * Will get a number picked randomly between factor1 and factor2.
  95085. * If factor2 is undefined then factor1 will be used
  95086. * @returns the picked number
  95087. */
  95088. getFactor(): number;
  95089. }
  95090. /**
  95091. * Helper used to simplify some generic gradient tasks
  95092. */
  95093. export class GradientHelper {
  95094. /**
  95095. * Gets the current gradient from an array of IValueGradient
  95096. * @param ratio defines the current ratio to get
  95097. * @param gradients defines the array of IValueGradient
  95098. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  95099. */
  95100. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  95101. }
  95102. }
  95103. declare module BABYLON {
  95104. interface ThinEngine {
  95105. /**
  95106. * Creates a raw texture
  95107. * @param data defines the data to store in the texture
  95108. * @param width defines the width of the texture
  95109. * @param height defines the height of the texture
  95110. * @param format defines the format of the data
  95111. * @param generateMipMaps defines if the engine should generate the mip levels
  95112. * @param invertY defines if data must be stored with Y axis inverted
  95113. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  95114. * @param compression defines the compression used (null by default)
  95115. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95116. * @returns the raw texture inside an InternalTexture
  95117. */
  95118. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  95119. /**
  95120. * Update a raw texture
  95121. * @param texture defines the texture to update
  95122. * @param data defines the data to store in the texture
  95123. * @param format defines the format of the data
  95124. * @param invertY defines if data must be stored with Y axis inverted
  95125. */
  95126. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  95127. /**
  95128. * Update a raw texture
  95129. * @param texture defines the texture to update
  95130. * @param data defines the data to store in the texture
  95131. * @param format defines the format of the data
  95132. * @param invertY defines if data must be stored with Y axis inverted
  95133. * @param compression defines the compression used (null by default)
  95134. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95135. */
  95136. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  95137. /**
  95138. * Creates a new raw cube texture
  95139. * @param data defines the array of data to use to create each face
  95140. * @param size defines the size of the textures
  95141. * @param format defines the format of the data
  95142. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  95143. * @param generateMipMaps defines if the engine should generate the mip levels
  95144. * @param invertY defines if data must be stored with Y axis inverted
  95145. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  95146. * @param compression defines the compression used (null by default)
  95147. * @returns the cube texture as an InternalTexture
  95148. */
  95149. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  95150. /**
  95151. * Update a raw cube texture
  95152. * @param texture defines the texture to udpdate
  95153. * @param data defines the data to store
  95154. * @param format defines the data format
  95155. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95156. * @param invertY defines if data must be stored with Y axis inverted
  95157. */
  95158. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  95159. /**
  95160. * Update a raw cube texture
  95161. * @param texture defines the texture to udpdate
  95162. * @param data defines the data to store
  95163. * @param format defines the data format
  95164. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95165. * @param invertY defines if data must be stored with Y axis inverted
  95166. * @param compression defines the compression used (null by default)
  95167. */
  95168. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  95169. /**
  95170. * Update a raw cube texture
  95171. * @param texture defines the texture to udpdate
  95172. * @param data defines the data to store
  95173. * @param format defines the data format
  95174. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95175. * @param invertY defines if data must be stored with Y axis inverted
  95176. * @param compression defines the compression used (null by default)
  95177. * @param level defines which level of the texture to update
  95178. */
  95179. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  95180. /**
  95181. * Creates a new raw cube texture from a specified url
  95182. * @param url defines the url where the data is located
  95183. * @param scene defines the current scene
  95184. * @param size defines the size of the textures
  95185. * @param format defines the format of the data
  95186. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  95187. * @param noMipmap defines if the engine should avoid generating the mip levels
  95188. * @param callback defines a callback used to extract texture data from loaded data
  95189. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  95190. * @param onLoad defines a callback called when texture is loaded
  95191. * @param onError defines a callback called if there is an error
  95192. * @returns the cube texture as an InternalTexture
  95193. */
  95194. 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;
  95195. /**
  95196. * Creates a new raw cube texture from a specified url
  95197. * @param url defines the url where the data is located
  95198. * @param scene defines the current scene
  95199. * @param size defines the size of the textures
  95200. * @param format defines the format of the data
  95201. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  95202. * @param noMipmap defines if the engine should avoid generating the mip levels
  95203. * @param callback defines a callback used to extract texture data from loaded data
  95204. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  95205. * @param onLoad defines a callback called when texture is loaded
  95206. * @param onError defines a callback called if there is an error
  95207. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  95208. * @param invertY defines if data must be stored with Y axis inverted
  95209. * @returns the cube texture as an InternalTexture
  95210. */
  95211. 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;
  95212. /**
  95213. * Creates a new raw 3D texture
  95214. * @param data defines the data used to create the texture
  95215. * @param width defines the width of the texture
  95216. * @param height defines the height of the texture
  95217. * @param depth defines the depth of the texture
  95218. * @param format defines the format of the texture
  95219. * @param generateMipMaps defines if the engine must generate mip levels
  95220. * @param invertY defines if data must be stored with Y axis inverted
  95221. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  95222. * @param compression defines the compressed used (can be null)
  95223. * @param textureType defines the compressed used (can be null)
  95224. * @returns a new raw 3D texture (stored in an InternalTexture)
  95225. */
  95226. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  95227. /**
  95228. * Update a raw 3D texture
  95229. * @param texture defines the texture to update
  95230. * @param data defines the data to store
  95231. * @param format defines the data format
  95232. * @param invertY defines if data must be stored with Y axis inverted
  95233. */
  95234. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  95235. /**
  95236. * Update a raw 3D texture
  95237. * @param texture defines the texture to update
  95238. * @param data defines the data to store
  95239. * @param format defines the data format
  95240. * @param invertY defines if data must be stored with Y axis inverted
  95241. * @param compression defines the used compression (can be null)
  95242. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  95243. */
  95244. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  95245. /**
  95246. * Creates a new raw 2D array texture
  95247. * @param data defines the data used to create the texture
  95248. * @param width defines the width of the texture
  95249. * @param height defines the height of the texture
  95250. * @param depth defines the number of layers of the texture
  95251. * @param format defines the format of the texture
  95252. * @param generateMipMaps defines if the engine must generate mip levels
  95253. * @param invertY defines if data must be stored with Y axis inverted
  95254. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  95255. * @param compression defines the compressed used (can be null)
  95256. * @param textureType defines the compressed used (can be null)
  95257. * @returns a new raw 2D array texture (stored in an InternalTexture)
  95258. */
  95259. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  95260. /**
  95261. * Update a raw 2D array texture
  95262. * @param texture defines the texture to update
  95263. * @param data defines the data to store
  95264. * @param format defines the data format
  95265. * @param invertY defines if data must be stored with Y axis inverted
  95266. */
  95267. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  95268. /**
  95269. * Update a raw 2D array texture
  95270. * @param texture defines the texture to update
  95271. * @param data defines the data to store
  95272. * @param format defines the data format
  95273. * @param invertY defines if data must be stored with Y axis inverted
  95274. * @param compression defines the used compression (can be null)
  95275. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  95276. */
  95277. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  95278. }
  95279. }
  95280. declare module BABYLON {
  95281. /**
  95282. * Raw texture can help creating a texture directly from an array of data.
  95283. * This can be super useful if you either get the data from an uncompressed source or
  95284. * if you wish to create your texture pixel by pixel.
  95285. */
  95286. export class RawTexture extends Texture {
  95287. /**
  95288. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  95289. */
  95290. format: number;
  95291. /**
  95292. * Instantiates a new RawTexture.
  95293. * Raw texture can help creating a texture directly from an array of data.
  95294. * This can be super useful if you either get the data from an uncompressed source or
  95295. * if you wish to create your texture pixel by pixel.
  95296. * @param data define the array of data to use to create the texture
  95297. * @param width define the width of the texture
  95298. * @param height define the height of the texture
  95299. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  95300. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95301. * @param generateMipMaps define whether mip maps should be generated or not
  95302. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95303. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95304. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  95305. */
  95306. constructor(data: ArrayBufferView, width: number, height: number,
  95307. /**
  95308. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  95309. */
  95310. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  95311. /**
  95312. * Updates the texture underlying data.
  95313. * @param data Define the new data of the texture
  95314. */
  95315. update(data: ArrayBufferView): void;
  95316. /**
  95317. * Creates a luminance texture from some data.
  95318. * @param data Define the texture data
  95319. * @param width Define the width of the texture
  95320. * @param height Define the height of the texture
  95321. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95322. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95323. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95324. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95325. * @returns the luminance texture
  95326. */
  95327. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  95328. /**
  95329. * Creates a luminance alpha texture from some data.
  95330. * @param data Define the texture data
  95331. * @param width Define the width of the texture
  95332. * @param height Define the height of the texture
  95333. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95334. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95335. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95336. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95337. * @returns the luminance alpha texture
  95338. */
  95339. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  95340. /**
  95341. * Creates an alpha texture from some data.
  95342. * @param data Define the texture data
  95343. * @param width Define the width of the texture
  95344. * @param height Define the height of the texture
  95345. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95346. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95347. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95348. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95349. * @returns the alpha texture
  95350. */
  95351. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  95352. /**
  95353. * Creates a RGB texture from some data.
  95354. * @param data Define the texture data
  95355. * @param width Define the width of the texture
  95356. * @param height Define the height of the texture
  95357. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95358. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95359. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95360. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95361. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  95362. * @returns the RGB alpha texture
  95363. */
  95364. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  95365. /**
  95366. * Creates a RGBA texture from some data.
  95367. * @param data Define the texture data
  95368. * @param width Define the width of the texture
  95369. * @param height Define the height of the texture
  95370. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95371. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95372. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95373. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95374. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  95375. * @returns the RGBA texture
  95376. */
  95377. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  95378. /**
  95379. * Creates a R texture from some data.
  95380. * @param data Define the texture data
  95381. * @param width Define the width of the texture
  95382. * @param height Define the height of the texture
  95383. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95384. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95385. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95386. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95387. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  95388. * @returns the R texture
  95389. */
  95390. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  95391. }
  95392. }
  95393. declare module BABYLON {
  95394. interface ThinEngine {
  95395. /**
  95396. * Update a dynamic index buffer
  95397. * @param indexBuffer defines the target index buffer
  95398. * @param indices defines the data to update
  95399. * @param offset defines the offset in the target index buffer where update should start
  95400. */
  95401. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  95402. /**
  95403. * Updates a dynamic vertex buffer.
  95404. * @param vertexBuffer the vertex buffer to update
  95405. * @param data the data used to update the vertex buffer
  95406. * @param byteOffset the byte offset of the data
  95407. * @param byteLength the byte length of the data
  95408. */
  95409. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  95410. }
  95411. }
  95412. declare module BABYLON {
  95413. interface AbstractScene {
  95414. /**
  95415. * The list of procedural textures added to the scene
  95416. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  95417. */
  95418. proceduralTextures: Array<ProceduralTexture>;
  95419. }
  95420. /**
  95421. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  95422. * in a given scene.
  95423. */
  95424. export class ProceduralTextureSceneComponent implements ISceneComponent {
  95425. /**
  95426. * The component name helpfull to identify the component in the list of scene components.
  95427. */
  95428. readonly name: string;
  95429. /**
  95430. * The scene the component belongs to.
  95431. */
  95432. scene: Scene;
  95433. /**
  95434. * Creates a new instance of the component for the given scene
  95435. * @param scene Defines the scene to register the component in
  95436. */
  95437. constructor(scene: Scene);
  95438. /**
  95439. * Registers the component in a given scene
  95440. */
  95441. register(): void;
  95442. /**
  95443. * Rebuilds the elements related to this component in case of
  95444. * context lost for instance.
  95445. */
  95446. rebuild(): void;
  95447. /**
  95448. * Disposes the component and the associated ressources.
  95449. */
  95450. dispose(): void;
  95451. private _beforeClear;
  95452. }
  95453. }
  95454. declare module BABYLON {
  95455. interface ThinEngine {
  95456. /**
  95457. * Creates a new render target cube texture
  95458. * @param size defines the size of the texture
  95459. * @param options defines the options used to create the texture
  95460. * @returns a new render target cube texture stored in an InternalTexture
  95461. */
  95462. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  95463. }
  95464. }
  95465. declare module BABYLON {
  95466. /** @hidden */
  95467. export var proceduralVertexShader: {
  95468. name: string;
  95469. shader: string;
  95470. };
  95471. }
  95472. declare module BABYLON {
  95473. /**
  95474. * 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.
  95475. * This is the base class of any Procedural texture and contains most of the shareable code.
  95476. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  95477. */
  95478. export class ProceduralTexture extends Texture {
  95479. /**
  95480. * Define if the texture is enabled or not (disabled texture will not render)
  95481. */
  95482. isEnabled: boolean;
  95483. /**
  95484. * Define if the texture must be cleared before rendering (default is true)
  95485. */
  95486. autoClear: boolean;
  95487. /**
  95488. * Callback called when the texture is generated
  95489. */
  95490. onGenerated: () => void;
  95491. /**
  95492. * Event raised when the texture is generated
  95493. */
  95494. onGeneratedObservable: Observable<ProceduralTexture>;
  95495. /**
  95496. * Event raised before the texture is generated
  95497. */
  95498. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  95499. /**
  95500. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  95501. */
  95502. nodeMaterialSource: Nullable<NodeMaterial>;
  95503. /** @hidden */
  95504. _generateMipMaps: boolean;
  95505. /** @hidden **/
  95506. _effect: Effect;
  95507. /** @hidden */
  95508. _textures: {
  95509. [key: string]: Texture;
  95510. };
  95511. /** @hidden */
  95512. protected _fallbackTexture: Nullable<Texture>;
  95513. private _size;
  95514. private _currentRefreshId;
  95515. private _frameId;
  95516. private _refreshRate;
  95517. private _vertexBuffers;
  95518. private _indexBuffer;
  95519. private _uniforms;
  95520. private _samplers;
  95521. private _fragment;
  95522. private _floats;
  95523. private _ints;
  95524. private _floatsArrays;
  95525. private _colors3;
  95526. private _colors4;
  95527. private _vectors2;
  95528. private _vectors3;
  95529. private _matrices;
  95530. private _fallbackTextureUsed;
  95531. private _fullEngine;
  95532. private _cachedDefines;
  95533. private _contentUpdateId;
  95534. private _contentData;
  95535. /**
  95536. * Instantiates a new procedural texture.
  95537. * 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.
  95538. * This is the base class of any Procedural texture and contains most of the shareable code.
  95539. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  95540. * @param name Define the name of the texture
  95541. * @param size Define the size of the texture to create
  95542. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  95543. * @param scene Define the scene the texture belongs to
  95544. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  95545. * @param generateMipMaps Define if the texture should creates mip maps or not
  95546. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  95547. * @param textureType The FBO internal texture type
  95548. */
  95549. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  95550. /**
  95551. * The effect that is created when initializing the post process.
  95552. * @returns The created effect corresponding the the postprocess.
  95553. */
  95554. getEffect(): Effect;
  95555. /**
  95556. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  95557. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  95558. */
  95559. getContent(): Nullable<ArrayBufferView>;
  95560. private _createIndexBuffer;
  95561. /** @hidden */
  95562. _rebuild(): void;
  95563. /**
  95564. * Resets the texture in order to recreate its associated resources.
  95565. * This can be called in case of context loss
  95566. */
  95567. reset(): void;
  95568. protected _getDefines(): string;
  95569. /**
  95570. * Is the texture ready to be used ? (rendered at least once)
  95571. * @returns true if ready, otherwise, false.
  95572. */
  95573. isReady(): boolean;
  95574. /**
  95575. * Resets the refresh counter of the texture and start bak from scratch.
  95576. * Could be useful to regenerate the texture if it is setup to render only once.
  95577. */
  95578. resetRefreshCounter(): void;
  95579. /**
  95580. * Set the fragment shader to use in order to render the texture.
  95581. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  95582. */
  95583. setFragment(fragment: any): void;
  95584. /**
  95585. * Define the refresh rate of the texture or the rendering frequency.
  95586. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  95587. */
  95588. get refreshRate(): number;
  95589. set refreshRate(value: number);
  95590. /** @hidden */
  95591. _shouldRender(): boolean;
  95592. /**
  95593. * Get the size the texture is rendering at.
  95594. * @returns the size (on cube texture it is always squared)
  95595. */
  95596. getRenderSize(): RenderTargetTextureSize;
  95597. /**
  95598. * Resize the texture to new value.
  95599. * @param size Define the new size the texture should have
  95600. * @param generateMipMaps Define whether the new texture should create mip maps
  95601. */
  95602. resize(size: number, generateMipMaps: boolean): void;
  95603. private _checkUniform;
  95604. /**
  95605. * Set a texture in the shader program used to render.
  95606. * @param name Define the name of the uniform samplers as defined in the shader
  95607. * @param texture Define the texture to bind to this sampler
  95608. * @return the texture itself allowing "fluent" like uniform updates
  95609. */
  95610. setTexture(name: string, texture: Texture): ProceduralTexture;
  95611. /**
  95612. * Set a float in the shader.
  95613. * @param name Define the name of the uniform as defined in the shader
  95614. * @param value Define the value to give to the uniform
  95615. * @return the texture itself allowing "fluent" like uniform updates
  95616. */
  95617. setFloat(name: string, value: number): ProceduralTexture;
  95618. /**
  95619. * Set a int in the shader.
  95620. * @param name Define the name of the uniform as defined in the shader
  95621. * @param value Define the value to give to the uniform
  95622. * @return the texture itself allowing "fluent" like uniform updates
  95623. */
  95624. setInt(name: string, value: number): ProceduralTexture;
  95625. /**
  95626. * Set an array of floats in the shader.
  95627. * @param name Define the name of the uniform as defined in the shader
  95628. * @param value Define the value to give to the uniform
  95629. * @return the texture itself allowing "fluent" like uniform updates
  95630. */
  95631. setFloats(name: string, value: number[]): ProceduralTexture;
  95632. /**
  95633. * Set a vec3 in the shader from a Color3.
  95634. * @param name Define the name of the uniform as defined in the shader
  95635. * @param value Define the value to give to the uniform
  95636. * @return the texture itself allowing "fluent" like uniform updates
  95637. */
  95638. setColor3(name: string, value: Color3): ProceduralTexture;
  95639. /**
  95640. * Set a vec4 in the shader from a Color4.
  95641. * @param name Define the name of the uniform as defined in the shader
  95642. * @param value Define the value to give to the uniform
  95643. * @return the texture itself allowing "fluent" like uniform updates
  95644. */
  95645. setColor4(name: string, value: Color4): ProceduralTexture;
  95646. /**
  95647. * Set a vec2 in the shader from a Vector2.
  95648. * @param name Define the name of the uniform as defined in the shader
  95649. * @param value Define the value to give to the uniform
  95650. * @return the texture itself allowing "fluent" like uniform updates
  95651. */
  95652. setVector2(name: string, value: Vector2): ProceduralTexture;
  95653. /**
  95654. * Set a vec3 in the shader from a Vector3.
  95655. * @param name Define the name of the uniform as defined in the shader
  95656. * @param value Define the value to give to the uniform
  95657. * @return the texture itself allowing "fluent" like uniform updates
  95658. */
  95659. setVector3(name: string, value: Vector3): ProceduralTexture;
  95660. /**
  95661. * Set a mat4 in the shader from a MAtrix.
  95662. * @param name Define the name of the uniform as defined in the shader
  95663. * @param value Define the value to give to the uniform
  95664. * @return the texture itself allowing "fluent" like uniform updates
  95665. */
  95666. setMatrix(name: string, value: Matrix): ProceduralTexture;
  95667. /**
  95668. * Render the texture to its associated render target.
  95669. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  95670. */
  95671. render(useCameraPostProcess?: boolean): void;
  95672. /**
  95673. * Clone the texture.
  95674. * @returns the cloned texture
  95675. */
  95676. clone(): ProceduralTexture;
  95677. /**
  95678. * Dispose the texture and release its asoociated resources.
  95679. */
  95680. dispose(): void;
  95681. }
  95682. }
  95683. declare module BABYLON {
  95684. /**
  95685. * This represents the base class for particle system in Babylon.
  95686. * 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.
  95687. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  95688. * @example https://doc.babylonjs.com/babylon101/particles
  95689. */
  95690. export class BaseParticleSystem {
  95691. /**
  95692. * Source color is added to the destination color without alpha affecting the result
  95693. */
  95694. static BLENDMODE_ONEONE: number;
  95695. /**
  95696. * Blend current color and particle color using particle’s alpha
  95697. */
  95698. static BLENDMODE_STANDARD: number;
  95699. /**
  95700. * Add current color and particle color multiplied by particle’s alpha
  95701. */
  95702. static BLENDMODE_ADD: number;
  95703. /**
  95704. * Multiply current color with particle color
  95705. */
  95706. static BLENDMODE_MULTIPLY: number;
  95707. /**
  95708. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  95709. */
  95710. static BLENDMODE_MULTIPLYADD: number;
  95711. /**
  95712. * List of animations used by the particle system.
  95713. */
  95714. animations: Animation[];
  95715. /**
  95716. * Gets or sets the unique id of the particle system
  95717. */
  95718. uniqueId: number;
  95719. /**
  95720. * The id of the Particle system.
  95721. */
  95722. id: string;
  95723. /**
  95724. * The friendly name of the Particle system.
  95725. */
  95726. name: string;
  95727. /**
  95728. * Snippet ID if the particle system was created from the snippet server
  95729. */
  95730. snippetId: string;
  95731. /**
  95732. * The rendering group used by the Particle system to chose when to render.
  95733. */
  95734. renderingGroupId: number;
  95735. /**
  95736. * The emitter represents the Mesh or position we are attaching the particle system to.
  95737. */
  95738. emitter: Nullable<AbstractMesh | Vector3>;
  95739. /**
  95740. * The maximum number of particles to emit per frame
  95741. */
  95742. emitRate: number;
  95743. /**
  95744. * If you want to launch only a few particles at once, that can be done, as well.
  95745. */
  95746. manualEmitCount: number;
  95747. /**
  95748. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  95749. */
  95750. updateSpeed: number;
  95751. /**
  95752. * The amount of time the particle system is running (depends of the overall update speed).
  95753. */
  95754. targetStopDuration: number;
  95755. /**
  95756. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  95757. */
  95758. disposeOnStop: boolean;
  95759. /**
  95760. * Minimum power of emitting particles.
  95761. */
  95762. minEmitPower: number;
  95763. /**
  95764. * Maximum power of emitting particles.
  95765. */
  95766. maxEmitPower: number;
  95767. /**
  95768. * Minimum life time of emitting particles.
  95769. */
  95770. minLifeTime: number;
  95771. /**
  95772. * Maximum life time of emitting particles.
  95773. */
  95774. maxLifeTime: number;
  95775. /**
  95776. * Minimum Size of emitting particles.
  95777. */
  95778. minSize: number;
  95779. /**
  95780. * Maximum Size of emitting particles.
  95781. */
  95782. maxSize: number;
  95783. /**
  95784. * Minimum scale of emitting particles on X axis.
  95785. */
  95786. minScaleX: number;
  95787. /**
  95788. * Maximum scale of emitting particles on X axis.
  95789. */
  95790. maxScaleX: number;
  95791. /**
  95792. * Minimum scale of emitting particles on Y axis.
  95793. */
  95794. minScaleY: number;
  95795. /**
  95796. * Maximum scale of emitting particles on Y axis.
  95797. */
  95798. maxScaleY: number;
  95799. /**
  95800. * Gets or sets the minimal initial rotation in radians.
  95801. */
  95802. minInitialRotation: number;
  95803. /**
  95804. * Gets or sets the maximal initial rotation in radians.
  95805. */
  95806. maxInitialRotation: number;
  95807. /**
  95808. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  95809. */
  95810. minAngularSpeed: number;
  95811. /**
  95812. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  95813. */
  95814. maxAngularSpeed: number;
  95815. /**
  95816. * The texture used to render each particle. (this can be a spritesheet)
  95817. */
  95818. particleTexture: Nullable<BaseTexture>;
  95819. /**
  95820. * The layer mask we are rendering the particles through.
  95821. */
  95822. layerMask: number;
  95823. /**
  95824. * This can help using your own shader to render the particle system.
  95825. * The according effect will be created
  95826. */
  95827. customShader: any;
  95828. /**
  95829. * By default particle system starts as soon as they are created. This prevents the
  95830. * automatic start to happen and let you decide when to start emitting particles.
  95831. */
  95832. preventAutoStart: boolean;
  95833. private _noiseTexture;
  95834. /**
  95835. * Gets or sets a texture used to add random noise to particle positions
  95836. */
  95837. get noiseTexture(): Nullable<ProceduralTexture>;
  95838. set noiseTexture(value: Nullable<ProceduralTexture>);
  95839. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  95840. noiseStrength: Vector3;
  95841. /**
  95842. * Callback triggered when the particle animation is ending.
  95843. */
  95844. onAnimationEnd: Nullable<() => void>;
  95845. /**
  95846. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  95847. */
  95848. blendMode: number;
  95849. /**
  95850. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  95851. * to override the particles.
  95852. */
  95853. forceDepthWrite: boolean;
  95854. /** 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 */
  95855. preWarmCycles: number;
  95856. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  95857. preWarmStepOffset: number;
  95858. /**
  95859. * 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)
  95860. */
  95861. spriteCellChangeSpeed: number;
  95862. /**
  95863. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  95864. */
  95865. startSpriteCellID: number;
  95866. /**
  95867. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  95868. */
  95869. endSpriteCellID: number;
  95870. /**
  95871. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  95872. */
  95873. spriteCellWidth: number;
  95874. /**
  95875. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  95876. */
  95877. spriteCellHeight: number;
  95878. /**
  95879. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  95880. */
  95881. spriteRandomStartCell: boolean;
  95882. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  95883. translationPivot: Vector2;
  95884. /** @hidden */
  95885. protected _isAnimationSheetEnabled: boolean;
  95886. /**
  95887. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  95888. */
  95889. beginAnimationOnStart: boolean;
  95890. /**
  95891. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  95892. */
  95893. beginAnimationFrom: number;
  95894. /**
  95895. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  95896. */
  95897. beginAnimationTo: number;
  95898. /**
  95899. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  95900. */
  95901. beginAnimationLoop: boolean;
  95902. /**
  95903. * Gets or sets a world offset applied to all particles
  95904. */
  95905. worldOffset: Vector3;
  95906. /**
  95907. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  95908. */
  95909. get isAnimationSheetEnabled(): boolean;
  95910. set isAnimationSheetEnabled(value: boolean);
  95911. /**
  95912. * Get hosting scene
  95913. * @returns the scene
  95914. */
  95915. getScene(): Nullable<Scene>;
  95916. /**
  95917. * You can use gravity if you want to give an orientation to your particles.
  95918. */
  95919. gravity: Vector3;
  95920. protected _colorGradients: Nullable<Array<ColorGradient>>;
  95921. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  95922. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  95923. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  95924. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  95925. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  95926. protected _dragGradients: Nullable<Array<FactorGradient>>;
  95927. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  95928. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  95929. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  95930. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  95931. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  95932. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  95933. /**
  95934. * Defines the delay in milliseconds before starting the system (0 by default)
  95935. */
  95936. startDelay: number;
  95937. /**
  95938. * Gets the current list of drag gradients.
  95939. * You must use addDragGradient and removeDragGradient to udpate this list
  95940. * @returns the list of drag gradients
  95941. */
  95942. getDragGradients(): Nullable<Array<FactorGradient>>;
  95943. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  95944. limitVelocityDamping: number;
  95945. /**
  95946. * Gets the current list of limit velocity gradients.
  95947. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  95948. * @returns the list of limit velocity gradients
  95949. */
  95950. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  95951. /**
  95952. * Gets the current list of color gradients.
  95953. * You must use addColorGradient and removeColorGradient to udpate this list
  95954. * @returns the list of color gradients
  95955. */
  95956. getColorGradients(): Nullable<Array<ColorGradient>>;
  95957. /**
  95958. * Gets the current list of size gradients.
  95959. * You must use addSizeGradient and removeSizeGradient to udpate this list
  95960. * @returns the list of size gradients
  95961. */
  95962. getSizeGradients(): Nullable<Array<FactorGradient>>;
  95963. /**
  95964. * Gets the current list of color remap gradients.
  95965. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  95966. * @returns the list of color remap gradients
  95967. */
  95968. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  95969. /**
  95970. * Gets the current list of alpha remap gradients.
  95971. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  95972. * @returns the list of alpha remap gradients
  95973. */
  95974. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  95975. /**
  95976. * Gets the current list of life time gradients.
  95977. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  95978. * @returns the list of life time gradients
  95979. */
  95980. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  95981. /**
  95982. * Gets the current list of angular speed gradients.
  95983. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  95984. * @returns the list of angular speed gradients
  95985. */
  95986. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  95987. /**
  95988. * Gets the current list of velocity gradients.
  95989. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  95990. * @returns the list of velocity gradients
  95991. */
  95992. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  95993. /**
  95994. * Gets the current list of start size gradients.
  95995. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  95996. * @returns the list of start size gradients
  95997. */
  95998. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  95999. /**
  96000. * Gets the current list of emit rate gradients.
  96001. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  96002. * @returns the list of emit rate gradients
  96003. */
  96004. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  96005. /**
  96006. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  96007. * This only works when particleEmitterTyps is a BoxParticleEmitter
  96008. */
  96009. get direction1(): Vector3;
  96010. set direction1(value: Vector3);
  96011. /**
  96012. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  96013. * This only works when particleEmitterTyps is a BoxParticleEmitter
  96014. */
  96015. get direction2(): Vector3;
  96016. set direction2(value: Vector3);
  96017. /**
  96018. * 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.
  96019. * This only works when particleEmitterTyps is a BoxParticleEmitter
  96020. */
  96021. get minEmitBox(): Vector3;
  96022. set minEmitBox(value: Vector3);
  96023. /**
  96024. * 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.
  96025. * This only works when particleEmitterTyps is a BoxParticleEmitter
  96026. */
  96027. get maxEmitBox(): Vector3;
  96028. set maxEmitBox(value: Vector3);
  96029. /**
  96030. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  96031. */
  96032. color1: Color4;
  96033. /**
  96034. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  96035. */
  96036. color2: Color4;
  96037. /**
  96038. * Color the particle will have at the end of its lifetime
  96039. */
  96040. colorDead: Color4;
  96041. /**
  96042. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  96043. */
  96044. textureMask: Color4;
  96045. /**
  96046. * The particle emitter type defines the emitter used by the particle system.
  96047. * It can be for example box, sphere, or cone...
  96048. */
  96049. particleEmitterType: IParticleEmitterType;
  96050. /** @hidden */
  96051. _isSubEmitter: boolean;
  96052. /**
  96053. * Gets or sets the billboard mode to use when isBillboardBased = true.
  96054. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  96055. */
  96056. billboardMode: number;
  96057. protected _isBillboardBased: boolean;
  96058. /**
  96059. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  96060. */
  96061. get isBillboardBased(): boolean;
  96062. set isBillboardBased(value: boolean);
  96063. /**
  96064. * The scene the particle system belongs to.
  96065. */
  96066. protected _scene: Nullable<Scene>;
  96067. /**
  96068. * The engine the particle system belongs to.
  96069. */
  96070. protected _engine: ThinEngine;
  96071. /**
  96072. * Local cache of defines for image processing.
  96073. */
  96074. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  96075. /**
  96076. * Default configuration related to image processing available in the standard Material.
  96077. */
  96078. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  96079. /**
  96080. * Gets the image processing configuration used either in this material.
  96081. */
  96082. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  96083. /**
  96084. * Sets the Default image processing configuration used either in the this material.
  96085. *
  96086. * If sets to null, the scene one is in use.
  96087. */
  96088. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  96089. /**
  96090. * Attaches a new image processing configuration to the Standard Material.
  96091. * @param configuration
  96092. */
  96093. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  96094. /** @hidden */
  96095. protected _reset(): void;
  96096. /** @hidden */
  96097. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  96098. /**
  96099. * Instantiates a particle system.
  96100. * 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.
  96101. * @param name The name of the particle system
  96102. */
  96103. constructor(name: string);
  96104. /**
  96105. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  96106. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  96107. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  96108. * @returns the emitter
  96109. */
  96110. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  96111. /**
  96112. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  96113. * @param radius The radius of the hemisphere to emit from
  96114. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  96115. * @returns the emitter
  96116. */
  96117. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  96118. /**
  96119. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  96120. * @param radius The radius of the sphere to emit from
  96121. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  96122. * @returns the emitter
  96123. */
  96124. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  96125. /**
  96126. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  96127. * @param radius The radius of the sphere to emit from
  96128. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  96129. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  96130. * @returns the emitter
  96131. */
  96132. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  96133. /**
  96134. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  96135. * @param radius The radius of the emission cylinder
  96136. * @param height The height of the emission cylinder
  96137. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  96138. * @param directionRandomizer How much to randomize the particle direction [0-1]
  96139. * @returns the emitter
  96140. */
  96141. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  96142. /**
  96143. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  96144. * @param radius The radius of the cylinder to emit from
  96145. * @param height The height of the emission cylinder
  96146. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  96147. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  96148. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  96149. * @returns the emitter
  96150. */
  96151. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  96152. /**
  96153. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  96154. * @param radius The radius of the cone to emit from
  96155. * @param angle The base angle of the cone
  96156. * @returns the emitter
  96157. */
  96158. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  96159. /**
  96160. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  96161. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  96162. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  96163. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  96164. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  96165. * @returns the emitter
  96166. */
  96167. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  96168. }
  96169. }
  96170. declare module BABYLON {
  96171. /**
  96172. * Type of sub emitter
  96173. */
  96174. export enum SubEmitterType {
  96175. /**
  96176. * Attached to the particle over it's lifetime
  96177. */
  96178. ATTACHED = 0,
  96179. /**
  96180. * Created when the particle dies
  96181. */
  96182. END = 1
  96183. }
  96184. /**
  96185. * Sub emitter class used to emit particles from an existing particle
  96186. */
  96187. export class SubEmitter {
  96188. /**
  96189. * the particle system to be used by the sub emitter
  96190. */
  96191. particleSystem: ParticleSystem;
  96192. /**
  96193. * Type of the submitter (Default: END)
  96194. */
  96195. type: SubEmitterType;
  96196. /**
  96197. * 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)
  96198. * Note: This only is supported when using an emitter of type Mesh
  96199. */
  96200. inheritDirection: boolean;
  96201. /**
  96202. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  96203. */
  96204. inheritedVelocityAmount: number;
  96205. /**
  96206. * Creates a sub emitter
  96207. * @param particleSystem the particle system to be used by the sub emitter
  96208. */
  96209. constructor(
  96210. /**
  96211. * the particle system to be used by the sub emitter
  96212. */
  96213. particleSystem: ParticleSystem);
  96214. /**
  96215. * Clones the sub emitter
  96216. * @returns the cloned sub emitter
  96217. */
  96218. clone(): SubEmitter;
  96219. /**
  96220. * Serialize current object to a JSON object
  96221. * @returns the serialized object
  96222. */
  96223. serialize(): any;
  96224. /** @hidden */
  96225. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  96226. /**
  96227. * Creates a new SubEmitter from a serialized JSON version
  96228. * @param serializationObject defines the JSON object to read from
  96229. * @param sceneOrEngine defines the hosting scene or the hosting engine
  96230. * @param rootUrl defines the rootUrl for data loading
  96231. * @returns a new SubEmitter
  96232. */
  96233. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  96234. /** Release associated resources */
  96235. dispose(): void;
  96236. }
  96237. }
  96238. declare module BABYLON {
  96239. /** @hidden */
  96240. export var clipPlaneFragmentDeclaration: {
  96241. name: string;
  96242. shader: string;
  96243. };
  96244. }
  96245. declare module BABYLON {
  96246. /** @hidden */
  96247. export var imageProcessingDeclaration: {
  96248. name: string;
  96249. shader: string;
  96250. };
  96251. }
  96252. declare module BABYLON {
  96253. /** @hidden */
  96254. export var imageProcessingFunctions: {
  96255. name: string;
  96256. shader: string;
  96257. };
  96258. }
  96259. declare module BABYLON {
  96260. /** @hidden */
  96261. export var clipPlaneFragment: {
  96262. name: string;
  96263. shader: string;
  96264. };
  96265. }
  96266. declare module BABYLON {
  96267. /** @hidden */
  96268. export var particlesPixelShader: {
  96269. name: string;
  96270. shader: string;
  96271. };
  96272. }
  96273. declare module BABYLON {
  96274. /** @hidden */
  96275. export var clipPlaneVertexDeclaration: {
  96276. name: string;
  96277. shader: string;
  96278. };
  96279. }
  96280. declare module BABYLON {
  96281. /** @hidden */
  96282. export var clipPlaneVertex: {
  96283. name: string;
  96284. shader: string;
  96285. };
  96286. }
  96287. declare module BABYLON {
  96288. /** @hidden */
  96289. export var particlesVertexShader: {
  96290. name: string;
  96291. shader: string;
  96292. };
  96293. }
  96294. declare module BABYLON {
  96295. /**
  96296. * Interface used to define entities containing multiple clip planes
  96297. */
  96298. export interface IClipPlanesHolder {
  96299. /**
  96300. * Gets or sets the active clipplane 1
  96301. */
  96302. clipPlane: Nullable<Plane>;
  96303. /**
  96304. * Gets or sets the active clipplane 2
  96305. */
  96306. clipPlane2: Nullable<Plane>;
  96307. /**
  96308. * Gets or sets the active clipplane 3
  96309. */
  96310. clipPlane3: Nullable<Plane>;
  96311. /**
  96312. * Gets or sets the active clipplane 4
  96313. */
  96314. clipPlane4: Nullable<Plane>;
  96315. /**
  96316. * Gets or sets the active clipplane 5
  96317. */
  96318. clipPlane5: Nullable<Plane>;
  96319. /**
  96320. * Gets or sets the active clipplane 6
  96321. */
  96322. clipPlane6: Nullable<Plane>;
  96323. }
  96324. }
  96325. declare module BABYLON {
  96326. /**
  96327. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  96328. *
  96329. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  96330. *
  96331. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  96332. */
  96333. export class ThinMaterialHelper {
  96334. /**
  96335. * Binds the clip plane information from the holder to the effect.
  96336. * @param effect The effect we are binding the data to
  96337. * @param holder The entity containing the clip plane information
  96338. */
  96339. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  96340. }
  96341. }
  96342. declare module BABYLON {
  96343. interface ThinEngine {
  96344. /**
  96345. * Sets alpha constants used by some alpha blending modes
  96346. * @param r defines the red component
  96347. * @param g defines the green component
  96348. * @param b defines the blue component
  96349. * @param a defines the alpha component
  96350. */
  96351. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  96352. /**
  96353. * Sets the current alpha mode
  96354. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  96355. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  96356. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96357. */
  96358. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  96359. /**
  96360. * Gets the current alpha mode
  96361. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96362. * @returns the current alpha mode
  96363. */
  96364. getAlphaMode(): number;
  96365. /**
  96366. * Sets the current alpha equation
  96367. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  96368. */
  96369. setAlphaEquation(equation: number): void;
  96370. /**
  96371. * Gets the current alpha equation.
  96372. * @returns the current alpha equation
  96373. */
  96374. getAlphaEquation(): number;
  96375. }
  96376. }
  96377. declare module BABYLON {
  96378. /**
  96379. * This represents a particle system in Babylon.
  96380. * 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.
  96381. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  96382. * @example https://doc.babylonjs.com/babylon101/particles
  96383. */
  96384. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  96385. /**
  96386. * Billboard mode will only apply to Y axis
  96387. */
  96388. static readonly BILLBOARDMODE_Y: number;
  96389. /**
  96390. * Billboard mode will apply to all axes
  96391. */
  96392. static readonly BILLBOARDMODE_ALL: number;
  96393. /**
  96394. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  96395. */
  96396. static readonly BILLBOARDMODE_STRETCHED: number;
  96397. /**
  96398. * This function can be defined to provide custom update for active particles.
  96399. * This function will be called instead of regular update (age, position, color, etc.).
  96400. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  96401. */
  96402. updateFunction: (particles: Particle[]) => void;
  96403. private _emitterWorldMatrix;
  96404. /**
  96405. * This function can be defined to specify initial direction for every new particle.
  96406. * It by default use the emitterType defined function
  96407. */
  96408. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  96409. /**
  96410. * This function can be defined to specify initial position for every new particle.
  96411. * It by default use the emitterType defined function
  96412. */
  96413. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  96414. /**
  96415. * @hidden
  96416. */
  96417. _inheritedVelocityOffset: Vector3;
  96418. /**
  96419. * An event triggered when the system is disposed
  96420. */
  96421. onDisposeObservable: Observable<IParticleSystem>;
  96422. /**
  96423. * An event triggered when the system is stopped
  96424. */
  96425. onStoppedObservable: Observable<IParticleSystem>;
  96426. private _onDisposeObserver;
  96427. /**
  96428. * Sets a callback that will be triggered when the system is disposed
  96429. */
  96430. set onDispose(callback: () => void);
  96431. private _particles;
  96432. private _epsilon;
  96433. private _capacity;
  96434. private _stockParticles;
  96435. private _newPartsExcess;
  96436. private _vertexData;
  96437. private _vertexBuffer;
  96438. private _vertexBuffers;
  96439. private _spriteBuffer;
  96440. private _indexBuffer;
  96441. private _effect;
  96442. private _customEffect;
  96443. private _cachedDefines;
  96444. private _scaledColorStep;
  96445. private _colorDiff;
  96446. private _scaledDirection;
  96447. private _scaledGravity;
  96448. private _currentRenderId;
  96449. private _alive;
  96450. private _useInstancing;
  96451. private _vertexArrayObject;
  96452. private _started;
  96453. private _stopped;
  96454. private _actualFrame;
  96455. private _scaledUpdateSpeed;
  96456. private _vertexBufferSize;
  96457. /** @hidden */
  96458. _currentEmitRateGradient: Nullable<FactorGradient>;
  96459. /** @hidden */
  96460. _currentEmitRate1: number;
  96461. /** @hidden */
  96462. _currentEmitRate2: number;
  96463. /** @hidden */
  96464. _currentStartSizeGradient: Nullable<FactorGradient>;
  96465. /** @hidden */
  96466. _currentStartSize1: number;
  96467. /** @hidden */
  96468. _currentStartSize2: number;
  96469. private readonly _rawTextureWidth;
  96470. private _rampGradientsTexture;
  96471. private _useRampGradients;
  96472. /** Gets or sets a matrix to use to compute projection */
  96473. defaultProjectionMatrix: Matrix;
  96474. /** Gets or sets a matrix to use to compute view */
  96475. defaultViewMatrix: Matrix;
  96476. /** Gets or sets a boolean indicating that ramp gradients must be used
  96477. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  96478. */
  96479. get useRampGradients(): boolean;
  96480. set useRampGradients(value: boolean);
  96481. /**
  96482. * 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.
  96483. * 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: [])
  96484. */
  96485. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  96486. private _subEmitters;
  96487. /**
  96488. * @hidden
  96489. * If the particle systems emitter should be disposed when the particle system is disposed
  96490. */
  96491. _disposeEmitterOnDispose: boolean;
  96492. /**
  96493. * The current active Sub-systems, this property is used by the root particle system only.
  96494. */
  96495. activeSubSystems: Array<ParticleSystem>;
  96496. /**
  96497. * Specifies if the particles are updated in emitter local space or world space
  96498. */
  96499. isLocal: boolean;
  96500. private _rootParticleSystem;
  96501. /**
  96502. * Gets the current list of active particles
  96503. */
  96504. get particles(): Particle[];
  96505. /**
  96506. * Gets the number of particles active at the same time.
  96507. * @returns The number of active particles.
  96508. */
  96509. getActiveCount(): number;
  96510. /**
  96511. * Returns the string "ParticleSystem"
  96512. * @returns a string containing the class name
  96513. */
  96514. getClassName(): string;
  96515. /**
  96516. * Gets a boolean indicating that the system is stopping
  96517. * @returns true if the system is currently stopping
  96518. */
  96519. isStopping(): boolean;
  96520. /**
  96521. * Gets the custom effect used to render the particles
  96522. * @param blendMode Blend mode for which the effect should be retrieved
  96523. * @returns The effect
  96524. */
  96525. getCustomEffect(blendMode?: number): Nullable<Effect>;
  96526. /**
  96527. * Sets the custom effect used to render the particles
  96528. * @param effect The effect to set
  96529. * @param blendMode Blend mode for which the effect should be set
  96530. */
  96531. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  96532. /** @hidden */
  96533. private _onBeforeDrawParticlesObservable;
  96534. /**
  96535. * Observable that will be called just before the particles are drawn
  96536. */
  96537. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  96538. /**
  96539. * Gets the name of the particle vertex shader
  96540. */
  96541. get vertexShaderName(): string;
  96542. /**
  96543. * Instantiates a particle system.
  96544. * 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.
  96545. * @param name The name of the particle system
  96546. * @param capacity The max number of particles alive at the same time
  96547. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  96548. * @param customEffect a custom effect used to change the way particles are rendered by default
  96549. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  96550. * @param epsilon Offset used to render the particles
  96551. */
  96552. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  96553. private _addFactorGradient;
  96554. private _removeFactorGradient;
  96555. /**
  96556. * Adds a new life time gradient
  96557. * @param gradient defines the gradient to use (between 0 and 1)
  96558. * @param factor defines the life time factor to affect to the specified gradient
  96559. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96560. * @returns the current particle system
  96561. */
  96562. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96563. /**
  96564. * Remove a specific life time gradient
  96565. * @param gradient defines the gradient to remove
  96566. * @returns the current particle system
  96567. */
  96568. removeLifeTimeGradient(gradient: number): IParticleSystem;
  96569. /**
  96570. * Adds a new size gradient
  96571. * @param gradient defines the gradient to use (between 0 and 1)
  96572. * @param factor defines the size factor to affect to the specified gradient
  96573. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96574. * @returns the current particle system
  96575. */
  96576. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96577. /**
  96578. * Remove a specific size gradient
  96579. * @param gradient defines the gradient to remove
  96580. * @returns the current particle system
  96581. */
  96582. removeSizeGradient(gradient: number): IParticleSystem;
  96583. /**
  96584. * Adds a new color remap gradient
  96585. * @param gradient defines the gradient to use (between 0 and 1)
  96586. * @param min defines the color remap minimal range
  96587. * @param max defines the color remap maximal range
  96588. * @returns the current particle system
  96589. */
  96590. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  96591. /**
  96592. * Remove a specific color remap gradient
  96593. * @param gradient defines the gradient to remove
  96594. * @returns the current particle system
  96595. */
  96596. removeColorRemapGradient(gradient: number): IParticleSystem;
  96597. /**
  96598. * Adds a new alpha remap gradient
  96599. * @param gradient defines the gradient to use (between 0 and 1)
  96600. * @param min defines the alpha remap minimal range
  96601. * @param max defines the alpha remap maximal range
  96602. * @returns the current particle system
  96603. */
  96604. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  96605. /**
  96606. * Remove a specific alpha remap gradient
  96607. * @param gradient defines the gradient to remove
  96608. * @returns the current particle system
  96609. */
  96610. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  96611. /**
  96612. * Adds a new angular speed gradient
  96613. * @param gradient defines the gradient to use (between 0 and 1)
  96614. * @param factor defines the angular speed to affect to the specified gradient
  96615. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96616. * @returns the current particle system
  96617. */
  96618. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96619. /**
  96620. * Remove a specific angular speed gradient
  96621. * @param gradient defines the gradient to remove
  96622. * @returns the current particle system
  96623. */
  96624. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  96625. /**
  96626. * Adds a new velocity gradient
  96627. * @param gradient defines the gradient to use (between 0 and 1)
  96628. * @param factor defines the velocity to affect to the specified gradient
  96629. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96630. * @returns the current particle system
  96631. */
  96632. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96633. /**
  96634. * Remove a specific velocity gradient
  96635. * @param gradient defines the gradient to remove
  96636. * @returns the current particle system
  96637. */
  96638. removeVelocityGradient(gradient: number): IParticleSystem;
  96639. /**
  96640. * Adds a new limit velocity gradient
  96641. * @param gradient defines the gradient to use (between 0 and 1)
  96642. * @param factor defines the limit velocity value to affect to the specified gradient
  96643. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96644. * @returns the current particle system
  96645. */
  96646. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96647. /**
  96648. * Remove a specific limit velocity gradient
  96649. * @param gradient defines the gradient to remove
  96650. * @returns the current particle system
  96651. */
  96652. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  96653. /**
  96654. * Adds a new drag gradient
  96655. * @param gradient defines the gradient to use (between 0 and 1)
  96656. * @param factor defines the drag value to affect to the specified gradient
  96657. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96658. * @returns the current particle system
  96659. */
  96660. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96661. /**
  96662. * Remove a specific drag gradient
  96663. * @param gradient defines the gradient to remove
  96664. * @returns the current particle system
  96665. */
  96666. removeDragGradient(gradient: number): IParticleSystem;
  96667. /**
  96668. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  96669. * @param gradient defines the gradient to use (between 0 and 1)
  96670. * @param factor defines the emit rate value to affect to the specified gradient
  96671. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96672. * @returns the current particle system
  96673. */
  96674. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96675. /**
  96676. * Remove a specific emit rate gradient
  96677. * @param gradient defines the gradient to remove
  96678. * @returns the current particle system
  96679. */
  96680. removeEmitRateGradient(gradient: number): IParticleSystem;
  96681. /**
  96682. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  96683. * @param gradient defines the gradient to use (between 0 and 1)
  96684. * @param factor defines the start size value to affect to the specified gradient
  96685. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96686. * @returns the current particle system
  96687. */
  96688. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96689. /**
  96690. * Remove a specific start size gradient
  96691. * @param gradient defines the gradient to remove
  96692. * @returns the current particle system
  96693. */
  96694. removeStartSizeGradient(gradient: number): IParticleSystem;
  96695. private _createRampGradientTexture;
  96696. /**
  96697. * Gets the current list of ramp gradients.
  96698. * You must use addRampGradient and removeRampGradient to udpate this list
  96699. * @returns the list of ramp gradients
  96700. */
  96701. getRampGradients(): Nullable<Array<Color3Gradient>>;
  96702. /** Force the system to rebuild all gradients that need to be resync */
  96703. forceRefreshGradients(): void;
  96704. private _syncRampGradientTexture;
  96705. /**
  96706. * Adds a new ramp gradient used to remap particle colors
  96707. * @param gradient defines the gradient to use (between 0 and 1)
  96708. * @param color defines the color to affect to the specified gradient
  96709. * @returns the current particle system
  96710. */
  96711. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  96712. /**
  96713. * Remove a specific ramp gradient
  96714. * @param gradient defines the gradient to remove
  96715. * @returns the current particle system
  96716. */
  96717. removeRampGradient(gradient: number): ParticleSystem;
  96718. /**
  96719. * Adds a new color gradient
  96720. * @param gradient defines the gradient to use (between 0 and 1)
  96721. * @param color1 defines the color to affect to the specified gradient
  96722. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  96723. * @returns this particle system
  96724. */
  96725. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  96726. /**
  96727. * Remove a specific color gradient
  96728. * @param gradient defines the gradient to remove
  96729. * @returns this particle system
  96730. */
  96731. removeColorGradient(gradient: number): IParticleSystem;
  96732. private _fetchR;
  96733. protected _reset(): void;
  96734. private _resetEffect;
  96735. private _createVertexBuffers;
  96736. private _createIndexBuffer;
  96737. /**
  96738. * Gets the maximum number of particles active at the same time.
  96739. * @returns The max number of active particles.
  96740. */
  96741. getCapacity(): number;
  96742. /**
  96743. * Gets whether there are still active particles in the system.
  96744. * @returns True if it is alive, otherwise false.
  96745. */
  96746. isAlive(): boolean;
  96747. /**
  96748. * Gets if the system has been started. (Note: this will still be true after stop is called)
  96749. * @returns True if it has been started, otherwise false.
  96750. */
  96751. isStarted(): boolean;
  96752. private _prepareSubEmitterInternalArray;
  96753. /**
  96754. * Starts the particle system and begins to emit
  96755. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  96756. */
  96757. start(delay?: number): void;
  96758. /**
  96759. * Stops the particle system.
  96760. * @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.
  96761. */
  96762. stop(stopSubEmitters?: boolean): void;
  96763. /**
  96764. * Remove all active particles
  96765. */
  96766. reset(): void;
  96767. /**
  96768. * @hidden (for internal use only)
  96769. */
  96770. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  96771. /**
  96772. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  96773. * Its lifetime will start back at 0.
  96774. */
  96775. recycleParticle: (particle: Particle) => void;
  96776. private _stopSubEmitters;
  96777. private _createParticle;
  96778. private _removeFromRoot;
  96779. private _emitFromParticle;
  96780. private _update;
  96781. /** @hidden */
  96782. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  96783. /** @hidden */
  96784. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  96785. /**
  96786. * Fill the defines array according to the current settings of the particle system
  96787. * @param defines Array to be updated
  96788. * @param blendMode blend mode to take into account when updating the array
  96789. */
  96790. fillDefines(defines: Array<string>, blendMode: number): void;
  96791. /**
  96792. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  96793. * @param uniforms Uniforms array to fill
  96794. * @param attributes Attributes array to fill
  96795. * @param samplers Samplers array to fill
  96796. */
  96797. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  96798. /** @hidden */
  96799. private _getEffect;
  96800. /**
  96801. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  96802. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  96803. */
  96804. animate(preWarmOnly?: boolean): void;
  96805. private _appendParticleVertices;
  96806. /**
  96807. * Rebuilds the particle system.
  96808. */
  96809. rebuild(): void;
  96810. /**
  96811. * Is this system ready to be used/rendered
  96812. * @return true if the system is ready
  96813. */
  96814. isReady(): boolean;
  96815. private _render;
  96816. /**
  96817. * Renders the particle system in its current state.
  96818. * @returns the current number of particles
  96819. */
  96820. render(): number;
  96821. /**
  96822. * Disposes the particle system and free the associated resources
  96823. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  96824. */
  96825. dispose(disposeTexture?: boolean): void;
  96826. /**
  96827. * Clones the particle system.
  96828. * @param name The name of the cloned object
  96829. * @param newEmitter The new emitter to use
  96830. * @returns the cloned particle system
  96831. */
  96832. clone(name: string, newEmitter: any): ParticleSystem;
  96833. /**
  96834. * Serializes the particle system to a JSON object
  96835. * @param serializeTexture defines if the texture must be serialized as well
  96836. * @returns the JSON object
  96837. */
  96838. serialize(serializeTexture?: boolean): any;
  96839. /** @hidden */
  96840. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  96841. /** @hidden */
  96842. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  96843. /**
  96844. * Parses a JSON object to create a particle system.
  96845. * @param parsedParticleSystem The JSON object to parse
  96846. * @param sceneOrEngine The scene or the engine to create the particle system in
  96847. * @param rootUrl The root url to use to load external dependencies like texture
  96848. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  96849. * @returns the Parsed particle system
  96850. */
  96851. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  96852. }
  96853. }
  96854. declare module BABYLON {
  96855. /**
  96856. * A particle represents one of the element emitted by a particle system.
  96857. * This is mainly define by its coordinates, direction, velocity and age.
  96858. */
  96859. export class Particle {
  96860. /**
  96861. * The particle system the particle belongs to.
  96862. */
  96863. particleSystem: ParticleSystem;
  96864. private static _Count;
  96865. /**
  96866. * Unique ID of the particle
  96867. */
  96868. id: number;
  96869. /**
  96870. * The world position of the particle in the scene.
  96871. */
  96872. position: Vector3;
  96873. /**
  96874. * The world direction of the particle in the scene.
  96875. */
  96876. direction: Vector3;
  96877. /**
  96878. * The color of the particle.
  96879. */
  96880. color: Color4;
  96881. /**
  96882. * The color change of the particle per step.
  96883. */
  96884. colorStep: Color4;
  96885. /**
  96886. * Defines how long will the life of the particle be.
  96887. */
  96888. lifeTime: number;
  96889. /**
  96890. * The current age of the particle.
  96891. */
  96892. age: number;
  96893. /**
  96894. * The current size of the particle.
  96895. */
  96896. size: number;
  96897. /**
  96898. * The current scale of the particle.
  96899. */
  96900. scale: Vector2;
  96901. /**
  96902. * The current angle of the particle.
  96903. */
  96904. angle: number;
  96905. /**
  96906. * Defines how fast is the angle changing.
  96907. */
  96908. angularSpeed: number;
  96909. /**
  96910. * Defines the cell index used by the particle to be rendered from a sprite.
  96911. */
  96912. cellIndex: number;
  96913. /**
  96914. * The information required to support color remapping
  96915. */
  96916. remapData: Vector4;
  96917. /** @hidden */
  96918. _randomCellOffset?: number;
  96919. /** @hidden */
  96920. _initialDirection: Nullable<Vector3>;
  96921. /** @hidden */
  96922. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  96923. /** @hidden */
  96924. _initialStartSpriteCellID: number;
  96925. /** @hidden */
  96926. _initialEndSpriteCellID: number;
  96927. /** @hidden */
  96928. _currentColorGradient: Nullable<ColorGradient>;
  96929. /** @hidden */
  96930. _currentColor1: Color4;
  96931. /** @hidden */
  96932. _currentColor2: Color4;
  96933. /** @hidden */
  96934. _currentSizeGradient: Nullable<FactorGradient>;
  96935. /** @hidden */
  96936. _currentSize1: number;
  96937. /** @hidden */
  96938. _currentSize2: number;
  96939. /** @hidden */
  96940. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  96941. /** @hidden */
  96942. _currentAngularSpeed1: number;
  96943. /** @hidden */
  96944. _currentAngularSpeed2: number;
  96945. /** @hidden */
  96946. _currentVelocityGradient: Nullable<FactorGradient>;
  96947. /** @hidden */
  96948. _currentVelocity1: number;
  96949. /** @hidden */
  96950. _currentVelocity2: number;
  96951. /** @hidden */
  96952. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  96953. /** @hidden */
  96954. _currentLimitVelocity1: number;
  96955. /** @hidden */
  96956. _currentLimitVelocity2: number;
  96957. /** @hidden */
  96958. _currentDragGradient: Nullable<FactorGradient>;
  96959. /** @hidden */
  96960. _currentDrag1: number;
  96961. /** @hidden */
  96962. _currentDrag2: number;
  96963. /** @hidden */
  96964. _randomNoiseCoordinates1: Vector3;
  96965. /** @hidden */
  96966. _randomNoiseCoordinates2: Vector3;
  96967. /** @hidden */
  96968. _localPosition?: Vector3;
  96969. /**
  96970. * Creates a new instance Particle
  96971. * @param particleSystem the particle system the particle belongs to
  96972. */
  96973. constructor(
  96974. /**
  96975. * The particle system the particle belongs to.
  96976. */
  96977. particleSystem: ParticleSystem);
  96978. private updateCellInfoFromSystem;
  96979. /**
  96980. * Defines how the sprite cell index is updated for the particle
  96981. */
  96982. updateCellIndex(): void;
  96983. /** @hidden */
  96984. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  96985. /** @hidden */
  96986. _inheritParticleInfoToSubEmitters(): void;
  96987. /** @hidden */
  96988. _reset(): void;
  96989. /**
  96990. * Copy the properties of particle to another one.
  96991. * @param other the particle to copy the information to.
  96992. */
  96993. copyTo(other: Particle): void;
  96994. }
  96995. }
  96996. declare module BABYLON {
  96997. /**
  96998. * Particle emitter represents a volume emitting particles.
  96999. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  97000. */
  97001. export interface IParticleEmitterType {
  97002. /**
  97003. * Called by the particle System when the direction is computed for the created particle.
  97004. * @param worldMatrix is the world matrix of the particle system
  97005. * @param directionToUpdate is the direction vector to update with the result
  97006. * @param particle is the particle we are computed the direction for
  97007. * @param isLocal defines if the direction should be set in local space
  97008. */
  97009. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97010. /**
  97011. * Called by the particle System when the position is computed for the created particle.
  97012. * @param worldMatrix is the world matrix of the particle system
  97013. * @param positionToUpdate is the position vector to update with the result
  97014. * @param particle is the particle we are computed the position for
  97015. * @param isLocal defines if the position should be set in local space
  97016. */
  97017. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97018. /**
  97019. * Clones the current emitter and returns a copy of it
  97020. * @returns the new emitter
  97021. */
  97022. clone(): IParticleEmitterType;
  97023. /**
  97024. * Called by the GPUParticleSystem to setup the update shader
  97025. * @param effect defines the update shader
  97026. */
  97027. applyToShader(effect: Effect): void;
  97028. /**
  97029. * Returns a string to use to update the GPU particles update shader
  97030. * @returns the effect defines string
  97031. */
  97032. getEffectDefines(): string;
  97033. /**
  97034. * Returns a string representing the class name
  97035. * @returns a string containing the class name
  97036. */
  97037. getClassName(): string;
  97038. /**
  97039. * Serializes the particle system to a JSON object.
  97040. * @returns the JSON object
  97041. */
  97042. serialize(): any;
  97043. /**
  97044. * Parse properties from a JSON object
  97045. * @param serializationObject defines the JSON object
  97046. * @param scene defines the hosting scene
  97047. */
  97048. parse(serializationObject: any, scene: Nullable<Scene>): void;
  97049. }
  97050. }
  97051. declare module BABYLON {
  97052. /**
  97053. * Particle emitter emitting particles from the inside of a box.
  97054. * It emits the particles randomly between 2 given directions.
  97055. */
  97056. export class BoxParticleEmitter implements IParticleEmitterType {
  97057. /**
  97058. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97059. */
  97060. direction1: Vector3;
  97061. /**
  97062. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97063. */
  97064. direction2: Vector3;
  97065. /**
  97066. * 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.
  97067. */
  97068. minEmitBox: Vector3;
  97069. /**
  97070. * 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.
  97071. */
  97072. maxEmitBox: Vector3;
  97073. /**
  97074. * Creates a new instance BoxParticleEmitter
  97075. */
  97076. constructor();
  97077. /**
  97078. * Called by the particle System when the direction is computed for the created particle.
  97079. * @param worldMatrix is the world matrix of the particle system
  97080. * @param directionToUpdate is the direction vector to update with the result
  97081. * @param particle is the particle we are computed the direction for
  97082. * @param isLocal defines if the direction should be set in local space
  97083. */
  97084. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97085. /**
  97086. * Called by the particle System when the position is computed for the created particle.
  97087. * @param worldMatrix is the world matrix of the particle system
  97088. * @param positionToUpdate is the position vector to update with the result
  97089. * @param particle is the particle we are computed the position for
  97090. * @param isLocal defines if the position should be set in local space
  97091. */
  97092. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97093. /**
  97094. * Clones the current emitter and returns a copy of it
  97095. * @returns the new emitter
  97096. */
  97097. clone(): BoxParticleEmitter;
  97098. /**
  97099. * Called by the GPUParticleSystem to setup the update shader
  97100. * @param effect defines the update shader
  97101. */
  97102. applyToShader(effect: Effect): void;
  97103. /**
  97104. * Returns a string to use to update the GPU particles update shader
  97105. * @returns a string containng the defines string
  97106. */
  97107. getEffectDefines(): string;
  97108. /**
  97109. * Returns the string "BoxParticleEmitter"
  97110. * @returns a string containing the class name
  97111. */
  97112. getClassName(): string;
  97113. /**
  97114. * Serializes the particle system to a JSON object.
  97115. * @returns the JSON object
  97116. */
  97117. serialize(): any;
  97118. /**
  97119. * Parse properties from a JSON object
  97120. * @param serializationObject defines the JSON object
  97121. */
  97122. parse(serializationObject: any): void;
  97123. }
  97124. }
  97125. declare module BABYLON {
  97126. /**
  97127. * Particle emitter emitting particles from the inside of a cone.
  97128. * It emits the particles alongside the cone volume from the base to the particle.
  97129. * The emission direction might be randomized.
  97130. */
  97131. export class ConeParticleEmitter implements IParticleEmitterType {
  97132. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  97133. directionRandomizer: number;
  97134. private _radius;
  97135. private _angle;
  97136. private _height;
  97137. /**
  97138. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  97139. */
  97140. radiusRange: number;
  97141. /**
  97142. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  97143. */
  97144. heightRange: number;
  97145. /**
  97146. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  97147. */
  97148. emitFromSpawnPointOnly: boolean;
  97149. /**
  97150. * Gets or sets the radius of the emission cone
  97151. */
  97152. get radius(): number;
  97153. set radius(value: number);
  97154. /**
  97155. * Gets or sets the angle of the emission cone
  97156. */
  97157. get angle(): number;
  97158. set angle(value: number);
  97159. private _buildHeight;
  97160. /**
  97161. * Creates a new instance ConeParticleEmitter
  97162. * @param radius the radius of the emission cone (1 by default)
  97163. * @param angle the cone base angle (PI by default)
  97164. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  97165. */
  97166. constructor(radius?: number, angle?: number,
  97167. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  97168. directionRandomizer?: number);
  97169. /**
  97170. * Called by the particle System when the direction is computed for the created particle.
  97171. * @param worldMatrix is the world matrix of the particle system
  97172. * @param directionToUpdate is the direction vector to update with the result
  97173. * @param particle is the particle we are computed the direction for
  97174. * @param isLocal defines if the direction should be set in local space
  97175. */
  97176. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97177. /**
  97178. * Called by the particle System when the position is computed for the created particle.
  97179. * @param worldMatrix is the world matrix of the particle system
  97180. * @param positionToUpdate is the position vector to update with the result
  97181. * @param particle is the particle we are computed the position for
  97182. * @param isLocal defines if the position should be set in local space
  97183. */
  97184. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97185. /**
  97186. * Clones the current emitter and returns a copy of it
  97187. * @returns the new emitter
  97188. */
  97189. clone(): ConeParticleEmitter;
  97190. /**
  97191. * Called by the GPUParticleSystem to setup the update shader
  97192. * @param effect defines the update shader
  97193. */
  97194. applyToShader(effect: Effect): void;
  97195. /**
  97196. * Returns a string to use to update the GPU particles update shader
  97197. * @returns a string containng the defines string
  97198. */
  97199. getEffectDefines(): string;
  97200. /**
  97201. * Returns the string "ConeParticleEmitter"
  97202. * @returns a string containing the class name
  97203. */
  97204. getClassName(): string;
  97205. /**
  97206. * Serializes the particle system to a JSON object.
  97207. * @returns the JSON object
  97208. */
  97209. serialize(): any;
  97210. /**
  97211. * Parse properties from a JSON object
  97212. * @param serializationObject defines the JSON object
  97213. */
  97214. parse(serializationObject: any): void;
  97215. }
  97216. }
  97217. declare module BABYLON {
  97218. /**
  97219. * Particle emitter emitting particles from the inside of a cylinder.
  97220. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  97221. */
  97222. export class CylinderParticleEmitter implements IParticleEmitterType {
  97223. /**
  97224. * The radius of the emission cylinder.
  97225. */
  97226. radius: number;
  97227. /**
  97228. * The height of the emission cylinder.
  97229. */
  97230. height: number;
  97231. /**
  97232. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97233. */
  97234. radiusRange: number;
  97235. /**
  97236. * How much to randomize the particle direction [0-1].
  97237. */
  97238. directionRandomizer: number;
  97239. /**
  97240. * Creates a new instance CylinderParticleEmitter
  97241. * @param radius the radius of the emission cylinder (1 by default)
  97242. * @param height the height of the emission cylinder (1 by default)
  97243. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  97244. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  97245. */
  97246. constructor(
  97247. /**
  97248. * The radius of the emission cylinder.
  97249. */
  97250. radius?: number,
  97251. /**
  97252. * The height of the emission cylinder.
  97253. */
  97254. height?: number,
  97255. /**
  97256. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97257. */
  97258. radiusRange?: number,
  97259. /**
  97260. * How much to randomize the particle direction [0-1].
  97261. */
  97262. directionRandomizer?: number);
  97263. /**
  97264. * Called by the particle System when the direction is computed for the created particle.
  97265. * @param worldMatrix is the world matrix of the particle system
  97266. * @param directionToUpdate is the direction vector to update with the result
  97267. * @param particle is the particle we are computed the direction for
  97268. * @param isLocal defines if the direction should be set in local space
  97269. */
  97270. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97271. /**
  97272. * Called by the particle System when the position is computed for the created particle.
  97273. * @param worldMatrix is the world matrix of the particle system
  97274. * @param positionToUpdate is the position vector to update with the result
  97275. * @param particle is the particle we are computed the position for
  97276. * @param isLocal defines if the position should be set in local space
  97277. */
  97278. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97279. /**
  97280. * Clones the current emitter and returns a copy of it
  97281. * @returns the new emitter
  97282. */
  97283. clone(): CylinderParticleEmitter;
  97284. /**
  97285. * Called by the GPUParticleSystem to setup the update shader
  97286. * @param effect defines the update shader
  97287. */
  97288. applyToShader(effect: Effect): void;
  97289. /**
  97290. * Returns a string to use to update the GPU particles update shader
  97291. * @returns a string containng the defines string
  97292. */
  97293. getEffectDefines(): string;
  97294. /**
  97295. * Returns the string "CylinderParticleEmitter"
  97296. * @returns a string containing the class name
  97297. */
  97298. getClassName(): string;
  97299. /**
  97300. * Serializes the particle system to a JSON object.
  97301. * @returns the JSON object
  97302. */
  97303. serialize(): any;
  97304. /**
  97305. * Parse properties from a JSON object
  97306. * @param serializationObject defines the JSON object
  97307. */
  97308. parse(serializationObject: any): void;
  97309. }
  97310. /**
  97311. * Particle emitter emitting particles from the inside of a cylinder.
  97312. * It emits the particles randomly between two vectors.
  97313. */
  97314. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  97315. /**
  97316. * The min limit of the emission direction.
  97317. */
  97318. direction1: Vector3;
  97319. /**
  97320. * The max limit of the emission direction.
  97321. */
  97322. direction2: Vector3;
  97323. /**
  97324. * Creates a new instance CylinderDirectedParticleEmitter
  97325. * @param radius the radius of the emission cylinder (1 by default)
  97326. * @param height the height of the emission cylinder (1 by default)
  97327. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  97328. * @param direction1 the min limit of the emission direction (up vector by default)
  97329. * @param direction2 the max limit of the emission direction (up vector by default)
  97330. */
  97331. constructor(radius?: number, height?: number, radiusRange?: number,
  97332. /**
  97333. * The min limit of the emission direction.
  97334. */
  97335. direction1?: Vector3,
  97336. /**
  97337. * The max limit of the emission direction.
  97338. */
  97339. direction2?: Vector3);
  97340. /**
  97341. * Called by the particle System when the direction is computed for the created particle.
  97342. * @param worldMatrix is the world matrix of the particle system
  97343. * @param directionToUpdate is the direction vector to update with the result
  97344. * @param particle is the particle we are computed the direction for
  97345. */
  97346. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  97347. /**
  97348. * Clones the current emitter and returns a copy of it
  97349. * @returns the new emitter
  97350. */
  97351. clone(): CylinderDirectedParticleEmitter;
  97352. /**
  97353. * Called by the GPUParticleSystem to setup the update shader
  97354. * @param effect defines the update shader
  97355. */
  97356. applyToShader(effect: Effect): void;
  97357. /**
  97358. * Returns a string to use to update the GPU particles update shader
  97359. * @returns a string containng the defines string
  97360. */
  97361. getEffectDefines(): string;
  97362. /**
  97363. * Returns the string "CylinderDirectedParticleEmitter"
  97364. * @returns a string containing the class name
  97365. */
  97366. getClassName(): string;
  97367. /**
  97368. * Serializes the particle system to a JSON object.
  97369. * @returns the JSON object
  97370. */
  97371. serialize(): any;
  97372. /**
  97373. * Parse properties from a JSON object
  97374. * @param serializationObject defines the JSON object
  97375. */
  97376. parse(serializationObject: any): void;
  97377. }
  97378. }
  97379. declare module BABYLON {
  97380. /**
  97381. * Particle emitter emitting particles from the inside of a hemisphere.
  97382. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  97383. */
  97384. export class HemisphericParticleEmitter implements IParticleEmitterType {
  97385. /**
  97386. * The radius of the emission hemisphere.
  97387. */
  97388. radius: number;
  97389. /**
  97390. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97391. */
  97392. radiusRange: number;
  97393. /**
  97394. * How much to randomize the particle direction [0-1].
  97395. */
  97396. directionRandomizer: number;
  97397. /**
  97398. * Creates a new instance HemisphericParticleEmitter
  97399. * @param radius the radius of the emission hemisphere (1 by default)
  97400. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  97401. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  97402. */
  97403. constructor(
  97404. /**
  97405. * The radius of the emission hemisphere.
  97406. */
  97407. radius?: number,
  97408. /**
  97409. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97410. */
  97411. radiusRange?: number,
  97412. /**
  97413. * How much to randomize the particle direction [0-1].
  97414. */
  97415. directionRandomizer?: number);
  97416. /**
  97417. * Called by the particle System when the direction is computed for the created particle.
  97418. * @param worldMatrix is the world matrix of the particle system
  97419. * @param directionToUpdate is the direction vector to update with the result
  97420. * @param particle is the particle we are computed the direction for
  97421. * @param isLocal defines if the direction should be set in local space
  97422. */
  97423. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97424. /**
  97425. * Called by the particle System when the position is computed for the created particle.
  97426. * @param worldMatrix is the world matrix of the particle system
  97427. * @param positionToUpdate is the position vector to update with the result
  97428. * @param particle is the particle we are computed the position for
  97429. * @param isLocal defines if the position should be set in local space
  97430. */
  97431. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97432. /**
  97433. * Clones the current emitter and returns a copy of it
  97434. * @returns the new emitter
  97435. */
  97436. clone(): HemisphericParticleEmitter;
  97437. /**
  97438. * Called by the GPUParticleSystem to setup the update shader
  97439. * @param effect defines the update shader
  97440. */
  97441. applyToShader(effect: Effect): void;
  97442. /**
  97443. * Returns a string to use to update the GPU particles update shader
  97444. * @returns a string containng the defines string
  97445. */
  97446. getEffectDefines(): string;
  97447. /**
  97448. * Returns the string "HemisphericParticleEmitter"
  97449. * @returns a string containing the class name
  97450. */
  97451. getClassName(): string;
  97452. /**
  97453. * Serializes the particle system to a JSON object.
  97454. * @returns the JSON object
  97455. */
  97456. serialize(): any;
  97457. /**
  97458. * Parse properties from a JSON object
  97459. * @param serializationObject defines the JSON object
  97460. */
  97461. parse(serializationObject: any): void;
  97462. }
  97463. }
  97464. declare module BABYLON {
  97465. /**
  97466. * Particle emitter emitting particles from a point.
  97467. * It emits the particles randomly between 2 given directions.
  97468. */
  97469. export class PointParticleEmitter implements IParticleEmitterType {
  97470. /**
  97471. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97472. */
  97473. direction1: Vector3;
  97474. /**
  97475. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97476. */
  97477. direction2: Vector3;
  97478. /**
  97479. * Creates a new instance PointParticleEmitter
  97480. */
  97481. constructor();
  97482. /**
  97483. * Called by the particle System when the direction is computed for the created particle.
  97484. * @param worldMatrix is the world matrix of the particle system
  97485. * @param directionToUpdate is the direction vector to update with the result
  97486. * @param particle is the particle we are computed the direction for
  97487. * @param isLocal defines if the direction should be set in local space
  97488. */
  97489. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97490. /**
  97491. * Called by the particle System when the position is computed for the created particle.
  97492. * @param worldMatrix is the world matrix of the particle system
  97493. * @param positionToUpdate is the position vector to update with the result
  97494. * @param particle is the particle we are computed the position for
  97495. * @param isLocal defines if the position should be set in local space
  97496. */
  97497. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97498. /**
  97499. * Clones the current emitter and returns a copy of it
  97500. * @returns the new emitter
  97501. */
  97502. clone(): PointParticleEmitter;
  97503. /**
  97504. * Called by the GPUParticleSystem to setup the update shader
  97505. * @param effect defines the update shader
  97506. */
  97507. applyToShader(effect: Effect): void;
  97508. /**
  97509. * Returns a string to use to update the GPU particles update shader
  97510. * @returns a string containng the defines string
  97511. */
  97512. getEffectDefines(): string;
  97513. /**
  97514. * Returns the string "PointParticleEmitter"
  97515. * @returns a string containing the class name
  97516. */
  97517. getClassName(): string;
  97518. /**
  97519. * Serializes the particle system to a JSON object.
  97520. * @returns the JSON object
  97521. */
  97522. serialize(): any;
  97523. /**
  97524. * Parse properties from a JSON object
  97525. * @param serializationObject defines the JSON object
  97526. */
  97527. parse(serializationObject: any): void;
  97528. }
  97529. }
  97530. declare module BABYLON {
  97531. /**
  97532. * Particle emitter emitting particles from the inside of a sphere.
  97533. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  97534. */
  97535. export class SphereParticleEmitter implements IParticleEmitterType {
  97536. /**
  97537. * The radius of the emission sphere.
  97538. */
  97539. radius: number;
  97540. /**
  97541. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97542. */
  97543. radiusRange: number;
  97544. /**
  97545. * How much to randomize the particle direction [0-1].
  97546. */
  97547. directionRandomizer: number;
  97548. /**
  97549. * Creates a new instance SphereParticleEmitter
  97550. * @param radius the radius of the emission sphere (1 by default)
  97551. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  97552. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  97553. */
  97554. constructor(
  97555. /**
  97556. * The radius of the emission sphere.
  97557. */
  97558. radius?: number,
  97559. /**
  97560. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97561. */
  97562. radiusRange?: number,
  97563. /**
  97564. * How much to randomize the particle direction [0-1].
  97565. */
  97566. directionRandomizer?: number);
  97567. /**
  97568. * Called by the particle System when the direction is computed for the created particle.
  97569. * @param worldMatrix is the world matrix of the particle system
  97570. * @param directionToUpdate is the direction vector to update with the result
  97571. * @param particle is the particle we are computed the direction for
  97572. * @param isLocal defines if the direction should be set in local space
  97573. */
  97574. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97575. /**
  97576. * Called by the particle System when the position is computed for the created particle.
  97577. * @param worldMatrix is the world matrix of the particle system
  97578. * @param positionToUpdate is the position vector to update with the result
  97579. * @param particle is the particle we are computed the position for
  97580. * @param isLocal defines if the position should be set in local space
  97581. */
  97582. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97583. /**
  97584. * Clones the current emitter and returns a copy of it
  97585. * @returns the new emitter
  97586. */
  97587. clone(): SphereParticleEmitter;
  97588. /**
  97589. * Called by the GPUParticleSystem to setup the update shader
  97590. * @param effect defines the update shader
  97591. */
  97592. applyToShader(effect: Effect): void;
  97593. /**
  97594. * Returns a string to use to update the GPU particles update shader
  97595. * @returns a string containng the defines string
  97596. */
  97597. getEffectDefines(): string;
  97598. /**
  97599. * Returns the string "SphereParticleEmitter"
  97600. * @returns a string containing the class name
  97601. */
  97602. getClassName(): string;
  97603. /**
  97604. * Serializes the particle system to a JSON object.
  97605. * @returns the JSON object
  97606. */
  97607. serialize(): any;
  97608. /**
  97609. * Parse properties from a JSON object
  97610. * @param serializationObject defines the JSON object
  97611. */
  97612. parse(serializationObject: any): void;
  97613. }
  97614. /**
  97615. * Particle emitter emitting particles from the inside of a sphere.
  97616. * It emits the particles randomly between two vectors.
  97617. */
  97618. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  97619. /**
  97620. * The min limit of the emission direction.
  97621. */
  97622. direction1: Vector3;
  97623. /**
  97624. * The max limit of the emission direction.
  97625. */
  97626. direction2: Vector3;
  97627. /**
  97628. * Creates a new instance SphereDirectedParticleEmitter
  97629. * @param radius the radius of the emission sphere (1 by default)
  97630. * @param direction1 the min limit of the emission direction (up vector by default)
  97631. * @param direction2 the max limit of the emission direction (up vector by default)
  97632. */
  97633. constructor(radius?: number,
  97634. /**
  97635. * The min limit of the emission direction.
  97636. */
  97637. direction1?: Vector3,
  97638. /**
  97639. * The max limit of the emission direction.
  97640. */
  97641. direction2?: Vector3);
  97642. /**
  97643. * Called by the particle System when the direction is computed for the created particle.
  97644. * @param worldMatrix is the world matrix of the particle system
  97645. * @param directionToUpdate is the direction vector to update with the result
  97646. * @param particle is the particle we are computed the direction for
  97647. */
  97648. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  97649. /**
  97650. * Clones the current emitter and returns a copy of it
  97651. * @returns the new emitter
  97652. */
  97653. clone(): SphereDirectedParticleEmitter;
  97654. /**
  97655. * Called by the GPUParticleSystem to setup the update shader
  97656. * @param effect defines the update shader
  97657. */
  97658. applyToShader(effect: Effect): void;
  97659. /**
  97660. * Returns a string to use to update the GPU particles update shader
  97661. * @returns a string containng the defines string
  97662. */
  97663. getEffectDefines(): string;
  97664. /**
  97665. * Returns the string "SphereDirectedParticleEmitter"
  97666. * @returns a string containing the class name
  97667. */
  97668. getClassName(): string;
  97669. /**
  97670. * Serializes the particle system to a JSON object.
  97671. * @returns the JSON object
  97672. */
  97673. serialize(): any;
  97674. /**
  97675. * Parse properties from a JSON object
  97676. * @param serializationObject defines the JSON object
  97677. */
  97678. parse(serializationObject: any): void;
  97679. }
  97680. }
  97681. declare module BABYLON {
  97682. /**
  97683. * Particle emitter emitting particles from a custom list of positions.
  97684. */
  97685. export class CustomParticleEmitter implements IParticleEmitterType {
  97686. /**
  97687. * Gets or sets the position generator that will create the inital position of each particle.
  97688. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  97689. */
  97690. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  97691. /**
  97692. * Gets or sets the destination generator that will create the final destination of each particle.
  97693. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  97694. */
  97695. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  97696. /**
  97697. * Creates a new instance CustomParticleEmitter
  97698. */
  97699. constructor();
  97700. /**
  97701. * Called by the particle System when the direction is computed for the created particle.
  97702. * @param worldMatrix is the world matrix of the particle system
  97703. * @param directionToUpdate is the direction vector to update with the result
  97704. * @param particle is the particle we are computed the direction for
  97705. * @param isLocal defines if the direction should be set in local space
  97706. */
  97707. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97708. /**
  97709. * Called by the particle System when the position is computed for the created particle.
  97710. * @param worldMatrix is the world matrix of the particle system
  97711. * @param positionToUpdate is the position vector to update with the result
  97712. * @param particle is the particle we are computed the position for
  97713. * @param isLocal defines if the position should be set in local space
  97714. */
  97715. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97716. /**
  97717. * Clones the current emitter and returns a copy of it
  97718. * @returns the new emitter
  97719. */
  97720. clone(): CustomParticleEmitter;
  97721. /**
  97722. * Called by the GPUParticleSystem to setup the update shader
  97723. * @param effect defines the update shader
  97724. */
  97725. applyToShader(effect: Effect): void;
  97726. /**
  97727. * Returns a string to use to update the GPU particles update shader
  97728. * @returns a string containng the defines string
  97729. */
  97730. getEffectDefines(): string;
  97731. /**
  97732. * Returns the string "PointParticleEmitter"
  97733. * @returns a string containing the class name
  97734. */
  97735. getClassName(): string;
  97736. /**
  97737. * Serializes the particle system to a JSON object.
  97738. * @returns the JSON object
  97739. */
  97740. serialize(): any;
  97741. /**
  97742. * Parse properties from a JSON object
  97743. * @param serializationObject defines the JSON object
  97744. */
  97745. parse(serializationObject: any): void;
  97746. }
  97747. }
  97748. declare module BABYLON {
  97749. /**
  97750. * Particle emitter emitting particles from the inside of a box.
  97751. * It emits the particles randomly between 2 given directions.
  97752. */
  97753. export class MeshParticleEmitter implements IParticleEmitterType {
  97754. private _indices;
  97755. private _positions;
  97756. private _normals;
  97757. private _storedNormal;
  97758. private _mesh;
  97759. /**
  97760. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97761. */
  97762. direction1: Vector3;
  97763. /**
  97764. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97765. */
  97766. direction2: Vector3;
  97767. /**
  97768. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  97769. */
  97770. useMeshNormalsForDirection: boolean;
  97771. /** Defines the mesh to use as source */
  97772. get mesh(): Nullable<AbstractMesh>;
  97773. set mesh(value: Nullable<AbstractMesh>);
  97774. /**
  97775. * Creates a new instance MeshParticleEmitter
  97776. * @param mesh defines the mesh to use as source
  97777. */
  97778. constructor(mesh?: Nullable<AbstractMesh>);
  97779. /**
  97780. * Called by the particle System when the direction is computed for the created particle.
  97781. * @param worldMatrix is the world matrix of the particle system
  97782. * @param directionToUpdate is the direction vector to update with the result
  97783. * @param particle is the particle we are computed the direction for
  97784. * @param isLocal defines if the direction should be set in local space
  97785. */
  97786. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97787. /**
  97788. * Called by the particle System when the position is computed for the created particle.
  97789. * @param worldMatrix is the world matrix of the particle system
  97790. * @param positionToUpdate is the position vector to update with the result
  97791. * @param particle is the particle we are computed the position for
  97792. * @param isLocal defines if the position should be set in local space
  97793. */
  97794. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97795. /**
  97796. * Clones the current emitter and returns a copy of it
  97797. * @returns the new emitter
  97798. */
  97799. clone(): MeshParticleEmitter;
  97800. /**
  97801. * Called by the GPUParticleSystem to setup the update shader
  97802. * @param effect defines the update shader
  97803. */
  97804. applyToShader(effect: Effect): void;
  97805. /**
  97806. * Returns a string to use to update the GPU particles update shader
  97807. * @returns a string containng the defines string
  97808. */
  97809. getEffectDefines(): string;
  97810. /**
  97811. * Returns the string "BoxParticleEmitter"
  97812. * @returns a string containing the class name
  97813. */
  97814. getClassName(): string;
  97815. /**
  97816. * Serializes the particle system to a JSON object.
  97817. * @returns the JSON object
  97818. */
  97819. serialize(): any;
  97820. /**
  97821. * Parse properties from a JSON object
  97822. * @param serializationObject defines the JSON object
  97823. * @param scene defines the hosting scene
  97824. */
  97825. parse(serializationObject: any, scene: Nullable<Scene>): void;
  97826. }
  97827. }
  97828. declare module BABYLON {
  97829. /**
  97830. * Interface representing a particle system in Babylon.js.
  97831. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  97832. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  97833. */
  97834. export interface IParticleSystem {
  97835. /**
  97836. * List of animations used by the particle system.
  97837. */
  97838. animations: Animation[];
  97839. /**
  97840. * The id of the Particle system.
  97841. */
  97842. id: string;
  97843. /**
  97844. * The name of the Particle system.
  97845. */
  97846. name: string;
  97847. /**
  97848. * The emitter represents the Mesh or position we are attaching the particle system to.
  97849. */
  97850. emitter: Nullable<AbstractMesh | Vector3>;
  97851. /**
  97852. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  97853. */
  97854. isBillboardBased: boolean;
  97855. /**
  97856. * The rendering group used by the Particle system to chose when to render.
  97857. */
  97858. renderingGroupId: number;
  97859. /**
  97860. * The layer mask we are rendering the particles through.
  97861. */
  97862. layerMask: number;
  97863. /**
  97864. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  97865. */
  97866. updateSpeed: number;
  97867. /**
  97868. * The amount of time the particle system is running (depends of the overall update speed).
  97869. */
  97870. targetStopDuration: number;
  97871. /**
  97872. * The texture used to render each particle. (this can be a spritesheet)
  97873. */
  97874. particleTexture: Nullable<BaseTexture>;
  97875. /**
  97876. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  97877. */
  97878. blendMode: number;
  97879. /**
  97880. * Minimum life time of emitting particles.
  97881. */
  97882. minLifeTime: number;
  97883. /**
  97884. * Maximum life time of emitting particles.
  97885. */
  97886. maxLifeTime: number;
  97887. /**
  97888. * Minimum Size of emitting particles.
  97889. */
  97890. minSize: number;
  97891. /**
  97892. * Maximum Size of emitting particles.
  97893. */
  97894. maxSize: number;
  97895. /**
  97896. * Minimum scale of emitting particles on X axis.
  97897. */
  97898. minScaleX: number;
  97899. /**
  97900. * Maximum scale of emitting particles on X axis.
  97901. */
  97902. maxScaleX: number;
  97903. /**
  97904. * Minimum scale of emitting particles on Y axis.
  97905. */
  97906. minScaleY: number;
  97907. /**
  97908. * Maximum scale of emitting particles on Y axis.
  97909. */
  97910. maxScaleY: number;
  97911. /**
  97912. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  97913. */
  97914. color1: Color4;
  97915. /**
  97916. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  97917. */
  97918. color2: Color4;
  97919. /**
  97920. * Color the particle will have at the end of its lifetime.
  97921. */
  97922. colorDead: Color4;
  97923. /**
  97924. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  97925. */
  97926. emitRate: number;
  97927. /**
  97928. * You can use gravity if you want to give an orientation to your particles.
  97929. */
  97930. gravity: Vector3;
  97931. /**
  97932. * Minimum power of emitting particles.
  97933. */
  97934. minEmitPower: number;
  97935. /**
  97936. * Maximum power of emitting particles.
  97937. */
  97938. maxEmitPower: number;
  97939. /**
  97940. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  97941. */
  97942. minAngularSpeed: number;
  97943. /**
  97944. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  97945. */
  97946. maxAngularSpeed: number;
  97947. /**
  97948. * Gets or sets the minimal initial rotation in radians.
  97949. */
  97950. minInitialRotation: number;
  97951. /**
  97952. * Gets or sets the maximal initial rotation in radians.
  97953. */
  97954. maxInitialRotation: number;
  97955. /**
  97956. * The particle emitter type defines the emitter used by the particle system.
  97957. * It can be for example box, sphere, or cone...
  97958. */
  97959. particleEmitterType: Nullable<IParticleEmitterType>;
  97960. /**
  97961. * Defines the delay in milliseconds before starting the system (0 by default)
  97962. */
  97963. startDelay: number;
  97964. /**
  97965. * 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
  97966. */
  97967. preWarmCycles: number;
  97968. /**
  97969. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  97970. */
  97971. preWarmStepOffset: number;
  97972. /**
  97973. * 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)
  97974. */
  97975. spriteCellChangeSpeed: number;
  97976. /**
  97977. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  97978. */
  97979. startSpriteCellID: number;
  97980. /**
  97981. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  97982. */
  97983. endSpriteCellID: number;
  97984. /**
  97985. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  97986. */
  97987. spriteCellWidth: number;
  97988. /**
  97989. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  97990. */
  97991. spriteCellHeight: number;
  97992. /**
  97993. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  97994. */
  97995. spriteRandomStartCell: boolean;
  97996. /**
  97997. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  97998. */
  97999. isAnimationSheetEnabled: boolean;
  98000. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  98001. translationPivot: Vector2;
  98002. /**
  98003. * Gets or sets a texture used to add random noise to particle positions
  98004. */
  98005. noiseTexture: Nullable<BaseTexture>;
  98006. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  98007. noiseStrength: Vector3;
  98008. /**
  98009. * Gets or sets the billboard mode to use when isBillboardBased = true.
  98010. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  98011. */
  98012. billboardMode: number;
  98013. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  98014. limitVelocityDamping: number;
  98015. /**
  98016. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  98017. */
  98018. beginAnimationOnStart: boolean;
  98019. /**
  98020. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  98021. */
  98022. beginAnimationFrom: number;
  98023. /**
  98024. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  98025. */
  98026. beginAnimationTo: number;
  98027. /**
  98028. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  98029. */
  98030. beginAnimationLoop: boolean;
  98031. /**
  98032. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  98033. */
  98034. disposeOnStop: boolean;
  98035. /**
  98036. * Specifies if the particles are updated in emitter local space or world space
  98037. */
  98038. isLocal: boolean;
  98039. /** Snippet ID if the particle system was created from the snippet server */
  98040. snippetId: string;
  98041. /** Gets or sets a matrix to use to compute projection */
  98042. defaultProjectionMatrix: Matrix;
  98043. /**
  98044. * Gets the maximum number of particles active at the same time.
  98045. * @returns The max number of active particles.
  98046. */
  98047. getCapacity(): number;
  98048. /**
  98049. * Gets the number of particles active at the same time.
  98050. * @returns The number of active particles.
  98051. */
  98052. getActiveCount(): number;
  98053. /**
  98054. * Gets if the system has been started. (Note: this will still be true after stop is called)
  98055. * @returns True if it has been started, otherwise false.
  98056. */
  98057. isStarted(): boolean;
  98058. /**
  98059. * Animates the particle system for this frame.
  98060. */
  98061. animate(): void;
  98062. /**
  98063. * Renders the particle system in its current state.
  98064. * @returns the current number of particles
  98065. */
  98066. render(): number;
  98067. /**
  98068. * Dispose the particle system and frees its associated resources.
  98069. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  98070. */
  98071. dispose(disposeTexture?: boolean): void;
  98072. /**
  98073. * An event triggered when the system is disposed
  98074. */
  98075. onDisposeObservable: Observable<IParticleSystem>;
  98076. /**
  98077. * An event triggered when the system is stopped
  98078. */
  98079. onStoppedObservable: Observable<IParticleSystem>;
  98080. /**
  98081. * Clones the particle system.
  98082. * @param name The name of the cloned object
  98083. * @param newEmitter The new emitter to use
  98084. * @returns the cloned particle system
  98085. */
  98086. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  98087. /**
  98088. * Serializes the particle system to a JSON object
  98089. * @param serializeTexture defines if the texture must be serialized as well
  98090. * @returns the JSON object
  98091. */
  98092. serialize(serializeTexture: boolean): any;
  98093. /**
  98094. * Rebuild the particle system
  98095. */
  98096. rebuild(): void;
  98097. /** Force the system to rebuild all gradients that need to be resync */
  98098. forceRefreshGradients(): void;
  98099. /**
  98100. * Starts the particle system and begins to emit
  98101. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  98102. */
  98103. start(delay?: number): void;
  98104. /**
  98105. * Stops the particle system.
  98106. */
  98107. stop(): void;
  98108. /**
  98109. * Remove all active particles
  98110. */
  98111. reset(): void;
  98112. /**
  98113. * Gets a boolean indicating that the system is stopping
  98114. * @returns true if the system is currently stopping
  98115. */
  98116. isStopping(): boolean;
  98117. /**
  98118. * Is this system ready to be used/rendered
  98119. * @return true if the system is ready
  98120. */
  98121. isReady(): boolean;
  98122. /**
  98123. * Returns the string "ParticleSystem"
  98124. * @returns a string containing the class name
  98125. */
  98126. getClassName(): string;
  98127. /**
  98128. * Gets the custom effect used to render the particles
  98129. * @param blendMode Blend mode for which the effect should be retrieved
  98130. * @returns The effect
  98131. */
  98132. getCustomEffect(blendMode: number): Nullable<Effect>;
  98133. /**
  98134. * Sets the custom effect used to render the particles
  98135. * @param effect The effect to set
  98136. * @param blendMode Blend mode for which the effect should be set
  98137. */
  98138. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  98139. /**
  98140. * Fill the defines array according to the current settings of the particle system
  98141. * @param defines Array to be updated
  98142. * @param blendMode blend mode to take into account when updating the array
  98143. */
  98144. fillDefines(defines: Array<string>, blendMode: number): void;
  98145. /**
  98146. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  98147. * @param uniforms Uniforms array to fill
  98148. * @param attributes Attributes array to fill
  98149. * @param samplers Samplers array to fill
  98150. */
  98151. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  98152. /**
  98153. * Observable that will be called just before the particles are drawn
  98154. */
  98155. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  98156. /**
  98157. * Gets the name of the particle vertex shader
  98158. */
  98159. vertexShaderName: string;
  98160. /**
  98161. * Adds a new color gradient
  98162. * @param gradient defines the gradient to use (between 0 and 1)
  98163. * @param color1 defines the color to affect to the specified gradient
  98164. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  98165. * @returns the current particle system
  98166. */
  98167. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  98168. /**
  98169. * Remove a specific color gradient
  98170. * @param gradient defines the gradient to remove
  98171. * @returns the current particle system
  98172. */
  98173. removeColorGradient(gradient: number): IParticleSystem;
  98174. /**
  98175. * Adds a new size gradient
  98176. * @param gradient defines the gradient to use (between 0 and 1)
  98177. * @param factor defines the size factor to affect to the specified gradient
  98178. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98179. * @returns the current particle system
  98180. */
  98181. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98182. /**
  98183. * Remove a specific size gradient
  98184. * @param gradient defines the gradient to remove
  98185. * @returns the current particle system
  98186. */
  98187. removeSizeGradient(gradient: number): IParticleSystem;
  98188. /**
  98189. * Gets the current list of color gradients.
  98190. * You must use addColorGradient and removeColorGradient to udpate this list
  98191. * @returns the list of color gradients
  98192. */
  98193. getColorGradients(): Nullable<Array<ColorGradient>>;
  98194. /**
  98195. * Gets the current list of size gradients.
  98196. * You must use addSizeGradient and removeSizeGradient to udpate this list
  98197. * @returns the list of size gradients
  98198. */
  98199. getSizeGradients(): Nullable<Array<FactorGradient>>;
  98200. /**
  98201. * Gets the current list of angular speed gradients.
  98202. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  98203. * @returns the list of angular speed gradients
  98204. */
  98205. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  98206. /**
  98207. * Adds a new angular speed gradient
  98208. * @param gradient defines the gradient to use (between 0 and 1)
  98209. * @param factor defines the angular speed to affect to the specified gradient
  98210. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98211. * @returns the current particle system
  98212. */
  98213. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98214. /**
  98215. * Remove a specific angular speed gradient
  98216. * @param gradient defines the gradient to remove
  98217. * @returns the current particle system
  98218. */
  98219. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  98220. /**
  98221. * Gets the current list of velocity gradients.
  98222. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  98223. * @returns the list of velocity gradients
  98224. */
  98225. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  98226. /**
  98227. * Adds a new velocity gradient
  98228. * @param gradient defines the gradient to use (between 0 and 1)
  98229. * @param factor defines the velocity to affect to the specified gradient
  98230. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98231. * @returns the current particle system
  98232. */
  98233. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98234. /**
  98235. * Remove a specific velocity gradient
  98236. * @param gradient defines the gradient to remove
  98237. * @returns the current particle system
  98238. */
  98239. removeVelocityGradient(gradient: number): IParticleSystem;
  98240. /**
  98241. * Gets the current list of limit velocity gradients.
  98242. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  98243. * @returns the list of limit velocity gradients
  98244. */
  98245. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  98246. /**
  98247. * Adds a new limit velocity gradient
  98248. * @param gradient defines the gradient to use (between 0 and 1)
  98249. * @param factor defines the limit velocity to affect to the specified gradient
  98250. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98251. * @returns the current particle system
  98252. */
  98253. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98254. /**
  98255. * Remove a specific limit velocity gradient
  98256. * @param gradient defines the gradient to remove
  98257. * @returns the current particle system
  98258. */
  98259. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  98260. /**
  98261. * Adds a new drag gradient
  98262. * @param gradient defines the gradient to use (between 0 and 1)
  98263. * @param factor defines the drag to affect to the specified gradient
  98264. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98265. * @returns the current particle system
  98266. */
  98267. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98268. /**
  98269. * Remove a specific drag gradient
  98270. * @param gradient defines the gradient to remove
  98271. * @returns the current particle system
  98272. */
  98273. removeDragGradient(gradient: number): IParticleSystem;
  98274. /**
  98275. * Gets the current list of drag gradients.
  98276. * You must use addDragGradient and removeDragGradient to udpate this list
  98277. * @returns the list of drag gradients
  98278. */
  98279. getDragGradients(): Nullable<Array<FactorGradient>>;
  98280. /**
  98281. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  98282. * @param gradient defines the gradient to use (between 0 and 1)
  98283. * @param factor defines the emit rate to affect to the specified gradient
  98284. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98285. * @returns the current particle system
  98286. */
  98287. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98288. /**
  98289. * Remove a specific emit rate gradient
  98290. * @param gradient defines the gradient to remove
  98291. * @returns the current particle system
  98292. */
  98293. removeEmitRateGradient(gradient: number): IParticleSystem;
  98294. /**
  98295. * Gets the current list of emit rate gradients.
  98296. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  98297. * @returns the list of emit rate gradients
  98298. */
  98299. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  98300. /**
  98301. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  98302. * @param gradient defines the gradient to use (between 0 and 1)
  98303. * @param factor defines the start size to affect to the specified gradient
  98304. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98305. * @returns the current particle system
  98306. */
  98307. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98308. /**
  98309. * Remove a specific start size gradient
  98310. * @param gradient defines the gradient to remove
  98311. * @returns the current particle system
  98312. */
  98313. removeStartSizeGradient(gradient: number): IParticleSystem;
  98314. /**
  98315. * Gets the current list of start size gradients.
  98316. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  98317. * @returns the list of start size gradients
  98318. */
  98319. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  98320. /**
  98321. * Adds a new life time gradient
  98322. * @param gradient defines the gradient to use (between 0 and 1)
  98323. * @param factor defines the life time factor to affect to the specified gradient
  98324. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98325. * @returns the current particle system
  98326. */
  98327. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98328. /**
  98329. * Remove a specific life time gradient
  98330. * @param gradient defines the gradient to remove
  98331. * @returns the current particle system
  98332. */
  98333. removeLifeTimeGradient(gradient: number): IParticleSystem;
  98334. /**
  98335. * Gets the current list of life time gradients.
  98336. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  98337. * @returns the list of life time gradients
  98338. */
  98339. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  98340. /**
  98341. * Gets the current list of color gradients.
  98342. * You must use addColorGradient and removeColorGradient to udpate this list
  98343. * @returns the list of color gradients
  98344. */
  98345. getColorGradients(): Nullable<Array<ColorGradient>>;
  98346. /**
  98347. * Adds a new ramp gradient used to remap particle colors
  98348. * @param gradient defines the gradient to use (between 0 and 1)
  98349. * @param color defines the color to affect to the specified gradient
  98350. * @returns the current particle system
  98351. */
  98352. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  98353. /**
  98354. * Gets the current list of ramp gradients.
  98355. * You must use addRampGradient and removeRampGradient to udpate this list
  98356. * @returns the list of ramp gradients
  98357. */
  98358. getRampGradients(): Nullable<Array<Color3Gradient>>;
  98359. /** Gets or sets a boolean indicating that ramp gradients must be used
  98360. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  98361. */
  98362. useRampGradients: boolean;
  98363. /**
  98364. * Adds a new color remap gradient
  98365. * @param gradient defines the gradient to use (between 0 and 1)
  98366. * @param min defines the color remap minimal range
  98367. * @param max defines the color remap maximal range
  98368. * @returns the current particle system
  98369. */
  98370. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  98371. /**
  98372. * Gets the current list of color remap gradients.
  98373. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  98374. * @returns the list of color remap gradients
  98375. */
  98376. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  98377. /**
  98378. * Adds a new alpha remap gradient
  98379. * @param gradient defines the gradient to use (between 0 and 1)
  98380. * @param min defines the alpha remap minimal range
  98381. * @param max defines the alpha remap maximal range
  98382. * @returns the current particle system
  98383. */
  98384. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  98385. /**
  98386. * Gets the current list of alpha remap gradients.
  98387. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  98388. * @returns the list of alpha remap gradients
  98389. */
  98390. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  98391. /**
  98392. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  98393. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  98394. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  98395. * @returns the emitter
  98396. */
  98397. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  98398. /**
  98399. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  98400. * @param radius The radius of the hemisphere to emit from
  98401. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  98402. * @returns the emitter
  98403. */
  98404. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  98405. /**
  98406. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  98407. * @param radius The radius of the sphere to emit from
  98408. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  98409. * @returns the emitter
  98410. */
  98411. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  98412. /**
  98413. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  98414. * @param radius The radius of the sphere to emit from
  98415. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  98416. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  98417. * @returns the emitter
  98418. */
  98419. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  98420. /**
  98421. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  98422. * @param radius The radius of the emission cylinder
  98423. * @param height The height of the emission cylinder
  98424. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  98425. * @param directionRandomizer How much to randomize the particle direction [0-1]
  98426. * @returns the emitter
  98427. */
  98428. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  98429. /**
  98430. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  98431. * @param radius The radius of the cylinder to emit from
  98432. * @param height The height of the emission cylinder
  98433. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  98434. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  98435. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  98436. * @returns the emitter
  98437. */
  98438. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  98439. /**
  98440. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  98441. * @param radius The radius of the cone to emit from
  98442. * @param angle The base angle of the cone
  98443. * @returns the emitter
  98444. */
  98445. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  98446. /**
  98447. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  98448. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  98449. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  98450. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  98451. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  98452. * @returns the emitter
  98453. */
  98454. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  98455. /**
  98456. * Get hosting scene
  98457. * @returns the scene
  98458. */
  98459. getScene(): Nullable<Scene>;
  98460. }
  98461. }
  98462. declare module BABYLON {
  98463. /**
  98464. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  98465. */
  98466. export class ColorSplitterBlock extends NodeMaterialBlock {
  98467. /**
  98468. * Create a new ColorSplitterBlock
  98469. * @param name defines the block name
  98470. */
  98471. constructor(name: string);
  98472. /**
  98473. * Gets the current class name
  98474. * @returns the class name
  98475. */
  98476. getClassName(): string;
  98477. /**
  98478. * Gets the rgba component (input)
  98479. */
  98480. get rgba(): NodeMaterialConnectionPoint;
  98481. /**
  98482. * Gets the rgb component (input)
  98483. */
  98484. get rgbIn(): NodeMaterialConnectionPoint;
  98485. /**
  98486. * Gets the rgb component (output)
  98487. */
  98488. get rgbOut(): NodeMaterialConnectionPoint;
  98489. /**
  98490. * Gets the r component (output)
  98491. */
  98492. get r(): NodeMaterialConnectionPoint;
  98493. /**
  98494. * Gets the g component (output)
  98495. */
  98496. get g(): NodeMaterialConnectionPoint;
  98497. /**
  98498. * Gets the b component (output)
  98499. */
  98500. get b(): NodeMaterialConnectionPoint;
  98501. /**
  98502. * Gets the a component (output)
  98503. */
  98504. get a(): NodeMaterialConnectionPoint;
  98505. protected _inputRename(name: string): string;
  98506. protected _outputRename(name: string): string;
  98507. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98508. }
  98509. }
  98510. declare module BABYLON {
  98511. /**
  98512. * Operations supported by the Trigonometry block
  98513. */
  98514. export enum TrigonometryBlockOperations {
  98515. /** Cos */
  98516. Cos = 0,
  98517. /** Sin */
  98518. Sin = 1,
  98519. /** Abs */
  98520. Abs = 2,
  98521. /** Exp */
  98522. Exp = 3,
  98523. /** Exp2 */
  98524. Exp2 = 4,
  98525. /** Round */
  98526. Round = 5,
  98527. /** Floor */
  98528. Floor = 6,
  98529. /** Ceiling */
  98530. Ceiling = 7,
  98531. /** Square root */
  98532. Sqrt = 8,
  98533. /** Log */
  98534. Log = 9,
  98535. /** Tangent */
  98536. Tan = 10,
  98537. /** Arc tangent */
  98538. ArcTan = 11,
  98539. /** Arc cosinus */
  98540. ArcCos = 12,
  98541. /** Arc sinus */
  98542. ArcSin = 13,
  98543. /** Fraction */
  98544. Fract = 14,
  98545. /** Sign */
  98546. Sign = 15,
  98547. /** To radians (from degrees) */
  98548. Radians = 16,
  98549. /** To degrees (from radians) */
  98550. Degrees = 17
  98551. }
  98552. /**
  98553. * Block used to apply trigonometry operation to floats
  98554. */
  98555. export class TrigonometryBlock extends NodeMaterialBlock {
  98556. /**
  98557. * Gets or sets the operation applied by the block
  98558. */
  98559. operation: TrigonometryBlockOperations;
  98560. /**
  98561. * Creates a new TrigonometryBlock
  98562. * @param name defines the block name
  98563. */
  98564. constructor(name: string);
  98565. /**
  98566. * Gets the current class name
  98567. * @returns the class name
  98568. */
  98569. getClassName(): string;
  98570. /**
  98571. * Gets the input component
  98572. */
  98573. get input(): NodeMaterialConnectionPoint;
  98574. /**
  98575. * Gets the output component
  98576. */
  98577. get output(): NodeMaterialConnectionPoint;
  98578. protected _buildBlock(state: NodeMaterialBuildState): this;
  98579. serialize(): any;
  98580. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98581. protected _dumpPropertiesCode(): string;
  98582. }
  98583. }
  98584. declare module BABYLON {
  98585. /**
  98586. * Interface used to configure the node material editor
  98587. */
  98588. export interface INodeMaterialEditorOptions {
  98589. /** Define the URl to load node editor script */
  98590. editorURL?: string;
  98591. }
  98592. /** @hidden */
  98593. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98594. NORMAL: boolean;
  98595. TANGENT: boolean;
  98596. UV1: boolean;
  98597. /** BONES */
  98598. NUM_BONE_INFLUENCERS: number;
  98599. BonesPerMesh: number;
  98600. BONETEXTURE: boolean;
  98601. /** MORPH TARGETS */
  98602. MORPHTARGETS: boolean;
  98603. MORPHTARGETS_NORMAL: boolean;
  98604. MORPHTARGETS_TANGENT: boolean;
  98605. MORPHTARGETS_UV: boolean;
  98606. NUM_MORPH_INFLUENCERS: number;
  98607. /** IMAGE PROCESSING */
  98608. IMAGEPROCESSING: boolean;
  98609. VIGNETTE: boolean;
  98610. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98611. VIGNETTEBLENDMODEOPAQUE: boolean;
  98612. TONEMAPPING: boolean;
  98613. TONEMAPPING_ACES: boolean;
  98614. CONTRAST: boolean;
  98615. EXPOSURE: boolean;
  98616. COLORCURVES: boolean;
  98617. COLORGRADING: boolean;
  98618. COLORGRADING3D: boolean;
  98619. SAMPLER3DGREENDEPTH: boolean;
  98620. SAMPLER3DBGRMAP: boolean;
  98621. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98622. /** MISC. */
  98623. BUMPDIRECTUV: number;
  98624. constructor();
  98625. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  98626. }
  98627. /**
  98628. * Class used to configure NodeMaterial
  98629. */
  98630. export interface INodeMaterialOptions {
  98631. /**
  98632. * Defines if blocks should emit comments
  98633. */
  98634. emitComments: boolean;
  98635. }
  98636. /**
  98637. * Class used to create a node based material built by assembling shader blocks
  98638. */
  98639. export class NodeMaterial extends PushMaterial {
  98640. private static _BuildIdGenerator;
  98641. private _options;
  98642. private _vertexCompilationState;
  98643. private _fragmentCompilationState;
  98644. private _sharedData;
  98645. private _buildId;
  98646. private _buildWasSuccessful;
  98647. private _cachedWorldViewMatrix;
  98648. private _cachedWorldViewProjectionMatrix;
  98649. private _optimizers;
  98650. private _animationFrame;
  98651. /** Define the Url to load node editor script */
  98652. static EditorURL: string;
  98653. /** Define the Url to load snippets */
  98654. static SnippetUrl: string;
  98655. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  98656. static IgnoreTexturesAtLoadTime: boolean;
  98657. private BJSNODEMATERIALEDITOR;
  98658. /** Get the inspector from bundle or global */
  98659. private _getGlobalNodeMaterialEditor;
  98660. /**
  98661. * Snippet ID if the material was created from the snippet server
  98662. */
  98663. snippetId: string;
  98664. /**
  98665. * Gets or sets data used by visual editor
  98666. * @see https://nme.babylonjs.com
  98667. */
  98668. editorData: any;
  98669. /**
  98670. * 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)
  98671. */
  98672. ignoreAlpha: boolean;
  98673. /**
  98674. * Defines the maximum number of lights that can be used in the material
  98675. */
  98676. maxSimultaneousLights: number;
  98677. /**
  98678. * Observable raised when the material is built
  98679. */
  98680. onBuildObservable: Observable<NodeMaterial>;
  98681. /**
  98682. * Gets or sets the root nodes of the material vertex shader
  98683. */
  98684. _vertexOutputNodes: NodeMaterialBlock[];
  98685. /**
  98686. * Gets or sets the root nodes of the material fragment (pixel) shader
  98687. */
  98688. _fragmentOutputNodes: NodeMaterialBlock[];
  98689. /** Gets or sets options to control the node material overall behavior */
  98690. get options(): INodeMaterialOptions;
  98691. set options(options: INodeMaterialOptions);
  98692. /**
  98693. * Default configuration related to image processing available in the standard Material.
  98694. */
  98695. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98696. /**
  98697. * Gets the image processing configuration used either in this material.
  98698. */
  98699. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  98700. /**
  98701. * Sets the Default image processing configuration used either in the this material.
  98702. *
  98703. * If sets to null, the scene one is in use.
  98704. */
  98705. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  98706. /**
  98707. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  98708. */
  98709. attachedBlocks: NodeMaterialBlock[];
  98710. /**
  98711. * Specifies the mode of the node material
  98712. * @hidden
  98713. */
  98714. _mode: NodeMaterialModes;
  98715. /**
  98716. * Gets the mode property
  98717. */
  98718. get mode(): NodeMaterialModes;
  98719. /**
  98720. * A free comment about the material
  98721. */
  98722. comment: string;
  98723. /**
  98724. * Create a new node based material
  98725. * @param name defines the material name
  98726. * @param scene defines the hosting scene
  98727. * @param options defines creation option
  98728. */
  98729. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  98730. /**
  98731. * Gets the current class name of the material e.g. "NodeMaterial"
  98732. * @returns the class name
  98733. */
  98734. getClassName(): string;
  98735. /**
  98736. * Keep track of the image processing observer to allow dispose and replace.
  98737. */
  98738. private _imageProcessingObserver;
  98739. /**
  98740. * Attaches a new image processing configuration to the Standard Material.
  98741. * @param configuration
  98742. */
  98743. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98744. /**
  98745. * Get a block by its name
  98746. * @param name defines the name of the block to retrieve
  98747. * @returns the required block or null if not found
  98748. */
  98749. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  98750. /**
  98751. * Get a block by its name
  98752. * @param predicate defines the predicate used to find the good candidate
  98753. * @returns the required block or null if not found
  98754. */
  98755. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  98756. /**
  98757. * Get an input block by its name
  98758. * @param predicate defines the predicate used to find the good candidate
  98759. * @returns the required input block or null if not found
  98760. */
  98761. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  98762. /**
  98763. * Gets the list of input blocks attached to this material
  98764. * @returns an array of InputBlocks
  98765. */
  98766. getInputBlocks(): InputBlock[];
  98767. /**
  98768. * Adds a new optimizer to the list of optimizers
  98769. * @param optimizer defines the optimizers to add
  98770. * @returns the current material
  98771. */
  98772. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  98773. /**
  98774. * Remove an optimizer from the list of optimizers
  98775. * @param optimizer defines the optimizers to remove
  98776. * @returns the current material
  98777. */
  98778. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  98779. /**
  98780. * Add a new block to the list of output nodes
  98781. * @param node defines the node to add
  98782. * @returns the current material
  98783. */
  98784. addOutputNode(node: NodeMaterialBlock): this;
  98785. /**
  98786. * Remove a block from the list of root nodes
  98787. * @param node defines the node to remove
  98788. * @returns the current material
  98789. */
  98790. removeOutputNode(node: NodeMaterialBlock): this;
  98791. private _addVertexOutputNode;
  98792. private _removeVertexOutputNode;
  98793. private _addFragmentOutputNode;
  98794. private _removeFragmentOutputNode;
  98795. /**
  98796. * Specifies if the material will require alpha blending
  98797. * @returns a boolean specifying if alpha blending is needed
  98798. */
  98799. needAlphaBlending(): boolean;
  98800. /**
  98801. * Specifies if this material should be rendered in alpha test mode
  98802. * @returns a boolean specifying if an alpha test is needed.
  98803. */
  98804. needAlphaTesting(): boolean;
  98805. private _initializeBlock;
  98806. private _resetDualBlocks;
  98807. /**
  98808. * Remove a block from the current node material
  98809. * @param block defines the block to remove
  98810. */
  98811. removeBlock(block: NodeMaterialBlock): void;
  98812. /**
  98813. * Build the material and generates the inner effect
  98814. * @param verbose defines if the build should log activity
  98815. */
  98816. build(verbose?: boolean): void;
  98817. /**
  98818. * Runs an otpimization phase to try to improve the shader code
  98819. */
  98820. optimize(): void;
  98821. private _prepareDefinesForAttributes;
  98822. /**
  98823. * Create a post process from the material
  98824. * @param camera The camera to apply the render pass to.
  98825. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  98826. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  98827. * @param engine The engine which the post process will be applied. (default: current engine)
  98828. * @param reusable If the post process can be reused on the same frame. (default: false)
  98829. * @param textureType Type of textures used when performing the post process. (default: 0)
  98830. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  98831. * @returns the post process created
  98832. */
  98833. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  98834. /**
  98835. * Create the post process effect from the material
  98836. * @param postProcess The post process to create the effect for
  98837. */
  98838. createEffectForPostProcess(postProcess: PostProcess): void;
  98839. private _createEffectForPostProcess;
  98840. /**
  98841. * Create a new procedural texture based on this node material
  98842. * @param size defines the size of the texture
  98843. * @param scene defines the hosting scene
  98844. * @returns the new procedural texture attached to this node material
  98845. */
  98846. createProceduralTexture(size: number | {
  98847. width: number;
  98848. height: number;
  98849. layers?: number;
  98850. }, scene: Scene): Nullable<ProceduralTexture>;
  98851. private _createEffectForParticles;
  98852. private _checkInternals;
  98853. /**
  98854. * Create the effect to be used as the custom effect for a particle system
  98855. * @param particleSystem Particle system to create the effect for
  98856. * @param onCompiled defines a function to call when the effect creation is successful
  98857. * @param onError defines a function to call when the effect creation has failed
  98858. */
  98859. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  98860. private _processDefines;
  98861. /**
  98862. * Get if the submesh is ready to be used and all its information available.
  98863. * Child classes can use it to update shaders
  98864. * @param mesh defines the mesh to check
  98865. * @param subMesh defines which submesh to check
  98866. * @param useInstances specifies that instances should be used
  98867. * @returns a boolean indicating that the submesh is ready or not
  98868. */
  98869. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98870. /**
  98871. * Get a string representing the shaders built by the current node graph
  98872. */
  98873. get compiledShaders(): string;
  98874. /**
  98875. * Binds the world matrix to the material
  98876. * @param world defines the world transformation matrix
  98877. */
  98878. bindOnlyWorldMatrix(world: Matrix): void;
  98879. /**
  98880. * Binds the submesh to this material by preparing the effect and shader to draw
  98881. * @param world defines the world transformation matrix
  98882. * @param mesh defines the mesh containing the submesh
  98883. * @param subMesh defines the submesh to bind the material to
  98884. */
  98885. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98886. /**
  98887. * Gets the active textures from the material
  98888. * @returns an array of textures
  98889. */
  98890. getActiveTextures(): BaseTexture[];
  98891. /**
  98892. * Gets the list of texture blocks
  98893. * @returns an array of texture blocks
  98894. */
  98895. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  98896. /**
  98897. * Specifies if the material uses a texture
  98898. * @param texture defines the texture to check against the material
  98899. * @returns a boolean specifying if the material uses the texture
  98900. */
  98901. hasTexture(texture: BaseTexture): boolean;
  98902. /**
  98903. * Disposes the material
  98904. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98905. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98906. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  98907. */
  98908. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  98909. /** Creates the node editor window. */
  98910. private _createNodeEditor;
  98911. /**
  98912. * Launch the node material editor
  98913. * @param config Define the configuration of the editor
  98914. * @return a promise fulfilled when the node editor is visible
  98915. */
  98916. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  98917. /**
  98918. * Clear the current material
  98919. */
  98920. clear(): void;
  98921. /**
  98922. * Clear the current material and set it to a default state
  98923. */
  98924. setToDefault(): void;
  98925. /**
  98926. * Clear the current material and set it to a default state for post process
  98927. */
  98928. setToDefaultPostProcess(): void;
  98929. /**
  98930. * Clear the current material and set it to a default state for procedural texture
  98931. */
  98932. setToDefaultProceduralTexture(): void;
  98933. /**
  98934. * Clear the current material and set it to a default state for particle
  98935. */
  98936. setToDefaultParticle(): void;
  98937. /**
  98938. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  98939. * @param url defines the url to load from
  98940. * @returns a promise that will fullfil when the material is fully loaded
  98941. */
  98942. loadAsync(url: string): Promise<void>;
  98943. private _gatherBlocks;
  98944. /**
  98945. * Generate a string containing the code declaration required to create an equivalent of this material
  98946. * @returns a string
  98947. */
  98948. generateCode(): string;
  98949. /**
  98950. * Serializes this material in a JSON representation
  98951. * @returns the serialized material object
  98952. */
  98953. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  98954. private _restoreConnections;
  98955. /**
  98956. * Clear the current graph and load a new one from a serialization object
  98957. * @param source defines the JSON representation of the material
  98958. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98959. * @param merge defines whether or not the source must be merged or replace the current content
  98960. */
  98961. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  98962. /**
  98963. * Makes a duplicate of the current material.
  98964. * @param name - name to use for the new material.
  98965. */
  98966. clone(name: string): NodeMaterial;
  98967. /**
  98968. * Creates a node material from parsed material data
  98969. * @param source defines the JSON representation of the material
  98970. * @param scene defines the hosting scene
  98971. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98972. * @returns a new node material
  98973. */
  98974. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  98975. /**
  98976. * Creates a node material from a snippet saved in a remote file
  98977. * @param name defines the name of the material to create
  98978. * @param url defines the url to load from
  98979. * @param scene defines the hosting scene
  98980. * @returns a promise that will resolve to the new node material
  98981. */
  98982. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  98983. /**
  98984. * Creates a node material from a snippet saved by the node material editor
  98985. * @param snippetId defines the snippet to load
  98986. * @param scene defines the hosting scene
  98987. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98988. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  98989. * @returns a promise that will resolve to the new node material
  98990. */
  98991. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  98992. /**
  98993. * Creates a new node material set to default basic configuration
  98994. * @param name defines the name of the material
  98995. * @param scene defines the hosting scene
  98996. * @returns a new NodeMaterial
  98997. */
  98998. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  98999. }
  99000. }
  99001. declare module BABYLON {
  99002. interface ThinEngine {
  99003. /**
  99004. * Unbind a list of render target textures from the webGL context
  99005. * This is used only when drawBuffer extension or webGL2 are active
  99006. * @param textures defines the render target textures to unbind
  99007. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  99008. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  99009. */
  99010. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  99011. /**
  99012. * Create a multi render target texture
  99013. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  99014. * @param size defines the size of the texture
  99015. * @param options defines the creation options
  99016. * @returns the cube texture as an InternalTexture
  99017. */
  99018. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  99019. /**
  99020. * Update the sample count for a given multiple render target texture
  99021. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  99022. * @param textures defines the textures to update
  99023. * @param samples defines the sample count to set
  99024. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  99025. */
  99026. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  99027. /**
  99028. * Select a subsets of attachments to draw to.
  99029. * @param attachments gl attachments
  99030. */
  99031. bindAttachments(attachments: number[]): void;
  99032. /**
  99033. * Creates a layout object to draw/clear on specific textures in a MRT
  99034. * @param textureStatus textureStatus[i] indicates if the i-th is active
  99035. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  99036. */
  99037. buildTextureLayout(textureStatus: boolean[]): number[];
  99038. /**
  99039. * Restores the webgl state to only draw on the main color attachment
  99040. */
  99041. restoreSingleAttachment(): void;
  99042. }
  99043. }
  99044. declare module BABYLON {
  99045. /**
  99046. * Creation options of the multi render target texture.
  99047. */
  99048. export interface IMultiRenderTargetOptions {
  99049. /**
  99050. * Define if the texture needs to create mip maps after render.
  99051. */
  99052. generateMipMaps?: boolean;
  99053. /**
  99054. * Define the types of all the draw buffers we want to create
  99055. */
  99056. types?: number[];
  99057. /**
  99058. * Define the sampling modes of all the draw buffers we want to create
  99059. */
  99060. samplingModes?: number[];
  99061. /**
  99062. * Define if a depth buffer is required
  99063. */
  99064. generateDepthBuffer?: boolean;
  99065. /**
  99066. * Define if a stencil buffer is required
  99067. */
  99068. generateStencilBuffer?: boolean;
  99069. /**
  99070. * Define if a depth texture is required instead of a depth buffer
  99071. */
  99072. generateDepthTexture?: boolean;
  99073. /**
  99074. * Define the number of desired draw buffers
  99075. */
  99076. textureCount?: number;
  99077. /**
  99078. * Define if aspect ratio should be adapted to the texture or stay the scene one
  99079. */
  99080. doNotChangeAspectRatio?: boolean;
  99081. /**
  99082. * Define the default type of the buffers we are creating
  99083. */
  99084. defaultType?: number;
  99085. }
  99086. /**
  99087. * A multi render target, like a render target provides the ability to render to a texture.
  99088. * Unlike the render target, it can render to several draw buffers in one draw.
  99089. * This is specially interesting in deferred rendering or for any effects requiring more than
  99090. * just one color from a single pass.
  99091. */
  99092. export class MultiRenderTarget extends RenderTargetTexture {
  99093. private _internalTextures;
  99094. private _textures;
  99095. private _multiRenderTargetOptions;
  99096. private _count;
  99097. /**
  99098. * Get if draw buffers are currently supported by the used hardware and browser.
  99099. */
  99100. get isSupported(): boolean;
  99101. /**
  99102. * Get the list of textures generated by the multi render target.
  99103. */
  99104. get textures(): Texture[];
  99105. /**
  99106. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  99107. */
  99108. get count(): number;
  99109. /**
  99110. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  99111. */
  99112. get depthTexture(): Texture;
  99113. /**
  99114. * Set the wrapping mode on U of all the textures we are rendering to.
  99115. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  99116. */
  99117. set wrapU(wrap: number);
  99118. /**
  99119. * Set the wrapping mode on V of all the textures we are rendering to.
  99120. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  99121. */
  99122. set wrapV(wrap: number);
  99123. /**
  99124. * Instantiate a new multi render target texture.
  99125. * A multi render target, like a render target provides the ability to render to a texture.
  99126. * Unlike the render target, it can render to several draw buffers in one draw.
  99127. * This is specially interesting in deferred rendering or for any effects requiring more than
  99128. * just one color from a single pass.
  99129. * @param name Define the name of the texture
  99130. * @param size Define the size of the buffers to render to
  99131. * @param count Define the number of target we are rendering into
  99132. * @param scene Define the scene the texture belongs to
  99133. * @param options Define the options used to create the multi render target
  99134. */
  99135. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  99136. private _initTypes;
  99137. /** @hidden */
  99138. _rebuild(forceFullRebuild?: boolean): void;
  99139. private _createInternalTextures;
  99140. private _createTextures;
  99141. /**
  99142. * Replaces a texture within the MRT.
  99143. * @param texture The new texture to insert in the MRT
  99144. * @param index The index of the texture to replace
  99145. */
  99146. replaceTexture(texture: Texture, index: number): void;
  99147. /**
  99148. * Define the number of samples used if MSAA is enabled.
  99149. */
  99150. get samples(): number;
  99151. set samples(value: number);
  99152. /**
  99153. * Resize all the textures in the multi render target.
  99154. * Be careful as it will recreate all the data in the new texture.
  99155. * @param size Define the new size
  99156. */
  99157. resize(size: any): void;
  99158. /**
  99159. * Changes the number of render targets in this MRT
  99160. * Be careful as it will recreate all the data in the new texture.
  99161. * @param count new texture count
  99162. * @param options Specifies texture types and sampling modes for new textures
  99163. */
  99164. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  99165. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  99166. /**
  99167. * Dispose the render targets and their associated resources
  99168. */
  99169. dispose(): void;
  99170. /**
  99171. * Release all the underlying texture used as draw buffers.
  99172. */
  99173. releaseInternalTextures(): void;
  99174. }
  99175. }
  99176. declare module BABYLON {
  99177. /** @hidden */
  99178. export var imageProcessingPixelShader: {
  99179. name: string;
  99180. shader: string;
  99181. };
  99182. }
  99183. declare module BABYLON {
  99184. /**
  99185. * ImageProcessingPostProcess
  99186. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  99187. */
  99188. export class ImageProcessingPostProcess extends PostProcess {
  99189. /**
  99190. * Default configuration related to image processing available in the PBR Material.
  99191. */
  99192. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99193. /**
  99194. * Gets the image processing configuration used either in this material.
  99195. */
  99196. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99197. /**
  99198. * Sets the Default image processing configuration used either in the this material.
  99199. *
  99200. * If sets to null, the scene one is in use.
  99201. */
  99202. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99203. /**
  99204. * Keep track of the image processing observer to allow dispose and replace.
  99205. */
  99206. private _imageProcessingObserver;
  99207. /**
  99208. * Attaches a new image processing configuration to the PBR Material.
  99209. * @param configuration
  99210. */
  99211. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  99212. /**
  99213. * If the post process is supported.
  99214. */
  99215. get isSupported(): boolean;
  99216. /**
  99217. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99218. */
  99219. get colorCurves(): Nullable<ColorCurves>;
  99220. /**
  99221. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99222. */
  99223. set colorCurves(value: Nullable<ColorCurves>);
  99224. /**
  99225. * Gets wether the color curves effect is enabled.
  99226. */
  99227. get colorCurvesEnabled(): boolean;
  99228. /**
  99229. * Sets wether the color curves effect is enabled.
  99230. */
  99231. set colorCurvesEnabled(value: boolean);
  99232. /**
  99233. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99234. */
  99235. get colorGradingTexture(): Nullable<BaseTexture>;
  99236. /**
  99237. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99238. */
  99239. set colorGradingTexture(value: Nullable<BaseTexture>);
  99240. /**
  99241. * Gets wether the color grading effect is enabled.
  99242. */
  99243. get colorGradingEnabled(): boolean;
  99244. /**
  99245. * Gets wether the color grading effect is enabled.
  99246. */
  99247. set colorGradingEnabled(value: boolean);
  99248. /**
  99249. * Gets exposure used in the effect.
  99250. */
  99251. get exposure(): number;
  99252. /**
  99253. * Sets exposure used in the effect.
  99254. */
  99255. set exposure(value: number);
  99256. /**
  99257. * Gets wether tonemapping is enabled or not.
  99258. */
  99259. get toneMappingEnabled(): boolean;
  99260. /**
  99261. * Sets wether tonemapping is enabled or not
  99262. */
  99263. set toneMappingEnabled(value: boolean);
  99264. /**
  99265. * Gets the type of tone mapping effect.
  99266. */
  99267. get toneMappingType(): number;
  99268. /**
  99269. * Sets the type of tone mapping effect.
  99270. */
  99271. set toneMappingType(value: number);
  99272. /**
  99273. * Gets contrast used in the effect.
  99274. */
  99275. get contrast(): number;
  99276. /**
  99277. * Sets contrast used in the effect.
  99278. */
  99279. set contrast(value: number);
  99280. /**
  99281. * Gets Vignette stretch size.
  99282. */
  99283. get vignetteStretch(): number;
  99284. /**
  99285. * Sets Vignette stretch size.
  99286. */
  99287. set vignetteStretch(value: number);
  99288. /**
  99289. * Gets Vignette centre X Offset.
  99290. */
  99291. get vignetteCentreX(): number;
  99292. /**
  99293. * Sets Vignette centre X Offset.
  99294. */
  99295. set vignetteCentreX(value: number);
  99296. /**
  99297. * Gets Vignette centre Y Offset.
  99298. */
  99299. get vignetteCentreY(): number;
  99300. /**
  99301. * Sets Vignette centre Y Offset.
  99302. */
  99303. set vignetteCentreY(value: number);
  99304. /**
  99305. * Gets Vignette weight or intensity of the vignette effect.
  99306. */
  99307. get vignetteWeight(): number;
  99308. /**
  99309. * Sets Vignette weight or intensity of the vignette effect.
  99310. */
  99311. set vignetteWeight(value: number);
  99312. /**
  99313. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99314. * if vignetteEnabled is set to true.
  99315. */
  99316. get vignetteColor(): Color4;
  99317. /**
  99318. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99319. * if vignetteEnabled is set to true.
  99320. */
  99321. set vignetteColor(value: Color4);
  99322. /**
  99323. * Gets Camera field of view used by the Vignette effect.
  99324. */
  99325. get vignetteCameraFov(): number;
  99326. /**
  99327. * Sets Camera field of view used by the Vignette effect.
  99328. */
  99329. set vignetteCameraFov(value: number);
  99330. /**
  99331. * Gets the vignette blend mode allowing different kind of effect.
  99332. */
  99333. get vignetteBlendMode(): number;
  99334. /**
  99335. * Sets the vignette blend mode allowing different kind of effect.
  99336. */
  99337. set vignetteBlendMode(value: number);
  99338. /**
  99339. * Gets wether the vignette effect is enabled.
  99340. */
  99341. get vignetteEnabled(): boolean;
  99342. /**
  99343. * Sets wether the vignette effect is enabled.
  99344. */
  99345. set vignetteEnabled(value: boolean);
  99346. private _fromLinearSpace;
  99347. /**
  99348. * Gets wether the input of the processing is in Gamma or Linear Space.
  99349. */
  99350. get fromLinearSpace(): boolean;
  99351. /**
  99352. * Sets wether the input of the processing is in Gamma or Linear Space.
  99353. */
  99354. set fromLinearSpace(value: boolean);
  99355. /**
  99356. * Defines cache preventing GC.
  99357. */
  99358. private _defines;
  99359. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  99360. /**
  99361. * "ImageProcessingPostProcess"
  99362. * @returns "ImageProcessingPostProcess"
  99363. */
  99364. getClassName(): string;
  99365. /**
  99366. * @hidden
  99367. */
  99368. _updateParameters(): void;
  99369. dispose(camera?: Camera): void;
  99370. }
  99371. }
  99372. declare module BABYLON {
  99373. /**
  99374. * Interface for defining prepass effects in the prepass post-process pipeline
  99375. */
  99376. export interface PrePassEffectConfiguration {
  99377. /**
  99378. * Name of the effect
  99379. */
  99380. name: string;
  99381. /**
  99382. * Post process to attach for this effect
  99383. */
  99384. postProcess?: PostProcess;
  99385. /**
  99386. * Textures required in the MRT
  99387. */
  99388. texturesRequired: number[];
  99389. /**
  99390. * Is the effect enabled
  99391. */
  99392. enabled: boolean;
  99393. /**
  99394. * Disposes the effect configuration
  99395. */
  99396. dispose?: () => void;
  99397. /**
  99398. * Creates the associated post process
  99399. */
  99400. createPostProcess?: () => PostProcess;
  99401. }
  99402. }
  99403. declare module BABYLON {
  99404. /**
  99405. * Options to be used when creating a FresnelParameters.
  99406. */
  99407. export type IFresnelParametersCreationOptions = {
  99408. /**
  99409. * Define the color used on edges (grazing angle)
  99410. */
  99411. leftColor?: Color3;
  99412. /**
  99413. * Define the color used on center
  99414. */
  99415. rightColor?: Color3;
  99416. /**
  99417. * Define bias applied to computed fresnel term
  99418. */
  99419. bias?: number;
  99420. /**
  99421. * Defined the power exponent applied to fresnel term
  99422. */
  99423. power?: number;
  99424. /**
  99425. * Define if the fresnel effect is enable or not.
  99426. */
  99427. isEnabled?: boolean;
  99428. };
  99429. /**
  99430. * Serialized format for FresnelParameters.
  99431. */
  99432. export type IFresnelParametersSerialized = {
  99433. /**
  99434. * Define the color used on edges (grazing angle) [as an array]
  99435. */
  99436. leftColor: number[];
  99437. /**
  99438. * Define the color used on center [as an array]
  99439. */
  99440. rightColor: number[];
  99441. /**
  99442. * Define bias applied to computed fresnel term
  99443. */
  99444. bias: number;
  99445. /**
  99446. * Defined the power exponent applied to fresnel term
  99447. */
  99448. power?: number;
  99449. /**
  99450. * Define if the fresnel effect is enable or not.
  99451. */
  99452. isEnabled: boolean;
  99453. };
  99454. /**
  99455. * This represents all the required information to add a fresnel effect on a material:
  99456. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99457. */
  99458. export class FresnelParameters {
  99459. private _isEnabled;
  99460. /**
  99461. * Define if the fresnel effect is enable or not.
  99462. */
  99463. get isEnabled(): boolean;
  99464. set isEnabled(value: boolean);
  99465. /**
  99466. * Define the color used on edges (grazing angle)
  99467. */
  99468. leftColor: Color3;
  99469. /**
  99470. * Define the color used on center
  99471. */
  99472. rightColor: Color3;
  99473. /**
  99474. * Define bias applied to computed fresnel term
  99475. */
  99476. bias: number;
  99477. /**
  99478. * Defined the power exponent applied to fresnel term
  99479. */
  99480. power: number;
  99481. /**
  99482. * Creates a new FresnelParameters object.
  99483. *
  99484. * @param options provide your own settings to optionally to override defaults
  99485. */
  99486. constructor(options?: IFresnelParametersCreationOptions);
  99487. /**
  99488. * Clones the current fresnel and its valuues
  99489. * @returns a clone fresnel configuration
  99490. */
  99491. clone(): FresnelParameters;
  99492. /**
  99493. * Determines equality between FresnelParameters objects
  99494. * @param otherFresnelParameters defines the second operand
  99495. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  99496. */
  99497. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  99498. /**
  99499. * Serializes the current fresnel parameters to a JSON representation.
  99500. * @return the JSON serialization
  99501. */
  99502. serialize(): IFresnelParametersSerialized;
  99503. /**
  99504. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99505. * @param parsedFresnelParameters Define the JSON representation
  99506. * @returns the parsed parameters
  99507. */
  99508. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  99509. }
  99510. }
  99511. declare module BABYLON {
  99512. /**
  99513. * This groups all the flags used to control the materials channel.
  99514. */
  99515. export class MaterialFlags {
  99516. private static _DiffuseTextureEnabled;
  99517. /**
  99518. * Are diffuse textures enabled in the application.
  99519. */
  99520. static get DiffuseTextureEnabled(): boolean;
  99521. static set DiffuseTextureEnabled(value: boolean);
  99522. private static _DetailTextureEnabled;
  99523. /**
  99524. * Are detail textures enabled in the application.
  99525. */
  99526. static get DetailTextureEnabled(): boolean;
  99527. static set DetailTextureEnabled(value: boolean);
  99528. private static _AmbientTextureEnabled;
  99529. /**
  99530. * Are ambient textures enabled in the application.
  99531. */
  99532. static get AmbientTextureEnabled(): boolean;
  99533. static set AmbientTextureEnabled(value: boolean);
  99534. private static _OpacityTextureEnabled;
  99535. /**
  99536. * Are opacity textures enabled in the application.
  99537. */
  99538. static get OpacityTextureEnabled(): boolean;
  99539. static set OpacityTextureEnabled(value: boolean);
  99540. private static _ReflectionTextureEnabled;
  99541. /**
  99542. * Are reflection textures enabled in the application.
  99543. */
  99544. static get ReflectionTextureEnabled(): boolean;
  99545. static set ReflectionTextureEnabled(value: boolean);
  99546. private static _EmissiveTextureEnabled;
  99547. /**
  99548. * Are emissive textures enabled in the application.
  99549. */
  99550. static get EmissiveTextureEnabled(): boolean;
  99551. static set EmissiveTextureEnabled(value: boolean);
  99552. private static _SpecularTextureEnabled;
  99553. /**
  99554. * Are specular textures enabled in the application.
  99555. */
  99556. static get SpecularTextureEnabled(): boolean;
  99557. static set SpecularTextureEnabled(value: boolean);
  99558. private static _BumpTextureEnabled;
  99559. /**
  99560. * Are bump textures enabled in the application.
  99561. */
  99562. static get BumpTextureEnabled(): boolean;
  99563. static set BumpTextureEnabled(value: boolean);
  99564. private static _LightmapTextureEnabled;
  99565. /**
  99566. * Are lightmap textures enabled in the application.
  99567. */
  99568. static get LightmapTextureEnabled(): boolean;
  99569. static set LightmapTextureEnabled(value: boolean);
  99570. private static _RefractionTextureEnabled;
  99571. /**
  99572. * Are refraction textures enabled in the application.
  99573. */
  99574. static get RefractionTextureEnabled(): boolean;
  99575. static set RefractionTextureEnabled(value: boolean);
  99576. private static _ColorGradingTextureEnabled;
  99577. /**
  99578. * Are color grading textures enabled in the application.
  99579. */
  99580. static get ColorGradingTextureEnabled(): boolean;
  99581. static set ColorGradingTextureEnabled(value: boolean);
  99582. private static _FresnelEnabled;
  99583. /**
  99584. * Are fresnels enabled in the application.
  99585. */
  99586. static get FresnelEnabled(): boolean;
  99587. static set FresnelEnabled(value: boolean);
  99588. private static _ClearCoatTextureEnabled;
  99589. /**
  99590. * Are clear coat textures enabled in the application.
  99591. */
  99592. static get ClearCoatTextureEnabled(): boolean;
  99593. static set ClearCoatTextureEnabled(value: boolean);
  99594. private static _ClearCoatBumpTextureEnabled;
  99595. /**
  99596. * Are clear coat bump textures enabled in the application.
  99597. */
  99598. static get ClearCoatBumpTextureEnabled(): boolean;
  99599. static set ClearCoatBumpTextureEnabled(value: boolean);
  99600. private static _ClearCoatTintTextureEnabled;
  99601. /**
  99602. * Are clear coat tint textures enabled in the application.
  99603. */
  99604. static get ClearCoatTintTextureEnabled(): boolean;
  99605. static set ClearCoatTintTextureEnabled(value: boolean);
  99606. private static _SheenTextureEnabled;
  99607. /**
  99608. * Are sheen textures enabled in the application.
  99609. */
  99610. static get SheenTextureEnabled(): boolean;
  99611. static set SheenTextureEnabled(value: boolean);
  99612. private static _AnisotropicTextureEnabled;
  99613. /**
  99614. * Are anisotropic textures enabled in the application.
  99615. */
  99616. static get AnisotropicTextureEnabled(): boolean;
  99617. static set AnisotropicTextureEnabled(value: boolean);
  99618. private static _ThicknessTextureEnabled;
  99619. /**
  99620. * Are thickness textures enabled in the application.
  99621. */
  99622. static get ThicknessTextureEnabled(): boolean;
  99623. static set ThicknessTextureEnabled(value: boolean);
  99624. }
  99625. }
  99626. declare module BABYLON {
  99627. /** @hidden */
  99628. export var defaultFragmentDeclaration: {
  99629. name: string;
  99630. shader: string;
  99631. };
  99632. }
  99633. declare module BABYLON {
  99634. /** @hidden */
  99635. export var defaultUboDeclaration: {
  99636. name: string;
  99637. shader: string;
  99638. };
  99639. }
  99640. declare module BABYLON {
  99641. /** @hidden */
  99642. export var prePassDeclaration: {
  99643. name: string;
  99644. shader: string;
  99645. };
  99646. }
  99647. declare module BABYLON {
  99648. /** @hidden */
  99649. export var lightFragmentDeclaration: {
  99650. name: string;
  99651. shader: string;
  99652. };
  99653. }
  99654. declare module BABYLON {
  99655. /** @hidden */
  99656. export var lightUboDeclaration: {
  99657. name: string;
  99658. shader: string;
  99659. };
  99660. }
  99661. declare module BABYLON {
  99662. /** @hidden */
  99663. export var lightsFragmentFunctions: {
  99664. name: string;
  99665. shader: string;
  99666. };
  99667. }
  99668. declare module BABYLON {
  99669. /** @hidden */
  99670. export var shadowsFragmentFunctions: {
  99671. name: string;
  99672. shader: string;
  99673. };
  99674. }
  99675. declare module BABYLON {
  99676. /** @hidden */
  99677. export var fresnelFunction: {
  99678. name: string;
  99679. shader: string;
  99680. };
  99681. }
  99682. declare module BABYLON {
  99683. /** @hidden */
  99684. export var bumpFragmentMainFunctions: {
  99685. name: string;
  99686. shader: string;
  99687. };
  99688. }
  99689. declare module BABYLON {
  99690. /** @hidden */
  99691. export var bumpFragmentFunctions: {
  99692. name: string;
  99693. shader: string;
  99694. };
  99695. }
  99696. declare module BABYLON {
  99697. /** @hidden */
  99698. export var logDepthDeclaration: {
  99699. name: string;
  99700. shader: string;
  99701. };
  99702. }
  99703. declare module BABYLON {
  99704. /** @hidden */
  99705. export var fogFragmentDeclaration: {
  99706. name: string;
  99707. shader: string;
  99708. };
  99709. }
  99710. declare module BABYLON {
  99711. /** @hidden */
  99712. export var bumpFragment: {
  99713. name: string;
  99714. shader: string;
  99715. };
  99716. }
  99717. declare module BABYLON {
  99718. /** @hidden */
  99719. export var depthPrePass: {
  99720. name: string;
  99721. shader: string;
  99722. };
  99723. }
  99724. declare module BABYLON {
  99725. /** @hidden */
  99726. export var lightFragment: {
  99727. name: string;
  99728. shader: string;
  99729. };
  99730. }
  99731. declare module BABYLON {
  99732. /** @hidden */
  99733. export var logDepthFragment: {
  99734. name: string;
  99735. shader: string;
  99736. };
  99737. }
  99738. declare module BABYLON {
  99739. /** @hidden */
  99740. export var fogFragment: {
  99741. name: string;
  99742. shader: string;
  99743. };
  99744. }
  99745. declare module BABYLON {
  99746. /** @hidden */
  99747. export var defaultPixelShader: {
  99748. name: string;
  99749. shader: string;
  99750. };
  99751. }
  99752. declare module BABYLON {
  99753. /** @hidden */
  99754. export var defaultVertexDeclaration: {
  99755. name: string;
  99756. shader: string;
  99757. };
  99758. }
  99759. declare module BABYLON {
  99760. /** @hidden */
  99761. export var bonesDeclaration: {
  99762. name: string;
  99763. shader: string;
  99764. };
  99765. }
  99766. declare module BABYLON {
  99767. /** @hidden */
  99768. export var instancesDeclaration: {
  99769. name: string;
  99770. shader: string;
  99771. };
  99772. }
  99773. declare module BABYLON {
  99774. /** @hidden */
  99775. export var prePassVertexDeclaration: {
  99776. name: string;
  99777. shader: string;
  99778. };
  99779. }
  99780. declare module BABYLON {
  99781. /** @hidden */
  99782. export var bumpVertexDeclaration: {
  99783. name: string;
  99784. shader: string;
  99785. };
  99786. }
  99787. declare module BABYLON {
  99788. /** @hidden */
  99789. export var fogVertexDeclaration: {
  99790. name: string;
  99791. shader: string;
  99792. };
  99793. }
  99794. declare module BABYLON {
  99795. /** @hidden */
  99796. export var morphTargetsVertexGlobalDeclaration: {
  99797. name: string;
  99798. shader: string;
  99799. };
  99800. }
  99801. declare module BABYLON {
  99802. /** @hidden */
  99803. export var morphTargetsVertexDeclaration: {
  99804. name: string;
  99805. shader: string;
  99806. };
  99807. }
  99808. declare module BABYLON {
  99809. /** @hidden */
  99810. export var morphTargetsVertex: {
  99811. name: string;
  99812. shader: string;
  99813. };
  99814. }
  99815. declare module BABYLON {
  99816. /** @hidden */
  99817. export var instancesVertex: {
  99818. name: string;
  99819. shader: string;
  99820. };
  99821. }
  99822. declare module BABYLON {
  99823. /** @hidden */
  99824. export var bonesVertex: {
  99825. name: string;
  99826. shader: string;
  99827. };
  99828. }
  99829. declare module BABYLON {
  99830. /** @hidden */
  99831. export var prePassVertex: {
  99832. name: string;
  99833. shader: string;
  99834. };
  99835. }
  99836. declare module BABYLON {
  99837. /** @hidden */
  99838. export var bumpVertex: {
  99839. name: string;
  99840. shader: string;
  99841. };
  99842. }
  99843. declare module BABYLON {
  99844. /** @hidden */
  99845. export var fogVertex: {
  99846. name: string;
  99847. shader: string;
  99848. };
  99849. }
  99850. declare module BABYLON {
  99851. /** @hidden */
  99852. export var shadowsVertex: {
  99853. name: string;
  99854. shader: string;
  99855. };
  99856. }
  99857. declare module BABYLON {
  99858. /** @hidden */
  99859. export var pointCloudVertex: {
  99860. name: string;
  99861. shader: string;
  99862. };
  99863. }
  99864. declare module BABYLON {
  99865. /** @hidden */
  99866. export var logDepthVertex: {
  99867. name: string;
  99868. shader: string;
  99869. };
  99870. }
  99871. declare module BABYLON {
  99872. /** @hidden */
  99873. export var defaultVertexShader: {
  99874. name: string;
  99875. shader: string;
  99876. };
  99877. }
  99878. declare module BABYLON {
  99879. /**
  99880. * @hidden
  99881. */
  99882. export interface IMaterialDetailMapDefines {
  99883. DETAIL: boolean;
  99884. DETAILDIRECTUV: number;
  99885. DETAIL_NORMALBLENDMETHOD: number;
  99886. /** @hidden */
  99887. _areTexturesDirty: boolean;
  99888. }
  99889. /**
  99890. * Define the code related to the detail map parameters of a material
  99891. *
  99892. * Inspired from:
  99893. * 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
  99894. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  99895. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  99896. */
  99897. export class DetailMapConfiguration {
  99898. private _texture;
  99899. /**
  99900. * The detail texture of the material.
  99901. */
  99902. texture: Nullable<BaseTexture>;
  99903. /**
  99904. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  99905. * Bigger values mean stronger blending
  99906. */
  99907. diffuseBlendLevel: number;
  99908. /**
  99909. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  99910. * Bigger values mean stronger blending. Only used with PBR materials
  99911. */
  99912. roughnessBlendLevel: number;
  99913. /**
  99914. * Defines how strong the bump effect from the detail map is
  99915. * Bigger values mean stronger effect
  99916. */
  99917. bumpLevel: number;
  99918. private _normalBlendMethod;
  99919. /**
  99920. * The method used to blend the bump and detail normals together
  99921. */
  99922. normalBlendMethod: number;
  99923. private _isEnabled;
  99924. /**
  99925. * Enable or disable the detail map on this material
  99926. */
  99927. isEnabled: boolean;
  99928. /** @hidden */
  99929. private _internalMarkAllSubMeshesAsTexturesDirty;
  99930. /** @hidden */
  99931. _markAllSubMeshesAsTexturesDirty(): void;
  99932. /**
  99933. * Instantiate a new detail map
  99934. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  99935. */
  99936. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  99937. /**
  99938. * Gets whether the submesh is ready to be used or not.
  99939. * @param defines the list of "defines" to update.
  99940. * @param scene defines the scene the material belongs to.
  99941. * @returns - boolean indicating that the submesh is ready or not.
  99942. */
  99943. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  99944. /**
  99945. * Update the defines for detail map usage
  99946. * @param defines the list of "defines" to update.
  99947. * @param scene defines the scene the material belongs to.
  99948. */
  99949. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  99950. /**
  99951. * Binds the material data.
  99952. * @param uniformBuffer defines the Uniform buffer to fill in.
  99953. * @param scene defines the scene the material belongs to.
  99954. * @param isFrozen defines whether the material is frozen or not.
  99955. */
  99956. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  99957. /**
  99958. * Checks to see if a texture is used in the material.
  99959. * @param texture - Base texture to use.
  99960. * @returns - Boolean specifying if a texture is used in the material.
  99961. */
  99962. hasTexture(texture: BaseTexture): boolean;
  99963. /**
  99964. * Returns an array of the actively used textures.
  99965. * @param activeTextures Array of BaseTextures
  99966. */
  99967. getActiveTextures(activeTextures: BaseTexture[]): void;
  99968. /**
  99969. * Returns the animatable textures.
  99970. * @param animatables Array of animatable textures.
  99971. */
  99972. getAnimatables(animatables: IAnimatable[]): void;
  99973. /**
  99974. * Disposes the resources of the material.
  99975. * @param forceDisposeTextures - Forces the disposal of all textures.
  99976. */
  99977. dispose(forceDisposeTextures?: boolean): void;
  99978. /**
  99979. * Get the current class name useful for serialization or dynamic coding.
  99980. * @returns "DetailMap"
  99981. */
  99982. getClassName(): string;
  99983. /**
  99984. * Add the required uniforms to the current list.
  99985. * @param uniforms defines the current uniform list.
  99986. */
  99987. static AddUniforms(uniforms: string[]): void;
  99988. /**
  99989. * Add the required samplers to the current list.
  99990. * @param samplers defines the current sampler list.
  99991. */
  99992. static AddSamplers(samplers: string[]): void;
  99993. /**
  99994. * Add the required uniforms to the current buffer.
  99995. * @param uniformBuffer defines the current uniform buffer.
  99996. */
  99997. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  99998. /**
  99999. * Makes a duplicate of the current instance into another one.
  100000. * @param detailMap define the instance where to copy the info
  100001. */
  100002. copyTo(detailMap: DetailMapConfiguration): void;
  100003. /**
  100004. * Serializes this detail map instance
  100005. * @returns - An object with the serialized instance.
  100006. */
  100007. serialize(): any;
  100008. /**
  100009. * Parses a detail map setting from a serialized object.
  100010. * @param source - Serialized object.
  100011. * @param scene Defines the scene we are parsing for
  100012. * @param rootUrl Defines the rootUrl to load from
  100013. */
  100014. parse(source: any, scene: Scene, rootUrl: string): void;
  100015. }
  100016. }
  100017. declare module BABYLON {
  100018. /** @hidden */
  100019. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  100020. MAINUV1: boolean;
  100021. MAINUV2: boolean;
  100022. DIFFUSE: boolean;
  100023. DIFFUSEDIRECTUV: number;
  100024. DETAIL: boolean;
  100025. DETAILDIRECTUV: number;
  100026. DETAIL_NORMALBLENDMETHOD: number;
  100027. AMBIENT: boolean;
  100028. AMBIENTDIRECTUV: number;
  100029. OPACITY: boolean;
  100030. OPACITYDIRECTUV: number;
  100031. OPACITYRGB: boolean;
  100032. REFLECTION: boolean;
  100033. EMISSIVE: boolean;
  100034. EMISSIVEDIRECTUV: number;
  100035. SPECULAR: boolean;
  100036. SPECULARDIRECTUV: number;
  100037. BUMP: boolean;
  100038. BUMPDIRECTUV: number;
  100039. PARALLAX: boolean;
  100040. PARALLAXOCCLUSION: boolean;
  100041. SPECULAROVERALPHA: boolean;
  100042. CLIPPLANE: boolean;
  100043. CLIPPLANE2: boolean;
  100044. CLIPPLANE3: boolean;
  100045. CLIPPLANE4: boolean;
  100046. CLIPPLANE5: boolean;
  100047. CLIPPLANE6: boolean;
  100048. ALPHATEST: boolean;
  100049. DEPTHPREPASS: boolean;
  100050. ALPHAFROMDIFFUSE: boolean;
  100051. POINTSIZE: boolean;
  100052. FOG: boolean;
  100053. SPECULARTERM: boolean;
  100054. DIFFUSEFRESNEL: boolean;
  100055. OPACITYFRESNEL: boolean;
  100056. REFLECTIONFRESNEL: boolean;
  100057. REFRACTIONFRESNEL: boolean;
  100058. EMISSIVEFRESNEL: boolean;
  100059. FRESNEL: boolean;
  100060. NORMAL: boolean;
  100061. UV1: boolean;
  100062. UV2: boolean;
  100063. VERTEXCOLOR: boolean;
  100064. VERTEXALPHA: boolean;
  100065. NUM_BONE_INFLUENCERS: number;
  100066. BonesPerMesh: number;
  100067. BONETEXTURE: boolean;
  100068. BONES_VELOCITY_ENABLED: boolean;
  100069. INSTANCES: boolean;
  100070. THIN_INSTANCES: boolean;
  100071. GLOSSINESS: boolean;
  100072. ROUGHNESS: boolean;
  100073. EMISSIVEASILLUMINATION: boolean;
  100074. LINKEMISSIVEWITHDIFFUSE: boolean;
  100075. REFLECTIONFRESNELFROMSPECULAR: boolean;
  100076. LIGHTMAP: boolean;
  100077. LIGHTMAPDIRECTUV: number;
  100078. OBJECTSPACE_NORMALMAP: boolean;
  100079. USELIGHTMAPASSHADOWMAP: boolean;
  100080. REFLECTIONMAP_3D: boolean;
  100081. REFLECTIONMAP_SPHERICAL: boolean;
  100082. REFLECTIONMAP_PLANAR: boolean;
  100083. REFLECTIONMAP_CUBIC: boolean;
  100084. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  100085. REFLECTIONMAP_PROJECTION: boolean;
  100086. REFLECTIONMAP_SKYBOX: boolean;
  100087. REFLECTIONMAP_EXPLICIT: boolean;
  100088. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  100089. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  100090. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  100091. INVERTCUBICMAP: boolean;
  100092. LOGARITHMICDEPTH: boolean;
  100093. REFRACTION: boolean;
  100094. REFRACTIONMAP_3D: boolean;
  100095. REFLECTIONOVERALPHA: boolean;
  100096. TWOSIDEDLIGHTING: boolean;
  100097. SHADOWFLOAT: boolean;
  100098. MORPHTARGETS: boolean;
  100099. MORPHTARGETS_NORMAL: boolean;
  100100. MORPHTARGETS_TANGENT: boolean;
  100101. MORPHTARGETS_UV: boolean;
  100102. NUM_MORPH_INFLUENCERS: number;
  100103. NONUNIFORMSCALING: boolean;
  100104. PREMULTIPLYALPHA: boolean;
  100105. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  100106. ALPHABLEND: boolean;
  100107. PREPASS: boolean;
  100108. PREPASS_IRRADIANCE: boolean;
  100109. PREPASS_IRRADIANCE_INDEX: number;
  100110. PREPASS_ALBEDO: boolean;
  100111. PREPASS_ALBEDO_INDEX: number;
  100112. PREPASS_DEPTHNORMAL: boolean;
  100113. PREPASS_DEPTHNORMAL_INDEX: number;
  100114. PREPASS_POSITION: boolean;
  100115. PREPASS_POSITION_INDEX: number;
  100116. PREPASS_VELOCITY: boolean;
  100117. PREPASS_VELOCITY_INDEX: number;
  100118. PREPASS_REFLECTIVITY: boolean;
  100119. PREPASS_REFLECTIVITY_INDEX: number;
  100120. SCENE_MRT_COUNT: number;
  100121. RGBDLIGHTMAP: boolean;
  100122. RGBDREFLECTION: boolean;
  100123. RGBDREFRACTION: boolean;
  100124. IMAGEPROCESSING: boolean;
  100125. VIGNETTE: boolean;
  100126. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100127. VIGNETTEBLENDMODEOPAQUE: boolean;
  100128. TONEMAPPING: boolean;
  100129. TONEMAPPING_ACES: boolean;
  100130. CONTRAST: boolean;
  100131. COLORCURVES: boolean;
  100132. COLORGRADING: boolean;
  100133. COLORGRADING3D: boolean;
  100134. SAMPLER3DGREENDEPTH: boolean;
  100135. SAMPLER3DBGRMAP: boolean;
  100136. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100137. MULTIVIEW: boolean;
  100138. /**
  100139. * If the reflection texture on this material is in linear color space
  100140. * @hidden
  100141. */
  100142. IS_REFLECTION_LINEAR: boolean;
  100143. /**
  100144. * If the refraction texture on this material is in linear color space
  100145. * @hidden
  100146. */
  100147. IS_REFRACTION_LINEAR: boolean;
  100148. EXPOSURE: boolean;
  100149. constructor();
  100150. setReflectionMode(modeToEnable: string): void;
  100151. }
  100152. /**
  100153. * This is the default material used in Babylon. It is the best trade off between quality
  100154. * and performances.
  100155. * @see https://doc.babylonjs.com/babylon101/materials
  100156. */
  100157. export class StandardMaterial extends PushMaterial {
  100158. private _diffuseTexture;
  100159. /**
  100160. * The basic texture of the material as viewed under a light.
  100161. */
  100162. diffuseTexture: Nullable<BaseTexture>;
  100163. private _ambientTexture;
  100164. /**
  100165. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  100166. */
  100167. ambientTexture: Nullable<BaseTexture>;
  100168. private _opacityTexture;
  100169. /**
  100170. * Define the transparency of the material from a texture.
  100171. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  100172. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  100173. */
  100174. opacityTexture: Nullable<BaseTexture>;
  100175. private _reflectionTexture;
  100176. /**
  100177. * Define the texture used to display the reflection.
  100178. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100179. */
  100180. reflectionTexture: Nullable<BaseTexture>;
  100181. private _emissiveTexture;
  100182. /**
  100183. * Define texture of the material as if self lit.
  100184. * This will be mixed in the final result even in the absence of light.
  100185. */
  100186. emissiveTexture: Nullable<BaseTexture>;
  100187. private _specularTexture;
  100188. /**
  100189. * Define how the color and intensity of the highlight given by the light in the material.
  100190. */
  100191. specularTexture: Nullable<BaseTexture>;
  100192. private _bumpTexture;
  100193. /**
  100194. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  100195. * 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.
  100196. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  100197. */
  100198. bumpTexture: Nullable<BaseTexture>;
  100199. private _lightmapTexture;
  100200. /**
  100201. * Complex lighting can be computationally expensive to compute at runtime.
  100202. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  100203. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  100204. */
  100205. lightmapTexture: Nullable<BaseTexture>;
  100206. private _refractionTexture;
  100207. /**
  100208. * Define the texture used to display the refraction.
  100209. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100210. */
  100211. refractionTexture: Nullable<BaseTexture>;
  100212. /**
  100213. * The color of the material lit by the environmental background lighting.
  100214. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  100215. */
  100216. ambientColor: Color3;
  100217. /**
  100218. * The basic color of the material as viewed under a light.
  100219. */
  100220. diffuseColor: Color3;
  100221. /**
  100222. * Define how the color and intensity of the highlight given by the light in the material.
  100223. */
  100224. specularColor: Color3;
  100225. /**
  100226. * Define the color of the material as if self lit.
  100227. * This will be mixed in the final result even in the absence of light.
  100228. */
  100229. emissiveColor: Color3;
  100230. /**
  100231. * Defines how sharp are the highlights in the material.
  100232. * The bigger the value the sharper giving a more glossy feeling to the result.
  100233. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  100234. */
  100235. specularPower: number;
  100236. private _useAlphaFromDiffuseTexture;
  100237. /**
  100238. * Does the transparency come from the diffuse texture alpha channel.
  100239. */
  100240. useAlphaFromDiffuseTexture: boolean;
  100241. private _useEmissiveAsIllumination;
  100242. /**
  100243. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  100244. */
  100245. useEmissiveAsIllumination: boolean;
  100246. private _linkEmissiveWithDiffuse;
  100247. /**
  100248. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  100249. * the emissive level when the final color is close to one.
  100250. */
  100251. linkEmissiveWithDiffuse: boolean;
  100252. private _useSpecularOverAlpha;
  100253. /**
  100254. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  100255. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  100256. */
  100257. useSpecularOverAlpha: boolean;
  100258. private _useReflectionOverAlpha;
  100259. /**
  100260. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  100261. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  100262. */
  100263. useReflectionOverAlpha: boolean;
  100264. private _disableLighting;
  100265. /**
  100266. * Does lights from the scene impacts this material.
  100267. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  100268. */
  100269. disableLighting: boolean;
  100270. private _useObjectSpaceNormalMap;
  100271. /**
  100272. * Allows using an object space normal map (instead of tangent space).
  100273. */
  100274. useObjectSpaceNormalMap: boolean;
  100275. private _useParallax;
  100276. /**
  100277. * Is parallax enabled or not.
  100278. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  100279. */
  100280. useParallax: boolean;
  100281. private _useParallaxOcclusion;
  100282. /**
  100283. * Is parallax occlusion enabled or not.
  100284. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  100285. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  100286. */
  100287. useParallaxOcclusion: boolean;
  100288. /**
  100289. * 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.
  100290. */
  100291. parallaxScaleBias: number;
  100292. private _roughness;
  100293. /**
  100294. * Helps to define how blurry the reflections should appears in the material.
  100295. */
  100296. roughness: number;
  100297. /**
  100298. * In case of refraction, define the value of the index of refraction.
  100299. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100300. */
  100301. indexOfRefraction: number;
  100302. /**
  100303. * Invert the refraction texture alongside the y axis.
  100304. * It can be useful with procedural textures or probe for instance.
  100305. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100306. */
  100307. invertRefractionY: boolean;
  100308. /**
  100309. * Defines the alpha limits in alpha test mode.
  100310. */
  100311. alphaCutOff: number;
  100312. private _useLightmapAsShadowmap;
  100313. /**
  100314. * In case of light mapping, define whether the map contains light or shadow informations.
  100315. */
  100316. useLightmapAsShadowmap: boolean;
  100317. private _diffuseFresnelParameters;
  100318. /**
  100319. * Define the diffuse fresnel parameters of the material.
  100320. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100321. */
  100322. diffuseFresnelParameters: FresnelParameters;
  100323. private _opacityFresnelParameters;
  100324. /**
  100325. * Define the opacity fresnel parameters of the material.
  100326. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100327. */
  100328. opacityFresnelParameters: FresnelParameters;
  100329. private _reflectionFresnelParameters;
  100330. /**
  100331. * Define the reflection fresnel parameters of the material.
  100332. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100333. */
  100334. reflectionFresnelParameters: FresnelParameters;
  100335. private _refractionFresnelParameters;
  100336. /**
  100337. * Define the refraction fresnel parameters of the material.
  100338. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100339. */
  100340. refractionFresnelParameters: FresnelParameters;
  100341. private _emissiveFresnelParameters;
  100342. /**
  100343. * Define the emissive fresnel parameters of the material.
  100344. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100345. */
  100346. emissiveFresnelParameters: FresnelParameters;
  100347. private _useReflectionFresnelFromSpecular;
  100348. /**
  100349. * If true automatically deducts the fresnels values from the material specularity.
  100350. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100351. */
  100352. useReflectionFresnelFromSpecular: boolean;
  100353. private _useGlossinessFromSpecularMapAlpha;
  100354. /**
  100355. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  100356. */
  100357. useGlossinessFromSpecularMapAlpha: boolean;
  100358. private _maxSimultaneousLights;
  100359. /**
  100360. * Defines the maximum number of lights that can be used in the material
  100361. */
  100362. maxSimultaneousLights: number;
  100363. private _invertNormalMapX;
  100364. /**
  100365. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  100366. */
  100367. invertNormalMapX: boolean;
  100368. private _invertNormalMapY;
  100369. /**
  100370. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  100371. */
  100372. invertNormalMapY: boolean;
  100373. private _twoSidedLighting;
  100374. /**
  100375. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  100376. */
  100377. twoSidedLighting: boolean;
  100378. /**
  100379. * Default configuration related to image processing available in the standard Material.
  100380. */
  100381. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100382. /**
  100383. * Gets the image processing configuration used either in this material.
  100384. */
  100385. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  100386. /**
  100387. * Sets the Default image processing configuration used either in the this material.
  100388. *
  100389. * If sets to null, the scene one is in use.
  100390. */
  100391. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  100392. /**
  100393. * Keep track of the image processing observer to allow dispose and replace.
  100394. */
  100395. private _imageProcessingObserver;
  100396. /**
  100397. * Attaches a new image processing configuration to the Standard Material.
  100398. * @param configuration
  100399. */
  100400. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100401. /**
  100402. * Defines additionnal PrePass parameters for the material.
  100403. */
  100404. readonly prePassConfiguration: PrePassConfiguration;
  100405. /**
  100406. * Gets wether the color curves effect is enabled.
  100407. */
  100408. get cameraColorCurvesEnabled(): boolean;
  100409. /**
  100410. * Sets wether the color curves effect is enabled.
  100411. */
  100412. set cameraColorCurvesEnabled(value: boolean);
  100413. /**
  100414. * Gets wether the color grading effect is enabled.
  100415. */
  100416. get cameraColorGradingEnabled(): boolean;
  100417. /**
  100418. * Gets wether the color grading effect is enabled.
  100419. */
  100420. set cameraColorGradingEnabled(value: boolean);
  100421. /**
  100422. * Gets wether tonemapping is enabled or not.
  100423. */
  100424. get cameraToneMappingEnabled(): boolean;
  100425. /**
  100426. * Sets wether tonemapping is enabled or not
  100427. */
  100428. set cameraToneMappingEnabled(value: boolean);
  100429. /**
  100430. * The camera exposure used on this material.
  100431. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100432. * This corresponds to a photographic exposure.
  100433. */
  100434. get cameraExposure(): number;
  100435. /**
  100436. * The camera exposure used on this material.
  100437. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100438. * This corresponds to a photographic exposure.
  100439. */
  100440. set cameraExposure(value: number);
  100441. /**
  100442. * Gets The camera contrast used on this material.
  100443. */
  100444. get cameraContrast(): number;
  100445. /**
  100446. * Sets The camera contrast used on this material.
  100447. */
  100448. set cameraContrast(value: number);
  100449. /**
  100450. * Gets the Color Grading 2D Lookup Texture.
  100451. */
  100452. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  100453. /**
  100454. * Sets the Color Grading 2D Lookup Texture.
  100455. */
  100456. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  100457. /**
  100458. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100459. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100460. * 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;
  100461. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100462. */
  100463. get cameraColorCurves(): Nullable<ColorCurves>;
  100464. /**
  100465. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100466. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100467. * 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;
  100468. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100469. */
  100470. set cameraColorCurves(value: Nullable<ColorCurves>);
  100471. /**
  100472. * Can this material render to several textures at once
  100473. */
  100474. get canRenderToMRT(): boolean;
  100475. /**
  100476. * Defines the detail map parameters for the material.
  100477. */
  100478. readonly detailMap: DetailMapConfiguration;
  100479. protected _renderTargets: SmartArray<RenderTargetTexture>;
  100480. protected _worldViewProjectionMatrix: Matrix;
  100481. protected _globalAmbientColor: Color3;
  100482. protected _useLogarithmicDepth: boolean;
  100483. protected _rebuildInParallel: boolean;
  100484. /**
  100485. * Instantiates a new standard material.
  100486. * This is the default material used in Babylon. It is the best trade off between quality
  100487. * and performances.
  100488. * @see https://doc.babylonjs.com/babylon101/materials
  100489. * @param name Define the name of the material in the scene
  100490. * @param scene Define the scene the material belong to
  100491. */
  100492. constructor(name: string, scene: Scene);
  100493. /**
  100494. * Gets a boolean indicating that current material needs to register RTT
  100495. */
  100496. get hasRenderTargetTextures(): boolean;
  100497. /**
  100498. * Gets the current class name of the material e.g. "StandardMaterial"
  100499. * Mainly use in serialization.
  100500. * @returns the class name
  100501. */
  100502. getClassName(): string;
  100503. /**
  100504. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  100505. * You can try switching to logarithmic depth.
  100506. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  100507. */
  100508. get useLogarithmicDepth(): boolean;
  100509. set useLogarithmicDepth(value: boolean);
  100510. /**
  100511. * Specifies if the material will require alpha blending
  100512. * @returns a boolean specifying if alpha blending is needed
  100513. */
  100514. needAlphaBlending(): boolean;
  100515. /**
  100516. * Specifies if this material should be rendered in alpha test mode
  100517. * @returns a boolean specifying if an alpha test is needed.
  100518. */
  100519. needAlphaTesting(): boolean;
  100520. /**
  100521. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  100522. */
  100523. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  100524. /**
  100525. * Specifies whether or not there is a usable alpha channel for transparency.
  100526. */
  100527. protected _hasAlphaChannel(): boolean;
  100528. /**
  100529. * Get the texture used for alpha test purpose.
  100530. * @returns the diffuse texture in case of the standard material.
  100531. */
  100532. getAlphaTestTexture(): Nullable<BaseTexture>;
  100533. /**
  100534. * Get if the submesh is ready to be used and all its information available.
  100535. * Child classes can use it to update shaders
  100536. * @param mesh defines the mesh to check
  100537. * @param subMesh defines which submesh to check
  100538. * @param useInstances specifies that instances should be used
  100539. * @returns a boolean indicating that the submesh is ready or not
  100540. */
  100541. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100542. /**
  100543. * Builds the material UBO layouts.
  100544. * Used internally during the effect preparation.
  100545. */
  100546. buildUniformLayout(): void;
  100547. /**
  100548. * Unbinds the material from the mesh
  100549. */
  100550. unbind(): void;
  100551. /**
  100552. * Binds the submesh to this material by preparing the effect and shader to draw
  100553. * @param world defines the world transformation matrix
  100554. * @param mesh defines the mesh containing the submesh
  100555. * @param subMesh defines the submesh to bind the material to
  100556. */
  100557. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100558. /**
  100559. * Get the list of animatables in the material.
  100560. * @returns the list of animatables object used in the material
  100561. */
  100562. getAnimatables(): IAnimatable[];
  100563. /**
  100564. * Gets the active textures from the material
  100565. * @returns an array of textures
  100566. */
  100567. getActiveTextures(): BaseTexture[];
  100568. /**
  100569. * Specifies if the material uses a texture
  100570. * @param texture defines the texture to check against the material
  100571. * @returns a boolean specifying if the material uses the texture
  100572. */
  100573. hasTexture(texture: BaseTexture): boolean;
  100574. /**
  100575. * Disposes the material
  100576. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100577. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100578. */
  100579. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100580. /**
  100581. * Makes a duplicate of the material, and gives it a new name
  100582. * @param name defines the new name for the duplicated material
  100583. * @returns the cloned material
  100584. */
  100585. clone(name: string): StandardMaterial;
  100586. /**
  100587. * Serializes this material in a JSON representation
  100588. * @returns the serialized material object
  100589. */
  100590. serialize(): any;
  100591. /**
  100592. * Creates a standard material from parsed material data
  100593. * @param source defines the JSON representation of the material
  100594. * @param scene defines the hosting scene
  100595. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100596. * @returns a new standard material
  100597. */
  100598. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100599. /**
  100600. * Are diffuse textures enabled in the application.
  100601. */
  100602. static get DiffuseTextureEnabled(): boolean;
  100603. static set DiffuseTextureEnabled(value: boolean);
  100604. /**
  100605. * Are detail textures enabled in the application.
  100606. */
  100607. static get DetailTextureEnabled(): boolean;
  100608. static set DetailTextureEnabled(value: boolean);
  100609. /**
  100610. * Are ambient textures enabled in the application.
  100611. */
  100612. static get AmbientTextureEnabled(): boolean;
  100613. static set AmbientTextureEnabled(value: boolean);
  100614. /**
  100615. * Are opacity textures enabled in the application.
  100616. */
  100617. static get OpacityTextureEnabled(): boolean;
  100618. static set OpacityTextureEnabled(value: boolean);
  100619. /**
  100620. * Are reflection textures enabled in the application.
  100621. */
  100622. static get ReflectionTextureEnabled(): boolean;
  100623. static set ReflectionTextureEnabled(value: boolean);
  100624. /**
  100625. * Are emissive textures enabled in the application.
  100626. */
  100627. static get EmissiveTextureEnabled(): boolean;
  100628. static set EmissiveTextureEnabled(value: boolean);
  100629. /**
  100630. * Are specular textures enabled in the application.
  100631. */
  100632. static get SpecularTextureEnabled(): boolean;
  100633. static set SpecularTextureEnabled(value: boolean);
  100634. /**
  100635. * Are bump textures enabled in the application.
  100636. */
  100637. static get BumpTextureEnabled(): boolean;
  100638. static set BumpTextureEnabled(value: boolean);
  100639. /**
  100640. * Are lightmap textures enabled in the application.
  100641. */
  100642. static get LightmapTextureEnabled(): boolean;
  100643. static set LightmapTextureEnabled(value: boolean);
  100644. /**
  100645. * Are refraction textures enabled in the application.
  100646. */
  100647. static get RefractionTextureEnabled(): boolean;
  100648. static set RefractionTextureEnabled(value: boolean);
  100649. /**
  100650. * Are color grading textures enabled in the application.
  100651. */
  100652. static get ColorGradingTextureEnabled(): boolean;
  100653. static set ColorGradingTextureEnabled(value: boolean);
  100654. /**
  100655. * Are fresnels enabled in the application.
  100656. */
  100657. static get FresnelEnabled(): boolean;
  100658. static set FresnelEnabled(value: boolean);
  100659. }
  100660. }
  100661. declare module BABYLON {
  100662. /** @hidden */
  100663. export var rgbdDecodePixelShader: {
  100664. name: string;
  100665. shader: string;
  100666. };
  100667. }
  100668. declare module BABYLON {
  100669. /**
  100670. * Class used to host RGBD texture specific utilities
  100671. */
  100672. export class RGBDTextureTools {
  100673. /**
  100674. * Expand the RGBD Texture from RGBD to Half Float if possible.
  100675. * @param texture the texture to expand.
  100676. */
  100677. static ExpandRGBDTexture(texture: Texture): void;
  100678. }
  100679. }
  100680. declare module BABYLON {
  100681. /**
  100682. * Class used to host texture specific utilities
  100683. */
  100684. export class BRDFTextureTools {
  100685. /**
  100686. * Prevents texture cache collision
  100687. */
  100688. private static _instanceNumber;
  100689. /**
  100690. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  100691. * @param scene defines the hosting scene
  100692. * @returns the environment BRDF texture
  100693. */
  100694. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  100695. private static _environmentBRDFBase64Texture;
  100696. }
  100697. }
  100698. declare module BABYLON {
  100699. /**
  100700. * @hidden
  100701. */
  100702. export interface IMaterialClearCoatDefines {
  100703. CLEARCOAT: boolean;
  100704. CLEARCOAT_DEFAULTIOR: boolean;
  100705. CLEARCOAT_TEXTURE: boolean;
  100706. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  100707. CLEARCOAT_TEXTUREDIRECTUV: number;
  100708. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  100709. CLEARCOAT_BUMP: boolean;
  100710. CLEARCOAT_BUMPDIRECTUV: number;
  100711. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  100712. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  100713. CLEARCOAT_REMAP_F0: boolean;
  100714. CLEARCOAT_TINT: boolean;
  100715. CLEARCOAT_TINT_TEXTURE: boolean;
  100716. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  100717. /** @hidden */
  100718. _areTexturesDirty: boolean;
  100719. }
  100720. /**
  100721. * Define the code related to the clear coat parameters of the pbr material.
  100722. */
  100723. export class PBRClearCoatConfiguration {
  100724. /**
  100725. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100726. * The default fits with a polyurethane material.
  100727. * @hidden
  100728. */
  100729. static readonly _DefaultIndexOfRefraction: number;
  100730. private _isEnabled;
  100731. /**
  100732. * Defines if the clear coat is enabled in the material.
  100733. */
  100734. isEnabled: boolean;
  100735. /**
  100736. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  100737. */
  100738. intensity: number;
  100739. /**
  100740. * Defines the clear coat layer roughness.
  100741. */
  100742. roughness: number;
  100743. private _indexOfRefraction;
  100744. /**
  100745. * Defines the index of refraction of the clear coat.
  100746. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100747. * The default fits with a polyurethane material.
  100748. * Changing the default value is more performance intensive.
  100749. */
  100750. indexOfRefraction: number;
  100751. private _texture;
  100752. /**
  100753. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  100754. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  100755. * if textureRoughness is not empty, else no texture roughness is used
  100756. */
  100757. texture: Nullable<BaseTexture>;
  100758. private _useRoughnessFromMainTexture;
  100759. /**
  100760. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  100761. * If false, the green channel from textureRoughness is used for roughness
  100762. */
  100763. useRoughnessFromMainTexture: boolean;
  100764. private _textureRoughness;
  100765. /**
  100766. * Stores the clear coat roughness in a texture (green channel)
  100767. * Not used if useRoughnessFromMainTexture is true
  100768. */
  100769. textureRoughness: Nullable<BaseTexture>;
  100770. private _remapF0OnInterfaceChange;
  100771. /**
  100772. * Defines if the F0 value should be remapped to account for the interface change in the material.
  100773. */
  100774. remapF0OnInterfaceChange: boolean;
  100775. private _bumpTexture;
  100776. /**
  100777. * Define the clear coat specific bump texture.
  100778. */
  100779. bumpTexture: Nullable<BaseTexture>;
  100780. private _isTintEnabled;
  100781. /**
  100782. * Defines if the clear coat tint is enabled in the material.
  100783. */
  100784. isTintEnabled: boolean;
  100785. /**
  100786. * Defines the clear coat tint of the material.
  100787. * This is only use if tint is enabled
  100788. */
  100789. tintColor: Color3;
  100790. /**
  100791. * Defines the distance at which the tint color should be found in the
  100792. * clear coat media.
  100793. * This is only use if tint is enabled
  100794. */
  100795. tintColorAtDistance: number;
  100796. /**
  100797. * Defines the clear coat layer thickness.
  100798. * This is only use if tint is enabled
  100799. */
  100800. tintThickness: number;
  100801. private _tintTexture;
  100802. /**
  100803. * Stores the clear tint values in a texture.
  100804. * rgb is tint
  100805. * a is a thickness factor
  100806. */
  100807. tintTexture: Nullable<BaseTexture>;
  100808. /** @hidden */
  100809. private _internalMarkAllSubMeshesAsTexturesDirty;
  100810. /** @hidden */
  100811. _markAllSubMeshesAsTexturesDirty(): void;
  100812. /**
  100813. * Instantiate a new istance of clear coat configuration.
  100814. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100815. */
  100816. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100817. /**
  100818. * Gets wehter the submesh is ready to be used or not.
  100819. * @param defines the list of "defines" to update.
  100820. * @param scene defines the scene the material belongs to.
  100821. * @param engine defines the engine the material belongs to.
  100822. * @param disableBumpMap defines wether the material disables bump or not.
  100823. * @returns - boolean indicating that the submesh is ready or not.
  100824. */
  100825. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  100826. /**
  100827. * Checks to see if a texture is used in the material.
  100828. * @param defines the list of "defines" to update.
  100829. * @param scene defines the scene to the material belongs to.
  100830. */
  100831. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  100832. /**
  100833. * Binds the material data.
  100834. * @param uniformBuffer defines the Uniform buffer to fill in.
  100835. * @param scene defines the scene the material belongs to.
  100836. * @param engine defines the engine the material belongs to.
  100837. * @param disableBumpMap defines wether the material disables bump or not.
  100838. * @param isFrozen defines wether the material is frozen or not.
  100839. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  100840. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  100841. * @param subMesh the submesh to bind data for
  100842. */
  100843. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  100844. /**
  100845. * Checks to see if a texture is used in the material.
  100846. * @param texture - Base texture to use.
  100847. * @returns - Boolean specifying if a texture is used in the material.
  100848. */
  100849. hasTexture(texture: BaseTexture): boolean;
  100850. /**
  100851. * Returns an array of the actively used textures.
  100852. * @param activeTextures Array of BaseTextures
  100853. */
  100854. getActiveTextures(activeTextures: BaseTexture[]): void;
  100855. /**
  100856. * Returns the animatable textures.
  100857. * @param animatables Array of animatable textures.
  100858. */
  100859. getAnimatables(animatables: IAnimatable[]): void;
  100860. /**
  100861. * Disposes the resources of the material.
  100862. * @param forceDisposeTextures - Forces the disposal of all textures.
  100863. */
  100864. dispose(forceDisposeTextures?: boolean): void;
  100865. /**
  100866. * Get the current class name of the texture useful for serialization or dynamic coding.
  100867. * @returns "PBRClearCoatConfiguration"
  100868. */
  100869. getClassName(): string;
  100870. /**
  100871. * Add fallbacks to the effect fallbacks list.
  100872. * @param defines defines the Base texture to use.
  100873. * @param fallbacks defines the current fallback list.
  100874. * @param currentRank defines the current fallback rank.
  100875. * @returns the new fallback rank.
  100876. */
  100877. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100878. /**
  100879. * Add the required uniforms to the current list.
  100880. * @param uniforms defines the current uniform list.
  100881. */
  100882. static AddUniforms(uniforms: string[]): void;
  100883. /**
  100884. * Add the required samplers to the current list.
  100885. * @param samplers defines the current sampler list.
  100886. */
  100887. static AddSamplers(samplers: string[]): void;
  100888. /**
  100889. * Add the required uniforms to the current buffer.
  100890. * @param uniformBuffer defines the current uniform buffer.
  100891. */
  100892. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100893. /**
  100894. * Makes a duplicate of the current configuration into another one.
  100895. * @param clearCoatConfiguration define the config where to copy the info
  100896. */
  100897. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  100898. /**
  100899. * Serializes this clear coat configuration.
  100900. * @returns - An object with the serialized config.
  100901. */
  100902. serialize(): any;
  100903. /**
  100904. * Parses a anisotropy Configuration from a serialized object.
  100905. * @param source - Serialized object.
  100906. * @param scene Defines the scene we are parsing for
  100907. * @param rootUrl Defines the rootUrl to load from
  100908. */
  100909. parse(source: any, scene: Scene, rootUrl: string): void;
  100910. }
  100911. }
  100912. declare module BABYLON {
  100913. /**
  100914. * @hidden
  100915. */
  100916. export interface IMaterialAnisotropicDefines {
  100917. ANISOTROPIC: boolean;
  100918. ANISOTROPIC_TEXTURE: boolean;
  100919. ANISOTROPIC_TEXTUREDIRECTUV: number;
  100920. MAINUV1: boolean;
  100921. _areTexturesDirty: boolean;
  100922. _needUVs: boolean;
  100923. }
  100924. /**
  100925. * Define the code related to the anisotropic parameters of the pbr material.
  100926. */
  100927. export class PBRAnisotropicConfiguration {
  100928. private _isEnabled;
  100929. /**
  100930. * Defines if the anisotropy is enabled in the material.
  100931. */
  100932. isEnabled: boolean;
  100933. /**
  100934. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  100935. */
  100936. intensity: number;
  100937. /**
  100938. * Defines if the effect is along the tangents, bitangents or in between.
  100939. * By default, the effect is "strectching" the highlights along the tangents.
  100940. */
  100941. direction: Vector2;
  100942. private _texture;
  100943. /**
  100944. * Stores the anisotropy values in a texture.
  100945. * rg is direction (like normal from -1 to 1)
  100946. * b is a intensity
  100947. */
  100948. texture: Nullable<BaseTexture>;
  100949. /** @hidden */
  100950. private _internalMarkAllSubMeshesAsTexturesDirty;
  100951. /** @hidden */
  100952. _markAllSubMeshesAsTexturesDirty(): void;
  100953. /**
  100954. * Instantiate a new istance of anisotropy configuration.
  100955. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100956. */
  100957. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100958. /**
  100959. * Specifies that the submesh is ready to be used.
  100960. * @param defines the list of "defines" to update.
  100961. * @param scene defines the scene the material belongs to.
  100962. * @returns - boolean indicating that the submesh is ready or not.
  100963. */
  100964. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  100965. /**
  100966. * Checks to see if a texture is used in the material.
  100967. * @param defines the list of "defines" to update.
  100968. * @param mesh the mesh we are preparing the defines for.
  100969. * @param scene defines the scene the material belongs to.
  100970. */
  100971. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  100972. /**
  100973. * Binds the material data.
  100974. * @param uniformBuffer defines the Uniform buffer to fill in.
  100975. * @param scene defines the scene the material belongs to.
  100976. * @param isFrozen defines wether the material is frozen or not.
  100977. */
  100978. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  100979. /**
  100980. * Checks to see if a texture is used in the material.
  100981. * @param texture - Base texture to use.
  100982. * @returns - Boolean specifying if a texture is used in the material.
  100983. */
  100984. hasTexture(texture: BaseTexture): boolean;
  100985. /**
  100986. * Returns an array of the actively used textures.
  100987. * @param activeTextures Array of BaseTextures
  100988. */
  100989. getActiveTextures(activeTextures: BaseTexture[]): void;
  100990. /**
  100991. * Returns the animatable textures.
  100992. * @param animatables Array of animatable textures.
  100993. */
  100994. getAnimatables(animatables: IAnimatable[]): void;
  100995. /**
  100996. * Disposes the resources of the material.
  100997. * @param forceDisposeTextures - Forces the disposal of all textures.
  100998. */
  100999. dispose(forceDisposeTextures?: boolean): void;
  101000. /**
  101001. * Get the current class name of the texture useful for serialization or dynamic coding.
  101002. * @returns "PBRAnisotropicConfiguration"
  101003. */
  101004. getClassName(): string;
  101005. /**
  101006. * Add fallbacks to the effect fallbacks list.
  101007. * @param defines defines the Base texture to use.
  101008. * @param fallbacks defines the current fallback list.
  101009. * @param currentRank defines the current fallback rank.
  101010. * @returns the new fallback rank.
  101011. */
  101012. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101013. /**
  101014. * Add the required uniforms to the current list.
  101015. * @param uniforms defines the current uniform list.
  101016. */
  101017. static AddUniforms(uniforms: string[]): void;
  101018. /**
  101019. * Add the required uniforms to the current buffer.
  101020. * @param uniformBuffer defines the current uniform buffer.
  101021. */
  101022. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101023. /**
  101024. * Add the required samplers to the current list.
  101025. * @param samplers defines the current sampler list.
  101026. */
  101027. static AddSamplers(samplers: string[]): void;
  101028. /**
  101029. * Makes a duplicate of the current configuration into another one.
  101030. * @param anisotropicConfiguration define the config where to copy the info
  101031. */
  101032. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  101033. /**
  101034. * Serializes this anisotropy configuration.
  101035. * @returns - An object with the serialized config.
  101036. */
  101037. serialize(): any;
  101038. /**
  101039. * Parses a anisotropy Configuration from a serialized object.
  101040. * @param source - Serialized object.
  101041. * @param scene Defines the scene we are parsing for
  101042. * @param rootUrl Defines the rootUrl to load from
  101043. */
  101044. parse(source: any, scene: Scene, rootUrl: string): void;
  101045. }
  101046. }
  101047. declare module BABYLON {
  101048. /**
  101049. * @hidden
  101050. */
  101051. export interface IMaterialBRDFDefines {
  101052. BRDF_V_HEIGHT_CORRELATED: boolean;
  101053. MS_BRDF_ENERGY_CONSERVATION: boolean;
  101054. SPHERICAL_HARMONICS: boolean;
  101055. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  101056. /** @hidden */
  101057. _areMiscDirty: boolean;
  101058. }
  101059. /**
  101060. * Define the code related to the BRDF parameters of the pbr material.
  101061. */
  101062. export class PBRBRDFConfiguration {
  101063. /**
  101064. * Default value used for the energy conservation.
  101065. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  101066. */
  101067. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  101068. /**
  101069. * Default value used for the Smith Visibility Height Correlated mode.
  101070. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  101071. */
  101072. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  101073. /**
  101074. * Default value used for the IBL diffuse part.
  101075. * This can help switching back to the polynomials mode globally which is a tiny bit
  101076. * less GPU intensive at the drawback of a lower quality.
  101077. */
  101078. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  101079. /**
  101080. * Default value used for activating energy conservation for the specular workflow.
  101081. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  101082. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  101083. */
  101084. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  101085. private _useEnergyConservation;
  101086. /**
  101087. * Defines if the material uses energy conservation.
  101088. */
  101089. useEnergyConservation: boolean;
  101090. private _useSmithVisibilityHeightCorrelated;
  101091. /**
  101092. * LEGACY Mode set to false
  101093. * Defines if the material uses height smith correlated visibility term.
  101094. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  101095. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101096. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  101097. * Not relying on height correlated will also disable energy conservation.
  101098. */
  101099. useSmithVisibilityHeightCorrelated: boolean;
  101100. private _useSphericalHarmonics;
  101101. /**
  101102. * LEGACY Mode set to false
  101103. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  101104. * diffuse part of the IBL.
  101105. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  101106. * to the ground truth.
  101107. */
  101108. useSphericalHarmonics: boolean;
  101109. private _useSpecularGlossinessInputEnergyConservation;
  101110. /**
  101111. * Defines if the material uses energy conservation, when the specular workflow is active.
  101112. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  101113. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  101114. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  101115. */
  101116. useSpecularGlossinessInputEnergyConservation: boolean;
  101117. /** @hidden */
  101118. private _internalMarkAllSubMeshesAsMiscDirty;
  101119. /** @hidden */
  101120. _markAllSubMeshesAsMiscDirty(): void;
  101121. /**
  101122. * Instantiate a new istance of clear coat configuration.
  101123. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  101124. */
  101125. constructor(markAllSubMeshesAsMiscDirty: () => void);
  101126. /**
  101127. * Checks to see if a texture is used in the material.
  101128. * @param defines the list of "defines" to update.
  101129. */
  101130. prepareDefines(defines: IMaterialBRDFDefines): void;
  101131. /**
  101132. * Get the current class name of the texture useful for serialization or dynamic coding.
  101133. * @returns "PBRClearCoatConfiguration"
  101134. */
  101135. getClassName(): string;
  101136. /**
  101137. * Makes a duplicate of the current configuration into another one.
  101138. * @param brdfConfiguration define the config where to copy the info
  101139. */
  101140. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  101141. /**
  101142. * Serializes this BRDF configuration.
  101143. * @returns - An object with the serialized config.
  101144. */
  101145. serialize(): any;
  101146. /**
  101147. * Parses a anisotropy Configuration from a serialized object.
  101148. * @param source - Serialized object.
  101149. * @param scene Defines the scene we are parsing for
  101150. * @param rootUrl Defines the rootUrl to load from
  101151. */
  101152. parse(source: any, scene: Scene, rootUrl: string): void;
  101153. }
  101154. }
  101155. declare module BABYLON {
  101156. /**
  101157. * @hidden
  101158. */
  101159. export interface IMaterialSheenDefines {
  101160. SHEEN: boolean;
  101161. SHEEN_TEXTURE: boolean;
  101162. SHEEN_TEXTURE_ROUGHNESS: boolean;
  101163. SHEEN_TEXTUREDIRECTUV: number;
  101164. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  101165. SHEEN_LINKWITHALBEDO: boolean;
  101166. SHEEN_ROUGHNESS: boolean;
  101167. SHEEN_ALBEDOSCALING: boolean;
  101168. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  101169. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  101170. /** @hidden */
  101171. _areTexturesDirty: boolean;
  101172. }
  101173. /**
  101174. * Define the code related to the Sheen parameters of the pbr material.
  101175. */
  101176. export class PBRSheenConfiguration {
  101177. private _isEnabled;
  101178. /**
  101179. * Defines if the material uses sheen.
  101180. */
  101181. isEnabled: boolean;
  101182. private _linkSheenWithAlbedo;
  101183. /**
  101184. * Defines if the sheen is linked to the sheen color.
  101185. */
  101186. linkSheenWithAlbedo: boolean;
  101187. /**
  101188. * Defines the sheen intensity.
  101189. */
  101190. intensity: number;
  101191. /**
  101192. * Defines the sheen color.
  101193. */
  101194. color: Color3;
  101195. private _texture;
  101196. /**
  101197. * Stores the sheen tint values in a texture.
  101198. * rgb is tint
  101199. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  101200. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  101201. */
  101202. texture: Nullable<BaseTexture>;
  101203. private _useRoughnessFromMainTexture;
  101204. /**
  101205. * Indicates that the alpha channel of the texture property will be used for roughness.
  101206. * Has no effect if the roughness (and texture!) property is not defined
  101207. */
  101208. useRoughnessFromMainTexture: boolean;
  101209. private _roughness;
  101210. /**
  101211. * Defines the sheen roughness.
  101212. * It is not taken into account if linkSheenWithAlbedo is true.
  101213. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  101214. */
  101215. roughness: Nullable<number>;
  101216. private _textureRoughness;
  101217. /**
  101218. * Stores the sheen roughness in a texture.
  101219. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  101220. */
  101221. textureRoughness: Nullable<BaseTexture>;
  101222. private _albedoScaling;
  101223. /**
  101224. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  101225. * It allows the strength of the sheen effect to not depend on the base color of the material,
  101226. * making it easier to setup and tweak the effect
  101227. */
  101228. albedoScaling: boolean;
  101229. /** @hidden */
  101230. private _internalMarkAllSubMeshesAsTexturesDirty;
  101231. /** @hidden */
  101232. _markAllSubMeshesAsTexturesDirty(): void;
  101233. /**
  101234. * Instantiate a new istance of clear coat configuration.
  101235. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101236. */
  101237. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101238. /**
  101239. * Specifies that the submesh is ready to be used.
  101240. * @param defines the list of "defines" to update.
  101241. * @param scene defines the scene the material belongs to.
  101242. * @returns - boolean indicating that the submesh is ready or not.
  101243. */
  101244. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  101245. /**
  101246. * Checks to see if a texture is used in the material.
  101247. * @param defines the list of "defines" to update.
  101248. * @param scene defines the scene the material belongs to.
  101249. */
  101250. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  101251. /**
  101252. * Binds the material data.
  101253. * @param uniformBuffer defines the Uniform buffer to fill in.
  101254. * @param scene defines the scene the material belongs to.
  101255. * @param isFrozen defines wether the material is frozen or not.
  101256. * @param subMesh the submesh to bind data for
  101257. */
  101258. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  101259. /**
  101260. * Checks to see if a texture is used in the material.
  101261. * @param texture - Base texture to use.
  101262. * @returns - Boolean specifying if a texture is used in the material.
  101263. */
  101264. hasTexture(texture: BaseTexture): boolean;
  101265. /**
  101266. * Returns an array of the actively used textures.
  101267. * @param activeTextures Array of BaseTextures
  101268. */
  101269. getActiveTextures(activeTextures: BaseTexture[]): void;
  101270. /**
  101271. * Returns the animatable textures.
  101272. * @param animatables Array of animatable textures.
  101273. */
  101274. getAnimatables(animatables: IAnimatable[]): void;
  101275. /**
  101276. * Disposes the resources of the material.
  101277. * @param forceDisposeTextures - Forces the disposal of all textures.
  101278. */
  101279. dispose(forceDisposeTextures?: boolean): void;
  101280. /**
  101281. * Get the current class name of the texture useful for serialization or dynamic coding.
  101282. * @returns "PBRSheenConfiguration"
  101283. */
  101284. getClassName(): string;
  101285. /**
  101286. * Add fallbacks to the effect fallbacks list.
  101287. * @param defines defines the Base texture to use.
  101288. * @param fallbacks defines the current fallback list.
  101289. * @param currentRank defines the current fallback rank.
  101290. * @returns the new fallback rank.
  101291. */
  101292. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101293. /**
  101294. * Add the required uniforms to the current list.
  101295. * @param uniforms defines the current uniform list.
  101296. */
  101297. static AddUniforms(uniforms: string[]): void;
  101298. /**
  101299. * Add the required uniforms to the current buffer.
  101300. * @param uniformBuffer defines the current uniform buffer.
  101301. */
  101302. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101303. /**
  101304. * Add the required samplers to the current list.
  101305. * @param samplers defines the current sampler list.
  101306. */
  101307. static AddSamplers(samplers: string[]): void;
  101308. /**
  101309. * Makes a duplicate of the current configuration into another one.
  101310. * @param sheenConfiguration define the config where to copy the info
  101311. */
  101312. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  101313. /**
  101314. * Serializes this BRDF configuration.
  101315. * @returns - An object with the serialized config.
  101316. */
  101317. serialize(): any;
  101318. /**
  101319. * Parses a anisotropy Configuration from a serialized object.
  101320. * @param source - Serialized object.
  101321. * @param scene Defines the scene we are parsing for
  101322. * @param rootUrl Defines the rootUrl to load from
  101323. */
  101324. parse(source: any, scene: Scene, rootUrl: string): void;
  101325. }
  101326. }
  101327. declare module BABYLON {
  101328. /**
  101329. * @hidden
  101330. */
  101331. export interface IMaterialSubSurfaceDefines {
  101332. SUBSURFACE: boolean;
  101333. SS_REFRACTION: boolean;
  101334. SS_TRANSLUCENCY: boolean;
  101335. SS_SCATTERING: boolean;
  101336. SS_THICKNESSANDMASK_TEXTURE: boolean;
  101337. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  101338. SS_REFRACTIONMAP_3D: boolean;
  101339. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  101340. SS_LODINREFRACTIONALPHA: boolean;
  101341. SS_GAMMAREFRACTION: boolean;
  101342. SS_RGBDREFRACTION: boolean;
  101343. SS_LINEARSPECULARREFRACTION: boolean;
  101344. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  101345. SS_ALBEDOFORREFRACTIONTINT: boolean;
  101346. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  101347. /** @hidden */
  101348. _areTexturesDirty: boolean;
  101349. }
  101350. /**
  101351. * Define the code related to the sub surface parameters of the pbr material.
  101352. */
  101353. export class PBRSubSurfaceConfiguration {
  101354. private _isRefractionEnabled;
  101355. /**
  101356. * Defines if the refraction is enabled in the material.
  101357. */
  101358. isRefractionEnabled: boolean;
  101359. private _isTranslucencyEnabled;
  101360. /**
  101361. * Defines if the translucency is enabled in the material.
  101362. */
  101363. isTranslucencyEnabled: boolean;
  101364. private _isScatteringEnabled;
  101365. /**
  101366. * Defines if the sub surface scattering is enabled in the material.
  101367. */
  101368. isScatteringEnabled: boolean;
  101369. private _scatteringDiffusionProfileIndex;
  101370. /**
  101371. * Diffusion profile for subsurface scattering.
  101372. * Useful for better scattering in the skins or foliages.
  101373. */
  101374. get scatteringDiffusionProfile(): Nullable<Color3>;
  101375. set scatteringDiffusionProfile(c: Nullable<Color3>);
  101376. /**
  101377. * Defines the refraction intensity of the material.
  101378. * The refraction when enabled replaces the Diffuse part of the material.
  101379. * The intensity helps transitionning between diffuse and refraction.
  101380. */
  101381. refractionIntensity: number;
  101382. /**
  101383. * Defines the translucency intensity of the material.
  101384. * When translucency has been enabled, this defines how much of the "translucency"
  101385. * is addded to the diffuse part of the material.
  101386. */
  101387. translucencyIntensity: number;
  101388. /**
  101389. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  101390. */
  101391. useAlbedoToTintRefraction: boolean;
  101392. private _thicknessTexture;
  101393. /**
  101394. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  101395. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  101396. * 0 would mean minimumThickness
  101397. * 1 would mean maximumThickness
  101398. * The other channels might be use as a mask to vary the different effects intensity.
  101399. */
  101400. thicknessTexture: Nullable<BaseTexture>;
  101401. private _refractionTexture;
  101402. /**
  101403. * Defines the texture to use for refraction.
  101404. */
  101405. refractionTexture: Nullable<BaseTexture>;
  101406. private _indexOfRefraction;
  101407. /**
  101408. * Index of refraction of the material base layer.
  101409. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  101410. *
  101411. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  101412. *
  101413. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  101414. */
  101415. indexOfRefraction: number;
  101416. private _volumeIndexOfRefraction;
  101417. /**
  101418. * Index of refraction of the material's volume.
  101419. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  101420. *
  101421. * This ONLY impacts refraction. If not provided or given a non-valid value,
  101422. * the volume will use the same IOR as the surface.
  101423. */
  101424. get volumeIndexOfRefraction(): number;
  101425. set volumeIndexOfRefraction(value: number);
  101426. private _invertRefractionY;
  101427. /**
  101428. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101429. */
  101430. invertRefractionY: boolean;
  101431. private _linkRefractionWithTransparency;
  101432. /**
  101433. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101434. * Materials half opaque for instance using refraction could benefit from this control.
  101435. */
  101436. linkRefractionWithTransparency: boolean;
  101437. /**
  101438. * Defines the minimum thickness stored in the thickness map.
  101439. * If no thickness map is defined, this value will be used to simulate thickness.
  101440. */
  101441. minimumThickness: number;
  101442. /**
  101443. * Defines the maximum thickness stored in the thickness map.
  101444. */
  101445. maximumThickness: number;
  101446. /**
  101447. * Defines the volume tint of the material.
  101448. * This is used for both translucency and scattering.
  101449. */
  101450. tintColor: Color3;
  101451. /**
  101452. * Defines the distance at which the tint color should be found in the media.
  101453. * This is used for refraction only.
  101454. */
  101455. tintColorAtDistance: number;
  101456. /**
  101457. * Defines how far each channel transmit through the media.
  101458. * It is defined as a color to simplify it selection.
  101459. */
  101460. diffusionDistance: Color3;
  101461. private _useMaskFromThicknessTexture;
  101462. /**
  101463. * Stores the intensity of the different subsurface effects in the thickness texture.
  101464. * * the green channel is the translucency intensity.
  101465. * * the blue channel is the scattering intensity.
  101466. * * the alpha channel is the refraction intensity.
  101467. */
  101468. useMaskFromThicknessTexture: boolean;
  101469. private _scene;
  101470. /** @hidden */
  101471. private _internalMarkAllSubMeshesAsTexturesDirty;
  101472. private _internalMarkScenePrePassDirty;
  101473. /** @hidden */
  101474. _markAllSubMeshesAsTexturesDirty(): void;
  101475. /** @hidden */
  101476. _markScenePrePassDirty(): void;
  101477. /**
  101478. * Instantiate a new istance of sub surface configuration.
  101479. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101480. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  101481. * @param scene The scene
  101482. */
  101483. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  101484. /**
  101485. * Gets wehter the submesh is ready to be used or not.
  101486. * @param defines the list of "defines" to update.
  101487. * @param scene defines the scene the material belongs to.
  101488. * @returns - boolean indicating that the submesh is ready or not.
  101489. */
  101490. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  101491. /**
  101492. * Checks to see if a texture is used in the material.
  101493. * @param defines the list of "defines" to update.
  101494. * @param scene defines the scene to the material belongs to.
  101495. */
  101496. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  101497. /**
  101498. * Binds the material data.
  101499. * @param uniformBuffer defines the Uniform buffer to fill in.
  101500. * @param scene defines the scene the material belongs to.
  101501. * @param engine defines the engine the material belongs to.
  101502. * @param isFrozen defines whether the material is frozen or not.
  101503. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  101504. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  101505. */
  101506. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  101507. /**
  101508. * Unbinds the material from the mesh.
  101509. * @param activeEffect defines the effect that should be unbound from.
  101510. * @returns true if unbound, otherwise false
  101511. */
  101512. unbind(activeEffect: Effect): boolean;
  101513. /**
  101514. * Returns the texture used for refraction or null if none is used.
  101515. * @param scene defines the scene the material belongs to.
  101516. * @returns - Refraction texture if present. If no refraction texture and refraction
  101517. * is linked with transparency, returns environment texture. Otherwise, returns null.
  101518. */
  101519. private _getRefractionTexture;
  101520. /**
  101521. * Returns true if alpha blending should be disabled.
  101522. */
  101523. get disableAlphaBlending(): boolean;
  101524. /**
  101525. * Fills the list of render target textures.
  101526. * @param renderTargets the list of render targets to update
  101527. */
  101528. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  101529. /**
  101530. * Checks to see if a texture is used in the material.
  101531. * @param texture - Base texture to use.
  101532. * @returns - Boolean specifying if a texture is used in the material.
  101533. */
  101534. hasTexture(texture: BaseTexture): boolean;
  101535. /**
  101536. * Gets a boolean indicating that current material needs to register RTT
  101537. * @returns true if this uses a render target otherwise false.
  101538. */
  101539. hasRenderTargetTextures(): boolean;
  101540. /**
  101541. * Returns an array of the actively used textures.
  101542. * @param activeTextures Array of BaseTextures
  101543. */
  101544. getActiveTextures(activeTextures: BaseTexture[]): void;
  101545. /**
  101546. * Returns the animatable textures.
  101547. * @param animatables Array of animatable textures.
  101548. */
  101549. getAnimatables(animatables: IAnimatable[]): void;
  101550. /**
  101551. * Disposes the resources of the material.
  101552. * @param forceDisposeTextures - Forces the disposal of all textures.
  101553. */
  101554. dispose(forceDisposeTextures?: boolean): void;
  101555. /**
  101556. * Get the current class name of the texture useful for serialization or dynamic coding.
  101557. * @returns "PBRSubSurfaceConfiguration"
  101558. */
  101559. getClassName(): string;
  101560. /**
  101561. * Add fallbacks to the effect fallbacks list.
  101562. * @param defines defines the Base texture to use.
  101563. * @param fallbacks defines the current fallback list.
  101564. * @param currentRank defines the current fallback rank.
  101565. * @returns the new fallback rank.
  101566. */
  101567. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101568. /**
  101569. * Add the required uniforms to the current list.
  101570. * @param uniforms defines the current uniform list.
  101571. */
  101572. static AddUniforms(uniforms: string[]): void;
  101573. /**
  101574. * Add the required samplers to the current list.
  101575. * @param samplers defines the current sampler list.
  101576. */
  101577. static AddSamplers(samplers: string[]): void;
  101578. /**
  101579. * Add the required uniforms to the current buffer.
  101580. * @param uniformBuffer defines the current uniform buffer.
  101581. */
  101582. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101583. /**
  101584. * Makes a duplicate of the current configuration into another one.
  101585. * @param configuration define the config where to copy the info
  101586. */
  101587. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  101588. /**
  101589. * Serializes this Sub Surface configuration.
  101590. * @returns - An object with the serialized config.
  101591. */
  101592. serialize(): any;
  101593. /**
  101594. * Parses a anisotropy Configuration from a serialized object.
  101595. * @param source - Serialized object.
  101596. * @param scene Defines the scene we are parsing for
  101597. * @param rootUrl Defines the rootUrl to load from
  101598. */
  101599. parse(source: any, scene: Scene, rootUrl: string): void;
  101600. }
  101601. }
  101602. declare module BABYLON {
  101603. /**
  101604. * Class representing spherical harmonics coefficients to the 3rd degree
  101605. */
  101606. export class SphericalHarmonics {
  101607. /**
  101608. * Defines whether or not the harmonics have been prescaled for rendering.
  101609. */
  101610. preScaled: boolean;
  101611. /**
  101612. * The l0,0 coefficients of the spherical harmonics
  101613. */
  101614. l00: Vector3;
  101615. /**
  101616. * The l1,-1 coefficients of the spherical harmonics
  101617. */
  101618. l1_1: Vector3;
  101619. /**
  101620. * The l1,0 coefficients of the spherical harmonics
  101621. */
  101622. l10: Vector3;
  101623. /**
  101624. * The l1,1 coefficients of the spherical harmonics
  101625. */
  101626. l11: Vector3;
  101627. /**
  101628. * The l2,-2 coefficients of the spherical harmonics
  101629. */
  101630. l2_2: Vector3;
  101631. /**
  101632. * The l2,-1 coefficients of the spherical harmonics
  101633. */
  101634. l2_1: Vector3;
  101635. /**
  101636. * The l2,0 coefficients of the spherical harmonics
  101637. */
  101638. l20: Vector3;
  101639. /**
  101640. * The l2,1 coefficients of the spherical harmonics
  101641. */
  101642. l21: Vector3;
  101643. /**
  101644. * The l2,2 coefficients of the spherical harmonics
  101645. */
  101646. l22: Vector3;
  101647. /**
  101648. * Adds a light to the spherical harmonics
  101649. * @param direction the direction of the light
  101650. * @param color the color of the light
  101651. * @param deltaSolidAngle the delta solid angle of the light
  101652. */
  101653. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  101654. /**
  101655. * Scales the spherical harmonics by the given amount
  101656. * @param scale the amount to scale
  101657. */
  101658. scaleInPlace(scale: number): void;
  101659. /**
  101660. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  101661. *
  101662. * ```
  101663. * E_lm = A_l * L_lm
  101664. * ```
  101665. *
  101666. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  101667. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  101668. * the scaling factors are given in equation 9.
  101669. */
  101670. convertIncidentRadianceToIrradiance(): void;
  101671. /**
  101672. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  101673. *
  101674. * ```
  101675. * L = (1/pi) * E * rho
  101676. * ```
  101677. *
  101678. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  101679. */
  101680. convertIrradianceToLambertianRadiance(): void;
  101681. /**
  101682. * Integrates the reconstruction coefficients directly in to the SH preventing further
  101683. * required operations at run time.
  101684. *
  101685. * This is simply done by scaling back the SH with Ylm constants parameter.
  101686. * The trigonometric part being applied by the shader at run time.
  101687. */
  101688. preScaleForRendering(): void;
  101689. /**
  101690. * Constructs a spherical harmonics from an array.
  101691. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  101692. * @returns the spherical harmonics
  101693. */
  101694. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  101695. /**
  101696. * Gets the spherical harmonics from polynomial
  101697. * @param polynomial the spherical polynomial
  101698. * @returns the spherical harmonics
  101699. */
  101700. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  101701. }
  101702. /**
  101703. * Class representing spherical polynomial coefficients to the 3rd degree
  101704. */
  101705. export class SphericalPolynomial {
  101706. private _harmonics;
  101707. /**
  101708. * The spherical harmonics used to create the polynomials.
  101709. */
  101710. get preScaledHarmonics(): SphericalHarmonics;
  101711. /**
  101712. * The x coefficients of the spherical polynomial
  101713. */
  101714. x: Vector3;
  101715. /**
  101716. * The y coefficients of the spherical polynomial
  101717. */
  101718. y: Vector3;
  101719. /**
  101720. * The z coefficients of the spherical polynomial
  101721. */
  101722. z: Vector3;
  101723. /**
  101724. * The xx coefficients of the spherical polynomial
  101725. */
  101726. xx: Vector3;
  101727. /**
  101728. * The yy coefficients of the spherical polynomial
  101729. */
  101730. yy: Vector3;
  101731. /**
  101732. * The zz coefficients of the spherical polynomial
  101733. */
  101734. zz: Vector3;
  101735. /**
  101736. * The xy coefficients of the spherical polynomial
  101737. */
  101738. xy: Vector3;
  101739. /**
  101740. * The yz coefficients of the spherical polynomial
  101741. */
  101742. yz: Vector3;
  101743. /**
  101744. * The zx coefficients of the spherical polynomial
  101745. */
  101746. zx: Vector3;
  101747. /**
  101748. * Adds an ambient color to the spherical polynomial
  101749. * @param color the color to add
  101750. */
  101751. addAmbient(color: Color3): void;
  101752. /**
  101753. * Scales the spherical polynomial by the given amount
  101754. * @param scale the amount to scale
  101755. */
  101756. scaleInPlace(scale: number): void;
  101757. /**
  101758. * Gets the spherical polynomial from harmonics
  101759. * @param harmonics the spherical harmonics
  101760. * @returns the spherical polynomial
  101761. */
  101762. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  101763. /**
  101764. * Constructs a spherical polynomial from an array.
  101765. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  101766. * @returns the spherical polynomial
  101767. */
  101768. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  101769. }
  101770. }
  101771. declare module BABYLON {
  101772. /**
  101773. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  101774. */
  101775. export interface CubeMapInfo {
  101776. /**
  101777. * The pixel array for the front face.
  101778. * This is stored in format, left to right, up to down format.
  101779. */
  101780. front: Nullable<ArrayBufferView>;
  101781. /**
  101782. * The pixel array for the back face.
  101783. * This is stored in format, left to right, up to down format.
  101784. */
  101785. back: Nullable<ArrayBufferView>;
  101786. /**
  101787. * The pixel array for the left face.
  101788. * This is stored in format, left to right, up to down format.
  101789. */
  101790. left: Nullable<ArrayBufferView>;
  101791. /**
  101792. * The pixel array for the right face.
  101793. * This is stored in format, left to right, up to down format.
  101794. */
  101795. right: Nullable<ArrayBufferView>;
  101796. /**
  101797. * The pixel array for the up face.
  101798. * This is stored in format, left to right, up to down format.
  101799. */
  101800. up: Nullable<ArrayBufferView>;
  101801. /**
  101802. * The pixel array for the down face.
  101803. * This is stored in format, left to right, up to down format.
  101804. */
  101805. down: Nullable<ArrayBufferView>;
  101806. /**
  101807. * The size of the cubemap stored.
  101808. *
  101809. * Each faces will be size * size pixels.
  101810. */
  101811. size: number;
  101812. /**
  101813. * The format of the texture.
  101814. *
  101815. * RGBA, RGB.
  101816. */
  101817. format: number;
  101818. /**
  101819. * The type of the texture data.
  101820. *
  101821. * UNSIGNED_INT, FLOAT.
  101822. */
  101823. type: number;
  101824. /**
  101825. * Specifies whether the texture is in gamma space.
  101826. */
  101827. gammaSpace: boolean;
  101828. }
  101829. /**
  101830. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  101831. */
  101832. export class PanoramaToCubeMapTools {
  101833. private static FACE_LEFT;
  101834. private static FACE_RIGHT;
  101835. private static FACE_FRONT;
  101836. private static FACE_BACK;
  101837. private static FACE_DOWN;
  101838. private static FACE_UP;
  101839. /**
  101840. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  101841. *
  101842. * @param float32Array The source data.
  101843. * @param inputWidth The width of the input panorama.
  101844. * @param inputHeight The height of the input panorama.
  101845. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  101846. * @return The cubemap data
  101847. */
  101848. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  101849. private static CreateCubemapTexture;
  101850. private static CalcProjectionSpherical;
  101851. }
  101852. }
  101853. declare module BABYLON {
  101854. /**
  101855. * Helper class dealing with the extraction of spherical polynomial dataArray
  101856. * from a cube map.
  101857. */
  101858. export class CubeMapToSphericalPolynomialTools {
  101859. private static FileFaces;
  101860. /**
  101861. * Converts a texture to the according Spherical Polynomial data.
  101862. * This extracts the first 3 orders only as they are the only one used in the lighting.
  101863. *
  101864. * @param texture The texture to extract the information from.
  101865. * @return The Spherical Polynomial data.
  101866. */
  101867. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  101868. /**
  101869. * Converts a cubemap to the according Spherical Polynomial data.
  101870. * This extracts the first 3 orders only as they are the only one used in the lighting.
  101871. *
  101872. * @param cubeInfo The Cube map to extract the information from.
  101873. * @return The Spherical Polynomial data.
  101874. */
  101875. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  101876. }
  101877. }
  101878. declare module BABYLON {
  101879. interface BaseTexture {
  101880. /**
  101881. * Get the polynomial representation of the texture data.
  101882. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  101883. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  101884. */
  101885. sphericalPolynomial: Nullable<SphericalPolynomial>;
  101886. }
  101887. }
  101888. declare module BABYLON {
  101889. /** @hidden */
  101890. export var pbrFragmentDeclaration: {
  101891. name: string;
  101892. shader: string;
  101893. };
  101894. }
  101895. declare module BABYLON {
  101896. /** @hidden */
  101897. export var pbrUboDeclaration: {
  101898. name: string;
  101899. shader: string;
  101900. };
  101901. }
  101902. declare module BABYLON {
  101903. /** @hidden */
  101904. export var pbrFragmentExtraDeclaration: {
  101905. name: string;
  101906. shader: string;
  101907. };
  101908. }
  101909. declare module BABYLON {
  101910. /** @hidden */
  101911. export var pbrFragmentSamplersDeclaration: {
  101912. name: string;
  101913. shader: string;
  101914. };
  101915. }
  101916. declare module BABYLON {
  101917. /** @hidden */
  101918. export var subSurfaceScatteringFunctions: {
  101919. name: string;
  101920. shader: string;
  101921. };
  101922. }
  101923. declare module BABYLON {
  101924. /** @hidden */
  101925. export var importanceSampling: {
  101926. name: string;
  101927. shader: string;
  101928. };
  101929. }
  101930. declare module BABYLON {
  101931. /** @hidden */
  101932. export var pbrHelperFunctions: {
  101933. name: string;
  101934. shader: string;
  101935. };
  101936. }
  101937. declare module BABYLON {
  101938. /** @hidden */
  101939. export var harmonicsFunctions: {
  101940. name: string;
  101941. shader: string;
  101942. };
  101943. }
  101944. declare module BABYLON {
  101945. /** @hidden */
  101946. export var pbrDirectLightingSetupFunctions: {
  101947. name: string;
  101948. shader: string;
  101949. };
  101950. }
  101951. declare module BABYLON {
  101952. /** @hidden */
  101953. export var pbrDirectLightingFalloffFunctions: {
  101954. name: string;
  101955. shader: string;
  101956. };
  101957. }
  101958. declare module BABYLON {
  101959. /** @hidden */
  101960. export var pbrBRDFFunctions: {
  101961. name: string;
  101962. shader: string;
  101963. };
  101964. }
  101965. declare module BABYLON {
  101966. /** @hidden */
  101967. export var hdrFilteringFunctions: {
  101968. name: string;
  101969. shader: string;
  101970. };
  101971. }
  101972. declare module BABYLON {
  101973. /** @hidden */
  101974. export var pbrDirectLightingFunctions: {
  101975. name: string;
  101976. shader: string;
  101977. };
  101978. }
  101979. declare module BABYLON {
  101980. /** @hidden */
  101981. export var pbrIBLFunctions: {
  101982. name: string;
  101983. shader: string;
  101984. };
  101985. }
  101986. declare module BABYLON {
  101987. /** @hidden */
  101988. export var pbrBlockAlbedoOpacity: {
  101989. name: string;
  101990. shader: string;
  101991. };
  101992. }
  101993. declare module BABYLON {
  101994. /** @hidden */
  101995. export var pbrBlockReflectivity: {
  101996. name: string;
  101997. shader: string;
  101998. };
  101999. }
  102000. declare module BABYLON {
  102001. /** @hidden */
  102002. export var pbrBlockAmbientOcclusion: {
  102003. name: string;
  102004. shader: string;
  102005. };
  102006. }
  102007. declare module BABYLON {
  102008. /** @hidden */
  102009. export var pbrBlockAlphaFresnel: {
  102010. name: string;
  102011. shader: string;
  102012. };
  102013. }
  102014. declare module BABYLON {
  102015. /** @hidden */
  102016. export var pbrBlockAnisotropic: {
  102017. name: string;
  102018. shader: string;
  102019. };
  102020. }
  102021. declare module BABYLON {
  102022. /** @hidden */
  102023. export var pbrBlockReflection: {
  102024. name: string;
  102025. shader: string;
  102026. };
  102027. }
  102028. declare module BABYLON {
  102029. /** @hidden */
  102030. export var pbrBlockSheen: {
  102031. name: string;
  102032. shader: string;
  102033. };
  102034. }
  102035. declare module BABYLON {
  102036. /** @hidden */
  102037. export var pbrBlockClearcoat: {
  102038. name: string;
  102039. shader: string;
  102040. };
  102041. }
  102042. declare module BABYLON {
  102043. /** @hidden */
  102044. export var pbrBlockSubSurface: {
  102045. name: string;
  102046. shader: string;
  102047. };
  102048. }
  102049. declare module BABYLON {
  102050. /** @hidden */
  102051. export var pbrBlockNormalGeometric: {
  102052. name: string;
  102053. shader: string;
  102054. };
  102055. }
  102056. declare module BABYLON {
  102057. /** @hidden */
  102058. export var pbrBlockNormalFinal: {
  102059. name: string;
  102060. shader: string;
  102061. };
  102062. }
  102063. declare module BABYLON {
  102064. /** @hidden */
  102065. export var pbrBlockLightmapInit: {
  102066. name: string;
  102067. shader: string;
  102068. };
  102069. }
  102070. declare module BABYLON {
  102071. /** @hidden */
  102072. export var pbrBlockGeometryInfo: {
  102073. name: string;
  102074. shader: string;
  102075. };
  102076. }
  102077. declare module BABYLON {
  102078. /** @hidden */
  102079. export var pbrBlockReflectance0: {
  102080. name: string;
  102081. shader: string;
  102082. };
  102083. }
  102084. declare module BABYLON {
  102085. /** @hidden */
  102086. export var pbrBlockReflectance: {
  102087. name: string;
  102088. shader: string;
  102089. };
  102090. }
  102091. declare module BABYLON {
  102092. /** @hidden */
  102093. export var pbrBlockDirectLighting: {
  102094. name: string;
  102095. shader: string;
  102096. };
  102097. }
  102098. declare module BABYLON {
  102099. /** @hidden */
  102100. export var pbrBlockFinalLitComponents: {
  102101. name: string;
  102102. shader: string;
  102103. };
  102104. }
  102105. declare module BABYLON {
  102106. /** @hidden */
  102107. export var pbrBlockFinalUnlitComponents: {
  102108. name: string;
  102109. shader: string;
  102110. };
  102111. }
  102112. declare module BABYLON {
  102113. /** @hidden */
  102114. export var pbrBlockFinalColorComposition: {
  102115. name: string;
  102116. shader: string;
  102117. };
  102118. }
  102119. declare module BABYLON {
  102120. /** @hidden */
  102121. export var pbrBlockImageProcessing: {
  102122. name: string;
  102123. shader: string;
  102124. };
  102125. }
  102126. declare module BABYLON {
  102127. /** @hidden */
  102128. export var pbrDebug: {
  102129. name: string;
  102130. shader: string;
  102131. };
  102132. }
  102133. declare module BABYLON {
  102134. /** @hidden */
  102135. export var pbrPixelShader: {
  102136. name: string;
  102137. shader: string;
  102138. };
  102139. }
  102140. declare module BABYLON {
  102141. /** @hidden */
  102142. export var pbrVertexDeclaration: {
  102143. name: string;
  102144. shader: string;
  102145. };
  102146. }
  102147. declare module BABYLON {
  102148. /** @hidden */
  102149. export var pbrVertexShader: {
  102150. name: string;
  102151. shader: string;
  102152. };
  102153. }
  102154. declare module BABYLON {
  102155. /**
  102156. * Manages the defines for the PBR Material.
  102157. * @hidden
  102158. */
  102159. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  102160. PBR: boolean;
  102161. NUM_SAMPLES: string;
  102162. REALTIME_FILTERING: boolean;
  102163. MAINUV1: boolean;
  102164. MAINUV2: boolean;
  102165. UV1: boolean;
  102166. UV2: boolean;
  102167. ALBEDO: boolean;
  102168. GAMMAALBEDO: boolean;
  102169. ALBEDODIRECTUV: number;
  102170. VERTEXCOLOR: boolean;
  102171. DETAIL: boolean;
  102172. DETAILDIRECTUV: number;
  102173. DETAIL_NORMALBLENDMETHOD: number;
  102174. AMBIENT: boolean;
  102175. AMBIENTDIRECTUV: number;
  102176. AMBIENTINGRAYSCALE: boolean;
  102177. OPACITY: boolean;
  102178. VERTEXALPHA: boolean;
  102179. OPACITYDIRECTUV: number;
  102180. OPACITYRGB: boolean;
  102181. ALPHATEST: boolean;
  102182. DEPTHPREPASS: boolean;
  102183. ALPHABLEND: boolean;
  102184. ALPHAFROMALBEDO: boolean;
  102185. ALPHATESTVALUE: string;
  102186. SPECULAROVERALPHA: boolean;
  102187. RADIANCEOVERALPHA: boolean;
  102188. ALPHAFRESNEL: boolean;
  102189. LINEARALPHAFRESNEL: boolean;
  102190. PREMULTIPLYALPHA: boolean;
  102191. EMISSIVE: boolean;
  102192. EMISSIVEDIRECTUV: number;
  102193. REFLECTIVITY: boolean;
  102194. REFLECTIVITYDIRECTUV: number;
  102195. SPECULARTERM: boolean;
  102196. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  102197. MICROSURFACEAUTOMATIC: boolean;
  102198. LODBASEDMICROSFURACE: boolean;
  102199. MICROSURFACEMAP: boolean;
  102200. MICROSURFACEMAPDIRECTUV: number;
  102201. METALLICWORKFLOW: boolean;
  102202. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  102203. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  102204. METALLNESSSTOREINMETALMAPBLUE: boolean;
  102205. AOSTOREINMETALMAPRED: boolean;
  102206. METALLIC_REFLECTANCE: boolean;
  102207. METALLIC_REFLECTANCEDIRECTUV: number;
  102208. ENVIRONMENTBRDF: boolean;
  102209. ENVIRONMENTBRDF_RGBD: boolean;
  102210. NORMAL: boolean;
  102211. TANGENT: boolean;
  102212. BUMP: boolean;
  102213. BUMPDIRECTUV: number;
  102214. OBJECTSPACE_NORMALMAP: boolean;
  102215. PARALLAX: boolean;
  102216. PARALLAXOCCLUSION: boolean;
  102217. NORMALXYSCALE: boolean;
  102218. LIGHTMAP: boolean;
  102219. LIGHTMAPDIRECTUV: number;
  102220. USELIGHTMAPASSHADOWMAP: boolean;
  102221. GAMMALIGHTMAP: boolean;
  102222. RGBDLIGHTMAP: boolean;
  102223. REFLECTION: boolean;
  102224. REFLECTIONMAP_3D: boolean;
  102225. REFLECTIONMAP_SPHERICAL: boolean;
  102226. REFLECTIONMAP_PLANAR: boolean;
  102227. REFLECTIONMAP_CUBIC: boolean;
  102228. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  102229. REFLECTIONMAP_PROJECTION: boolean;
  102230. REFLECTIONMAP_SKYBOX: boolean;
  102231. REFLECTIONMAP_EXPLICIT: boolean;
  102232. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  102233. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  102234. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  102235. INVERTCUBICMAP: boolean;
  102236. USESPHERICALFROMREFLECTIONMAP: boolean;
  102237. USEIRRADIANCEMAP: boolean;
  102238. SPHERICAL_HARMONICS: boolean;
  102239. USESPHERICALINVERTEX: boolean;
  102240. REFLECTIONMAP_OPPOSITEZ: boolean;
  102241. LODINREFLECTIONALPHA: boolean;
  102242. GAMMAREFLECTION: boolean;
  102243. RGBDREFLECTION: boolean;
  102244. LINEARSPECULARREFLECTION: boolean;
  102245. RADIANCEOCCLUSION: boolean;
  102246. HORIZONOCCLUSION: boolean;
  102247. INSTANCES: boolean;
  102248. THIN_INSTANCES: boolean;
  102249. PREPASS: boolean;
  102250. PREPASS_IRRADIANCE: boolean;
  102251. PREPASS_IRRADIANCE_INDEX: number;
  102252. PREPASS_ALBEDO: boolean;
  102253. PREPASS_ALBEDO_INDEX: number;
  102254. PREPASS_DEPTHNORMAL: boolean;
  102255. PREPASS_DEPTHNORMAL_INDEX: number;
  102256. PREPASS_POSITION: boolean;
  102257. PREPASS_POSITION_INDEX: number;
  102258. PREPASS_VELOCITY: boolean;
  102259. PREPASS_VELOCITY_INDEX: number;
  102260. PREPASS_REFLECTIVITY: boolean;
  102261. PREPASS_REFLECTIVITY_INDEX: number;
  102262. SCENE_MRT_COUNT: number;
  102263. NUM_BONE_INFLUENCERS: number;
  102264. BonesPerMesh: number;
  102265. BONETEXTURE: boolean;
  102266. BONES_VELOCITY_ENABLED: boolean;
  102267. NONUNIFORMSCALING: boolean;
  102268. MORPHTARGETS: boolean;
  102269. MORPHTARGETS_NORMAL: boolean;
  102270. MORPHTARGETS_TANGENT: boolean;
  102271. MORPHTARGETS_UV: boolean;
  102272. NUM_MORPH_INFLUENCERS: number;
  102273. IMAGEPROCESSING: boolean;
  102274. VIGNETTE: boolean;
  102275. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102276. VIGNETTEBLENDMODEOPAQUE: boolean;
  102277. TONEMAPPING: boolean;
  102278. TONEMAPPING_ACES: boolean;
  102279. CONTRAST: boolean;
  102280. COLORCURVES: boolean;
  102281. COLORGRADING: boolean;
  102282. COLORGRADING3D: boolean;
  102283. SAMPLER3DGREENDEPTH: boolean;
  102284. SAMPLER3DBGRMAP: boolean;
  102285. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102286. EXPOSURE: boolean;
  102287. MULTIVIEW: boolean;
  102288. USEPHYSICALLIGHTFALLOFF: boolean;
  102289. USEGLTFLIGHTFALLOFF: boolean;
  102290. TWOSIDEDLIGHTING: boolean;
  102291. SHADOWFLOAT: boolean;
  102292. CLIPPLANE: boolean;
  102293. CLIPPLANE2: boolean;
  102294. CLIPPLANE3: boolean;
  102295. CLIPPLANE4: boolean;
  102296. CLIPPLANE5: boolean;
  102297. CLIPPLANE6: boolean;
  102298. POINTSIZE: boolean;
  102299. FOG: boolean;
  102300. LOGARITHMICDEPTH: boolean;
  102301. FORCENORMALFORWARD: boolean;
  102302. SPECULARAA: boolean;
  102303. CLEARCOAT: boolean;
  102304. CLEARCOAT_DEFAULTIOR: boolean;
  102305. CLEARCOAT_TEXTURE: boolean;
  102306. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  102307. CLEARCOAT_TEXTUREDIRECTUV: number;
  102308. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  102309. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  102310. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  102311. CLEARCOAT_BUMP: boolean;
  102312. CLEARCOAT_BUMPDIRECTUV: number;
  102313. CLEARCOAT_REMAP_F0: boolean;
  102314. CLEARCOAT_TINT: boolean;
  102315. CLEARCOAT_TINT_TEXTURE: boolean;
  102316. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  102317. ANISOTROPIC: boolean;
  102318. ANISOTROPIC_TEXTURE: boolean;
  102319. ANISOTROPIC_TEXTUREDIRECTUV: number;
  102320. BRDF_V_HEIGHT_CORRELATED: boolean;
  102321. MS_BRDF_ENERGY_CONSERVATION: boolean;
  102322. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  102323. SHEEN: boolean;
  102324. SHEEN_TEXTURE: boolean;
  102325. SHEEN_TEXTURE_ROUGHNESS: boolean;
  102326. SHEEN_TEXTUREDIRECTUV: number;
  102327. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  102328. SHEEN_LINKWITHALBEDO: boolean;
  102329. SHEEN_ROUGHNESS: boolean;
  102330. SHEEN_ALBEDOSCALING: boolean;
  102331. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  102332. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  102333. SUBSURFACE: boolean;
  102334. SS_REFRACTION: boolean;
  102335. SS_TRANSLUCENCY: boolean;
  102336. SS_SCATTERING: boolean;
  102337. SS_THICKNESSANDMASK_TEXTURE: boolean;
  102338. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  102339. SS_REFRACTIONMAP_3D: boolean;
  102340. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  102341. SS_LODINREFRACTIONALPHA: boolean;
  102342. SS_GAMMAREFRACTION: boolean;
  102343. SS_RGBDREFRACTION: boolean;
  102344. SS_LINEARSPECULARREFRACTION: boolean;
  102345. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  102346. SS_ALBEDOFORREFRACTIONTINT: boolean;
  102347. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  102348. UNLIT: boolean;
  102349. DEBUGMODE: number;
  102350. /**
  102351. * Initializes the PBR Material defines.
  102352. */
  102353. constructor();
  102354. /**
  102355. * Resets the PBR Material defines.
  102356. */
  102357. reset(): void;
  102358. }
  102359. /**
  102360. * The Physically based material base class of BJS.
  102361. *
  102362. * This offers the main features of a standard PBR material.
  102363. * For more information, please refer to the documentation :
  102364. * https://doc.babylonjs.com/how_to/physically_based_rendering
  102365. */
  102366. export abstract class PBRBaseMaterial extends PushMaterial {
  102367. /**
  102368. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102369. */
  102370. static readonly PBRMATERIAL_OPAQUE: number;
  102371. /**
  102372. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102373. */
  102374. static readonly PBRMATERIAL_ALPHATEST: number;
  102375. /**
  102376. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102377. */
  102378. static readonly PBRMATERIAL_ALPHABLEND: number;
  102379. /**
  102380. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102381. * They are also discarded below the alpha cutoff threshold to improve performances.
  102382. */
  102383. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  102384. /**
  102385. * Defines the default value of how much AO map is occluding the analytical lights
  102386. * (point spot...).
  102387. */
  102388. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  102389. /**
  102390. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  102391. */
  102392. static readonly LIGHTFALLOFF_PHYSICAL: number;
  102393. /**
  102394. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  102395. * to enhance interoperability with other engines.
  102396. */
  102397. static readonly LIGHTFALLOFF_GLTF: number;
  102398. /**
  102399. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  102400. * to enhance interoperability with other materials.
  102401. */
  102402. static readonly LIGHTFALLOFF_STANDARD: number;
  102403. /**
  102404. * Intensity of the direct lights e.g. the four lights available in your scene.
  102405. * This impacts both the direct diffuse and specular highlights.
  102406. */
  102407. protected _directIntensity: number;
  102408. /**
  102409. * Intensity of the emissive part of the material.
  102410. * This helps controlling the emissive effect without modifying the emissive color.
  102411. */
  102412. protected _emissiveIntensity: number;
  102413. /**
  102414. * Intensity of the environment e.g. how much the environment will light the object
  102415. * either through harmonics for rough material or through the refelction for shiny ones.
  102416. */
  102417. protected _environmentIntensity: number;
  102418. /**
  102419. * This is a special control allowing the reduction of the specular highlights coming from the
  102420. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  102421. */
  102422. protected _specularIntensity: number;
  102423. /**
  102424. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  102425. */
  102426. private _lightingInfos;
  102427. /**
  102428. * Debug Control allowing disabling the bump map on this material.
  102429. */
  102430. protected _disableBumpMap: boolean;
  102431. /**
  102432. * AKA Diffuse Texture in standard nomenclature.
  102433. */
  102434. protected _albedoTexture: Nullable<BaseTexture>;
  102435. /**
  102436. * AKA Occlusion Texture in other nomenclature.
  102437. */
  102438. protected _ambientTexture: Nullable<BaseTexture>;
  102439. /**
  102440. * AKA Occlusion Texture Intensity in other nomenclature.
  102441. */
  102442. protected _ambientTextureStrength: number;
  102443. /**
  102444. * Defines how much the AO map is occluding the analytical lights (point spot...).
  102445. * 1 means it completely occludes it
  102446. * 0 mean it has no impact
  102447. */
  102448. protected _ambientTextureImpactOnAnalyticalLights: number;
  102449. /**
  102450. * Stores the alpha values in a texture.
  102451. */
  102452. protected _opacityTexture: Nullable<BaseTexture>;
  102453. /**
  102454. * Stores the reflection values in a texture.
  102455. */
  102456. protected _reflectionTexture: Nullable<BaseTexture>;
  102457. /**
  102458. * Stores the emissive values in a texture.
  102459. */
  102460. protected _emissiveTexture: Nullable<BaseTexture>;
  102461. /**
  102462. * AKA Specular texture in other nomenclature.
  102463. */
  102464. protected _reflectivityTexture: Nullable<BaseTexture>;
  102465. /**
  102466. * Used to switch from specular/glossiness to metallic/roughness workflow.
  102467. */
  102468. protected _metallicTexture: Nullable<BaseTexture>;
  102469. /**
  102470. * Specifies the metallic scalar of the metallic/roughness workflow.
  102471. * Can also be used to scale the metalness values of the metallic texture.
  102472. */
  102473. protected _metallic: Nullable<number>;
  102474. /**
  102475. * Specifies the roughness scalar of the metallic/roughness workflow.
  102476. * Can also be used to scale the roughness values of the metallic texture.
  102477. */
  102478. protected _roughness: Nullable<number>;
  102479. /**
  102480. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  102481. * By default the indexOfrefraction is used to compute F0;
  102482. *
  102483. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  102484. *
  102485. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  102486. * F90 = metallicReflectanceColor;
  102487. */
  102488. protected _metallicF0Factor: number;
  102489. /**
  102490. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  102491. * By default the F90 is always 1;
  102492. *
  102493. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  102494. *
  102495. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  102496. * F90 = metallicReflectanceColor;
  102497. */
  102498. protected _metallicReflectanceColor: Color3;
  102499. /**
  102500. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  102501. * This is multiply against the scalar values defined in the material.
  102502. */
  102503. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  102504. /**
  102505. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  102506. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  102507. */
  102508. protected _microSurfaceTexture: Nullable<BaseTexture>;
  102509. /**
  102510. * Stores surface normal data used to displace a mesh in a texture.
  102511. */
  102512. protected _bumpTexture: Nullable<BaseTexture>;
  102513. /**
  102514. * Stores the pre-calculated light information of a mesh in a texture.
  102515. */
  102516. protected _lightmapTexture: Nullable<BaseTexture>;
  102517. /**
  102518. * The color of a material in ambient lighting.
  102519. */
  102520. protected _ambientColor: Color3;
  102521. /**
  102522. * AKA Diffuse Color in other nomenclature.
  102523. */
  102524. protected _albedoColor: Color3;
  102525. /**
  102526. * AKA Specular Color in other nomenclature.
  102527. */
  102528. protected _reflectivityColor: Color3;
  102529. /**
  102530. * The color applied when light is reflected from a material.
  102531. */
  102532. protected _reflectionColor: Color3;
  102533. /**
  102534. * The color applied when light is emitted from a material.
  102535. */
  102536. protected _emissiveColor: Color3;
  102537. /**
  102538. * AKA Glossiness in other nomenclature.
  102539. */
  102540. protected _microSurface: number;
  102541. /**
  102542. * Specifies that the material will use the light map as a show map.
  102543. */
  102544. protected _useLightmapAsShadowmap: boolean;
  102545. /**
  102546. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  102547. * makes the reflect vector face the model (under horizon).
  102548. */
  102549. protected _useHorizonOcclusion: boolean;
  102550. /**
  102551. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  102552. * too much the area relying on ambient texture to define their ambient occlusion.
  102553. */
  102554. protected _useRadianceOcclusion: boolean;
  102555. /**
  102556. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  102557. */
  102558. protected _useAlphaFromAlbedoTexture: boolean;
  102559. /**
  102560. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  102561. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102562. */
  102563. protected _useSpecularOverAlpha: boolean;
  102564. /**
  102565. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  102566. */
  102567. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  102568. /**
  102569. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  102570. */
  102571. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  102572. /**
  102573. * Specifies if the metallic texture contains the roughness information in its green channel.
  102574. */
  102575. protected _useRoughnessFromMetallicTextureGreen: boolean;
  102576. /**
  102577. * Specifies if the metallic texture contains the metallness information in its blue channel.
  102578. */
  102579. protected _useMetallnessFromMetallicTextureBlue: boolean;
  102580. /**
  102581. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  102582. */
  102583. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  102584. /**
  102585. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  102586. */
  102587. protected _useAmbientInGrayScale: boolean;
  102588. /**
  102589. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  102590. * The material will try to infer what glossiness each pixel should be.
  102591. */
  102592. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  102593. /**
  102594. * Defines the falloff type used in this material.
  102595. * It by default is Physical.
  102596. */
  102597. protected _lightFalloff: number;
  102598. /**
  102599. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102600. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102601. */
  102602. protected _useRadianceOverAlpha: boolean;
  102603. /**
  102604. * Allows using an object space normal map (instead of tangent space).
  102605. */
  102606. protected _useObjectSpaceNormalMap: boolean;
  102607. /**
  102608. * Allows using the bump map in parallax mode.
  102609. */
  102610. protected _useParallax: boolean;
  102611. /**
  102612. * Allows using the bump map in parallax occlusion mode.
  102613. */
  102614. protected _useParallaxOcclusion: boolean;
  102615. /**
  102616. * Controls the scale bias of the parallax mode.
  102617. */
  102618. protected _parallaxScaleBias: number;
  102619. /**
  102620. * If sets to true, disables all the lights affecting the material.
  102621. */
  102622. protected _disableLighting: boolean;
  102623. /**
  102624. * Number of Simultaneous lights allowed on the material.
  102625. */
  102626. protected _maxSimultaneousLights: number;
  102627. /**
  102628. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  102629. */
  102630. protected _invertNormalMapX: boolean;
  102631. /**
  102632. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  102633. */
  102634. protected _invertNormalMapY: boolean;
  102635. /**
  102636. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102637. */
  102638. protected _twoSidedLighting: boolean;
  102639. /**
  102640. * Defines the alpha limits in alpha test mode.
  102641. */
  102642. protected _alphaCutOff: number;
  102643. /**
  102644. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102645. */
  102646. protected _forceAlphaTest: boolean;
  102647. /**
  102648. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102649. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  102650. */
  102651. protected _useAlphaFresnel: boolean;
  102652. /**
  102653. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102654. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  102655. */
  102656. protected _useLinearAlphaFresnel: boolean;
  102657. /**
  102658. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  102659. * from cos thetav and roughness:
  102660. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  102661. */
  102662. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  102663. /**
  102664. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  102665. */
  102666. protected _forceIrradianceInFragment: boolean;
  102667. private _realTimeFiltering;
  102668. /**
  102669. * Enables realtime filtering on the texture.
  102670. */
  102671. get realTimeFiltering(): boolean;
  102672. set realTimeFiltering(b: boolean);
  102673. private _realTimeFilteringQuality;
  102674. /**
  102675. * Quality switch for realtime filtering
  102676. */
  102677. get realTimeFilteringQuality(): number;
  102678. set realTimeFilteringQuality(n: number);
  102679. /**
  102680. * Can this material render to several textures at once
  102681. */
  102682. get canRenderToMRT(): boolean;
  102683. /**
  102684. * Force normal to face away from face.
  102685. */
  102686. protected _forceNormalForward: boolean;
  102687. /**
  102688. * Enables specular anti aliasing in the PBR shader.
  102689. * It will both interacts on the Geometry for analytical and IBL lighting.
  102690. * It also prefilter the roughness map based on the bump values.
  102691. */
  102692. protected _enableSpecularAntiAliasing: boolean;
  102693. /**
  102694. * Default configuration related to image processing available in the PBR Material.
  102695. */
  102696. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102697. /**
  102698. * Keep track of the image processing observer to allow dispose and replace.
  102699. */
  102700. private _imageProcessingObserver;
  102701. /**
  102702. * Attaches a new image processing configuration to the PBR Material.
  102703. * @param configuration
  102704. */
  102705. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102706. /**
  102707. * Stores the available render targets.
  102708. */
  102709. private _renderTargets;
  102710. /**
  102711. * Sets the global ambient color for the material used in lighting calculations.
  102712. */
  102713. private _globalAmbientColor;
  102714. /**
  102715. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  102716. */
  102717. private _useLogarithmicDepth;
  102718. /**
  102719. * If set to true, no lighting calculations will be applied.
  102720. */
  102721. private _unlit;
  102722. private _debugMode;
  102723. /**
  102724. * @hidden
  102725. * This is reserved for the inspector.
  102726. * Defines the material debug mode.
  102727. * It helps seeing only some components of the material while troubleshooting.
  102728. */
  102729. debugMode: number;
  102730. /**
  102731. * @hidden
  102732. * This is reserved for the inspector.
  102733. * Specify from where on screen the debug mode should start.
  102734. * The value goes from -1 (full screen) to 1 (not visible)
  102735. * It helps with side by side comparison against the final render
  102736. * This defaults to -1
  102737. */
  102738. private debugLimit;
  102739. /**
  102740. * @hidden
  102741. * This is reserved for the inspector.
  102742. * As the default viewing range might not be enough (if the ambient is really small for instance)
  102743. * You can use the factor to better multiply the final value.
  102744. */
  102745. private debugFactor;
  102746. /**
  102747. * Defines the clear coat layer parameters for the material.
  102748. */
  102749. readonly clearCoat: PBRClearCoatConfiguration;
  102750. /**
  102751. * Defines the anisotropic parameters for the material.
  102752. */
  102753. readonly anisotropy: PBRAnisotropicConfiguration;
  102754. /**
  102755. * Defines the BRDF parameters for the material.
  102756. */
  102757. readonly brdf: PBRBRDFConfiguration;
  102758. /**
  102759. * Defines the Sheen parameters for the material.
  102760. */
  102761. readonly sheen: PBRSheenConfiguration;
  102762. /**
  102763. * Defines the SubSurface parameters for the material.
  102764. */
  102765. readonly subSurface: PBRSubSurfaceConfiguration;
  102766. /**
  102767. * Defines additionnal PrePass parameters for the material.
  102768. */
  102769. readonly prePassConfiguration: PrePassConfiguration;
  102770. /**
  102771. * Defines the detail map parameters for the material.
  102772. */
  102773. readonly detailMap: DetailMapConfiguration;
  102774. protected _rebuildInParallel: boolean;
  102775. /**
  102776. * Instantiates a new PBRMaterial instance.
  102777. *
  102778. * @param name The material name
  102779. * @param scene The scene the material will be use in.
  102780. */
  102781. constructor(name: string, scene: Scene);
  102782. /**
  102783. * Gets a boolean indicating that current material needs to register RTT
  102784. */
  102785. get hasRenderTargetTextures(): boolean;
  102786. /**
  102787. * Gets the name of the material class.
  102788. */
  102789. getClassName(): string;
  102790. /**
  102791. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  102792. */
  102793. get useLogarithmicDepth(): boolean;
  102794. /**
  102795. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  102796. */
  102797. set useLogarithmicDepth(value: boolean);
  102798. /**
  102799. * Returns true if alpha blending should be disabled.
  102800. */
  102801. protected get _disableAlphaBlending(): boolean;
  102802. /**
  102803. * Specifies whether or not this material should be rendered in alpha blend mode.
  102804. */
  102805. needAlphaBlending(): boolean;
  102806. /**
  102807. * Specifies whether or not this material should be rendered in alpha test mode.
  102808. */
  102809. needAlphaTesting(): boolean;
  102810. /**
  102811. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  102812. */
  102813. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  102814. /**
  102815. * Specifies whether or not there is a usable alpha channel for transparency.
  102816. */
  102817. protected _hasAlphaChannel(): boolean;
  102818. /**
  102819. * Gets the texture used for the alpha test.
  102820. */
  102821. getAlphaTestTexture(): Nullable<BaseTexture>;
  102822. /**
  102823. * Specifies that the submesh is ready to be used.
  102824. * @param mesh - BJS mesh.
  102825. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  102826. * @param useInstances - Specifies that instances should be used.
  102827. * @returns - boolean indicating that the submesh is ready or not.
  102828. */
  102829. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102830. /**
  102831. * Specifies if the material uses metallic roughness workflow.
  102832. * @returns boolean specifiying if the material uses metallic roughness workflow.
  102833. */
  102834. isMetallicWorkflow(): boolean;
  102835. private _prepareEffect;
  102836. private _prepareDefines;
  102837. /**
  102838. * Force shader compilation
  102839. */
  102840. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  102841. /**
  102842. * Initializes the uniform buffer layout for the shader.
  102843. */
  102844. buildUniformLayout(): void;
  102845. /**
  102846. * Unbinds the material from the mesh
  102847. */
  102848. unbind(): void;
  102849. /**
  102850. * Binds the submesh data.
  102851. * @param world - The world matrix.
  102852. * @param mesh - The BJS mesh.
  102853. * @param subMesh - A submesh of the BJS mesh.
  102854. */
  102855. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102856. /**
  102857. * Returns the animatable textures.
  102858. * @returns - Array of animatable textures.
  102859. */
  102860. getAnimatables(): IAnimatable[];
  102861. /**
  102862. * Returns the texture used for reflections.
  102863. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  102864. */
  102865. private _getReflectionTexture;
  102866. /**
  102867. * Returns an array of the actively used textures.
  102868. * @returns - Array of BaseTextures
  102869. */
  102870. getActiveTextures(): BaseTexture[];
  102871. /**
  102872. * Checks to see if a texture is used in the material.
  102873. * @param texture - Base texture to use.
  102874. * @returns - Boolean specifying if a texture is used in the material.
  102875. */
  102876. hasTexture(texture: BaseTexture): boolean;
  102877. /**
  102878. * Sets the required values to the prepass renderer.
  102879. * @param prePassRenderer defines the prepass renderer to setup
  102880. */
  102881. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  102882. /**
  102883. * Disposes the resources of the material.
  102884. * @param forceDisposeEffect - Forces the disposal of effects.
  102885. * @param forceDisposeTextures - Forces the disposal of all textures.
  102886. */
  102887. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102888. }
  102889. }
  102890. declare module BABYLON {
  102891. /**
  102892. * The Physically based material of BJS.
  102893. *
  102894. * This offers the main features of a standard PBR material.
  102895. * For more information, please refer to the documentation :
  102896. * https://doc.babylonjs.com/how_to/physically_based_rendering
  102897. */
  102898. export class PBRMaterial extends PBRBaseMaterial {
  102899. /**
  102900. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102901. */
  102902. static readonly PBRMATERIAL_OPAQUE: number;
  102903. /**
  102904. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102905. */
  102906. static readonly PBRMATERIAL_ALPHATEST: number;
  102907. /**
  102908. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102909. */
  102910. static readonly PBRMATERIAL_ALPHABLEND: number;
  102911. /**
  102912. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102913. * They are also discarded below the alpha cutoff threshold to improve performances.
  102914. */
  102915. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  102916. /**
  102917. * Defines the default value of how much AO map is occluding the analytical lights
  102918. * (point spot...).
  102919. */
  102920. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  102921. /**
  102922. * Intensity of the direct lights e.g. the four lights available in your scene.
  102923. * This impacts both the direct diffuse and specular highlights.
  102924. */
  102925. directIntensity: number;
  102926. /**
  102927. * Intensity of the emissive part of the material.
  102928. * This helps controlling the emissive effect without modifying the emissive color.
  102929. */
  102930. emissiveIntensity: number;
  102931. /**
  102932. * Intensity of the environment e.g. how much the environment will light the object
  102933. * either through harmonics for rough material or through the refelction for shiny ones.
  102934. */
  102935. environmentIntensity: number;
  102936. /**
  102937. * This is a special control allowing the reduction of the specular highlights coming from the
  102938. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  102939. */
  102940. specularIntensity: number;
  102941. /**
  102942. * Debug Control allowing disabling the bump map on this material.
  102943. */
  102944. disableBumpMap: boolean;
  102945. /**
  102946. * AKA Diffuse Texture in standard nomenclature.
  102947. */
  102948. albedoTexture: BaseTexture;
  102949. /**
  102950. * AKA Occlusion Texture in other nomenclature.
  102951. */
  102952. ambientTexture: BaseTexture;
  102953. /**
  102954. * AKA Occlusion Texture Intensity in other nomenclature.
  102955. */
  102956. ambientTextureStrength: number;
  102957. /**
  102958. * Defines how much the AO map is occluding the analytical lights (point spot...).
  102959. * 1 means it completely occludes it
  102960. * 0 mean it has no impact
  102961. */
  102962. ambientTextureImpactOnAnalyticalLights: number;
  102963. /**
  102964. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  102965. */
  102966. opacityTexture: BaseTexture;
  102967. /**
  102968. * Stores the reflection values in a texture.
  102969. */
  102970. reflectionTexture: Nullable<BaseTexture>;
  102971. /**
  102972. * Stores the emissive values in a texture.
  102973. */
  102974. emissiveTexture: BaseTexture;
  102975. /**
  102976. * AKA Specular texture in other nomenclature.
  102977. */
  102978. reflectivityTexture: BaseTexture;
  102979. /**
  102980. * Used to switch from specular/glossiness to metallic/roughness workflow.
  102981. */
  102982. metallicTexture: BaseTexture;
  102983. /**
  102984. * Specifies the metallic scalar of the metallic/roughness workflow.
  102985. * Can also be used to scale the metalness values of the metallic texture.
  102986. */
  102987. metallic: Nullable<number>;
  102988. /**
  102989. * Specifies the roughness scalar of the metallic/roughness workflow.
  102990. * Can also be used to scale the roughness values of the metallic texture.
  102991. */
  102992. roughness: Nullable<number>;
  102993. /**
  102994. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  102995. * By default the indexOfrefraction is used to compute F0;
  102996. *
  102997. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  102998. *
  102999. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  103000. * F90 = metallicReflectanceColor;
  103001. */
  103002. metallicF0Factor: number;
  103003. /**
  103004. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  103005. * By default the F90 is always 1;
  103006. *
  103007. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  103008. *
  103009. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  103010. * F90 = metallicReflectanceColor;
  103011. */
  103012. metallicReflectanceColor: Color3;
  103013. /**
  103014. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  103015. * This is multiply against the scalar values defined in the material.
  103016. */
  103017. metallicReflectanceTexture: Nullable<BaseTexture>;
  103018. /**
  103019. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  103020. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  103021. */
  103022. microSurfaceTexture: BaseTexture;
  103023. /**
  103024. * Stores surface normal data used to displace a mesh in a texture.
  103025. */
  103026. bumpTexture: BaseTexture;
  103027. /**
  103028. * Stores the pre-calculated light information of a mesh in a texture.
  103029. */
  103030. lightmapTexture: BaseTexture;
  103031. /**
  103032. * Stores the refracted light information in a texture.
  103033. */
  103034. get refractionTexture(): Nullable<BaseTexture>;
  103035. set refractionTexture(value: Nullable<BaseTexture>);
  103036. /**
  103037. * The color of a material in ambient lighting.
  103038. */
  103039. ambientColor: Color3;
  103040. /**
  103041. * AKA Diffuse Color in other nomenclature.
  103042. */
  103043. albedoColor: Color3;
  103044. /**
  103045. * AKA Specular Color in other nomenclature.
  103046. */
  103047. reflectivityColor: Color3;
  103048. /**
  103049. * The color reflected from the material.
  103050. */
  103051. reflectionColor: Color3;
  103052. /**
  103053. * The color emitted from the material.
  103054. */
  103055. emissiveColor: Color3;
  103056. /**
  103057. * AKA Glossiness in other nomenclature.
  103058. */
  103059. microSurface: number;
  103060. /**
  103061. * Index of refraction of the material base layer.
  103062. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  103063. *
  103064. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  103065. *
  103066. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  103067. */
  103068. get indexOfRefraction(): number;
  103069. set indexOfRefraction(value: number);
  103070. /**
  103071. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  103072. */
  103073. get invertRefractionY(): boolean;
  103074. set invertRefractionY(value: boolean);
  103075. /**
  103076. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  103077. * Materials half opaque for instance using refraction could benefit from this control.
  103078. */
  103079. get linkRefractionWithTransparency(): boolean;
  103080. set linkRefractionWithTransparency(value: boolean);
  103081. /**
  103082. * If true, the light map contains occlusion information instead of lighting info.
  103083. */
  103084. useLightmapAsShadowmap: boolean;
  103085. /**
  103086. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  103087. */
  103088. useAlphaFromAlbedoTexture: boolean;
  103089. /**
  103090. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  103091. */
  103092. forceAlphaTest: boolean;
  103093. /**
  103094. * Defines the alpha limits in alpha test mode.
  103095. */
  103096. alphaCutOff: number;
  103097. /**
  103098. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  103099. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  103100. */
  103101. useSpecularOverAlpha: boolean;
  103102. /**
  103103. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  103104. */
  103105. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  103106. /**
  103107. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  103108. */
  103109. useRoughnessFromMetallicTextureAlpha: boolean;
  103110. /**
  103111. * Specifies if the metallic texture contains the roughness information in its green channel.
  103112. */
  103113. useRoughnessFromMetallicTextureGreen: boolean;
  103114. /**
  103115. * Specifies if the metallic texture contains the metallness information in its blue channel.
  103116. */
  103117. useMetallnessFromMetallicTextureBlue: boolean;
  103118. /**
  103119. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  103120. */
  103121. useAmbientOcclusionFromMetallicTextureRed: boolean;
  103122. /**
  103123. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  103124. */
  103125. useAmbientInGrayScale: boolean;
  103126. /**
  103127. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  103128. * The material will try to infer what glossiness each pixel should be.
  103129. */
  103130. useAutoMicroSurfaceFromReflectivityMap: boolean;
  103131. /**
  103132. * BJS is using an harcoded light falloff based on a manually sets up range.
  103133. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  103134. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  103135. */
  103136. get usePhysicalLightFalloff(): boolean;
  103137. /**
  103138. * BJS is using an harcoded light falloff based on a manually sets up range.
  103139. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  103140. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  103141. */
  103142. set usePhysicalLightFalloff(value: boolean);
  103143. /**
  103144. * In order to support the falloff compatibility with gltf, a special mode has been added
  103145. * to reproduce the gltf light falloff.
  103146. */
  103147. get useGLTFLightFalloff(): boolean;
  103148. /**
  103149. * In order to support the falloff compatibility with gltf, a special mode has been added
  103150. * to reproduce the gltf light falloff.
  103151. */
  103152. set useGLTFLightFalloff(value: boolean);
  103153. /**
  103154. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  103155. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  103156. */
  103157. useRadianceOverAlpha: boolean;
  103158. /**
  103159. * Allows using an object space normal map (instead of tangent space).
  103160. */
  103161. useObjectSpaceNormalMap: boolean;
  103162. /**
  103163. * Allows using the bump map in parallax mode.
  103164. */
  103165. useParallax: boolean;
  103166. /**
  103167. * Allows using the bump map in parallax occlusion mode.
  103168. */
  103169. useParallaxOcclusion: boolean;
  103170. /**
  103171. * Controls the scale bias of the parallax mode.
  103172. */
  103173. parallaxScaleBias: number;
  103174. /**
  103175. * If sets to true, disables all the lights affecting the material.
  103176. */
  103177. disableLighting: boolean;
  103178. /**
  103179. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  103180. */
  103181. forceIrradianceInFragment: boolean;
  103182. /**
  103183. * Number of Simultaneous lights allowed on the material.
  103184. */
  103185. maxSimultaneousLights: number;
  103186. /**
  103187. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  103188. */
  103189. invertNormalMapX: boolean;
  103190. /**
  103191. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  103192. */
  103193. invertNormalMapY: boolean;
  103194. /**
  103195. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103196. */
  103197. twoSidedLighting: boolean;
  103198. /**
  103199. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103200. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  103201. */
  103202. useAlphaFresnel: boolean;
  103203. /**
  103204. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103205. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  103206. */
  103207. useLinearAlphaFresnel: boolean;
  103208. /**
  103209. * Let user defines the brdf lookup texture used for IBL.
  103210. * A default 8bit version is embedded but you could point at :
  103211. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  103212. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  103213. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  103214. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  103215. */
  103216. environmentBRDFTexture: Nullable<BaseTexture>;
  103217. /**
  103218. * Force normal to face away from face.
  103219. */
  103220. forceNormalForward: boolean;
  103221. /**
  103222. * Enables specular anti aliasing in the PBR shader.
  103223. * It will both interacts on the Geometry for analytical and IBL lighting.
  103224. * It also prefilter the roughness map based on the bump values.
  103225. */
  103226. enableSpecularAntiAliasing: boolean;
  103227. /**
  103228. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  103229. * makes the reflect vector face the model (under horizon).
  103230. */
  103231. useHorizonOcclusion: boolean;
  103232. /**
  103233. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  103234. * too much the area relying on ambient texture to define their ambient occlusion.
  103235. */
  103236. useRadianceOcclusion: boolean;
  103237. /**
  103238. * If set to true, no lighting calculations will be applied.
  103239. */
  103240. unlit: boolean;
  103241. /**
  103242. * Gets the image processing configuration used either in this material.
  103243. */
  103244. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103245. /**
  103246. * Sets the Default image processing configuration used either in the this material.
  103247. *
  103248. * If sets to null, the scene one is in use.
  103249. */
  103250. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103251. /**
  103252. * Gets wether the color curves effect is enabled.
  103253. */
  103254. get cameraColorCurvesEnabled(): boolean;
  103255. /**
  103256. * Sets wether the color curves effect is enabled.
  103257. */
  103258. set cameraColorCurvesEnabled(value: boolean);
  103259. /**
  103260. * Gets wether the color grading effect is enabled.
  103261. */
  103262. get cameraColorGradingEnabled(): boolean;
  103263. /**
  103264. * Gets wether the color grading effect is enabled.
  103265. */
  103266. set cameraColorGradingEnabled(value: boolean);
  103267. /**
  103268. * Gets wether tonemapping is enabled or not.
  103269. */
  103270. get cameraToneMappingEnabled(): boolean;
  103271. /**
  103272. * Sets wether tonemapping is enabled or not
  103273. */
  103274. set cameraToneMappingEnabled(value: boolean);
  103275. /**
  103276. * The camera exposure used on this material.
  103277. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103278. * This corresponds to a photographic exposure.
  103279. */
  103280. get cameraExposure(): number;
  103281. /**
  103282. * The camera exposure used on this material.
  103283. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103284. * This corresponds to a photographic exposure.
  103285. */
  103286. set cameraExposure(value: number);
  103287. /**
  103288. * Gets The camera contrast used on this material.
  103289. */
  103290. get cameraContrast(): number;
  103291. /**
  103292. * Sets The camera contrast used on this material.
  103293. */
  103294. set cameraContrast(value: number);
  103295. /**
  103296. * Gets the Color Grading 2D Lookup Texture.
  103297. */
  103298. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  103299. /**
  103300. * Sets the Color Grading 2D Lookup Texture.
  103301. */
  103302. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  103303. /**
  103304. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103305. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103306. * 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;
  103307. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103308. */
  103309. get cameraColorCurves(): Nullable<ColorCurves>;
  103310. /**
  103311. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103312. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103313. * 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;
  103314. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103315. */
  103316. set cameraColorCurves(value: Nullable<ColorCurves>);
  103317. /**
  103318. * Instantiates a new PBRMaterial instance.
  103319. *
  103320. * @param name The material name
  103321. * @param scene The scene the material will be use in.
  103322. */
  103323. constructor(name: string, scene: Scene);
  103324. /**
  103325. * Returns the name of this material class.
  103326. */
  103327. getClassName(): string;
  103328. /**
  103329. * Makes a duplicate of the current material.
  103330. * @param name - name to use for the new material.
  103331. */
  103332. clone(name: string): PBRMaterial;
  103333. /**
  103334. * Serializes this PBR Material.
  103335. * @returns - An object with the serialized material.
  103336. */
  103337. serialize(): any;
  103338. /**
  103339. * Parses a PBR Material from a serialized object.
  103340. * @param source - Serialized object.
  103341. * @param scene - BJS scene instance.
  103342. * @param rootUrl - url for the scene object
  103343. * @returns - PBRMaterial
  103344. */
  103345. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  103346. }
  103347. }
  103348. declare module BABYLON {
  103349. /** @hidden */
  103350. export var mrtFragmentDeclaration: {
  103351. name: string;
  103352. shader: string;
  103353. };
  103354. }
  103355. declare module BABYLON {
  103356. /** @hidden */
  103357. export var geometryPixelShader: {
  103358. name: string;
  103359. shader: string;
  103360. };
  103361. }
  103362. declare module BABYLON {
  103363. /** @hidden */
  103364. export var geometryVertexShader: {
  103365. name: string;
  103366. shader: string;
  103367. };
  103368. }
  103369. declare module BABYLON {
  103370. /** @hidden */
  103371. interface ISavedTransformationMatrix {
  103372. world: Matrix;
  103373. viewProjection: Matrix;
  103374. }
  103375. /**
  103376. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  103377. */
  103378. export class GeometryBufferRenderer {
  103379. /**
  103380. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  103381. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  103382. */
  103383. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  103384. /**
  103385. * Constant used to retrieve the position texture index in the G-Buffer textures array
  103386. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  103387. */
  103388. static readonly POSITION_TEXTURE_TYPE: number;
  103389. /**
  103390. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  103391. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  103392. */
  103393. static readonly VELOCITY_TEXTURE_TYPE: number;
  103394. /**
  103395. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  103396. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  103397. */
  103398. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  103399. /**
  103400. * Dictionary used to store the previous transformation matrices of each rendered mesh
  103401. * in order to compute objects velocities when enableVelocity is set to "true"
  103402. * @hidden
  103403. */
  103404. _previousTransformationMatrices: {
  103405. [index: number]: ISavedTransformationMatrix;
  103406. };
  103407. /**
  103408. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  103409. * in order to compute objects velocities when enableVelocity is set to "true"
  103410. * @hidden
  103411. */
  103412. _previousBonesTransformationMatrices: {
  103413. [index: number]: Float32Array;
  103414. };
  103415. /**
  103416. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  103417. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  103418. */
  103419. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  103420. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  103421. renderTransparentMeshes: boolean;
  103422. private _scene;
  103423. private _resizeObserver;
  103424. private _multiRenderTarget;
  103425. private _ratio;
  103426. private _enablePosition;
  103427. private _enableVelocity;
  103428. private _enableReflectivity;
  103429. private _positionIndex;
  103430. private _velocityIndex;
  103431. private _reflectivityIndex;
  103432. private _depthNormalIndex;
  103433. private _linkedWithPrePass;
  103434. private _prePassRenderer;
  103435. private _attachments;
  103436. protected _effect: Effect;
  103437. protected _cachedDefines: string;
  103438. /**
  103439. * @hidden
  103440. * Sets up internal structures to share outputs with PrePassRenderer
  103441. * This method should only be called by the PrePassRenderer itself
  103442. */
  103443. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  103444. /**
  103445. * @hidden
  103446. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  103447. * This method should only be called by the PrePassRenderer itself
  103448. */
  103449. _unlinkPrePassRenderer(): void;
  103450. /**
  103451. * @hidden
  103452. * Resets the geometry buffer layout
  103453. */
  103454. _resetLayout(): void;
  103455. /**
  103456. * @hidden
  103457. * Replaces a texture in the geometry buffer renderer
  103458. * Useful when linking textures of the prepass renderer
  103459. */
  103460. _forceTextureType(geometryBufferType: number, index: number): void;
  103461. /**
  103462. * @hidden
  103463. * Sets texture attachments
  103464. * Useful when linking textures of the prepass renderer
  103465. */
  103466. _setAttachments(attachments: number[]): void;
  103467. /**
  103468. * @hidden
  103469. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  103470. * Useful when linking textures of the prepass renderer
  103471. */
  103472. _linkInternalTexture(internalTexture: InternalTexture): void;
  103473. /**
  103474. * Gets the render list (meshes to be rendered) used in the G buffer.
  103475. */
  103476. get renderList(): Nullable<AbstractMesh[]>;
  103477. /**
  103478. * Set the render list (meshes to be rendered) used in the G buffer.
  103479. */
  103480. set renderList(meshes: Nullable<AbstractMesh[]>);
  103481. /**
  103482. * Gets wether or not G buffer are supported by the running hardware.
  103483. * This requires draw buffer supports
  103484. */
  103485. get isSupported(): boolean;
  103486. /**
  103487. * Returns the index of the given texture type in the G-Buffer textures array
  103488. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  103489. * @returns the index of the given texture type in the G-Buffer textures array
  103490. */
  103491. getTextureIndex(textureType: number): number;
  103492. /**
  103493. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  103494. */
  103495. get enablePosition(): boolean;
  103496. /**
  103497. * Sets whether or not objects positions are enabled for the G buffer.
  103498. */
  103499. set enablePosition(enable: boolean);
  103500. /**
  103501. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  103502. */
  103503. get enableVelocity(): boolean;
  103504. /**
  103505. * Sets wether or not objects velocities are enabled for the G buffer.
  103506. */
  103507. set enableVelocity(enable: boolean);
  103508. /**
  103509. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  103510. */
  103511. get enableReflectivity(): boolean;
  103512. /**
  103513. * Sets wether or not objects roughness are enabled for the G buffer.
  103514. */
  103515. set enableReflectivity(enable: boolean);
  103516. /**
  103517. * Gets the scene associated with the buffer.
  103518. */
  103519. get scene(): Scene;
  103520. /**
  103521. * Gets the ratio used by the buffer during its creation.
  103522. * How big is the buffer related to the main canvas.
  103523. */
  103524. get ratio(): number;
  103525. /** @hidden */
  103526. static _SceneComponentInitialization: (scene: Scene) => void;
  103527. /**
  103528. * Creates a new G Buffer for the scene
  103529. * @param scene The scene the buffer belongs to
  103530. * @param ratio How big is the buffer related to the main canvas.
  103531. */
  103532. constructor(scene: Scene, ratio?: number);
  103533. /**
  103534. * Checks wether everything is ready to render a submesh to the G buffer.
  103535. * @param subMesh the submesh to check readiness for
  103536. * @param useInstances is the mesh drawn using instance or not
  103537. * @returns true if ready otherwise false
  103538. */
  103539. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103540. /**
  103541. * Gets the current underlying G Buffer.
  103542. * @returns the buffer
  103543. */
  103544. getGBuffer(): MultiRenderTarget;
  103545. /**
  103546. * Gets the number of samples used to render the buffer (anti aliasing).
  103547. */
  103548. get samples(): number;
  103549. /**
  103550. * Sets the number of samples used to render the buffer (anti aliasing).
  103551. */
  103552. set samples(value: number);
  103553. /**
  103554. * Disposes the renderer and frees up associated resources.
  103555. */
  103556. dispose(): void;
  103557. private _assignRenderTargetIndices;
  103558. protected _createRenderTargets(): void;
  103559. private _copyBonesTransformationMatrices;
  103560. }
  103561. }
  103562. declare module BABYLON {
  103563. /**
  103564. * Renders a pre pass of the scene
  103565. * This means every mesh in the scene will be rendered to a render target texture
  103566. * And then this texture will be composited to the rendering canvas with post processes
  103567. * It is necessary for effects like subsurface scattering or deferred shading
  103568. */
  103569. export class PrePassRenderer {
  103570. /** @hidden */
  103571. static _SceneComponentInitialization: (scene: Scene) => void;
  103572. private _textureFormats;
  103573. /**
  103574. * To save performance, we can excluded skinned meshes from the prepass
  103575. */
  103576. excludedSkinnedMesh: AbstractMesh[];
  103577. /**
  103578. * Force material to be excluded from the prepass
  103579. * Can be useful when `useGeometryBufferFallback` is set to `true`
  103580. * and you don't want a material to show in the effect.
  103581. */
  103582. excludedMaterials: Material[];
  103583. private _textureIndices;
  103584. private _scene;
  103585. private _engine;
  103586. private _isDirty;
  103587. /**
  103588. * Number of textures in the multi render target texture where the scene is directly rendered
  103589. */
  103590. mrtCount: number;
  103591. /**
  103592. * The render target where the scene is directly rendered
  103593. */
  103594. prePassRT: MultiRenderTarget;
  103595. private _multiRenderAttachments;
  103596. private _defaultAttachments;
  103597. private _clearAttachments;
  103598. private _postProcesses;
  103599. private readonly _clearColor;
  103600. /**
  103601. * Image processing post process for composition
  103602. */
  103603. imageProcessingPostProcess: ImageProcessingPostProcess;
  103604. /**
  103605. * Configuration for prepass effects
  103606. */
  103607. private _effectConfigurations;
  103608. private _mrtFormats;
  103609. private _mrtLayout;
  103610. private _enabled;
  103611. /**
  103612. * Indicates if the prepass is enabled
  103613. */
  103614. get enabled(): boolean;
  103615. /**
  103616. * How many samples are used for MSAA of the scene render target
  103617. */
  103618. get samples(): number;
  103619. set samples(n: number);
  103620. private _geometryBuffer;
  103621. private _useGeometryBufferFallback;
  103622. /**
  103623. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  103624. */
  103625. get useGeometryBufferFallback(): boolean;
  103626. set useGeometryBufferFallback(value: boolean);
  103627. /**
  103628. * Instanciates a prepass renderer
  103629. * @param scene The scene
  103630. */
  103631. constructor(scene: Scene);
  103632. private _initializeAttachments;
  103633. private _createCompositionEffect;
  103634. /**
  103635. * Indicates if rendering a prepass is supported
  103636. */
  103637. get isSupported(): boolean;
  103638. /**
  103639. * Sets the proper output textures to draw in the engine.
  103640. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  103641. * @param subMesh Submesh on which the effect is applied
  103642. */
  103643. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  103644. /**
  103645. * @hidden
  103646. */
  103647. _beforeCameraDraw(): void;
  103648. /**
  103649. * @hidden
  103650. */
  103651. _afterCameraDraw(): void;
  103652. private _checkRTSize;
  103653. private _bindFrameBuffer;
  103654. /**
  103655. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  103656. */
  103657. clear(): void;
  103658. private _setState;
  103659. private _updateGeometryBufferLayout;
  103660. /**
  103661. * Adds an effect configuration to the prepass.
  103662. * If an effect has already been added, it won't add it twice and will return the configuration
  103663. * already present.
  103664. * @param cfg the effect configuration
  103665. * @return the effect configuration now used by the prepass
  103666. */
  103667. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  103668. /**
  103669. * Returns the index of a texture in the multi render target texture array.
  103670. * @param type Texture type
  103671. * @return The index
  103672. */
  103673. getIndex(type: number): number;
  103674. private _enable;
  103675. private _disable;
  103676. private _resetLayout;
  103677. private _resetPostProcessChain;
  103678. private _bindPostProcessChain;
  103679. /**
  103680. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  103681. */
  103682. markAsDirty(): void;
  103683. /**
  103684. * Enables a texture on the MultiRenderTarget for prepass
  103685. */
  103686. private _enableTextures;
  103687. private _update;
  103688. private _markAllMaterialsAsPrePassDirty;
  103689. /**
  103690. * Disposes the prepass renderer.
  103691. */
  103692. dispose(): void;
  103693. }
  103694. }
  103695. declare module BABYLON {
  103696. /**
  103697. * Size options for a post process
  103698. */
  103699. export type PostProcessOptions = {
  103700. width: number;
  103701. height: number;
  103702. };
  103703. /**
  103704. * PostProcess can be used to apply a shader to a texture after it has been rendered
  103705. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103706. */
  103707. export class PostProcess {
  103708. /**
  103709. * Gets or sets the unique id of the post process
  103710. */
  103711. uniqueId: number;
  103712. /** Name of the PostProcess. */
  103713. name: string;
  103714. /**
  103715. * Width of the texture to apply the post process on
  103716. */
  103717. width: number;
  103718. /**
  103719. * Height of the texture to apply the post process on
  103720. */
  103721. height: number;
  103722. /**
  103723. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  103724. */
  103725. nodeMaterialSource: Nullable<NodeMaterial>;
  103726. /**
  103727. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  103728. * @hidden
  103729. */
  103730. _outputTexture: Nullable<InternalTexture>;
  103731. /**
  103732. * Sampling mode used by the shader
  103733. * See https://doc.babylonjs.com/classes/3.1/texture
  103734. */
  103735. renderTargetSamplingMode: number;
  103736. /**
  103737. * Clear color to use when screen clearing
  103738. */
  103739. clearColor: Color4;
  103740. /**
  103741. * If the buffer needs to be cleared before applying the post process. (default: true)
  103742. * Should be set to false if shader will overwrite all previous pixels.
  103743. */
  103744. autoClear: boolean;
  103745. /**
  103746. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  103747. */
  103748. alphaMode: number;
  103749. /**
  103750. * Sets the setAlphaBlendConstants of the babylon engine
  103751. */
  103752. alphaConstants: Color4;
  103753. /**
  103754. * Animations to be used for the post processing
  103755. */
  103756. animations: Animation[];
  103757. /**
  103758. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  103759. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  103760. */
  103761. enablePixelPerfectMode: boolean;
  103762. /**
  103763. * Force the postprocess to be applied without taking in account viewport
  103764. */
  103765. forceFullscreenViewport: boolean;
  103766. /**
  103767. * List of inspectable custom properties (used by the Inspector)
  103768. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103769. */
  103770. inspectableCustomProperties: IInspectable[];
  103771. /**
  103772. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  103773. *
  103774. * | Value | Type | Description |
  103775. * | ----- | ----------------------------------- | ----------- |
  103776. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  103777. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  103778. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  103779. *
  103780. */
  103781. scaleMode: number;
  103782. /**
  103783. * Force textures to be a power of two (default: false)
  103784. */
  103785. alwaysForcePOT: boolean;
  103786. private _samples;
  103787. /**
  103788. * Number of sample textures (default: 1)
  103789. */
  103790. get samples(): number;
  103791. set samples(n: number);
  103792. /**
  103793. * Modify the scale of the post process to be the same as the viewport (default: false)
  103794. */
  103795. adaptScaleToCurrentViewport: boolean;
  103796. private _camera;
  103797. protected _scene: Scene;
  103798. private _engine;
  103799. private _options;
  103800. private _reusable;
  103801. private _textureType;
  103802. private _textureFormat;
  103803. /**
  103804. * Smart array of input and output textures for the post process.
  103805. * @hidden
  103806. */
  103807. _textures: SmartArray<InternalTexture>;
  103808. /**
  103809. * The index in _textures that corresponds to the output texture.
  103810. * @hidden
  103811. */
  103812. _currentRenderTextureInd: number;
  103813. private _effect;
  103814. private _samplers;
  103815. private _fragmentUrl;
  103816. private _vertexUrl;
  103817. private _parameters;
  103818. private _scaleRatio;
  103819. protected _indexParameters: any;
  103820. private _shareOutputWithPostProcess;
  103821. private _texelSize;
  103822. private _forcedOutputTexture;
  103823. /**
  103824. * Prepass configuration in case this post process needs a texture from prepass
  103825. * @hidden
  103826. */
  103827. _prePassEffectConfiguration: PrePassEffectConfiguration;
  103828. /**
  103829. * Returns the fragment url or shader name used in the post process.
  103830. * @returns the fragment url or name in the shader store.
  103831. */
  103832. getEffectName(): string;
  103833. /**
  103834. * An event triggered when the postprocess is activated.
  103835. */
  103836. onActivateObservable: Observable<Camera>;
  103837. private _onActivateObserver;
  103838. /**
  103839. * A function that is added to the onActivateObservable
  103840. */
  103841. set onActivate(callback: Nullable<(camera: Camera) => void>);
  103842. /**
  103843. * An event triggered when the postprocess changes its size.
  103844. */
  103845. onSizeChangedObservable: Observable<PostProcess>;
  103846. private _onSizeChangedObserver;
  103847. /**
  103848. * A function that is added to the onSizeChangedObservable
  103849. */
  103850. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  103851. /**
  103852. * An event triggered when the postprocess applies its effect.
  103853. */
  103854. onApplyObservable: Observable<Effect>;
  103855. private _onApplyObserver;
  103856. /**
  103857. * A function that is added to the onApplyObservable
  103858. */
  103859. set onApply(callback: (effect: Effect) => void);
  103860. /**
  103861. * An event triggered before rendering the postprocess
  103862. */
  103863. onBeforeRenderObservable: Observable<Effect>;
  103864. private _onBeforeRenderObserver;
  103865. /**
  103866. * A function that is added to the onBeforeRenderObservable
  103867. */
  103868. set onBeforeRender(callback: (effect: Effect) => void);
  103869. /**
  103870. * An event triggered after rendering the postprocess
  103871. */
  103872. onAfterRenderObservable: Observable<Effect>;
  103873. private _onAfterRenderObserver;
  103874. /**
  103875. * A function that is added to the onAfterRenderObservable
  103876. */
  103877. set onAfterRender(callback: (efect: Effect) => void);
  103878. /**
  103879. * 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
  103880. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  103881. */
  103882. get inputTexture(): InternalTexture;
  103883. set inputTexture(value: InternalTexture);
  103884. /**
  103885. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  103886. * the only way to unset it is to use this function to restore its internal state
  103887. */
  103888. restoreDefaultInputTexture(): void;
  103889. /**
  103890. * Gets the camera which post process is applied to.
  103891. * @returns The camera the post process is applied to.
  103892. */
  103893. getCamera(): Camera;
  103894. /**
  103895. * Gets the texel size of the postprocess.
  103896. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  103897. */
  103898. get texelSize(): Vector2;
  103899. /**
  103900. * Creates a new instance PostProcess
  103901. * @param name The name of the PostProcess.
  103902. * @param fragmentUrl The url of the fragment shader to be used.
  103903. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  103904. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  103905. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103906. * @param camera The camera to apply the render pass to.
  103907. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103908. * @param engine The engine which the post process will be applied. (default: current engine)
  103909. * @param reusable If the post process can be reused on the same frame. (default: false)
  103910. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  103911. * @param textureType Type of textures used when performing the post process. (default: 0)
  103912. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  103913. * @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
  103914. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  103915. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  103916. */
  103917. 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);
  103918. /**
  103919. * Gets a string identifying the name of the class
  103920. * @returns "PostProcess" string
  103921. */
  103922. getClassName(): string;
  103923. /**
  103924. * Gets the engine which this post process belongs to.
  103925. * @returns The engine the post process was enabled with.
  103926. */
  103927. getEngine(): Engine;
  103928. /**
  103929. * The effect that is created when initializing the post process.
  103930. * @returns The created effect corresponding the the postprocess.
  103931. */
  103932. getEffect(): Effect;
  103933. /**
  103934. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  103935. * @param postProcess The post process to share the output with.
  103936. * @returns This post process.
  103937. */
  103938. shareOutputWith(postProcess: PostProcess): PostProcess;
  103939. /**
  103940. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  103941. * This should be called if the post process that shares output with this post process is disabled/disposed.
  103942. */
  103943. useOwnOutput(): void;
  103944. /**
  103945. * Updates the effect with the current post process compile time values and recompiles the shader.
  103946. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  103947. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  103948. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  103949. * @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
  103950. * @param onCompiled Called when the shader has been compiled.
  103951. * @param onError Called if there is an error when compiling a shader.
  103952. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  103953. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  103954. */
  103955. 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;
  103956. /**
  103957. * The post process is reusable if it can be used multiple times within one frame.
  103958. * @returns If the post process is reusable
  103959. */
  103960. isReusable(): boolean;
  103961. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  103962. markTextureDirty(): void;
  103963. /**
  103964. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  103965. * 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.
  103966. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  103967. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  103968. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  103969. * @returns The target texture that was bound to be written to.
  103970. */
  103971. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  103972. /**
  103973. * If the post process is supported.
  103974. */
  103975. get isSupported(): boolean;
  103976. /**
  103977. * The aspect ratio of the output texture.
  103978. */
  103979. get aspectRatio(): number;
  103980. /**
  103981. * Get a value indicating if the post-process is ready to be used
  103982. * @returns true if the post-process is ready (shader is compiled)
  103983. */
  103984. isReady(): boolean;
  103985. /**
  103986. * Binds all textures and uniforms to the shader, this will be run on every pass.
  103987. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  103988. */
  103989. apply(): Nullable<Effect>;
  103990. private _disposeTextures;
  103991. /**
  103992. * Sets the required values to the prepass renderer.
  103993. * @param prePassRenderer defines the prepass renderer to setup.
  103994. * @returns true if the pre pass is needed.
  103995. */
  103996. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  103997. /**
  103998. * Disposes the post process.
  103999. * @param camera The camera to dispose the post process on.
  104000. */
  104001. dispose(camera?: Camera): void;
  104002. /**
  104003. * Serializes the particle system to a JSON object
  104004. * @returns the JSON object
  104005. */
  104006. serialize(): any;
  104007. /**
  104008. * Creates a material from parsed material data
  104009. * @param parsedPostProcess defines parsed post process data
  104010. * @param scene defines the hosting scene
  104011. * @param rootUrl defines the root URL to use to load textures
  104012. * @returns a new post process
  104013. */
  104014. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  104015. }
  104016. }
  104017. declare module BABYLON {
  104018. /** @hidden */
  104019. export var kernelBlurVaryingDeclaration: {
  104020. name: string;
  104021. shader: string;
  104022. };
  104023. }
  104024. declare module BABYLON {
  104025. /** @hidden */
  104026. export var packingFunctions: {
  104027. name: string;
  104028. shader: string;
  104029. };
  104030. }
  104031. declare module BABYLON {
  104032. /** @hidden */
  104033. export var kernelBlurFragment: {
  104034. name: string;
  104035. shader: string;
  104036. };
  104037. }
  104038. declare module BABYLON {
  104039. /** @hidden */
  104040. export var kernelBlurFragment2: {
  104041. name: string;
  104042. shader: string;
  104043. };
  104044. }
  104045. declare module BABYLON {
  104046. /** @hidden */
  104047. export var kernelBlurPixelShader: {
  104048. name: string;
  104049. shader: string;
  104050. };
  104051. }
  104052. declare module BABYLON {
  104053. /** @hidden */
  104054. export var kernelBlurVertex: {
  104055. name: string;
  104056. shader: string;
  104057. };
  104058. }
  104059. declare module BABYLON {
  104060. /** @hidden */
  104061. export var kernelBlurVertexShader: {
  104062. name: string;
  104063. shader: string;
  104064. };
  104065. }
  104066. declare module BABYLON {
  104067. /**
  104068. * The Blur Post Process which blurs an image based on a kernel and direction.
  104069. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  104070. */
  104071. export class BlurPostProcess extends PostProcess {
  104072. private blockCompilation;
  104073. protected _kernel: number;
  104074. protected _idealKernel: number;
  104075. protected _packedFloat: boolean;
  104076. private _staticDefines;
  104077. /** The direction in which to blur the image. */
  104078. direction: Vector2;
  104079. /**
  104080. * Sets the length in pixels of the blur sample region
  104081. */
  104082. set kernel(v: number);
  104083. /**
  104084. * Gets the length in pixels of the blur sample region
  104085. */
  104086. get kernel(): number;
  104087. /**
  104088. * Sets wether or not the blur needs to unpack/repack floats
  104089. */
  104090. set packedFloat(v: boolean);
  104091. /**
  104092. * Gets wether or not the blur is unpacking/repacking floats
  104093. */
  104094. get packedFloat(): boolean;
  104095. /**
  104096. * Gets a string identifying the name of the class
  104097. * @returns "BlurPostProcess" string
  104098. */
  104099. getClassName(): string;
  104100. /**
  104101. * Creates a new instance BlurPostProcess
  104102. * @param name The name of the effect.
  104103. * @param direction The direction in which to blur the image.
  104104. * @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.
  104105. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  104106. * @param camera The camera to apply the render pass to.
  104107. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104108. * @param engine The engine which the post process will be applied. (default: current engine)
  104109. * @param reusable If the post process can be reused on the same frame. (default: false)
  104110. * @param textureType Type of textures used when performing the post process. (default: 0)
  104111. * @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)
  104112. */
  104113. 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);
  104114. /**
  104115. * Updates the effect with the current post process compile time values and recompiles the shader.
  104116. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  104117. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  104118. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  104119. * @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
  104120. * @param onCompiled Called when the shader has been compiled.
  104121. * @param onError Called if there is an error when compiling a shader.
  104122. */
  104123. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  104124. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  104125. /**
  104126. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  104127. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  104128. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  104129. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  104130. * The gaps between physical kernels are compensated for in the weighting of the samples
  104131. * @param idealKernel Ideal blur kernel.
  104132. * @return Nearest best kernel.
  104133. */
  104134. protected _nearestBestKernel(idealKernel: number): number;
  104135. /**
  104136. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  104137. * @param x The point on the Gaussian distribution to sample.
  104138. * @return the value of the Gaussian function at x.
  104139. */
  104140. protected _gaussianWeight(x: number): number;
  104141. /**
  104142. * Generates a string that can be used as a floating point number in GLSL.
  104143. * @param x Value to print.
  104144. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  104145. * @return GLSL float string.
  104146. */
  104147. protected _glslFloat(x: number, decimalFigures?: number): string;
  104148. /** @hidden */
  104149. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  104150. }
  104151. }
  104152. declare module BABYLON {
  104153. /**
  104154. * Mirror texture can be used to simulate the view from a mirror in a scene.
  104155. * It will dynamically be rendered every frame to adapt to the camera point of view.
  104156. * You can then easily use it as a reflectionTexture on a flat surface.
  104157. * In case the surface is not a plane, please consider relying on reflection probes.
  104158. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104159. */
  104160. export class MirrorTexture extends RenderTargetTexture {
  104161. private scene;
  104162. /**
  104163. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  104164. * 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.
  104165. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104166. */
  104167. mirrorPlane: Plane;
  104168. /**
  104169. * Define the blur ratio used to blur the reflection if needed.
  104170. */
  104171. set blurRatio(value: number);
  104172. get blurRatio(): number;
  104173. /**
  104174. * Define the adaptive blur kernel used to blur the reflection if needed.
  104175. * This will autocompute the closest best match for the `blurKernel`
  104176. */
  104177. set adaptiveBlurKernel(value: number);
  104178. /**
  104179. * Define the blur kernel used to blur the reflection if needed.
  104180. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104181. */
  104182. set blurKernel(value: number);
  104183. /**
  104184. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  104185. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104186. */
  104187. set blurKernelX(value: number);
  104188. get blurKernelX(): number;
  104189. /**
  104190. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  104191. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104192. */
  104193. set blurKernelY(value: number);
  104194. get blurKernelY(): number;
  104195. private _autoComputeBlurKernel;
  104196. protected _onRatioRescale(): void;
  104197. private _updateGammaSpace;
  104198. private _imageProcessingConfigChangeObserver;
  104199. private _transformMatrix;
  104200. private _mirrorMatrix;
  104201. private _savedViewMatrix;
  104202. private _blurX;
  104203. private _blurY;
  104204. private _adaptiveBlurKernel;
  104205. private _blurKernelX;
  104206. private _blurKernelY;
  104207. private _blurRatio;
  104208. /**
  104209. * Instantiates a Mirror Texture.
  104210. * Mirror texture can be used to simulate the view from a mirror in a scene.
  104211. * It will dynamically be rendered every frame to adapt to the camera point of view.
  104212. * You can then easily use it as a reflectionTexture on a flat surface.
  104213. * In case the surface is not a plane, please consider relying on reflection probes.
  104214. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104215. * @param name
  104216. * @param size
  104217. * @param scene
  104218. * @param generateMipMaps
  104219. * @param type
  104220. * @param samplingMode
  104221. * @param generateDepthBuffer
  104222. */
  104223. constructor(name: string, size: number | {
  104224. width: number;
  104225. height: number;
  104226. } | {
  104227. ratio: number;
  104228. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  104229. private _preparePostProcesses;
  104230. /**
  104231. * Clone the mirror texture.
  104232. * @returns the cloned texture
  104233. */
  104234. clone(): MirrorTexture;
  104235. /**
  104236. * Serialize the texture to a JSON representation you could use in Parse later on
  104237. * @returns the serialized JSON representation
  104238. */
  104239. serialize(): any;
  104240. /**
  104241. * Dispose the texture and release its associated resources.
  104242. */
  104243. dispose(): void;
  104244. }
  104245. }
  104246. declare module BABYLON {
  104247. /**
  104248. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  104249. * @see https://doc.babylonjs.com/babylon101/materials#texture
  104250. */
  104251. export class Texture extends BaseTexture {
  104252. /**
  104253. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  104254. */
  104255. static SerializeBuffers: boolean;
  104256. /**
  104257. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  104258. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  104259. */
  104260. static ForceSerializeBuffers: boolean;
  104261. /** @hidden */
  104262. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  104263. /** @hidden */
  104264. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  104265. /** @hidden */
  104266. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  104267. /** nearest is mag = nearest and min = nearest and mip = linear */
  104268. static readonly NEAREST_SAMPLINGMODE: number;
  104269. /** nearest is mag = nearest and min = nearest and mip = linear */
  104270. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  104271. /** Bilinear is mag = linear and min = linear and mip = nearest */
  104272. static readonly BILINEAR_SAMPLINGMODE: number;
  104273. /** Bilinear is mag = linear and min = linear and mip = nearest */
  104274. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  104275. /** Trilinear is mag = linear and min = linear and mip = linear */
  104276. static readonly TRILINEAR_SAMPLINGMODE: number;
  104277. /** Trilinear is mag = linear and min = linear and mip = linear */
  104278. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  104279. /** mag = nearest and min = nearest and mip = nearest */
  104280. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  104281. /** mag = nearest and min = linear and mip = nearest */
  104282. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  104283. /** mag = nearest and min = linear and mip = linear */
  104284. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  104285. /** mag = nearest and min = linear and mip = none */
  104286. static readonly NEAREST_LINEAR: number;
  104287. /** mag = nearest and min = nearest and mip = none */
  104288. static readonly NEAREST_NEAREST: number;
  104289. /** mag = linear and min = nearest and mip = nearest */
  104290. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  104291. /** mag = linear and min = nearest and mip = linear */
  104292. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  104293. /** mag = linear and min = linear and mip = none */
  104294. static readonly LINEAR_LINEAR: number;
  104295. /** mag = linear and min = nearest and mip = none */
  104296. static readonly LINEAR_NEAREST: number;
  104297. /** Explicit coordinates mode */
  104298. static readonly EXPLICIT_MODE: number;
  104299. /** Spherical coordinates mode */
  104300. static readonly SPHERICAL_MODE: number;
  104301. /** Planar coordinates mode */
  104302. static readonly PLANAR_MODE: number;
  104303. /** Cubic coordinates mode */
  104304. static readonly CUBIC_MODE: number;
  104305. /** Projection coordinates mode */
  104306. static readonly PROJECTION_MODE: number;
  104307. /** Inverse Cubic coordinates mode */
  104308. static readonly SKYBOX_MODE: number;
  104309. /** Inverse Cubic coordinates mode */
  104310. static readonly INVCUBIC_MODE: number;
  104311. /** Equirectangular coordinates mode */
  104312. static readonly EQUIRECTANGULAR_MODE: number;
  104313. /** Equirectangular Fixed coordinates mode */
  104314. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  104315. /** Equirectangular Fixed Mirrored coordinates mode */
  104316. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  104317. /** Texture is not repeating outside of 0..1 UVs */
  104318. static readonly CLAMP_ADDRESSMODE: number;
  104319. /** Texture is repeating outside of 0..1 UVs */
  104320. static readonly WRAP_ADDRESSMODE: number;
  104321. /** Texture is repeating and mirrored */
  104322. static readonly MIRROR_ADDRESSMODE: number;
  104323. /**
  104324. * 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
  104325. */
  104326. static UseSerializedUrlIfAny: boolean;
  104327. /**
  104328. * Define the url of the texture.
  104329. */
  104330. url: Nullable<string>;
  104331. /**
  104332. * Define an offset on the texture to offset the u coordinates of the UVs
  104333. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  104334. */
  104335. uOffset: number;
  104336. /**
  104337. * Define an offset on the texture to offset the v coordinates of the UVs
  104338. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  104339. */
  104340. vOffset: number;
  104341. /**
  104342. * Define an offset on the texture to scale the u coordinates of the UVs
  104343. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  104344. */
  104345. uScale: number;
  104346. /**
  104347. * Define an offset on the texture to scale the v coordinates of the UVs
  104348. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  104349. */
  104350. vScale: number;
  104351. /**
  104352. * Define an offset on the texture to rotate around the u coordinates of the UVs
  104353. * @see https://doc.babylonjs.com/how_to/more_materials
  104354. */
  104355. uAng: number;
  104356. /**
  104357. * Define an offset on the texture to rotate around the v coordinates of the UVs
  104358. * @see https://doc.babylonjs.com/how_to/more_materials
  104359. */
  104360. vAng: number;
  104361. /**
  104362. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  104363. * @see https://doc.babylonjs.com/how_to/more_materials
  104364. */
  104365. wAng: number;
  104366. /**
  104367. * Defines the center of rotation (U)
  104368. */
  104369. uRotationCenter: number;
  104370. /**
  104371. * Defines the center of rotation (V)
  104372. */
  104373. vRotationCenter: number;
  104374. /**
  104375. * Defines the center of rotation (W)
  104376. */
  104377. wRotationCenter: number;
  104378. /**
  104379. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  104380. */
  104381. homogeneousRotationInUVTransform: boolean;
  104382. /**
  104383. * Are mip maps generated for this texture or not.
  104384. */
  104385. get noMipmap(): boolean;
  104386. /**
  104387. * List of inspectable custom properties (used by the Inspector)
  104388. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  104389. */
  104390. inspectableCustomProperties: Nullable<IInspectable[]>;
  104391. private _noMipmap;
  104392. /** @hidden */
  104393. _invertY: boolean;
  104394. private _rowGenerationMatrix;
  104395. private _cachedTextureMatrix;
  104396. private _projectionModeMatrix;
  104397. private _t0;
  104398. private _t1;
  104399. private _t2;
  104400. private _cachedUOffset;
  104401. private _cachedVOffset;
  104402. private _cachedUScale;
  104403. private _cachedVScale;
  104404. private _cachedUAng;
  104405. private _cachedVAng;
  104406. private _cachedWAng;
  104407. private _cachedProjectionMatrixId;
  104408. private _cachedURotationCenter;
  104409. private _cachedVRotationCenter;
  104410. private _cachedWRotationCenter;
  104411. private _cachedHomogeneousRotationInUVTransform;
  104412. private _cachedCoordinatesMode;
  104413. /** @hidden */
  104414. protected _initialSamplingMode: number;
  104415. /** @hidden */
  104416. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  104417. private _deleteBuffer;
  104418. protected _format: Nullable<number>;
  104419. private _delayedOnLoad;
  104420. private _delayedOnError;
  104421. private _mimeType?;
  104422. private _loaderOptions?;
  104423. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  104424. get mimeType(): string | undefined;
  104425. /**
  104426. * Observable triggered once the texture has been loaded.
  104427. */
  104428. onLoadObservable: Observable<Texture>;
  104429. protected _isBlocking: boolean;
  104430. /**
  104431. * Is the texture preventing material to render while loading.
  104432. * If false, a default texture will be used instead of the loading one during the preparation step.
  104433. */
  104434. set isBlocking(value: boolean);
  104435. get isBlocking(): boolean;
  104436. /**
  104437. * Get the current sampling mode associated with the texture.
  104438. */
  104439. get samplingMode(): number;
  104440. /**
  104441. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  104442. */
  104443. get invertY(): boolean;
  104444. /**
  104445. * Instantiates a new texture.
  104446. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  104447. * @see https://doc.babylonjs.com/babylon101/materials#texture
  104448. * @param url defines the url of the picture to load as a texture
  104449. * @param sceneOrEngine defines the scene or engine the texture will belong to
  104450. * @param noMipmap defines if the texture will require mip maps or not
  104451. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  104452. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104453. * @param onLoad defines a callback triggered when the texture has been loaded
  104454. * @param onError defines a callback triggered when an error occurred during the loading session
  104455. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  104456. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  104457. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104458. * @param mimeType defines an optional mime type information
  104459. * @param loaderOptions options to be passed to the loader
  104460. */
  104461. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string, loaderOptions?: any);
  104462. /**
  104463. * Update the url (and optional buffer) of this texture if url was null during construction.
  104464. * @param url the url of the texture
  104465. * @param buffer the buffer of the texture (defaults to null)
  104466. * @param onLoad callback called when the texture is loaded (defaults to null)
  104467. */
  104468. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  104469. /**
  104470. * Finish the loading sequence of a texture flagged as delayed load.
  104471. * @hidden
  104472. */
  104473. delayLoad(): void;
  104474. private _prepareRowForTextureGeneration;
  104475. /**
  104476. * Checks if the texture has the same transform matrix than another texture
  104477. * @param texture texture to check against
  104478. * @returns true if the transforms are the same, else false
  104479. */
  104480. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  104481. /**
  104482. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  104483. * @returns the transform matrix of the texture.
  104484. */
  104485. getTextureMatrix(uBase?: number): Matrix;
  104486. /**
  104487. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  104488. * @returns The reflection texture transform
  104489. */
  104490. getReflectionTextureMatrix(): Matrix;
  104491. /**
  104492. * Clones the texture.
  104493. * @returns the cloned texture
  104494. */
  104495. clone(): Texture;
  104496. /**
  104497. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  104498. * @returns The JSON representation of the texture
  104499. */
  104500. serialize(): any;
  104501. /**
  104502. * Get the current class name of the texture useful for serialization or dynamic coding.
  104503. * @returns "Texture"
  104504. */
  104505. getClassName(): string;
  104506. /**
  104507. * Dispose the texture and release its associated resources.
  104508. */
  104509. dispose(): void;
  104510. /**
  104511. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  104512. * @param parsedTexture Define the JSON representation of the texture
  104513. * @param scene Define the scene the parsed texture should be instantiated in
  104514. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  104515. * @returns The parsed texture if successful
  104516. */
  104517. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  104518. /**
  104519. * Creates a texture from its base 64 representation.
  104520. * @param data Define the base64 payload without the data: prefix
  104521. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  104522. * @param scene Define the scene the texture should belong to
  104523. * @param noMipmap Forces the texture to not create mip map information if true
  104524. * @param invertY define if the texture needs to be inverted on the y axis during loading
  104525. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104526. * @param onLoad define a callback triggered when the texture has been loaded
  104527. * @param onError define a callback triggered when an error occurred during the loading session
  104528. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104529. * @returns the created texture
  104530. */
  104531. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  104532. /**
  104533. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  104534. * @param data Define the base64 payload without the data: prefix
  104535. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  104536. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  104537. * @param scene Define the scene the texture should belong to
  104538. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  104539. * @param noMipmap Forces the texture to not create mip map information if true
  104540. * @param invertY define if the texture needs to be inverted on the y axis during loading
  104541. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104542. * @param onLoad define a callback triggered when the texture has been loaded
  104543. * @param onError define a callback triggered when an error occurred during the loading session
  104544. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104545. * @returns the created texture
  104546. */
  104547. 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;
  104548. }
  104549. }
  104550. declare module BABYLON {
  104551. /** @hidden */
  104552. export var imageProcessingCompatibility: {
  104553. name: string;
  104554. shader: string;
  104555. };
  104556. }
  104557. declare module BABYLON {
  104558. /** @hidden */
  104559. export var spritesPixelShader: {
  104560. name: string;
  104561. shader: string;
  104562. };
  104563. }
  104564. declare module BABYLON {
  104565. /** @hidden */
  104566. export var spritesVertexShader: {
  104567. name: string;
  104568. shader: string;
  104569. };
  104570. }
  104571. declare module BABYLON {
  104572. /**
  104573. * ThinSprite Class used to represent a thin sprite
  104574. * This is the base class for sprites but can also directly be used with ThinEngine
  104575. * @see https://doc.babylonjs.com/babylon101/sprites
  104576. */
  104577. export class ThinSprite {
  104578. /** Gets or sets the cell index in the sprite sheet */
  104579. cellIndex: number;
  104580. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  104581. cellRef: string;
  104582. /** Gets or sets the current world position */
  104583. position: IVector3Like;
  104584. /** Gets or sets the main color */
  104585. color: IColor4Like;
  104586. /** Gets or sets the width */
  104587. width: number;
  104588. /** Gets or sets the height */
  104589. height: number;
  104590. /** Gets or sets rotation angle */
  104591. angle: number;
  104592. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  104593. invertU: boolean;
  104594. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  104595. invertV: boolean;
  104596. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  104597. isVisible: boolean;
  104598. /**
  104599. * Returns a boolean indicating if the animation is started
  104600. */
  104601. get animationStarted(): boolean;
  104602. /** Gets the initial key for the animation (setting it will restart the animation) */
  104603. get fromIndex(): number;
  104604. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  104605. get toIndex(): number;
  104606. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  104607. get loopAnimation(): boolean;
  104608. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  104609. get delay(): number;
  104610. /** @hidden */
  104611. _xOffset: number;
  104612. /** @hidden */
  104613. _yOffset: number;
  104614. /** @hidden */
  104615. _xSize: number;
  104616. /** @hidden */
  104617. _ySize: number;
  104618. private _animationStarted;
  104619. private _loopAnimation;
  104620. private _fromIndex;
  104621. private _toIndex;
  104622. private _delay;
  104623. private _direction;
  104624. private _time;
  104625. private _onBaseAnimationEnd;
  104626. /**
  104627. * Creates a new Thin Sprite
  104628. */
  104629. constructor();
  104630. /**
  104631. * Starts an animation
  104632. * @param from defines the initial key
  104633. * @param to defines the end key
  104634. * @param loop defines if the animation must loop
  104635. * @param delay defines the start delay (in ms)
  104636. * @param onAnimationEnd defines a callback for when the animation ends
  104637. */
  104638. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  104639. /** Stops current animation (if any) */
  104640. stopAnimation(): void;
  104641. /** @hidden */
  104642. _animate(deltaTime: number): void;
  104643. }
  104644. }
  104645. declare module BABYLON {
  104646. /**
  104647. * Class used to render sprites.
  104648. *
  104649. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  104650. */
  104651. export class SpriteRenderer {
  104652. /**
  104653. * Defines the texture of the spritesheet
  104654. */
  104655. texture: Nullable<ThinTexture>;
  104656. /**
  104657. * Defines the default width of a cell in the spritesheet
  104658. */
  104659. cellWidth: number;
  104660. /**
  104661. * Defines the default height of a cell in the spritesheet
  104662. */
  104663. cellHeight: number;
  104664. /**
  104665. * Blend mode use to render the particle, it can be any of
  104666. * the static Constants.ALPHA_x properties provided in this class.
  104667. * Default value is Constants.ALPHA_COMBINE
  104668. */
  104669. blendMode: number;
  104670. /**
  104671. * Gets or sets a boolean indicating if alpha mode is automatically
  104672. * reset.
  104673. */
  104674. autoResetAlpha: boolean;
  104675. /**
  104676. * Disables writing to the depth buffer when rendering the sprites.
  104677. * It can be handy to disable depth writing when using textures without alpha channel
  104678. * and setting some specific blend modes.
  104679. */
  104680. disableDepthWrite: boolean;
  104681. /**
  104682. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  104683. */
  104684. fogEnabled: boolean;
  104685. /**
  104686. * Gets the capacity of the manager
  104687. */
  104688. get capacity(): number;
  104689. private readonly _engine;
  104690. private readonly _useVAO;
  104691. private readonly _useInstancing;
  104692. private readonly _scene;
  104693. private readonly _capacity;
  104694. private readonly _epsilon;
  104695. private _vertexBufferSize;
  104696. private _vertexData;
  104697. private _buffer;
  104698. private _vertexBuffers;
  104699. private _spriteBuffer;
  104700. private _indexBuffer;
  104701. private _effectBase;
  104702. private _effectFog;
  104703. private _vertexArrayObject;
  104704. /**
  104705. * Creates a new sprite Renderer
  104706. * @param engine defines the engine the renderer works with
  104707. * @param capacity defines the maximum allowed number of sprites
  104708. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  104709. * @param scene defines the hosting scene
  104710. */
  104711. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  104712. /**
  104713. * Render all child sprites
  104714. * @param sprites defines the list of sprites to render
  104715. * @param deltaTime defines the time since last frame
  104716. * @param viewMatrix defines the viewMatrix to use to render the sprites
  104717. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  104718. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  104719. */
  104720. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  104721. private _appendSpriteVertex;
  104722. /**
  104723. * Release associated resources
  104724. */
  104725. dispose(): void;
  104726. }
  104727. }
  104728. declare module BABYLON {
  104729. /**
  104730. * Defines the minimum interface to fullfil in order to be a sprite manager.
  104731. */
  104732. export interface ISpriteManager extends IDisposable {
  104733. /**
  104734. * Gets manager's name
  104735. */
  104736. name: string;
  104737. /**
  104738. * Restricts the camera to viewing objects with the same layerMask.
  104739. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  104740. */
  104741. layerMask: number;
  104742. /**
  104743. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  104744. */
  104745. isPickable: boolean;
  104746. /**
  104747. * Gets the hosting scene
  104748. */
  104749. scene: Scene;
  104750. /**
  104751. * Specifies the rendering group id for this mesh (0 by default)
  104752. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  104753. */
  104754. renderingGroupId: number;
  104755. /**
  104756. * Defines the list of sprites managed by the manager.
  104757. */
  104758. sprites: Array<Sprite>;
  104759. /**
  104760. * Gets or sets the spritesheet texture
  104761. */
  104762. texture: Texture;
  104763. /** Defines the default width of a cell in the spritesheet */
  104764. cellWidth: number;
  104765. /** Defines the default height of a cell in the spritesheet */
  104766. cellHeight: number;
  104767. /**
  104768. * Tests the intersection of a sprite with a specific ray.
  104769. * @param ray The ray we are sending to test the collision
  104770. * @param camera The camera space we are sending rays in
  104771. * @param predicate A predicate allowing excluding sprites from the list of object to test
  104772. * @param fastCheck defines if the first intersection will be used (and not the closest)
  104773. * @returns picking info or null.
  104774. */
  104775. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  104776. /**
  104777. * Intersects the sprites with a ray
  104778. * @param ray defines the ray to intersect with
  104779. * @param camera defines the current active camera
  104780. * @param predicate defines a predicate used to select candidate sprites
  104781. * @returns null if no hit or a PickingInfo array
  104782. */
  104783. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  104784. /**
  104785. * Renders the list of sprites on screen.
  104786. */
  104787. render(): void;
  104788. }
  104789. /**
  104790. * Class used to manage multiple sprites on the same spritesheet
  104791. * @see https://doc.babylonjs.com/babylon101/sprites
  104792. */
  104793. export class SpriteManager implements ISpriteManager {
  104794. /** defines the manager's name */
  104795. name: string;
  104796. /** Define the Url to load snippets */
  104797. static SnippetUrl: string;
  104798. /** Snippet ID if the manager was created from the snippet server */
  104799. snippetId: string;
  104800. /** Gets the list of sprites */
  104801. sprites: Sprite[];
  104802. /** Gets or sets the rendering group id (0 by default) */
  104803. renderingGroupId: number;
  104804. /** Gets or sets camera layer mask */
  104805. layerMask: number;
  104806. /** Gets or sets a boolean indicating if the sprites are pickable */
  104807. isPickable: boolean;
  104808. /**
  104809. * An event triggered when the manager is disposed.
  104810. */
  104811. onDisposeObservable: Observable<SpriteManager>;
  104812. /**
  104813. * Callback called when the manager is disposed
  104814. */
  104815. set onDispose(callback: () => void);
  104816. /**
  104817. * Gets or sets the unique id of the sprite
  104818. */
  104819. uniqueId: number;
  104820. /**
  104821. * Gets the array of sprites
  104822. */
  104823. get children(): Sprite[];
  104824. /**
  104825. * Gets the hosting scene
  104826. */
  104827. get scene(): Scene;
  104828. /**
  104829. * Gets the capacity of the manager
  104830. */
  104831. get capacity(): number;
  104832. /**
  104833. * Gets or sets the spritesheet texture
  104834. */
  104835. get texture(): Texture;
  104836. set texture(value: Texture);
  104837. /** Defines the default width of a cell in the spritesheet */
  104838. get cellWidth(): number;
  104839. set cellWidth(value: number);
  104840. /** Defines the default height of a cell in the spritesheet */
  104841. get cellHeight(): number;
  104842. set cellHeight(value: number);
  104843. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  104844. get fogEnabled(): boolean;
  104845. set fogEnabled(value: boolean);
  104846. /**
  104847. * Blend mode use to render the particle, it can be any of
  104848. * the static Constants.ALPHA_x properties provided in this class.
  104849. * Default value is Constants.ALPHA_COMBINE
  104850. */
  104851. get blendMode(): number;
  104852. set blendMode(blendMode: number);
  104853. /** Disables writing to the depth buffer when rendering the sprites.
  104854. * It can be handy to disable depth writing when using textures without alpha channel
  104855. * and setting some specific blend modes.
  104856. */
  104857. disableDepthWrite: boolean;
  104858. private _spriteRenderer;
  104859. /** Associative array from JSON sprite data file */
  104860. private _cellData;
  104861. /** Array of sprite names from JSON sprite data file */
  104862. private _spriteMap;
  104863. /** True when packed cell data from JSON file is ready*/
  104864. private _packedAndReady;
  104865. private _textureContent;
  104866. private _onDisposeObserver;
  104867. private _fromPacked;
  104868. private _scene;
  104869. /**
  104870. * Creates a new sprite manager
  104871. * @param name defines the manager's name
  104872. * @param imgUrl defines the sprite sheet url
  104873. * @param capacity defines the maximum allowed number of sprites
  104874. * @param cellSize defines the size of a sprite cell
  104875. * @param scene defines the hosting scene
  104876. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  104877. * @param samplingMode defines the smapling mode to use with spritesheet
  104878. * @param fromPacked set to false; do not alter
  104879. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  104880. */
  104881. constructor(
  104882. /** defines the manager's name */
  104883. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  104884. /**
  104885. * Returns the string "SpriteManager"
  104886. * @returns "SpriteManager"
  104887. */
  104888. getClassName(): string;
  104889. private _makePacked;
  104890. private _checkTextureAlpha;
  104891. /**
  104892. * Intersects the sprites with a ray
  104893. * @param ray defines the ray to intersect with
  104894. * @param camera defines the current active camera
  104895. * @param predicate defines a predicate used to select candidate sprites
  104896. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  104897. * @returns null if no hit or a PickingInfo
  104898. */
  104899. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  104900. /**
  104901. * Intersects the sprites with a ray
  104902. * @param ray defines the ray to intersect with
  104903. * @param camera defines the current active camera
  104904. * @param predicate defines a predicate used to select candidate sprites
  104905. * @returns null if no hit or a PickingInfo array
  104906. */
  104907. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  104908. /**
  104909. * Render all child sprites
  104910. */
  104911. render(): void;
  104912. private _customUpdate;
  104913. /**
  104914. * Release associated resources
  104915. */
  104916. dispose(): void;
  104917. /**
  104918. * Serializes the sprite manager to a JSON object
  104919. * @param serializeTexture defines if the texture must be serialized as well
  104920. * @returns the JSON object
  104921. */
  104922. serialize(serializeTexture?: boolean): any;
  104923. /**
  104924. * Parses a JSON object to create a new sprite manager.
  104925. * @param parsedManager The JSON object to parse
  104926. * @param scene The scene to create the sprite managerin
  104927. * @param rootUrl The root url to use to load external dependencies like texture
  104928. * @returns the new sprite manager
  104929. */
  104930. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  104931. /**
  104932. * Creates a sprite manager from a snippet saved in a remote file
  104933. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  104934. * @param url defines the url to load from
  104935. * @param scene defines the hosting scene
  104936. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104937. * @returns a promise that will resolve to the new sprite manager
  104938. */
  104939. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  104940. /**
  104941. * Creates a sprite manager from a snippet saved by the sprite editor
  104942. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  104943. * @param scene defines the hosting scene
  104944. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104945. * @returns a promise that will resolve to the new sprite manager
  104946. */
  104947. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  104948. }
  104949. }
  104950. declare module BABYLON {
  104951. /**
  104952. * Class used to represent a sprite
  104953. * @see https://doc.babylonjs.com/babylon101/sprites
  104954. */
  104955. export class Sprite extends ThinSprite implements IAnimatable {
  104956. /** defines the name */
  104957. name: string;
  104958. /** Gets or sets the current world position */
  104959. position: Vector3;
  104960. /** Gets or sets the main color */
  104961. color: Color4;
  104962. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  104963. disposeWhenFinishedAnimating: boolean;
  104964. /** Gets the list of attached animations */
  104965. animations: Nullable<Array<Animation>>;
  104966. /** Gets or sets a boolean indicating if the sprite can be picked */
  104967. isPickable: boolean;
  104968. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  104969. useAlphaForPicking: boolean;
  104970. /**
  104971. * Gets or sets the associated action manager
  104972. */
  104973. actionManager: Nullable<ActionManager>;
  104974. /**
  104975. * An event triggered when the control has been disposed
  104976. */
  104977. onDisposeObservable: Observable<Sprite>;
  104978. private _manager;
  104979. private _onAnimationEnd;
  104980. /**
  104981. * Gets or sets the sprite size
  104982. */
  104983. get size(): number;
  104984. set size(value: number);
  104985. /**
  104986. * Gets or sets the unique id of the sprite
  104987. */
  104988. uniqueId: number;
  104989. /**
  104990. * Gets the manager of this sprite
  104991. */
  104992. get manager(): ISpriteManager;
  104993. /**
  104994. * Creates a new Sprite
  104995. * @param name defines the name
  104996. * @param manager defines the manager
  104997. */
  104998. constructor(
  104999. /** defines the name */
  105000. name: string, manager: ISpriteManager);
  105001. /**
  105002. * Returns the string "Sprite"
  105003. * @returns "Sprite"
  105004. */
  105005. getClassName(): string;
  105006. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  105007. set fromIndex(value: number);
  105008. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  105009. set toIndex(value: number);
  105010. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  105011. set loopAnimation(value: boolean);
  105012. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  105013. set delay(value: number);
  105014. /**
  105015. * Starts an animation
  105016. * @param from defines the initial key
  105017. * @param to defines the end key
  105018. * @param loop defines if the animation must loop
  105019. * @param delay defines the start delay (in ms)
  105020. * @param onAnimationEnd defines a callback to call when animation ends
  105021. */
  105022. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  105023. private _endAnimation;
  105024. /** Release associated resources */
  105025. dispose(): void;
  105026. /**
  105027. * Serializes the sprite to a JSON object
  105028. * @returns the JSON object
  105029. */
  105030. serialize(): any;
  105031. /**
  105032. * Parses a JSON object to create a new sprite
  105033. * @param parsedSprite The JSON object to parse
  105034. * @param manager defines the hosting manager
  105035. * @returns the new sprite
  105036. */
  105037. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  105038. }
  105039. }
  105040. declare module BABYLON {
  105041. /**
  105042. * Information about the result of picking within a scene
  105043. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  105044. */
  105045. export class PickingInfo {
  105046. /** @hidden */
  105047. _pickingUnavailable: boolean;
  105048. /**
  105049. * If the pick collided with an object
  105050. */
  105051. hit: boolean;
  105052. /**
  105053. * Distance away where the pick collided
  105054. */
  105055. distance: number;
  105056. /**
  105057. * The location of pick collision
  105058. */
  105059. pickedPoint: Nullable<Vector3>;
  105060. /**
  105061. * The mesh corresponding the the pick collision
  105062. */
  105063. pickedMesh: Nullable<AbstractMesh>;
  105064. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  105065. bu: number;
  105066. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  105067. bv: number;
  105068. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  105069. faceId: number;
  105070. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  105071. subMeshFaceId: number;
  105072. /** Id of the the submesh that was picked */
  105073. subMeshId: number;
  105074. /** If a sprite was picked, this will be the sprite the pick collided with */
  105075. pickedSprite: Nullable<Sprite>;
  105076. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  105077. thinInstanceIndex: number;
  105078. /**
  105079. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  105080. */
  105081. originMesh: Nullable<AbstractMesh>;
  105082. /**
  105083. * The ray that was used to perform the picking.
  105084. */
  105085. ray: Nullable<Ray>;
  105086. /**
  105087. * Gets the normal correspodning to the face the pick collided with
  105088. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  105089. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  105090. * @returns The normal correspodning to the face the pick collided with
  105091. */
  105092. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  105093. /**
  105094. * Gets the texture coordinates of where the pick occured
  105095. * @returns the vector containing the coordnates of the texture
  105096. */
  105097. getTextureCoordinates(): Nullable<Vector2>;
  105098. }
  105099. }
  105100. declare module BABYLON {
  105101. /**
  105102. * Gather the list of pointer event types as constants.
  105103. */
  105104. export class PointerEventTypes {
  105105. /**
  105106. * 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.
  105107. */
  105108. static readonly POINTERDOWN: number;
  105109. /**
  105110. * The pointerup event is fired when a pointer is no longer active.
  105111. */
  105112. static readonly POINTERUP: number;
  105113. /**
  105114. * The pointermove event is fired when a pointer changes coordinates.
  105115. */
  105116. static readonly POINTERMOVE: number;
  105117. /**
  105118. * The pointerwheel event is fired when a mouse wheel has been rotated.
  105119. */
  105120. static readonly POINTERWHEEL: number;
  105121. /**
  105122. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  105123. */
  105124. static readonly POINTERPICK: number;
  105125. /**
  105126. * The pointertap event is fired when a the object has been touched and released without drag.
  105127. */
  105128. static readonly POINTERTAP: number;
  105129. /**
  105130. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  105131. */
  105132. static readonly POINTERDOUBLETAP: number;
  105133. }
  105134. /**
  105135. * Base class of pointer info types.
  105136. */
  105137. export class PointerInfoBase {
  105138. /**
  105139. * Defines the type of event (PointerEventTypes)
  105140. */
  105141. type: number;
  105142. /**
  105143. * Defines the related dom event
  105144. */
  105145. event: PointerEvent | MouseWheelEvent;
  105146. /**
  105147. * Instantiates the base class of pointers info.
  105148. * @param type Defines the type of event (PointerEventTypes)
  105149. * @param event Defines the related dom event
  105150. */
  105151. constructor(
  105152. /**
  105153. * Defines the type of event (PointerEventTypes)
  105154. */
  105155. type: number,
  105156. /**
  105157. * Defines the related dom event
  105158. */
  105159. event: PointerEvent | MouseWheelEvent);
  105160. }
  105161. /**
  105162. * This class is used to store pointer related info for the onPrePointerObservable event.
  105163. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  105164. */
  105165. export class PointerInfoPre extends PointerInfoBase {
  105166. /**
  105167. * Ray from a pointer if availible (eg. 6dof controller)
  105168. */
  105169. ray: Nullable<Ray>;
  105170. /**
  105171. * Defines the local position of the pointer on the canvas.
  105172. */
  105173. localPosition: Vector2;
  105174. /**
  105175. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  105176. */
  105177. skipOnPointerObservable: boolean;
  105178. /**
  105179. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  105180. * @param type Defines the type of event (PointerEventTypes)
  105181. * @param event Defines the related dom event
  105182. * @param localX Defines the local x coordinates of the pointer when the event occured
  105183. * @param localY Defines the local y coordinates of the pointer when the event occured
  105184. */
  105185. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  105186. }
  105187. /**
  105188. * This type contains all the data related to a pointer event in Babylon.js.
  105189. * 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.
  105190. */
  105191. export class PointerInfo extends PointerInfoBase {
  105192. /**
  105193. * Defines the picking info associated to the info (if any)\
  105194. */
  105195. pickInfo: Nullable<PickingInfo>;
  105196. /**
  105197. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  105198. * @param type Defines the type of event (PointerEventTypes)
  105199. * @param event Defines the related dom event
  105200. * @param pickInfo Defines the picking info associated to the info (if any)\
  105201. */
  105202. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  105203. /**
  105204. * Defines the picking info associated to the info (if any)\
  105205. */
  105206. pickInfo: Nullable<PickingInfo>);
  105207. }
  105208. /**
  105209. * Data relating to a touch event on the screen.
  105210. */
  105211. export interface PointerTouch {
  105212. /**
  105213. * X coordinate of touch.
  105214. */
  105215. x: number;
  105216. /**
  105217. * Y coordinate of touch.
  105218. */
  105219. y: number;
  105220. /**
  105221. * Id of touch. Unique for each finger.
  105222. */
  105223. pointerId: number;
  105224. /**
  105225. * Event type passed from DOM.
  105226. */
  105227. type: any;
  105228. }
  105229. }
  105230. declare module BABYLON {
  105231. /**
  105232. * Manage the mouse inputs to control the movement of a free camera.
  105233. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105234. */
  105235. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  105236. /**
  105237. * Define if touch is enabled in the mouse input
  105238. */
  105239. touchEnabled: boolean;
  105240. /**
  105241. * Defines the camera the input is attached to.
  105242. */
  105243. camera: FreeCamera;
  105244. /**
  105245. * Defines the buttons associated with the input to handle camera move.
  105246. */
  105247. buttons: number[];
  105248. /**
  105249. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  105250. */
  105251. angularSensibility: number;
  105252. private _pointerInput;
  105253. private _onMouseMove;
  105254. private _observer;
  105255. private previousPosition;
  105256. /**
  105257. * Observable for when a pointer move event occurs containing the move offset
  105258. */
  105259. onPointerMovedObservable: Observable<{
  105260. offsetX: number;
  105261. offsetY: number;
  105262. }>;
  105263. /**
  105264. * @hidden
  105265. * If the camera should be rotated automatically based on pointer movement
  105266. */
  105267. _allowCameraRotation: boolean;
  105268. /**
  105269. * Manage the mouse inputs to control the movement of a free camera.
  105270. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105271. * @param touchEnabled Defines if touch is enabled or not
  105272. */
  105273. constructor(
  105274. /**
  105275. * Define if touch is enabled in the mouse input
  105276. */
  105277. touchEnabled?: boolean);
  105278. /**
  105279. * Attach the input controls to a specific dom element to get the input from.
  105280. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105281. */
  105282. attachControl(noPreventDefault?: boolean): void;
  105283. /**
  105284. * Called on JS contextmenu event.
  105285. * Override this method to provide functionality.
  105286. */
  105287. protected onContextMenu(evt: PointerEvent): void;
  105288. /**
  105289. * Detach the current controls from the specified dom element.
  105290. */
  105291. detachControl(): void;
  105292. /**
  105293. * Gets the class name of the current intput.
  105294. * @returns the class name
  105295. */
  105296. getClassName(): string;
  105297. /**
  105298. * Get the friendly name associated with the input class.
  105299. * @returns the input friendly name
  105300. */
  105301. getSimpleName(): string;
  105302. }
  105303. }
  105304. declare module BABYLON {
  105305. /**
  105306. * Base class for mouse wheel input..
  105307. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  105308. * for example usage.
  105309. */
  105310. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  105311. /**
  105312. * Defines the camera the input is attached to.
  105313. */
  105314. abstract camera: Camera;
  105315. /**
  105316. * How fast is the camera moves in relation to X axis mouseWheel events.
  105317. * Use negative value to reverse direction.
  105318. */
  105319. wheelPrecisionX: number;
  105320. /**
  105321. * How fast is the camera moves in relation to Y axis mouseWheel events.
  105322. * Use negative value to reverse direction.
  105323. */
  105324. wheelPrecisionY: number;
  105325. /**
  105326. * How fast is the camera moves in relation to Z axis mouseWheel events.
  105327. * Use negative value to reverse direction.
  105328. */
  105329. wheelPrecisionZ: number;
  105330. /**
  105331. * Observable for when a mouse wheel move event occurs.
  105332. */
  105333. onChangedObservable: Observable<{
  105334. wheelDeltaX: number;
  105335. wheelDeltaY: number;
  105336. wheelDeltaZ: number;
  105337. }>;
  105338. private _wheel;
  105339. private _observer;
  105340. /**
  105341. * Attach the input controls to a specific dom element to get the input from.
  105342. * @param noPreventDefault Defines whether event caught by the controls
  105343. * should call preventdefault().
  105344. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105345. */
  105346. attachControl(noPreventDefault?: boolean): void;
  105347. /**
  105348. * Detach the current controls from the specified dom element.
  105349. */
  105350. detachControl(): void;
  105351. /**
  105352. * Called for each rendered frame.
  105353. */
  105354. checkInputs(): void;
  105355. /**
  105356. * Gets the class name of the current intput.
  105357. * @returns the class name
  105358. */
  105359. getClassName(): string;
  105360. /**
  105361. * Get the friendly name associated with the input class.
  105362. * @returns the input friendly name
  105363. */
  105364. getSimpleName(): string;
  105365. /**
  105366. * Incremental value of multiple mouse wheel movements of the X axis.
  105367. * Should be zero-ed when read.
  105368. */
  105369. protected _wheelDeltaX: number;
  105370. /**
  105371. * Incremental value of multiple mouse wheel movements of the Y axis.
  105372. * Should be zero-ed when read.
  105373. */
  105374. protected _wheelDeltaY: number;
  105375. /**
  105376. * Incremental value of multiple mouse wheel movements of the Z axis.
  105377. * Should be zero-ed when read.
  105378. */
  105379. protected _wheelDeltaZ: number;
  105380. /**
  105381. * Firefox uses a different scheme to report scroll distances to other
  105382. * browsers. Rather than use complicated methods to calculate the exact
  105383. * multiple we need to apply, let's just cheat and use a constant.
  105384. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  105385. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  105386. */
  105387. private readonly _ffMultiplier;
  105388. /**
  105389. * Different event attributes for wheel data fall into a few set ranges.
  105390. * Some relevant but dated date here:
  105391. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  105392. */
  105393. private readonly _normalize;
  105394. }
  105395. }
  105396. declare module BABYLON {
  105397. /**
  105398. * Manage the mouse wheel inputs to control a free camera.
  105399. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105400. */
  105401. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  105402. /**
  105403. * Defines the camera the input is attached to.
  105404. */
  105405. camera: FreeCamera;
  105406. /**
  105407. * Gets the class name of the current input.
  105408. * @returns the class name
  105409. */
  105410. getClassName(): string;
  105411. /**
  105412. * Set which movement axis (relative to camera's orientation) the mouse
  105413. * wheel's X axis controls.
  105414. * @param axis The axis to be moved. Set null to clear.
  105415. */
  105416. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  105417. /**
  105418. * Get the configured movement axis (relative to camera's orientation) the
  105419. * mouse wheel's X axis controls.
  105420. * @returns The configured axis or null if none.
  105421. */
  105422. get wheelXMoveRelative(): Nullable<Coordinate>;
  105423. /**
  105424. * Set which movement axis (relative to camera's orientation) the mouse
  105425. * wheel's Y axis controls.
  105426. * @param axis The axis to be moved. Set null to clear.
  105427. */
  105428. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  105429. /**
  105430. * Get the configured movement axis (relative to camera's orientation) the
  105431. * mouse wheel's Y axis controls.
  105432. * @returns The configured axis or null if none.
  105433. */
  105434. get wheelYMoveRelative(): Nullable<Coordinate>;
  105435. /**
  105436. * Set which movement axis (relative to camera's orientation) the mouse
  105437. * wheel's Z axis controls.
  105438. * @param axis The axis to be moved. Set null to clear.
  105439. */
  105440. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  105441. /**
  105442. * Get the configured movement axis (relative to camera's orientation) the
  105443. * mouse wheel's Z axis controls.
  105444. * @returns The configured axis or null if none.
  105445. */
  105446. get wheelZMoveRelative(): Nullable<Coordinate>;
  105447. /**
  105448. * Set which rotation axis (relative to camera's orientation) the mouse
  105449. * wheel's X axis controls.
  105450. * @param axis The axis to be moved. Set null to clear.
  105451. */
  105452. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  105453. /**
  105454. * Get the configured rotation axis (relative to camera's orientation) the
  105455. * mouse wheel's X axis controls.
  105456. * @returns The configured axis or null if none.
  105457. */
  105458. get wheelXRotateRelative(): Nullable<Coordinate>;
  105459. /**
  105460. * Set which rotation axis (relative to camera's orientation) the mouse
  105461. * wheel's Y axis controls.
  105462. * @param axis The axis to be moved. Set null to clear.
  105463. */
  105464. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  105465. /**
  105466. * Get the configured rotation axis (relative to camera's orientation) the
  105467. * mouse wheel's Y axis controls.
  105468. * @returns The configured axis or null if none.
  105469. */
  105470. get wheelYRotateRelative(): Nullable<Coordinate>;
  105471. /**
  105472. * Set which rotation axis (relative to camera's orientation) the mouse
  105473. * wheel's Z axis controls.
  105474. * @param axis The axis to be moved. Set null to clear.
  105475. */
  105476. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  105477. /**
  105478. * Get the configured rotation axis (relative to camera's orientation) the
  105479. * mouse wheel's Z axis controls.
  105480. * @returns The configured axis or null if none.
  105481. */
  105482. get wheelZRotateRelative(): Nullable<Coordinate>;
  105483. /**
  105484. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  105485. * controls.
  105486. * @param axis The axis to be moved. Set null to clear.
  105487. */
  105488. set wheelXMoveScene(axis: Nullable<Coordinate>);
  105489. /**
  105490. * Get the configured movement axis (relative to the scene) the mouse wheel's
  105491. * X axis controls.
  105492. * @returns The configured axis or null if none.
  105493. */
  105494. get wheelXMoveScene(): Nullable<Coordinate>;
  105495. /**
  105496. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  105497. * controls.
  105498. * @param axis The axis to be moved. Set null to clear.
  105499. */
  105500. set wheelYMoveScene(axis: Nullable<Coordinate>);
  105501. /**
  105502. * Get the configured movement axis (relative to the scene) the mouse wheel's
  105503. * Y axis controls.
  105504. * @returns The configured axis or null if none.
  105505. */
  105506. get wheelYMoveScene(): Nullable<Coordinate>;
  105507. /**
  105508. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  105509. * controls.
  105510. * @param axis The axis to be moved. Set null to clear.
  105511. */
  105512. set wheelZMoveScene(axis: Nullable<Coordinate>);
  105513. /**
  105514. * Get the configured movement axis (relative to the scene) the mouse wheel's
  105515. * Z axis controls.
  105516. * @returns The configured axis or null if none.
  105517. */
  105518. get wheelZMoveScene(): Nullable<Coordinate>;
  105519. /**
  105520. * Called for each rendered frame.
  105521. */
  105522. checkInputs(): void;
  105523. private _moveRelative;
  105524. private _rotateRelative;
  105525. private _moveScene;
  105526. /**
  105527. * These are set to the desired default behaviour.
  105528. */
  105529. private _wheelXAction;
  105530. private _wheelXActionCoordinate;
  105531. private _wheelYAction;
  105532. private _wheelYActionCoordinate;
  105533. private _wheelZAction;
  105534. private _wheelZActionCoordinate;
  105535. /**
  105536. * Update the camera according to any configured properties for the 3
  105537. * mouse-wheel axis.
  105538. */
  105539. private _updateCamera;
  105540. }
  105541. }
  105542. declare module BABYLON {
  105543. /**
  105544. * Manage the touch inputs to control the movement of a free camera.
  105545. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105546. */
  105547. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  105548. /**
  105549. * Define if mouse events can be treated as touch events
  105550. */
  105551. allowMouse: boolean;
  105552. /**
  105553. * Defines the camera the input is attached to.
  105554. */
  105555. camera: FreeCamera;
  105556. /**
  105557. * Defines the touch sensibility for rotation.
  105558. * The higher the faster.
  105559. */
  105560. touchAngularSensibility: number;
  105561. /**
  105562. * Defines the touch sensibility for move.
  105563. * The higher the faster.
  105564. */
  105565. touchMoveSensibility: number;
  105566. private _offsetX;
  105567. private _offsetY;
  105568. private _pointerPressed;
  105569. private _pointerInput?;
  105570. private _observer;
  105571. private _onLostFocus;
  105572. /**
  105573. * Manage the touch inputs to control the movement of a free camera.
  105574. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105575. * @param allowMouse Defines if mouse events can be treated as touch events
  105576. */
  105577. constructor(
  105578. /**
  105579. * Define if mouse events can be treated as touch events
  105580. */
  105581. allowMouse?: boolean);
  105582. /**
  105583. * Attach the input controls to a specific dom element to get the input from.
  105584. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105585. */
  105586. attachControl(noPreventDefault?: boolean): void;
  105587. /**
  105588. * Detach the current controls from the specified dom element.
  105589. */
  105590. detachControl(): void;
  105591. /**
  105592. * Update the current camera state depending on the inputs that have been used this frame.
  105593. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105594. */
  105595. checkInputs(): void;
  105596. /**
  105597. * Gets the class name of the current intput.
  105598. * @returns the class name
  105599. */
  105600. getClassName(): string;
  105601. /**
  105602. * Get the friendly name associated with the input class.
  105603. * @returns the input friendly name
  105604. */
  105605. getSimpleName(): string;
  105606. }
  105607. }
  105608. declare module BABYLON {
  105609. /**
  105610. * Default Inputs manager for the FreeCamera.
  105611. * It groups all the default supported inputs for ease of use.
  105612. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105613. */
  105614. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  105615. /**
  105616. * @hidden
  105617. */
  105618. _mouseInput: Nullable<FreeCameraMouseInput>;
  105619. /**
  105620. * @hidden
  105621. */
  105622. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  105623. /**
  105624. * Instantiates a new FreeCameraInputsManager.
  105625. * @param camera Defines the camera the inputs belong to
  105626. */
  105627. constructor(camera: FreeCamera);
  105628. /**
  105629. * Add keyboard input support to the input manager.
  105630. * @returns the current input manager
  105631. */
  105632. addKeyboard(): FreeCameraInputsManager;
  105633. /**
  105634. * Add mouse input support to the input manager.
  105635. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  105636. * @returns the current input manager
  105637. */
  105638. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  105639. /**
  105640. * Removes the mouse input support from the manager
  105641. * @returns the current input manager
  105642. */
  105643. removeMouse(): FreeCameraInputsManager;
  105644. /**
  105645. * Add mouse wheel input support to the input manager.
  105646. * @returns the current input manager
  105647. */
  105648. addMouseWheel(): FreeCameraInputsManager;
  105649. /**
  105650. * Removes the mouse wheel input support from the manager
  105651. * @returns the current input manager
  105652. */
  105653. removeMouseWheel(): FreeCameraInputsManager;
  105654. /**
  105655. * Add touch input support to the input manager.
  105656. * @returns the current input manager
  105657. */
  105658. addTouch(): FreeCameraInputsManager;
  105659. /**
  105660. * Remove all attached input methods from a camera
  105661. */
  105662. clear(): void;
  105663. }
  105664. }
  105665. declare module BABYLON {
  105666. /**
  105667. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  105668. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  105669. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  105670. */
  105671. export class FreeCamera extends TargetCamera {
  105672. /**
  105673. * Define the collision ellipsoid of the camera.
  105674. * This is helpful to simulate a camera body like the player body around the camera
  105675. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  105676. */
  105677. ellipsoid: Vector3;
  105678. /**
  105679. * Define an offset for the position of the ellipsoid around the camera.
  105680. * This can be helpful to determine the center of the body near the gravity center of the body
  105681. * instead of its head.
  105682. */
  105683. ellipsoidOffset: Vector3;
  105684. /**
  105685. * Enable or disable collisions of the camera with the rest of the scene objects.
  105686. */
  105687. checkCollisions: boolean;
  105688. /**
  105689. * Enable or disable gravity on the camera.
  105690. */
  105691. applyGravity: boolean;
  105692. /**
  105693. * Define the input manager associated to the camera.
  105694. */
  105695. inputs: FreeCameraInputsManager;
  105696. /**
  105697. * Gets the input sensibility for a mouse input. (default is 2000.0)
  105698. * Higher values reduce sensitivity.
  105699. */
  105700. get angularSensibility(): number;
  105701. /**
  105702. * Sets the input sensibility for a mouse input. (default is 2000.0)
  105703. * Higher values reduce sensitivity.
  105704. */
  105705. set angularSensibility(value: number);
  105706. /**
  105707. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  105708. */
  105709. get keysUp(): number[];
  105710. set keysUp(value: number[]);
  105711. /**
  105712. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  105713. */
  105714. get keysUpward(): number[];
  105715. set keysUpward(value: number[]);
  105716. /**
  105717. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  105718. */
  105719. get keysDown(): number[];
  105720. set keysDown(value: number[]);
  105721. /**
  105722. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  105723. */
  105724. get keysDownward(): number[];
  105725. set keysDownward(value: number[]);
  105726. /**
  105727. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  105728. */
  105729. get keysLeft(): number[];
  105730. set keysLeft(value: number[]);
  105731. /**
  105732. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  105733. */
  105734. get keysRight(): number[];
  105735. set keysRight(value: number[]);
  105736. /**
  105737. * Event raised when the camera collide with a mesh in the scene.
  105738. */
  105739. onCollide: (collidedMesh: AbstractMesh) => void;
  105740. private _collider;
  105741. private _needMoveForGravity;
  105742. private _oldPosition;
  105743. private _diffPosition;
  105744. private _newPosition;
  105745. /** @hidden */
  105746. _localDirection: Vector3;
  105747. /** @hidden */
  105748. _transformedDirection: Vector3;
  105749. /**
  105750. * Instantiates a Free Camera.
  105751. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  105752. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  105753. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  105754. * @param name Define the name of the camera in the scene
  105755. * @param position Define the start position of the camera in the scene
  105756. * @param scene Define the scene the camera belongs to
  105757. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  105758. */
  105759. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105760. /**
  105761. * Attach the input controls to a specific dom element to get the input from.
  105762. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105763. */
  105764. attachControl(noPreventDefault?: boolean): void;
  105765. /**
  105766. * Attach the input controls to a specific dom element to get the input from.
  105767. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  105768. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105769. * BACK COMPAT SIGNATURE ONLY.
  105770. */
  105771. attachControl(ignored: any, noPreventDefault?: boolean): void;
  105772. /**
  105773. * Detach the current controls from the specified dom element.
  105774. */
  105775. detachControl(): void;
  105776. /**
  105777. * Detach the current controls from the specified dom element.
  105778. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  105779. */
  105780. detachControl(ignored: any): void;
  105781. private _collisionMask;
  105782. /**
  105783. * Define a collision mask to limit the list of object the camera can collide with
  105784. */
  105785. get collisionMask(): number;
  105786. set collisionMask(mask: number);
  105787. /** @hidden */
  105788. _collideWithWorld(displacement: Vector3): void;
  105789. private _onCollisionPositionChange;
  105790. /** @hidden */
  105791. _checkInputs(): void;
  105792. /** @hidden */
  105793. _decideIfNeedsToMove(): boolean;
  105794. /** @hidden */
  105795. _updatePosition(): void;
  105796. /**
  105797. * Destroy the camera and release the current resources hold by it.
  105798. */
  105799. dispose(): void;
  105800. /**
  105801. * Gets the current object class name.
  105802. * @return the class name
  105803. */
  105804. getClassName(): string;
  105805. }
  105806. }
  105807. declare module BABYLON {
  105808. /**
  105809. * Represents a gamepad control stick position
  105810. */
  105811. export class StickValues {
  105812. /**
  105813. * The x component of the control stick
  105814. */
  105815. x: number;
  105816. /**
  105817. * The y component of the control stick
  105818. */
  105819. y: number;
  105820. /**
  105821. * Initializes the gamepad x and y control stick values
  105822. * @param x The x component of the gamepad control stick value
  105823. * @param y The y component of the gamepad control stick value
  105824. */
  105825. constructor(
  105826. /**
  105827. * The x component of the control stick
  105828. */
  105829. x: number,
  105830. /**
  105831. * The y component of the control stick
  105832. */
  105833. y: number);
  105834. }
  105835. /**
  105836. * An interface which manages callbacks for gamepad button changes
  105837. */
  105838. export interface GamepadButtonChanges {
  105839. /**
  105840. * Called when a gamepad has been changed
  105841. */
  105842. changed: boolean;
  105843. /**
  105844. * Called when a gamepad press event has been triggered
  105845. */
  105846. pressChanged: boolean;
  105847. /**
  105848. * Called when a touch event has been triggered
  105849. */
  105850. touchChanged: boolean;
  105851. /**
  105852. * Called when a value has changed
  105853. */
  105854. valueChanged: boolean;
  105855. }
  105856. /**
  105857. * Represents a gamepad
  105858. */
  105859. export class Gamepad {
  105860. /**
  105861. * The id of the gamepad
  105862. */
  105863. id: string;
  105864. /**
  105865. * The index of the gamepad
  105866. */
  105867. index: number;
  105868. /**
  105869. * The browser gamepad
  105870. */
  105871. browserGamepad: any;
  105872. /**
  105873. * Specifies what type of gamepad this represents
  105874. */
  105875. type: number;
  105876. private _leftStick;
  105877. private _rightStick;
  105878. /** @hidden */
  105879. _isConnected: boolean;
  105880. private _leftStickAxisX;
  105881. private _leftStickAxisY;
  105882. private _rightStickAxisX;
  105883. private _rightStickAxisY;
  105884. /**
  105885. * Triggered when the left control stick has been changed
  105886. */
  105887. private _onleftstickchanged;
  105888. /**
  105889. * Triggered when the right control stick has been changed
  105890. */
  105891. private _onrightstickchanged;
  105892. /**
  105893. * Represents a gamepad controller
  105894. */
  105895. static GAMEPAD: number;
  105896. /**
  105897. * Represents a generic controller
  105898. */
  105899. static GENERIC: number;
  105900. /**
  105901. * Represents an XBox controller
  105902. */
  105903. static XBOX: number;
  105904. /**
  105905. * Represents a pose-enabled controller
  105906. */
  105907. static POSE_ENABLED: number;
  105908. /**
  105909. * Represents an Dual Shock controller
  105910. */
  105911. static DUALSHOCK: number;
  105912. /**
  105913. * Specifies whether the left control stick should be Y-inverted
  105914. */
  105915. protected _invertLeftStickY: boolean;
  105916. /**
  105917. * Specifies if the gamepad has been connected
  105918. */
  105919. get isConnected(): boolean;
  105920. /**
  105921. * Initializes the gamepad
  105922. * @param id The id of the gamepad
  105923. * @param index The index of the gamepad
  105924. * @param browserGamepad The browser gamepad
  105925. * @param leftStickX The x component of the left joystick
  105926. * @param leftStickY The y component of the left joystick
  105927. * @param rightStickX The x component of the right joystick
  105928. * @param rightStickY The y component of the right joystick
  105929. */
  105930. constructor(
  105931. /**
  105932. * The id of the gamepad
  105933. */
  105934. id: string,
  105935. /**
  105936. * The index of the gamepad
  105937. */
  105938. index: number,
  105939. /**
  105940. * The browser gamepad
  105941. */
  105942. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  105943. /**
  105944. * Callback triggered when the left joystick has changed
  105945. * @param callback
  105946. */
  105947. onleftstickchanged(callback: (values: StickValues) => void): void;
  105948. /**
  105949. * Callback triggered when the right joystick has changed
  105950. * @param callback
  105951. */
  105952. onrightstickchanged(callback: (values: StickValues) => void): void;
  105953. /**
  105954. * Gets the left joystick
  105955. */
  105956. get leftStick(): StickValues;
  105957. /**
  105958. * Sets the left joystick values
  105959. */
  105960. set leftStick(newValues: StickValues);
  105961. /**
  105962. * Gets the right joystick
  105963. */
  105964. get rightStick(): StickValues;
  105965. /**
  105966. * Sets the right joystick value
  105967. */
  105968. set rightStick(newValues: StickValues);
  105969. /**
  105970. * Updates the gamepad joystick positions
  105971. */
  105972. update(): void;
  105973. /**
  105974. * Disposes the gamepad
  105975. */
  105976. dispose(): void;
  105977. }
  105978. /**
  105979. * Represents a generic gamepad
  105980. */
  105981. export class GenericPad extends Gamepad {
  105982. private _buttons;
  105983. private _onbuttondown;
  105984. private _onbuttonup;
  105985. /**
  105986. * Observable triggered when a button has been pressed
  105987. */
  105988. onButtonDownObservable: Observable<number>;
  105989. /**
  105990. * Observable triggered when a button has been released
  105991. */
  105992. onButtonUpObservable: Observable<number>;
  105993. /**
  105994. * Callback triggered when a button has been pressed
  105995. * @param callback Called when a button has been pressed
  105996. */
  105997. onbuttondown(callback: (buttonPressed: number) => void): void;
  105998. /**
  105999. * Callback triggered when a button has been released
  106000. * @param callback Called when a button has been released
  106001. */
  106002. onbuttonup(callback: (buttonReleased: number) => void): void;
  106003. /**
  106004. * Initializes the generic gamepad
  106005. * @param id The id of the generic gamepad
  106006. * @param index The index of the generic gamepad
  106007. * @param browserGamepad The browser gamepad
  106008. */
  106009. constructor(id: string, index: number, browserGamepad: any);
  106010. private _setButtonValue;
  106011. /**
  106012. * Updates the generic gamepad
  106013. */
  106014. update(): void;
  106015. /**
  106016. * Disposes the generic gamepad
  106017. */
  106018. dispose(): void;
  106019. }
  106020. }
  106021. declare module BABYLON {
  106022. /**
  106023. * Defines a runtime animation
  106024. */
  106025. export class RuntimeAnimation {
  106026. private _events;
  106027. /**
  106028. * The current frame of the runtime animation
  106029. */
  106030. private _currentFrame;
  106031. /**
  106032. * The animation used by the runtime animation
  106033. */
  106034. private _animation;
  106035. /**
  106036. * The target of the runtime animation
  106037. */
  106038. private _target;
  106039. /**
  106040. * The initiating animatable
  106041. */
  106042. private _host;
  106043. /**
  106044. * The original value of the runtime animation
  106045. */
  106046. private _originalValue;
  106047. /**
  106048. * The original blend value of the runtime animation
  106049. */
  106050. private _originalBlendValue;
  106051. /**
  106052. * The offsets cache of the runtime animation
  106053. */
  106054. private _offsetsCache;
  106055. /**
  106056. * The high limits cache of the runtime animation
  106057. */
  106058. private _highLimitsCache;
  106059. /**
  106060. * Specifies if the runtime animation has been stopped
  106061. */
  106062. private _stopped;
  106063. /**
  106064. * The blending factor of the runtime animation
  106065. */
  106066. private _blendingFactor;
  106067. /**
  106068. * The BabylonJS scene
  106069. */
  106070. private _scene;
  106071. /**
  106072. * The current value of the runtime animation
  106073. */
  106074. private _currentValue;
  106075. /** @hidden */
  106076. _animationState: _IAnimationState;
  106077. /**
  106078. * The active target of the runtime animation
  106079. */
  106080. private _activeTargets;
  106081. private _currentActiveTarget;
  106082. private _directTarget;
  106083. /**
  106084. * The target path of the runtime animation
  106085. */
  106086. private _targetPath;
  106087. /**
  106088. * The weight of the runtime animation
  106089. */
  106090. private _weight;
  106091. /**
  106092. * The ratio offset of the runtime animation
  106093. */
  106094. private _ratioOffset;
  106095. /**
  106096. * The previous delay of the runtime animation
  106097. */
  106098. private _previousDelay;
  106099. /**
  106100. * The previous ratio of the runtime animation
  106101. */
  106102. private _previousRatio;
  106103. private _enableBlending;
  106104. private _keys;
  106105. private _minFrame;
  106106. private _maxFrame;
  106107. private _minValue;
  106108. private _maxValue;
  106109. private _targetIsArray;
  106110. /**
  106111. * Gets the current frame of the runtime animation
  106112. */
  106113. get currentFrame(): number;
  106114. /**
  106115. * Gets the weight of the runtime animation
  106116. */
  106117. get weight(): number;
  106118. /**
  106119. * Gets the current value of the runtime animation
  106120. */
  106121. get currentValue(): any;
  106122. /**
  106123. * Gets the target path of the runtime animation
  106124. */
  106125. get targetPath(): string;
  106126. /**
  106127. * Gets the actual target of the runtime animation
  106128. */
  106129. get target(): any;
  106130. /**
  106131. * Gets the additive state of the runtime animation
  106132. */
  106133. get isAdditive(): boolean;
  106134. /** @hidden */
  106135. _onLoop: () => void;
  106136. /**
  106137. * Create a new RuntimeAnimation object
  106138. * @param target defines the target of the animation
  106139. * @param animation defines the source animation object
  106140. * @param scene defines the hosting scene
  106141. * @param host defines the initiating Animatable
  106142. */
  106143. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  106144. private _preparePath;
  106145. /**
  106146. * Gets the animation from the runtime animation
  106147. */
  106148. get animation(): Animation;
  106149. /**
  106150. * Resets the runtime animation to the beginning
  106151. * @param restoreOriginal defines whether to restore the target property to the original value
  106152. */
  106153. reset(restoreOriginal?: boolean): void;
  106154. /**
  106155. * Specifies if the runtime animation is stopped
  106156. * @returns Boolean specifying if the runtime animation is stopped
  106157. */
  106158. isStopped(): boolean;
  106159. /**
  106160. * Disposes of the runtime animation
  106161. */
  106162. dispose(): void;
  106163. /**
  106164. * Apply the interpolated value to the target
  106165. * @param currentValue defines the value computed by the animation
  106166. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  106167. */
  106168. setValue(currentValue: any, weight: number): void;
  106169. private _getOriginalValues;
  106170. private _setValue;
  106171. /**
  106172. * Gets the loop pmode of the runtime animation
  106173. * @returns Loop Mode
  106174. */
  106175. private _getCorrectLoopMode;
  106176. /**
  106177. * Move the current animation to a given frame
  106178. * @param frame defines the frame to move to
  106179. */
  106180. goToFrame(frame: number): void;
  106181. /**
  106182. * @hidden Internal use only
  106183. */
  106184. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  106185. /**
  106186. * Execute the current animation
  106187. * @param delay defines the delay to add to the current frame
  106188. * @param from defines the lower bound of the animation range
  106189. * @param to defines the upper bound of the animation range
  106190. * @param loop defines if the current animation must loop
  106191. * @param speedRatio defines the current speed ratio
  106192. * @param weight defines the weight of the animation (default is -1 so no weight)
  106193. * @param onLoop optional callback called when animation loops
  106194. * @returns a boolean indicating if the animation is running
  106195. */
  106196. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  106197. }
  106198. }
  106199. declare module BABYLON {
  106200. /**
  106201. * Class used to store an actual running animation
  106202. */
  106203. export class Animatable {
  106204. /** defines the target object */
  106205. target: any;
  106206. /** defines the starting frame number (default is 0) */
  106207. fromFrame: number;
  106208. /** defines the ending frame number (default is 100) */
  106209. toFrame: number;
  106210. /** defines if the animation must loop (default is false) */
  106211. loopAnimation: boolean;
  106212. /** defines a callback to call when animation ends if it is not looping */
  106213. onAnimationEnd?: (() => void) | null | undefined;
  106214. /** defines a callback to call when animation loops */
  106215. onAnimationLoop?: (() => void) | null | undefined;
  106216. /** defines whether the animation should be evaluated additively */
  106217. isAdditive: boolean;
  106218. private _localDelayOffset;
  106219. private _pausedDelay;
  106220. private _runtimeAnimations;
  106221. private _paused;
  106222. private _scene;
  106223. private _speedRatio;
  106224. private _weight;
  106225. private _syncRoot;
  106226. /**
  106227. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  106228. * This will only apply for non looping animation (default is true)
  106229. */
  106230. disposeOnEnd: boolean;
  106231. /**
  106232. * Gets a boolean indicating if the animation has started
  106233. */
  106234. animationStarted: boolean;
  106235. /**
  106236. * Observer raised when the animation ends
  106237. */
  106238. onAnimationEndObservable: Observable<Animatable>;
  106239. /**
  106240. * Observer raised when the animation loops
  106241. */
  106242. onAnimationLoopObservable: Observable<Animatable>;
  106243. /**
  106244. * Gets the root Animatable used to synchronize and normalize animations
  106245. */
  106246. get syncRoot(): Nullable<Animatable>;
  106247. /**
  106248. * Gets the current frame of the first RuntimeAnimation
  106249. * Used to synchronize Animatables
  106250. */
  106251. get masterFrame(): number;
  106252. /**
  106253. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  106254. */
  106255. get weight(): number;
  106256. set weight(value: number);
  106257. /**
  106258. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  106259. */
  106260. get speedRatio(): number;
  106261. set speedRatio(value: number);
  106262. /**
  106263. * Creates a new Animatable
  106264. * @param scene defines the hosting scene
  106265. * @param target defines the target object
  106266. * @param fromFrame defines the starting frame number (default is 0)
  106267. * @param toFrame defines the ending frame number (default is 100)
  106268. * @param loopAnimation defines if the animation must loop (default is false)
  106269. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  106270. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  106271. * @param animations defines a group of animation to add to the new Animatable
  106272. * @param onAnimationLoop defines a callback to call when animation loops
  106273. * @param isAdditive defines whether the animation should be evaluated additively
  106274. */
  106275. constructor(scene: Scene,
  106276. /** defines the target object */
  106277. target: any,
  106278. /** defines the starting frame number (default is 0) */
  106279. fromFrame?: number,
  106280. /** defines the ending frame number (default is 100) */
  106281. toFrame?: number,
  106282. /** defines if the animation must loop (default is false) */
  106283. loopAnimation?: boolean, speedRatio?: number,
  106284. /** defines a callback to call when animation ends if it is not looping */
  106285. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  106286. /** defines a callback to call when animation loops */
  106287. onAnimationLoop?: (() => void) | null | undefined,
  106288. /** defines whether the animation should be evaluated additively */
  106289. isAdditive?: boolean);
  106290. /**
  106291. * Synchronize and normalize current Animatable with a source Animatable
  106292. * This is useful when using animation weights and when animations are not of the same length
  106293. * @param root defines the root Animatable to synchronize with
  106294. * @returns the current Animatable
  106295. */
  106296. syncWith(root: Animatable): Animatable;
  106297. /**
  106298. * Gets the list of runtime animations
  106299. * @returns an array of RuntimeAnimation
  106300. */
  106301. getAnimations(): RuntimeAnimation[];
  106302. /**
  106303. * Adds more animations to the current animatable
  106304. * @param target defines the target of the animations
  106305. * @param animations defines the new animations to add
  106306. */
  106307. appendAnimations(target: any, animations: Animation[]): void;
  106308. /**
  106309. * Gets the source animation for a specific property
  106310. * @param property defines the propertyu to look for
  106311. * @returns null or the source animation for the given property
  106312. */
  106313. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  106314. /**
  106315. * Gets the runtime animation for a specific property
  106316. * @param property defines the propertyu to look for
  106317. * @returns null or the runtime animation for the given property
  106318. */
  106319. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  106320. /**
  106321. * Resets the animatable to its original state
  106322. */
  106323. reset(): void;
  106324. /**
  106325. * Allows the animatable to blend with current running animations
  106326. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  106327. * @param blendingSpeed defines the blending speed to use
  106328. */
  106329. enableBlending(blendingSpeed: number): void;
  106330. /**
  106331. * Disable animation blending
  106332. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  106333. */
  106334. disableBlending(): void;
  106335. /**
  106336. * Jump directly to a given frame
  106337. * @param frame defines the frame to jump to
  106338. */
  106339. goToFrame(frame: number): void;
  106340. /**
  106341. * Pause the animation
  106342. */
  106343. pause(): void;
  106344. /**
  106345. * Restart the animation
  106346. */
  106347. restart(): void;
  106348. private _raiseOnAnimationEnd;
  106349. /**
  106350. * Stop and delete the current animation
  106351. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  106352. * @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)
  106353. */
  106354. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  106355. /**
  106356. * Wait asynchronously for the animation to end
  106357. * @returns a promise which will be fullfilled when the animation ends
  106358. */
  106359. waitAsync(): Promise<Animatable>;
  106360. /** @hidden */
  106361. _animate(delay: number): boolean;
  106362. }
  106363. interface Scene {
  106364. /** @hidden */
  106365. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  106366. /** @hidden */
  106367. _processLateAnimationBindingsForMatrices(holder: {
  106368. totalWeight: number;
  106369. totalAdditiveWeight: number;
  106370. animations: RuntimeAnimation[];
  106371. additiveAnimations: RuntimeAnimation[];
  106372. originalValue: Matrix;
  106373. }): any;
  106374. /** @hidden */
  106375. _processLateAnimationBindingsForQuaternions(holder: {
  106376. totalWeight: number;
  106377. totalAdditiveWeight: number;
  106378. animations: RuntimeAnimation[];
  106379. additiveAnimations: RuntimeAnimation[];
  106380. originalValue: Quaternion;
  106381. }, refQuaternion: Quaternion): Quaternion;
  106382. /** @hidden */
  106383. _processLateAnimationBindings(): void;
  106384. /**
  106385. * Will start the animation sequence of a given target
  106386. * @param target defines the target
  106387. * @param from defines from which frame should animation start
  106388. * @param to defines until which frame should animation run.
  106389. * @param weight defines the weight to apply to the animation (1.0 by default)
  106390. * @param loop defines if the animation loops
  106391. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  106392. * @param onAnimationEnd defines the function to be executed when the animation ends
  106393. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  106394. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  106395. * @param onAnimationLoop defines the callback to call when an animation loops
  106396. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106397. * @returns the animatable object created for this animation
  106398. */
  106399. 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;
  106400. /**
  106401. * Will start the animation sequence of a given target
  106402. * @param target defines the target
  106403. * @param from defines from which frame should animation start
  106404. * @param to defines until which frame should animation run.
  106405. * @param loop defines if the animation loops
  106406. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  106407. * @param onAnimationEnd defines the function to be executed when the animation ends
  106408. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  106409. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  106410. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  106411. * @param onAnimationLoop defines the callback to call when an animation loops
  106412. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106413. * @returns the animatable object created for this animation
  106414. */
  106415. 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;
  106416. /**
  106417. * Will start the animation sequence of a given target and its hierarchy
  106418. * @param target defines the target
  106419. * @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.
  106420. * @param from defines from which frame should animation start
  106421. * @param to defines until which frame should animation run.
  106422. * @param loop defines if the animation loops
  106423. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  106424. * @param onAnimationEnd defines the function to be executed when the animation ends
  106425. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  106426. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  106427. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  106428. * @param onAnimationLoop defines the callback to call when an animation loops
  106429. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106430. * @returns the list of created animatables
  106431. */
  106432. 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[];
  106433. /**
  106434. * Begin a new animation on a given node
  106435. * @param target defines the target where the animation will take place
  106436. * @param animations defines the list of animations to start
  106437. * @param from defines the initial value
  106438. * @param to defines the final value
  106439. * @param loop defines if you want animation to loop (off by default)
  106440. * @param speedRatio defines the speed ratio to apply to all animations
  106441. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  106442. * @param onAnimationLoop defines the callback to call when an animation loops
  106443. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106444. * @returns the list of created animatables
  106445. */
  106446. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  106447. /**
  106448. * Begin a new animation on a given node and its hierarchy
  106449. * @param target defines the root node where the animation will take place
  106450. * @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.
  106451. * @param animations defines the list of animations to start
  106452. * @param from defines the initial value
  106453. * @param to defines the final value
  106454. * @param loop defines if you want animation to loop (off by default)
  106455. * @param speedRatio defines the speed ratio to apply to all animations
  106456. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  106457. * @param onAnimationLoop defines the callback to call when an animation loops
  106458. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106459. * @returns the list of animatables created for all nodes
  106460. */
  106461. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  106462. /**
  106463. * Gets the animatable associated with a specific target
  106464. * @param target defines the target of the animatable
  106465. * @returns the required animatable if found
  106466. */
  106467. getAnimatableByTarget(target: any): Nullable<Animatable>;
  106468. /**
  106469. * Gets all animatables associated with a given target
  106470. * @param target defines the target to look animatables for
  106471. * @returns an array of Animatables
  106472. */
  106473. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  106474. /**
  106475. * Stops and removes all animations that have been applied to the scene
  106476. */
  106477. stopAllAnimations(): void;
  106478. /**
  106479. * Gets the current delta time used by animation engine
  106480. */
  106481. deltaTime: number;
  106482. }
  106483. interface Bone {
  106484. /**
  106485. * Copy an animation range from another bone
  106486. * @param source defines the source bone
  106487. * @param rangeName defines the range name to copy
  106488. * @param frameOffset defines the frame offset
  106489. * @param rescaleAsRequired defines if rescaling must be applied if required
  106490. * @param skelDimensionsRatio defines the scaling ratio
  106491. * @returns true if operation was successful
  106492. */
  106493. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  106494. }
  106495. }
  106496. declare module BABYLON {
  106497. /**
  106498. * Class used to override all child animations of a given target
  106499. */
  106500. export class AnimationPropertiesOverride {
  106501. /**
  106502. * Gets or sets a value indicating if animation blending must be used
  106503. */
  106504. enableBlending: boolean;
  106505. /**
  106506. * Gets or sets the blending speed to use when enableBlending is true
  106507. */
  106508. blendingSpeed: number;
  106509. /**
  106510. * Gets or sets the default loop mode to use
  106511. */
  106512. loopMode: number;
  106513. }
  106514. }
  106515. declare module BABYLON {
  106516. /**
  106517. * Class used to handle skinning animations
  106518. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  106519. */
  106520. export class Skeleton implements IAnimatable {
  106521. /** defines the skeleton name */
  106522. name: string;
  106523. /** defines the skeleton Id */
  106524. id: string;
  106525. /**
  106526. * Defines the list of child bones
  106527. */
  106528. bones: Bone[];
  106529. /**
  106530. * Defines an estimate of the dimension of the skeleton at rest
  106531. */
  106532. dimensionsAtRest: Vector3;
  106533. /**
  106534. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  106535. */
  106536. needInitialSkinMatrix: boolean;
  106537. /**
  106538. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  106539. */
  106540. overrideMesh: Nullable<AbstractMesh>;
  106541. /**
  106542. * Gets the list of animations attached to this skeleton
  106543. */
  106544. animations: Array<Animation>;
  106545. private _scene;
  106546. private _isDirty;
  106547. private _transformMatrices;
  106548. private _transformMatrixTexture;
  106549. private _meshesWithPoseMatrix;
  106550. private _animatables;
  106551. private _identity;
  106552. private _synchronizedWithMesh;
  106553. private _ranges;
  106554. private _lastAbsoluteTransformsUpdateId;
  106555. private _canUseTextureForBones;
  106556. private _uniqueId;
  106557. /** @hidden */
  106558. _numBonesWithLinkedTransformNode: number;
  106559. /** @hidden */
  106560. _hasWaitingData: Nullable<boolean>;
  106561. /** @hidden */
  106562. _waitingOverrideMeshId: Nullable<string>;
  106563. /**
  106564. * Specifies if the skeleton should be serialized
  106565. */
  106566. doNotSerialize: boolean;
  106567. private _useTextureToStoreBoneMatrices;
  106568. /**
  106569. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  106570. * Please note that this option is not available if the hardware does not support it
  106571. */
  106572. get useTextureToStoreBoneMatrices(): boolean;
  106573. set useTextureToStoreBoneMatrices(value: boolean);
  106574. private _animationPropertiesOverride;
  106575. /**
  106576. * Gets or sets the animation properties override
  106577. */
  106578. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  106579. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  106580. /**
  106581. * List of inspectable custom properties (used by the Inspector)
  106582. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  106583. */
  106584. inspectableCustomProperties: IInspectable[];
  106585. /**
  106586. * An observable triggered before computing the skeleton's matrices
  106587. */
  106588. onBeforeComputeObservable: Observable<Skeleton>;
  106589. /**
  106590. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  106591. */
  106592. get isUsingTextureForMatrices(): boolean;
  106593. /**
  106594. * Gets the unique ID of this skeleton
  106595. */
  106596. get uniqueId(): number;
  106597. /**
  106598. * Creates a new skeleton
  106599. * @param name defines the skeleton name
  106600. * @param id defines the skeleton Id
  106601. * @param scene defines the hosting scene
  106602. */
  106603. constructor(
  106604. /** defines the skeleton name */
  106605. name: string,
  106606. /** defines the skeleton Id */
  106607. id: string, scene: Scene);
  106608. /**
  106609. * Gets the current object class name.
  106610. * @return the class name
  106611. */
  106612. getClassName(): string;
  106613. /**
  106614. * Returns an array containing the root bones
  106615. * @returns an array containing the root bones
  106616. */
  106617. getChildren(): Array<Bone>;
  106618. /**
  106619. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  106620. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  106621. * @returns a Float32Array containing matrices data
  106622. */
  106623. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  106624. /**
  106625. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  106626. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  106627. * @returns a raw texture containing the data
  106628. */
  106629. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  106630. /**
  106631. * Gets the current hosting scene
  106632. * @returns a scene object
  106633. */
  106634. getScene(): Scene;
  106635. /**
  106636. * Gets a string representing the current skeleton data
  106637. * @param fullDetails defines a boolean indicating if we want a verbose version
  106638. * @returns a string representing the current skeleton data
  106639. */
  106640. toString(fullDetails?: boolean): string;
  106641. /**
  106642. * Get bone's index searching by name
  106643. * @param name defines bone's name to search for
  106644. * @return the indice of the bone. Returns -1 if not found
  106645. */
  106646. getBoneIndexByName(name: string): number;
  106647. /**
  106648. * Creater a new animation range
  106649. * @param name defines the name of the range
  106650. * @param from defines the start key
  106651. * @param to defines the end key
  106652. */
  106653. createAnimationRange(name: string, from: number, to: number): void;
  106654. /**
  106655. * Delete a specific animation range
  106656. * @param name defines the name of the range
  106657. * @param deleteFrames defines if frames must be removed as well
  106658. */
  106659. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  106660. /**
  106661. * Gets a specific animation range
  106662. * @param name defines the name of the range to look for
  106663. * @returns the requested animation range or null if not found
  106664. */
  106665. getAnimationRange(name: string): Nullable<AnimationRange>;
  106666. /**
  106667. * Gets the list of all animation ranges defined on this skeleton
  106668. * @returns an array
  106669. */
  106670. getAnimationRanges(): Nullable<AnimationRange>[];
  106671. /**
  106672. * Copy animation range from a source skeleton.
  106673. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  106674. * @param source defines the source skeleton
  106675. * @param name defines the name of the range to copy
  106676. * @param rescaleAsRequired defines if rescaling must be applied if required
  106677. * @returns true if operation was successful
  106678. */
  106679. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  106680. /**
  106681. * Forces the skeleton to go to rest pose
  106682. */
  106683. returnToRest(): void;
  106684. private _getHighestAnimationFrame;
  106685. /**
  106686. * Begin a specific animation range
  106687. * @param name defines the name of the range to start
  106688. * @param loop defines if looping must be turned on (false by default)
  106689. * @param speedRatio defines the speed ratio to apply (1 by default)
  106690. * @param onAnimationEnd defines a callback which will be called when animation will end
  106691. * @returns a new animatable
  106692. */
  106693. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  106694. /**
  106695. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  106696. * @param skeleton defines the Skeleton containing the animation range to convert
  106697. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  106698. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  106699. * @returns the original skeleton
  106700. */
  106701. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  106702. /** @hidden */
  106703. _markAsDirty(): void;
  106704. /** @hidden */
  106705. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  106706. /** @hidden */
  106707. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  106708. private _computeTransformMatrices;
  106709. /**
  106710. * Build all resources required to render a skeleton
  106711. */
  106712. prepare(): void;
  106713. /**
  106714. * Gets the list of animatables currently running for this skeleton
  106715. * @returns an array of animatables
  106716. */
  106717. getAnimatables(): IAnimatable[];
  106718. /**
  106719. * Clone the current skeleton
  106720. * @param name defines the name of the new skeleton
  106721. * @param id defines the id of the new skeleton
  106722. * @returns the new skeleton
  106723. */
  106724. clone(name: string, id?: string): Skeleton;
  106725. /**
  106726. * Enable animation blending for this skeleton
  106727. * @param blendingSpeed defines the blending speed to apply
  106728. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  106729. */
  106730. enableBlending(blendingSpeed?: number): void;
  106731. /**
  106732. * Releases all resources associated with the current skeleton
  106733. */
  106734. dispose(): void;
  106735. /**
  106736. * Serialize the skeleton in a JSON object
  106737. * @returns a JSON object
  106738. */
  106739. serialize(): any;
  106740. /**
  106741. * Creates a new skeleton from serialized data
  106742. * @param parsedSkeleton defines the serialized data
  106743. * @param scene defines the hosting scene
  106744. * @returns a new skeleton
  106745. */
  106746. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  106747. /**
  106748. * Compute all node absolute transforms
  106749. * @param forceUpdate defines if computation must be done even if cache is up to date
  106750. */
  106751. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  106752. /**
  106753. * Gets the root pose matrix
  106754. * @returns a matrix
  106755. */
  106756. getPoseMatrix(): Nullable<Matrix>;
  106757. /**
  106758. * Sorts bones per internal index
  106759. */
  106760. sortBones(): void;
  106761. private _sortBones;
  106762. /**
  106763. * Set the current local matrix as the restPose for all bones in the skeleton.
  106764. */
  106765. setCurrentPoseAsRest(): void;
  106766. }
  106767. }
  106768. declare module BABYLON {
  106769. /**
  106770. * Class used to store bone information
  106771. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  106772. */
  106773. export class Bone extends Node {
  106774. /**
  106775. * defines the bone name
  106776. */
  106777. name: string;
  106778. private static _tmpVecs;
  106779. private static _tmpQuat;
  106780. private static _tmpMats;
  106781. /**
  106782. * Gets the list of child bones
  106783. */
  106784. children: Bone[];
  106785. /** Gets the animations associated with this bone */
  106786. animations: Animation[];
  106787. /**
  106788. * Gets or sets bone length
  106789. */
  106790. length: number;
  106791. /**
  106792. * @hidden Internal only
  106793. * Set this value to map this bone to a different index in the transform matrices
  106794. * Set this value to -1 to exclude the bone from the transform matrices
  106795. */
  106796. _index: Nullable<number>;
  106797. private _skeleton;
  106798. private _localMatrix;
  106799. private _restPose;
  106800. private _bindPose;
  106801. private _baseMatrix;
  106802. private _absoluteTransform;
  106803. private _invertedAbsoluteTransform;
  106804. private _parent;
  106805. private _scalingDeterminant;
  106806. private _worldTransform;
  106807. private _localScaling;
  106808. private _localRotation;
  106809. private _localPosition;
  106810. private _needToDecompose;
  106811. private _needToCompose;
  106812. /** @hidden */
  106813. _linkedTransformNode: Nullable<TransformNode>;
  106814. /** @hidden */
  106815. _waitingTransformNodeId: Nullable<string>;
  106816. /** @hidden */
  106817. get _matrix(): Matrix;
  106818. /** @hidden */
  106819. set _matrix(value: Matrix);
  106820. /**
  106821. * Create a new bone
  106822. * @param name defines the bone name
  106823. * @param skeleton defines the parent skeleton
  106824. * @param parentBone defines the parent (can be null if the bone is the root)
  106825. * @param localMatrix defines the local matrix
  106826. * @param restPose defines the rest pose matrix
  106827. * @param baseMatrix defines the base matrix
  106828. * @param index defines index of the bone in the hiearchy
  106829. */
  106830. constructor(
  106831. /**
  106832. * defines the bone name
  106833. */
  106834. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  106835. /**
  106836. * Gets the current object class name.
  106837. * @return the class name
  106838. */
  106839. getClassName(): string;
  106840. /**
  106841. * Gets the parent skeleton
  106842. * @returns a skeleton
  106843. */
  106844. getSkeleton(): Skeleton;
  106845. /**
  106846. * Gets parent bone
  106847. * @returns a bone or null if the bone is the root of the bone hierarchy
  106848. */
  106849. getParent(): Nullable<Bone>;
  106850. /**
  106851. * Returns an array containing the root bones
  106852. * @returns an array containing the root bones
  106853. */
  106854. getChildren(): Array<Bone>;
  106855. /**
  106856. * Gets the node index in matrix array generated for rendering
  106857. * @returns the node index
  106858. */
  106859. getIndex(): number;
  106860. /**
  106861. * Sets the parent bone
  106862. * @param parent defines the parent (can be null if the bone is the root)
  106863. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  106864. */
  106865. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  106866. /**
  106867. * Gets the local matrix
  106868. * @returns a matrix
  106869. */
  106870. getLocalMatrix(): Matrix;
  106871. /**
  106872. * Gets the base matrix (initial matrix which remains unchanged)
  106873. * @returns a matrix
  106874. */
  106875. getBaseMatrix(): Matrix;
  106876. /**
  106877. * Gets the rest pose matrix
  106878. * @returns a matrix
  106879. */
  106880. getRestPose(): Matrix;
  106881. /**
  106882. * Sets the rest pose matrix
  106883. * @param matrix the local-space rest pose to set for this bone
  106884. */
  106885. setRestPose(matrix: Matrix): void;
  106886. /**
  106887. * Gets the bind pose matrix
  106888. * @returns the bind pose matrix
  106889. */
  106890. getBindPose(): Matrix;
  106891. /**
  106892. * Sets the bind pose matrix
  106893. * @param matrix the local-space bind pose to set for this bone
  106894. */
  106895. setBindPose(matrix: Matrix): void;
  106896. /**
  106897. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  106898. */
  106899. getWorldMatrix(): Matrix;
  106900. /**
  106901. * Sets the local matrix to rest pose matrix
  106902. */
  106903. returnToRest(): void;
  106904. /**
  106905. * Gets the inverse of the absolute transform matrix.
  106906. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  106907. * @returns a matrix
  106908. */
  106909. getInvertedAbsoluteTransform(): Matrix;
  106910. /**
  106911. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  106912. * @returns a matrix
  106913. */
  106914. getAbsoluteTransform(): Matrix;
  106915. /**
  106916. * Links with the given transform node.
  106917. * The local matrix of this bone is copied from the transform node every frame.
  106918. * @param transformNode defines the transform node to link to
  106919. */
  106920. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  106921. /**
  106922. * Gets the node used to drive the bone's transformation
  106923. * @returns a transform node or null
  106924. */
  106925. getTransformNode(): Nullable<TransformNode>;
  106926. /** Gets or sets current position (in local space) */
  106927. get position(): Vector3;
  106928. set position(newPosition: Vector3);
  106929. /** Gets or sets current rotation (in local space) */
  106930. get rotation(): Vector3;
  106931. set rotation(newRotation: Vector3);
  106932. /** Gets or sets current rotation quaternion (in local space) */
  106933. get rotationQuaternion(): Quaternion;
  106934. set rotationQuaternion(newRotation: Quaternion);
  106935. /** Gets or sets current scaling (in local space) */
  106936. get scaling(): Vector3;
  106937. set scaling(newScaling: Vector3);
  106938. /**
  106939. * Gets the animation properties override
  106940. */
  106941. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  106942. private _decompose;
  106943. private _compose;
  106944. /**
  106945. * Update the base and local matrices
  106946. * @param matrix defines the new base or local matrix
  106947. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  106948. * @param updateLocalMatrix defines if the local matrix should be updated
  106949. */
  106950. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  106951. /** @hidden */
  106952. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  106953. /**
  106954. * Flag the bone as dirty (Forcing it to update everything)
  106955. */
  106956. markAsDirty(): void;
  106957. /** @hidden */
  106958. _markAsDirtyAndCompose(): void;
  106959. private _markAsDirtyAndDecompose;
  106960. /**
  106961. * Translate the bone in local or world space
  106962. * @param vec The amount to translate the bone
  106963. * @param space The space that the translation is in
  106964. * @param mesh The mesh that this bone is attached to. This is only used in world space
  106965. */
  106966. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  106967. /**
  106968. * Set the postion of the bone in local or world space
  106969. * @param position The position to set the bone
  106970. * @param space The space that the position is in
  106971. * @param mesh The mesh that this bone is attached to. This is only used in world space
  106972. */
  106973. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  106974. /**
  106975. * Set the absolute position of the bone (world space)
  106976. * @param position The position to set the bone
  106977. * @param mesh The mesh that this bone is attached to
  106978. */
  106979. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  106980. /**
  106981. * Scale the bone on the x, y and z axes (in local space)
  106982. * @param x The amount to scale the bone on the x axis
  106983. * @param y The amount to scale the bone on the y axis
  106984. * @param z The amount to scale the bone on the z axis
  106985. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  106986. */
  106987. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  106988. /**
  106989. * Set the bone scaling in local space
  106990. * @param scale defines the scaling vector
  106991. */
  106992. setScale(scale: Vector3): void;
  106993. /**
  106994. * Gets the current scaling in local space
  106995. * @returns the current scaling vector
  106996. */
  106997. getScale(): Vector3;
  106998. /**
  106999. * Gets the current scaling in local space and stores it in a target vector
  107000. * @param result defines the target vector
  107001. */
  107002. getScaleToRef(result: Vector3): void;
  107003. /**
  107004. * Set the yaw, pitch, and roll of the bone in local or world space
  107005. * @param yaw The rotation of the bone on the y axis
  107006. * @param pitch The rotation of the bone on the x axis
  107007. * @param roll The rotation of the bone on the z axis
  107008. * @param space The space that the axes of rotation are in
  107009. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107010. */
  107011. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  107012. /**
  107013. * Add a rotation to the bone on an axis in local or world space
  107014. * @param axis The axis to rotate the bone on
  107015. * @param amount The amount to rotate the bone
  107016. * @param space The space that the axis is in
  107017. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107018. */
  107019. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  107020. /**
  107021. * Set the rotation of the bone to a particular axis angle in local or world space
  107022. * @param axis The axis to rotate the bone on
  107023. * @param angle The angle that the bone should be rotated to
  107024. * @param space The space that the axis is in
  107025. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107026. */
  107027. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  107028. /**
  107029. * Set the euler rotation of the bone in local or world space
  107030. * @param rotation The euler rotation that the bone should be set to
  107031. * @param space The space that the rotation is in
  107032. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107033. */
  107034. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  107035. /**
  107036. * Set the quaternion rotation of the bone in local or world space
  107037. * @param quat The quaternion rotation that the bone should be set to
  107038. * @param space The space that the rotation is in
  107039. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107040. */
  107041. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  107042. /**
  107043. * Set the rotation matrix of the bone in local or world space
  107044. * @param rotMat The rotation matrix that the bone should be set to
  107045. * @param space The space that the rotation is in
  107046. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107047. */
  107048. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  107049. private _rotateWithMatrix;
  107050. private _getNegativeRotationToRef;
  107051. /**
  107052. * Get the position of the bone in local or world space
  107053. * @param space The space that the returned position is in
  107054. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107055. * @returns The position of the bone
  107056. */
  107057. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  107058. /**
  107059. * Copy the position of the bone to a vector3 in local or world space
  107060. * @param space The space that the returned position is in
  107061. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107062. * @param result The vector3 to copy the position to
  107063. */
  107064. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  107065. /**
  107066. * Get the absolute position of the bone (world space)
  107067. * @param mesh The mesh that this bone is attached to
  107068. * @returns The absolute position of the bone
  107069. */
  107070. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  107071. /**
  107072. * Copy the absolute position of the bone (world space) to the result param
  107073. * @param mesh The mesh that this bone is attached to
  107074. * @param result The vector3 to copy the absolute position to
  107075. */
  107076. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  107077. /**
  107078. * Compute the absolute transforms of this bone and its children
  107079. */
  107080. computeAbsoluteTransforms(): void;
  107081. /**
  107082. * Get the world direction from an axis that is in the local space of the bone
  107083. * @param localAxis The local direction that is used to compute the world direction
  107084. * @param mesh The mesh that this bone is attached to
  107085. * @returns The world direction
  107086. */
  107087. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  107088. /**
  107089. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  107090. * @param localAxis The local direction that is used to compute the world direction
  107091. * @param mesh The mesh that this bone is attached to
  107092. * @param result The vector3 that the world direction will be copied to
  107093. */
  107094. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  107095. /**
  107096. * Get the euler rotation of the bone in local or world space
  107097. * @param space The space that the rotation should be in
  107098. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107099. * @returns The euler rotation
  107100. */
  107101. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  107102. /**
  107103. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  107104. * @param space The space that the rotation should be in
  107105. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107106. * @param result The vector3 that the rotation should be copied to
  107107. */
  107108. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  107109. /**
  107110. * Get the quaternion rotation of the bone in either local or world space
  107111. * @param space The space that the rotation should be in
  107112. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107113. * @returns The quaternion rotation
  107114. */
  107115. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  107116. /**
  107117. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  107118. * @param space The space that the rotation should be in
  107119. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107120. * @param result The quaternion that the rotation should be copied to
  107121. */
  107122. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  107123. /**
  107124. * Get the rotation matrix of the bone in local or world space
  107125. * @param space The space that the rotation should be in
  107126. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107127. * @returns The rotation matrix
  107128. */
  107129. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  107130. /**
  107131. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  107132. * @param space The space that the rotation should be in
  107133. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107134. * @param result The quaternion that the rotation should be copied to
  107135. */
  107136. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  107137. /**
  107138. * Get the world position of a point that is in the local space of the bone
  107139. * @param position The local position
  107140. * @param mesh The mesh that this bone is attached to
  107141. * @returns The world position
  107142. */
  107143. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  107144. /**
  107145. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  107146. * @param position The local position
  107147. * @param mesh The mesh that this bone is attached to
  107148. * @param result The vector3 that the world position should be copied to
  107149. */
  107150. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  107151. /**
  107152. * Get the local position of a point that is in world space
  107153. * @param position The world position
  107154. * @param mesh The mesh that this bone is attached to
  107155. * @returns The local position
  107156. */
  107157. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  107158. /**
  107159. * Get the local position of a point that is in world space and copy it to the result param
  107160. * @param position The world position
  107161. * @param mesh The mesh that this bone is attached to
  107162. * @param result The vector3 that the local position should be copied to
  107163. */
  107164. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  107165. /**
  107166. * Set the current local matrix as the restPose for this bone.
  107167. */
  107168. setCurrentPoseAsRest(): void;
  107169. }
  107170. }
  107171. declare module BABYLON {
  107172. /**
  107173. * 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.
  107174. * @see https://doc.babylonjs.com/how_to/transformnode
  107175. */
  107176. export class TransformNode extends Node {
  107177. /**
  107178. * Object will not rotate to face the camera
  107179. */
  107180. static BILLBOARDMODE_NONE: number;
  107181. /**
  107182. * Object will rotate to face the camera but only on the x axis
  107183. */
  107184. static BILLBOARDMODE_X: number;
  107185. /**
  107186. * Object will rotate to face the camera but only on the y axis
  107187. */
  107188. static BILLBOARDMODE_Y: number;
  107189. /**
  107190. * Object will rotate to face the camera but only on the z axis
  107191. */
  107192. static BILLBOARDMODE_Z: number;
  107193. /**
  107194. * Object will rotate to face the camera
  107195. */
  107196. static BILLBOARDMODE_ALL: number;
  107197. /**
  107198. * Object will rotate to face the camera's position instead of orientation
  107199. */
  107200. static BILLBOARDMODE_USE_POSITION: number;
  107201. private static _TmpRotation;
  107202. private static _TmpScaling;
  107203. private static _TmpTranslation;
  107204. private _forward;
  107205. private _forwardInverted;
  107206. private _up;
  107207. private _right;
  107208. private _rightInverted;
  107209. private _position;
  107210. private _rotation;
  107211. private _rotationQuaternion;
  107212. protected _scaling: Vector3;
  107213. protected _isDirty: boolean;
  107214. private _transformToBoneReferal;
  107215. private _isAbsoluteSynced;
  107216. private _billboardMode;
  107217. /**
  107218. * Gets or sets the billboard mode. Default is 0.
  107219. *
  107220. * | Value | Type | Description |
  107221. * | --- | --- | --- |
  107222. * | 0 | BILLBOARDMODE_NONE | |
  107223. * | 1 | BILLBOARDMODE_X | |
  107224. * | 2 | BILLBOARDMODE_Y | |
  107225. * | 4 | BILLBOARDMODE_Z | |
  107226. * | 7 | BILLBOARDMODE_ALL | |
  107227. *
  107228. */
  107229. get billboardMode(): number;
  107230. set billboardMode(value: number);
  107231. private _preserveParentRotationForBillboard;
  107232. /**
  107233. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  107234. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  107235. */
  107236. get preserveParentRotationForBillboard(): boolean;
  107237. set preserveParentRotationForBillboard(value: boolean);
  107238. /**
  107239. * 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
  107240. */
  107241. scalingDeterminant: number;
  107242. private _infiniteDistance;
  107243. /**
  107244. * Gets or sets the distance of the object to max, often used by skybox
  107245. */
  107246. get infiniteDistance(): boolean;
  107247. set infiniteDistance(value: boolean);
  107248. /**
  107249. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  107250. * By default the system will update normals to compensate
  107251. */
  107252. ignoreNonUniformScaling: boolean;
  107253. /**
  107254. * 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
  107255. */
  107256. reIntegrateRotationIntoRotationQuaternion: boolean;
  107257. /** @hidden */
  107258. _poseMatrix: Nullable<Matrix>;
  107259. /** @hidden */
  107260. _localMatrix: Matrix;
  107261. private _usePivotMatrix;
  107262. private _absolutePosition;
  107263. private _absoluteScaling;
  107264. private _absoluteRotationQuaternion;
  107265. private _pivotMatrix;
  107266. private _pivotMatrixInverse;
  107267. /** @hidden */
  107268. _postMultiplyPivotMatrix: boolean;
  107269. protected _isWorldMatrixFrozen: boolean;
  107270. /** @hidden */
  107271. _indexInSceneTransformNodesArray: number;
  107272. /**
  107273. * An event triggered after the world matrix is updated
  107274. */
  107275. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  107276. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  107277. /**
  107278. * Gets a string identifying the name of the class
  107279. * @returns "TransformNode" string
  107280. */
  107281. getClassName(): string;
  107282. /**
  107283. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  107284. */
  107285. get position(): Vector3;
  107286. set position(newPosition: Vector3);
  107287. /**
  107288. * 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)).
  107289. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  107290. */
  107291. get rotation(): Vector3;
  107292. set rotation(newRotation: Vector3);
  107293. /**
  107294. * 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)).
  107295. */
  107296. get scaling(): Vector3;
  107297. set scaling(newScaling: Vector3);
  107298. /**
  107299. * 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).
  107300. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  107301. */
  107302. get rotationQuaternion(): Nullable<Quaternion>;
  107303. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  107304. /**
  107305. * The forward direction of that transform in world space.
  107306. */
  107307. get forward(): Vector3;
  107308. /**
  107309. * The up direction of that transform in world space.
  107310. */
  107311. get up(): Vector3;
  107312. /**
  107313. * The right direction of that transform in world space.
  107314. */
  107315. get right(): Vector3;
  107316. /**
  107317. * Copies the parameter passed Matrix into the mesh Pose matrix.
  107318. * @param matrix the matrix to copy the pose from
  107319. * @returns this TransformNode.
  107320. */
  107321. updatePoseMatrix(matrix: Matrix): TransformNode;
  107322. /**
  107323. * Returns the mesh Pose matrix.
  107324. * @returns the pose matrix
  107325. */
  107326. getPoseMatrix(): Matrix;
  107327. /** @hidden */
  107328. _isSynchronized(): boolean;
  107329. /** @hidden */
  107330. _initCache(): void;
  107331. /**
  107332. * Flag the transform node as dirty (Forcing it to update everything)
  107333. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  107334. * @returns this transform node
  107335. */
  107336. markAsDirty(property: string): TransformNode;
  107337. /**
  107338. * Returns the current mesh absolute position.
  107339. * Returns a Vector3.
  107340. */
  107341. get absolutePosition(): Vector3;
  107342. /**
  107343. * Returns the current mesh absolute scaling.
  107344. * Returns a Vector3.
  107345. */
  107346. get absoluteScaling(): Vector3;
  107347. /**
  107348. * Returns the current mesh absolute rotation.
  107349. * Returns a Quaternion.
  107350. */
  107351. get absoluteRotationQuaternion(): Quaternion;
  107352. /**
  107353. * Sets a new matrix to apply before all other transformation
  107354. * @param matrix defines the transform matrix
  107355. * @returns the current TransformNode
  107356. */
  107357. setPreTransformMatrix(matrix: Matrix): TransformNode;
  107358. /**
  107359. * Sets a new pivot matrix to the current node
  107360. * @param matrix defines the new pivot matrix to use
  107361. * @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
  107362. * @returns the current TransformNode
  107363. */
  107364. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  107365. /**
  107366. * Returns the mesh pivot matrix.
  107367. * Default : Identity.
  107368. * @returns the matrix
  107369. */
  107370. getPivotMatrix(): Matrix;
  107371. /**
  107372. * Instantiate (when possible) or clone that node with its hierarchy
  107373. * @param newParent defines the new parent to use for the instance (or clone)
  107374. * @param options defines options to configure how copy is done
  107375. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  107376. * @returns an instance (or a clone) of the current node with its hiearchy
  107377. */
  107378. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  107379. doNotInstantiate: boolean;
  107380. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  107381. /**
  107382. * Prevents the World matrix to be computed any longer
  107383. * @param newWorldMatrix defines an optional matrix to use as world matrix
  107384. * @returns the TransformNode.
  107385. */
  107386. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  107387. /**
  107388. * Allows back the World matrix computation.
  107389. * @returns the TransformNode.
  107390. */
  107391. unfreezeWorldMatrix(): this;
  107392. /**
  107393. * True if the World matrix has been frozen.
  107394. */
  107395. get isWorldMatrixFrozen(): boolean;
  107396. /**
  107397. * Retuns the mesh absolute position in the World.
  107398. * @returns a Vector3.
  107399. */
  107400. getAbsolutePosition(): Vector3;
  107401. /**
  107402. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  107403. * @param absolutePosition the absolute position to set
  107404. * @returns the TransformNode.
  107405. */
  107406. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  107407. /**
  107408. * Sets the mesh position in its local space.
  107409. * @param vector3 the position to set in localspace
  107410. * @returns the TransformNode.
  107411. */
  107412. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  107413. /**
  107414. * Returns the mesh position in the local space from the current World matrix values.
  107415. * @returns a new Vector3.
  107416. */
  107417. getPositionExpressedInLocalSpace(): Vector3;
  107418. /**
  107419. * Translates the mesh along the passed Vector3 in its local space.
  107420. * @param vector3 the distance to translate in localspace
  107421. * @returns the TransformNode.
  107422. */
  107423. locallyTranslate(vector3: Vector3): TransformNode;
  107424. private static _lookAtVectorCache;
  107425. /**
  107426. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  107427. * @param targetPoint the position (must be in same space as current mesh) to look at
  107428. * @param yawCor optional yaw (y-axis) correction in radians
  107429. * @param pitchCor optional pitch (x-axis) correction in radians
  107430. * @param rollCor optional roll (z-axis) correction in radians
  107431. * @param space the choosen space of the target
  107432. * @returns the TransformNode.
  107433. */
  107434. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  107435. /**
  107436. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  107437. * This Vector3 is expressed in the World space.
  107438. * @param localAxis axis to rotate
  107439. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  107440. */
  107441. getDirection(localAxis: Vector3): Vector3;
  107442. /**
  107443. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  107444. * localAxis is expressed in the mesh local space.
  107445. * result is computed in the Wordl space from the mesh World matrix.
  107446. * @param localAxis axis to rotate
  107447. * @param result the resulting transformnode
  107448. * @returns this TransformNode.
  107449. */
  107450. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  107451. /**
  107452. * Sets this transform node rotation to the given local axis.
  107453. * @param localAxis the axis in local space
  107454. * @param yawCor optional yaw (y-axis) correction in radians
  107455. * @param pitchCor optional pitch (x-axis) correction in radians
  107456. * @param rollCor optional roll (z-axis) correction in radians
  107457. * @returns this TransformNode
  107458. */
  107459. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  107460. /**
  107461. * Sets a new pivot point to the current node
  107462. * @param point defines the new pivot point to use
  107463. * @param space defines if the point is in world or local space (local by default)
  107464. * @returns the current TransformNode
  107465. */
  107466. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  107467. /**
  107468. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  107469. * @returns the pivot point
  107470. */
  107471. getPivotPoint(): Vector3;
  107472. /**
  107473. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  107474. * @param result the vector3 to store the result
  107475. * @returns this TransformNode.
  107476. */
  107477. getPivotPointToRef(result: Vector3): TransformNode;
  107478. /**
  107479. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  107480. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  107481. */
  107482. getAbsolutePivotPoint(): Vector3;
  107483. /**
  107484. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  107485. * @param result vector3 to store the result
  107486. * @returns this TransformNode.
  107487. */
  107488. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  107489. /**
  107490. * Defines the passed node as the parent of the current node.
  107491. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  107492. * @see https://doc.babylonjs.com/how_to/parenting
  107493. * @param node the node ot set as the parent
  107494. * @returns this TransformNode.
  107495. */
  107496. setParent(node: Nullable<Node>): TransformNode;
  107497. private _nonUniformScaling;
  107498. /**
  107499. * True if the scaling property of this object is non uniform eg. (1,2,1)
  107500. */
  107501. get nonUniformScaling(): boolean;
  107502. /** @hidden */
  107503. _updateNonUniformScalingState(value: boolean): boolean;
  107504. /**
  107505. * Attach the current TransformNode to another TransformNode associated with a bone
  107506. * @param bone Bone affecting the TransformNode
  107507. * @param affectedTransformNode TransformNode associated with the bone
  107508. * @returns this object
  107509. */
  107510. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  107511. /**
  107512. * Detach the transform node if its associated with a bone
  107513. * @returns this object
  107514. */
  107515. detachFromBone(): TransformNode;
  107516. private static _rotationAxisCache;
  107517. /**
  107518. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  107519. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  107520. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  107521. * The passed axis is also normalized.
  107522. * @param axis the axis to rotate around
  107523. * @param amount the amount to rotate in radians
  107524. * @param space Space to rotate in (Default: local)
  107525. * @returns the TransformNode.
  107526. */
  107527. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  107528. /**
  107529. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  107530. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  107531. * The passed axis is also normalized. .
  107532. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  107533. * @param point the point to rotate around
  107534. * @param axis the axis to rotate around
  107535. * @param amount the amount to rotate in radians
  107536. * @returns the TransformNode
  107537. */
  107538. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  107539. /**
  107540. * Translates the mesh along the axis vector for the passed distance in the given space.
  107541. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  107542. * @param axis the axis to translate in
  107543. * @param distance the distance to translate
  107544. * @param space Space to rotate in (Default: local)
  107545. * @returns the TransformNode.
  107546. */
  107547. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  107548. /**
  107549. * Adds a rotation step to the mesh current rotation.
  107550. * x, y, z are Euler angles expressed in radians.
  107551. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  107552. * This means this rotation is made in the mesh local space only.
  107553. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  107554. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  107555. * ```javascript
  107556. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  107557. * ```
  107558. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  107559. * 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.
  107560. * @param x Rotation to add
  107561. * @param y Rotation to add
  107562. * @param z Rotation to add
  107563. * @returns the TransformNode.
  107564. */
  107565. addRotation(x: number, y: number, z: number): TransformNode;
  107566. /**
  107567. * @hidden
  107568. */
  107569. protected _getEffectiveParent(): Nullable<Node>;
  107570. /**
  107571. * Computes the world matrix of the node
  107572. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  107573. * @returns the world matrix
  107574. */
  107575. computeWorldMatrix(force?: boolean): Matrix;
  107576. /**
  107577. * Resets this nodeTransform's local matrix to Matrix.Identity().
  107578. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  107579. */
  107580. resetLocalMatrix(independentOfChildren?: boolean): void;
  107581. protected _afterComputeWorldMatrix(): void;
  107582. /**
  107583. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  107584. * @param func callback function to add
  107585. *
  107586. * @returns the TransformNode.
  107587. */
  107588. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  107589. /**
  107590. * Removes a registered callback function.
  107591. * @param func callback function to remove
  107592. * @returns the TransformNode.
  107593. */
  107594. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  107595. /**
  107596. * Gets the position of the current mesh in camera space
  107597. * @param camera defines the camera to use
  107598. * @returns a position
  107599. */
  107600. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  107601. /**
  107602. * Returns the distance from the mesh to the active camera
  107603. * @param camera defines the camera to use
  107604. * @returns the distance
  107605. */
  107606. getDistanceToCamera(camera?: Nullable<Camera>): number;
  107607. /**
  107608. * Clone the current transform node
  107609. * @param name Name of the new clone
  107610. * @param newParent New parent for the clone
  107611. * @param doNotCloneChildren Do not clone children hierarchy
  107612. * @returns the new transform node
  107613. */
  107614. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  107615. /**
  107616. * Serializes the objects information.
  107617. * @param currentSerializationObject defines the object to serialize in
  107618. * @returns the serialized object
  107619. */
  107620. serialize(currentSerializationObject?: any): any;
  107621. /**
  107622. * Returns a new TransformNode object parsed from the source provided.
  107623. * @param parsedTransformNode is the source.
  107624. * @param scene the scne the object belongs to
  107625. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  107626. * @returns a new TransformNode object parsed from the source provided.
  107627. */
  107628. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  107629. /**
  107630. * Get all child-transformNodes of this node
  107631. * @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
  107632. * @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
  107633. * @returns an array of TransformNode
  107634. */
  107635. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  107636. /**
  107637. * Releases resources associated with this transform node.
  107638. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107639. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107640. */
  107641. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107642. /**
  107643. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  107644. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  107645. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  107646. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  107647. * @returns the current mesh
  107648. */
  107649. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  107650. private _syncAbsoluteScalingAndRotation;
  107651. }
  107652. }
  107653. declare module BABYLON {
  107654. /**
  107655. * Defines the types of pose enabled controllers that are supported
  107656. */
  107657. export enum PoseEnabledControllerType {
  107658. /**
  107659. * HTC Vive
  107660. */
  107661. VIVE = 0,
  107662. /**
  107663. * Oculus Rift
  107664. */
  107665. OCULUS = 1,
  107666. /**
  107667. * Windows mixed reality
  107668. */
  107669. WINDOWS = 2,
  107670. /**
  107671. * Samsung gear VR
  107672. */
  107673. GEAR_VR = 3,
  107674. /**
  107675. * Google Daydream
  107676. */
  107677. DAYDREAM = 4,
  107678. /**
  107679. * Generic
  107680. */
  107681. GENERIC = 5
  107682. }
  107683. /**
  107684. * Defines the MutableGamepadButton interface for the state of a gamepad button
  107685. */
  107686. export interface MutableGamepadButton {
  107687. /**
  107688. * Value of the button/trigger
  107689. */
  107690. value: number;
  107691. /**
  107692. * If the button/trigger is currently touched
  107693. */
  107694. touched: boolean;
  107695. /**
  107696. * If the button/trigger is currently pressed
  107697. */
  107698. pressed: boolean;
  107699. }
  107700. /**
  107701. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  107702. * @hidden
  107703. */
  107704. export interface ExtendedGamepadButton extends GamepadButton {
  107705. /**
  107706. * If the button/trigger is currently pressed
  107707. */
  107708. readonly pressed: boolean;
  107709. /**
  107710. * If the button/trigger is currently touched
  107711. */
  107712. readonly touched: boolean;
  107713. /**
  107714. * Value of the button/trigger
  107715. */
  107716. readonly value: number;
  107717. }
  107718. /** @hidden */
  107719. export interface _GamePadFactory {
  107720. /**
  107721. * Returns whether or not the current gamepad can be created for this type of controller.
  107722. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  107723. * @returns true if it can be created, otherwise false
  107724. */
  107725. canCreate(gamepadInfo: any): boolean;
  107726. /**
  107727. * Creates a new instance of the Gamepad.
  107728. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  107729. * @returns the new gamepad instance
  107730. */
  107731. create(gamepadInfo: any): Gamepad;
  107732. }
  107733. /**
  107734. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  107735. */
  107736. export class PoseEnabledControllerHelper {
  107737. /** @hidden */
  107738. static _ControllerFactories: _GamePadFactory[];
  107739. /** @hidden */
  107740. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  107741. /**
  107742. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  107743. * @param vrGamepad the gamepad to initialized
  107744. * @returns a vr controller of the type the gamepad identified as
  107745. */
  107746. static InitiateController(vrGamepad: any): Gamepad;
  107747. }
  107748. /**
  107749. * Defines the PoseEnabledController object that contains state of a vr capable controller
  107750. */
  107751. export class PoseEnabledController extends Gamepad implements PoseControlled {
  107752. /**
  107753. * If the controller is used in a webXR session
  107754. */
  107755. isXR: boolean;
  107756. private _deviceRoomPosition;
  107757. private _deviceRoomRotationQuaternion;
  107758. /**
  107759. * The device position in babylon space
  107760. */
  107761. devicePosition: Vector3;
  107762. /**
  107763. * The device rotation in babylon space
  107764. */
  107765. deviceRotationQuaternion: Quaternion;
  107766. /**
  107767. * The scale factor of the device in babylon space
  107768. */
  107769. deviceScaleFactor: number;
  107770. /**
  107771. * (Likely devicePosition should be used instead) The device position in its room space
  107772. */
  107773. position: Vector3;
  107774. /**
  107775. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  107776. */
  107777. rotationQuaternion: Quaternion;
  107778. /**
  107779. * The type of controller (Eg. Windows mixed reality)
  107780. */
  107781. controllerType: PoseEnabledControllerType;
  107782. protected _calculatedPosition: Vector3;
  107783. private _calculatedRotation;
  107784. /**
  107785. * The raw pose from the device
  107786. */
  107787. rawPose: DevicePose;
  107788. private _trackPosition;
  107789. private _maxRotationDistFromHeadset;
  107790. private _draggedRoomRotation;
  107791. /**
  107792. * @hidden
  107793. */
  107794. _disableTrackPosition(fixedPosition: Vector3): void;
  107795. /**
  107796. * Internal, the mesh attached to the controller
  107797. * @hidden
  107798. */
  107799. _mesh: Nullable<AbstractMesh>;
  107800. private _poseControlledCamera;
  107801. private _leftHandSystemQuaternion;
  107802. /**
  107803. * Internal, matrix used to convert room space to babylon space
  107804. * @hidden
  107805. */
  107806. _deviceToWorld: Matrix;
  107807. /**
  107808. * Node to be used when casting a ray from the controller
  107809. * @hidden
  107810. */
  107811. _pointingPoseNode: Nullable<TransformNode>;
  107812. /**
  107813. * Name of the child mesh that can be used to cast a ray from the controller
  107814. */
  107815. static readonly POINTING_POSE: string;
  107816. /**
  107817. * Creates a new PoseEnabledController from a gamepad
  107818. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  107819. */
  107820. constructor(browserGamepad: any);
  107821. private _workingMatrix;
  107822. /**
  107823. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  107824. */
  107825. update(): void;
  107826. /**
  107827. * Updates only the pose device and mesh without doing any button event checking
  107828. */
  107829. protected _updatePoseAndMesh(): void;
  107830. /**
  107831. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  107832. * @param poseData raw pose fromthe device
  107833. */
  107834. updateFromDevice(poseData: DevicePose): void;
  107835. /**
  107836. * @hidden
  107837. */
  107838. _meshAttachedObservable: Observable<AbstractMesh>;
  107839. /**
  107840. * Attaches a mesh to the controller
  107841. * @param mesh the mesh to be attached
  107842. */
  107843. attachToMesh(mesh: AbstractMesh): void;
  107844. /**
  107845. * Attaches the controllers mesh to a camera
  107846. * @param camera the camera the mesh should be attached to
  107847. */
  107848. attachToPoseControlledCamera(camera: TargetCamera): void;
  107849. /**
  107850. * Disposes of the controller
  107851. */
  107852. dispose(): void;
  107853. /**
  107854. * The mesh that is attached to the controller
  107855. */
  107856. get mesh(): Nullable<AbstractMesh>;
  107857. /**
  107858. * Gets the ray of the controller in the direction the controller is pointing
  107859. * @param length the length the resulting ray should be
  107860. * @returns a ray in the direction the controller is pointing
  107861. */
  107862. getForwardRay(length?: number): Ray;
  107863. }
  107864. }
  107865. declare module BABYLON {
  107866. /**
  107867. * Defines the WebVRController object that represents controllers tracked in 3D space
  107868. */
  107869. export abstract class WebVRController extends PoseEnabledController {
  107870. /**
  107871. * Internal, the default controller model for the controller
  107872. */
  107873. protected _defaultModel: Nullable<AbstractMesh>;
  107874. /**
  107875. * Fired when the trigger state has changed
  107876. */
  107877. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  107878. /**
  107879. * Fired when the main button state has changed
  107880. */
  107881. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107882. /**
  107883. * Fired when the secondary button state has changed
  107884. */
  107885. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107886. /**
  107887. * Fired when the pad state has changed
  107888. */
  107889. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  107890. /**
  107891. * Fired when controllers stick values have changed
  107892. */
  107893. onPadValuesChangedObservable: Observable<StickValues>;
  107894. /**
  107895. * Array of button availible on the controller
  107896. */
  107897. protected _buttons: Array<MutableGamepadButton>;
  107898. private _onButtonStateChange;
  107899. /**
  107900. * Fired when a controller button's state has changed
  107901. * @param callback the callback containing the button that was modified
  107902. */
  107903. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  107904. /**
  107905. * X and Y axis corresponding to the controllers joystick
  107906. */
  107907. pad: StickValues;
  107908. /**
  107909. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  107910. */
  107911. hand: string;
  107912. /**
  107913. * The default controller model for the controller
  107914. */
  107915. get defaultModel(): Nullable<AbstractMesh>;
  107916. /**
  107917. * Creates a new WebVRController from a gamepad
  107918. * @param vrGamepad the gamepad that the WebVRController should be created from
  107919. */
  107920. constructor(vrGamepad: any);
  107921. /**
  107922. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  107923. */
  107924. update(): void;
  107925. /**
  107926. * Function to be called when a button is modified
  107927. */
  107928. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107929. /**
  107930. * Loads a mesh and attaches it to the controller
  107931. * @param scene the scene the mesh should be added to
  107932. * @param meshLoaded callback for when the mesh has been loaded
  107933. */
  107934. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107935. private _setButtonValue;
  107936. private _changes;
  107937. private _checkChanges;
  107938. /**
  107939. * Disposes of th webVRCOntroller
  107940. */
  107941. dispose(): void;
  107942. }
  107943. }
  107944. declare module BABYLON {
  107945. /**
  107946. * The HemisphericLight simulates the ambient environment light,
  107947. * so the passed direction is the light reflection direction, not the incoming direction.
  107948. */
  107949. export class HemisphericLight extends Light {
  107950. /**
  107951. * The groundColor is the light in the opposite direction to the one specified during creation.
  107952. * 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.
  107953. */
  107954. groundColor: Color3;
  107955. /**
  107956. * The light reflection direction, not the incoming direction.
  107957. */
  107958. direction: Vector3;
  107959. /**
  107960. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  107961. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  107962. * The HemisphericLight can't cast shadows.
  107963. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107964. * @param name The friendly name of the light
  107965. * @param direction The direction of the light reflection
  107966. * @param scene The scene the light belongs to
  107967. */
  107968. constructor(name: string, direction: Vector3, scene: Scene);
  107969. protected _buildUniformLayout(): void;
  107970. /**
  107971. * Returns the string "HemisphericLight".
  107972. * @return The class name
  107973. */
  107974. getClassName(): string;
  107975. /**
  107976. * Sets the HemisphericLight direction towards the passed target (Vector3).
  107977. * Returns the updated direction.
  107978. * @param target The target the direction should point to
  107979. * @return The computed direction
  107980. */
  107981. setDirectionToTarget(target: Vector3): Vector3;
  107982. /**
  107983. * Returns the shadow generator associated to the light.
  107984. * @returns Always null for hemispheric lights because it does not support shadows.
  107985. */
  107986. getShadowGenerator(): Nullable<IShadowGenerator>;
  107987. /**
  107988. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  107989. * @param effect The effect to update
  107990. * @param lightIndex The index of the light in the effect to update
  107991. * @returns The hemispheric light
  107992. */
  107993. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  107994. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  107995. /**
  107996. * Computes the world matrix of the node
  107997. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  107998. * @param useWasUpdatedFlag defines a reserved property
  107999. * @returns the world matrix
  108000. */
  108001. computeWorldMatrix(): Matrix;
  108002. /**
  108003. * Returns the integer 3.
  108004. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  108005. */
  108006. getTypeID(): number;
  108007. /**
  108008. * Prepares the list of defines specific to the light type.
  108009. * @param defines the list of defines
  108010. * @param lightIndex defines the index of the light for the effect
  108011. */
  108012. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  108013. }
  108014. }
  108015. declare module BABYLON {
  108016. /** @hidden */
  108017. export var vrMultiviewToSingleviewPixelShader: {
  108018. name: string;
  108019. shader: string;
  108020. };
  108021. }
  108022. declare module BABYLON {
  108023. /**
  108024. * Renders to multiple views with a single draw call
  108025. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  108026. */
  108027. export class MultiviewRenderTarget extends RenderTargetTexture {
  108028. /**
  108029. * Creates a multiview render target
  108030. * @param scene scene used with the render target
  108031. * @param size the size of the render target (used for each view)
  108032. */
  108033. constructor(scene: Scene, size?: number | {
  108034. width: number;
  108035. height: number;
  108036. } | {
  108037. ratio: number;
  108038. });
  108039. /**
  108040. * @hidden
  108041. * @param faceIndex the face index, if its a cube texture
  108042. */
  108043. _bindFrameBuffer(faceIndex?: number): void;
  108044. /**
  108045. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  108046. * @returns the view count
  108047. */
  108048. getViewCount(): number;
  108049. }
  108050. }
  108051. declare module BABYLON {
  108052. interface Engine {
  108053. /**
  108054. * Creates a new multiview render target
  108055. * @param width defines the width of the texture
  108056. * @param height defines the height of the texture
  108057. * @returns the created multiview texture
  108058. */
  108059. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  108060. /**
  108061. * Binds a multiview framebuffer to be drawn to
  108062. * @param multiviewTexture texture to bind
  108063. */
  108064. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  108065. }
  108066. interface Camera {
  108067. /**
  108068. * @hidden
  108069. * 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)
  108070. */
  108071. _useMultiviewToSingleView: boolean;
  108072. /**
  108073. * @hidden
  108074. * 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)
  108075. */
  108076. _multiviewTexture: Nullable<RenderTargetTexture>;
  108077. /**
  108078. * @hidden
  108079. * ensures the multiview texture of the camera exists and has the specified width/height
  108080. * @param width height to set on the multiview texture
  108081. * @param height width to set on the multiview texture
  108082. */
  108083. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  108084. }
  108085. interface Scene {
  108086. /** @hidden */
  108087. _transformMatrixR: Matrix;
  108088. /** @hidden */
  108089. _multiviewSceneUbo: Nullable<UniformBuffer>;
  108090. /** @hidden */
  108091. _createMultiviewUbo(): void;
  108092. /** @hidden */
  108093. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  108094. /** @hidden */
  108095. _renderMultiviewToSingleView(camera: Camera): void;
  108096. }
  108097. }
  108098. declare module BABYLON {
  108099. /**
  108100. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  108101. * This will not be used for webXR as it supports displaying texture arrays directly
  108102. */
  108103. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  108104. /**
  108105. * Gets a string identifying the name of the class
  108106. * @returns "VRMultiviewToSingleviewPostProcess" string
  108107. */
  108108. getClassName(): string;
  108109. /**
  108110. * Initializes a VRMultiviewToSingleview
  108111. * @param name name of the post process
  108112. * @param camera camera to be applied to
  108113. * @param scaleFactor scaling factor to the size of the output texture
  108114. */
  108115. constructor(name: string, camera: Camera, scaleFactor: number);
  108116. }
  108117. }
  108118. declare module BABYLON {
  108119. /**
  108120. * Interface used to define additional presentation attributes
  108121. */
  108122. export interface IVRPresentationAttributes {
  108123. /**
  108124. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  108125. */
  108126. highRefreshRate: boolean;
  108127. /**
  108128. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  108129. */
  108130. foveationLevel: number;
  108131. }
  108132. interface Engine {
  108133. /** @hidden */
  108134. _vrDisplay: any;
  108135. /** @hidden */
  108136. _vrSupported: boolean;
  108137. /** @hidden */
  108138. _oldSize: Size;
  108139. /** @hidden */
  108140. _oldHardwareScaleFactor: number;
  108141. /** @hidden */
  108142. _vrExclusivePointerMode: boolean;
  108143. /** @hidden */
  108144. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  108145. /** @hidden */
  108146. _onVRDisplayPointerRestricted: () => void;
  108147. /** @hidden */
  108148. _onVRDisplayPointerUnrestricted: () => void;
  108149. /** @hidden */
  108150. _onVrDisplayConnect: Nullable<(display: any) => void>;
  108151. /** @hidden */
  108152. _onVrDisplayDisconnect: Nullable<() => void>;
  108153. /** @hidden */
  108154. _onVrDisplayPresentChange: Nullable<() => void>;
  108155. /**
  108156. * Observable signaled when VR display mode changes
  108157. */
  108158. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  108159. /**
  108160. * Observable signaled when VR request present is complete
  108161. */
  108162. onVRRequestPresentComplete: Observable<boolean>;
  108163. /**
  108164. * Observable signaled when VR request present starts
  108165. */
  108166. onVRRequestPresentStart: Observable<Engine>;
  108167. /**
  108168. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  108169. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  108170. */
  108171. isInVRExclusivePointerMode: boolean;
  108172. /**
  108173. * Gets a boolean indicating if a webVR device was detected
  108174. * @returns true if a webVR device was detected
  108175. */
  108176. isVRDevicePresent(): boolean;
  108177. /**
  108178. * Gets the current webVR device
  108179. * @returns the current webVR device (or null)
  108180. */
  108181. getVRDevice(): any;
  108182. /**
  108183. * Initializes a webVR display and starts listening to display change events
  108184. * The onVRDisplayChangedObservable will be notified upon these changes
  108185. * @returns A promise containing a VRDisplay and if vr is supported
  108186. */
  108187. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  108188. /** @hidden */
  108189. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  108190. /**
  108191. * Gets or sets the presentation attributes used to configure VR rendering
  108192. */
  108193. vrPresentationAttributes?: IVRPresentationAttributes;
  108194. /**
  108195. * Call this function to switch to webVR mode
  108196. * Will do nothing if webVR is not supported or if there is no webVR device
  108197. * @param options the webvr options provided to the camera. mainly used for multiview
  108198. * @see https://doc.babylonjs.com/how_to/webvr_camera
  108199. */
  108200. enableVR(options: WebVROptions): void;
  108201. /** @hidden */
  108202. _onVRFullScreenTriggered(): void;
  108203. }
  108204. }
  108205. declare module BABYLON {
  108206. /**
  108207. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  108208. * IMPORTANT!! The data is right-hand data.
  108209. * @export
  108210. * @interface DevicePose
  108211. */
  108212. export interface DevicePose {
  108213. /**
  108214. * The position of the device, values in array are [x,y,z].
  108215. */
  108216. readonly position: Nullable<Float32Array>;
  108217. /**
  108218. * The linearVelocity of the device, values in array are [x,y,z].
  108219. */
  108220. readonly linearVelocity: Nullable<Float32Array>;
  108221. /**
  108222. * The linearAcceleration of the device, values in array are [x,y,z].
  108223. */
  108224. readonly linearAcceleration: Nullable<Float32Array>;
  108225. /**
  108226. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  108227. */
  108228. readonly orientation: Nullable<Float32Array>;
  108229. /**
  108230. * The angularVelocity of the device, values in array are [x,y,z].
  108231. */
  108232. readonly angularVelocity: Nullable<Float32Array>;
  108233. /**
  108234. * The angularAcceleration of the device, values in array are [x,y,z].
  108235. */
  108236. readonly angularAcceleration: Nullable<Float32Array>;
  108237. }
  108238. /**
  108239. * Interface representing a pose controlled object in Babylon.
  108240. * A pose controlled object has both regular pose values as well as pose values
  108241. * from an external device such as a VR head mounted display
  108242. */
  108243. export interface PoseControlled {
  108244. /**
  108245. * The position of the object in babylon space.
  108246. */
  108247. position: Vector3;
  108248. /**
  108249. * The rotation quaternion of the object in babylon space.
  108250. */
  108251. rotationQuaternion: Quaternion;
  108252. /**
  108253. * The position of the device in babylon space.
  108254. */
  108255. devicePosition?: Vector3;
  108256. /**
  108257. * The rotation quaternion of the device in babylon space.
  108258. */
  108259. deviceRotationQuaternion: Quaternion;
  108260. /**
  108261. * The raw pose coming from the device.
  108262. */
  108263. rawPose: Nullable<DevicePose>;
  108264. /**
  108265. * The scale of the device to be used when translating from device space to babylon space.
  108266. */
  108267. deviceScaleFactor: number;
  108268. /**
  108269. * Updates the poseControlled values based on the input device pose.
  108270. * @param poseData the pose data to update the object with
  108271. */
  108272. updateFromDevice(poseData: DevicePose): void;
  108273. }
  108274. /**
  108275. * Set of options to customize the webVRCamera
  108276. */
  108277. export interface WebVROptions {
  108278. /**
  108279. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  108280. */
  108281. trackPosition?: boolean;
  108282. /**
  108283. * Sets the scale of the vrDevice in babylon space. (default: 1)
  108284. */
  108285. positionScale?: number;
  108286. /**
  108287. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  108288. */
  108289. displayName?: string;
  108290. /**
  108291. * Should the native controller meshes be initialized. (default: true)
  108292. */
  108293. controllerMeshes?: boolean;
  108294. /**
  108295. * Creating a default HemiLight only on controllers. (default: true)
  108296. */
  108297. defaultLightingOnControllers?: boolean;
  108298. /**
  108299. * If you don't want to use the default VR button of the helper. (default: false)
  108300. */
  108301. useCustomVRButton?: boolean;
  108302. /**
  108303. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  108304. */
  108305. customVRButton?: HTMLButtonElement;
  108306. /**
  108307. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  108308. */
  108309. rayLength?: number;
  108310. /**
  108311. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  108312. */
  108313. defaultHeight?: number;
  108314. /**
  108315. * If multiview should be used if availible (default: false)
  108316. */
  108317. useMultiview?: boolean;
  108318. }
  108319. /**
  108320. * This represents a WebVR camera.
  108321. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  108322. * @example https://doc.babylonjs.com/how_to/webvr_camera
  108323. */
  108324. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  108325. private webVROptions;
  108326. /**
  108327. * @hidden
  108328. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  108329. */
  108330. _vrDevice: any;
  108331. /**
  108332. * The rawPose of the vrDevice.
  108333. */
  108334. rawPose: Nullable<DevicePose>;
  108335. private _onVREnabled;
  108336. private _specsVersion;
  108337. private _attached;
  108338. private _frameData;
  108339. protected _descendants: Array<Node>;
  108340. private _deviceRoomPosition;
  108341. /** @hidden */
  108342. _deviceRoomRotationQuaternion: Quaternion;
  108343. private _standingMatrix;
  108344. /**
  108345. * Represents device position in babylon space.
  108346. */
  108347. devicePosition: Vector3;
  108348. /**
  108349. * Represents device rotation in babylon space.
  108350. */
  108351. deviceRotationQuaternion: Quaternion;
  108352. /**
  108353. * The scale of the device to be used when translating from device space to babylon space.
  108354. */
  108355. deviceScaleFactor: number;
  108356. private _deviceToWorld;
  108357. private _worldToDevice;
  108358. /**
  108359. * References to the webVR controllers for the vrDevice.
  108360. */
  108361. controllers: Array<WebVRController>;
  108362. /**
  108363. * Emits an event when a controller is attached.
  108364. */
  108365. onControllersAttachedObservable: Observable<WebVRController[]>;
  108366. /**
  108367. * Emits an event when a controller's mesh has been loaded;
  108368. */
  108369. onControllerMeshLoadedObservable: Observable<WebVRController>;
  108370. /**
  108371. * Emits an event when the HMD's pose has been updated.
  108372. */
  108373. onPoseUpdatedFromDeviceObservable: Observable<any>;
  108374. private _poseSet;
  108375. /**
  108376. * If the rig cameras be used as parent instead of this camera.
  108377. */
  108378. rigParenting: boolean;
  108379. private _lightOnControllers;
  108380. private _defaultHeight?;
  108381. /**
  108382. * Instantiates a WebVRFreeCamera.
  108383. * @param name The name of the WebVRFreeCamera
  108384. * @param position The starting anchor position for the camera
  108385. * @param scene The scene the camera belongs to
  108386. * @param webVROptions a set of customizable options for the webVRCamera
  108387. */
  108388. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  108389. /**
  108390. * Gets the device distance from the ground in meters.
  108391. * @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.
  108392. */
  108393. deviceDistanceToRoomGround(): number;
  108394. /**
  108395. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  108396. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  108397. */
  108398. useStandingMatrix(callback?: (bool: boolean) => void): void;
  108399. /**
  108400. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  108401. * @returns A promise with a boolean set to if the standing matrix is supported.
  108402. */
  108403. useStandingMatrixAsync(): Promise<boolean>;
  108404. /**
  108405. * Disposes the camera
  108406. */
  108407. dispose(): void;
  108408. /**
  108409. * Gets a vrController by name.
  108410. * @param name The name of the controller to retreive
  108411. * @returns the controller matching the name specified or null if not found
  108412. */
  108413. getControllerByName(name: string): Nullable<WebVRController>;
  108414. private _leftController;
  108415. /**
  108416. * The controller corresponding to the users left hand.
  108417. */
  108418. get leftController(): Nullable<WebVRController>;
  108419. private _rightController;
  108420. /**
  108421. * The controller corresponding to the users right hand.
  108422. */
  108423. get rightController(): Nullable<WebVRController>;
  108424. /**
  108425. * Casts a ray forward from the vrCamera's gaze.
  108426. * @param length Length of the ray (default: 100)
  108427. * @returns the ray corresponding to the gaze
  108428. */
  108429. getForwardRay(length?: number): Ray;
  108430. /**
  108431. * @hidden
  108432. * Updates the camera based on device's frame data
  108433. */
  108434. _checkInputs(): void;
  108435. /**
  108436. * Updates the poseControlled values based on the input device pose.
  108437. * @param poseData Pose coming from the device
  108438. */
  108439. updateFromDevice(poseData: DevicePose): void;
  108440. private _detachIfAttached;
  108441. /**
  108442. * WebVR's attach control will start broadcasting frames to the device.
  108443. * Note that in certain browsers (chrome for example) this function must be called
  108444. * within a user-interaction callback. Example:
  108445. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  108446. *
  108447. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  108448. */
  108449. attachControl(noPreventDefault?: boolean): void;
  108450. /**
  108451. * Detach the current controls from the specified dom element.
  108452. */
  108453. detachControl(): void;
  108454. /**
  108455. * @returns the name of this class
  108456. */
  108457. getClassName(): string;
  108458. /**
  108459. * Calls resetPose on the vrDisplay
  108460. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  108461. */
  108462. resetToCurrentRotation(): void;
  108463. /**
  108464. * @hidden
  108465. * Updates the rig cameras (left and right eye)
  108466. */
  108467. _updateRigCameras(): void;
  108468. private _workingVector;
  108469. private _oneVector;
  108470. private _workingMatrix;
  108471. private updateCacheCalled;
  108472. private _correctPositionIfNotTrackPosition;
  108473. /**
  108474. * @hidden
  108475. * Updates the cached values of the camera
  108476. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  108477. */
  108478. _updateCache(ignoreParentClass?: boolean): void;
  108479. /**
  108480. * @hidden
  108481. * Get current device position in babylon world
  108482. */
  108483. _computeDevicePosition(): void;
  108484. /**
  108485. * Updates the current device position and rotation in the babylon world
  108486. */
  108487. update(): void;
  108488. /**
  108489. * @hidden
  108490. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  108491. * @returns an identity matrix
  108492. */
  108493. _getViewMatrix(): Matrix;
  108494. private _tmpMatrix;
  108495. /**
  108496. * This function is called by the two RIG cameras.
  108497. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  108498. * @hidden
  108499. */
  108500. _getWebVRViewMatrix(): Matrix;
  108501. /** @hidden */
  108502. _getWebVRProjectionMatrix(): Matrix;
  108503. private _onGamepadConnectedObserver;
  108504. private _onGamepadDisconnectedObserver;
  108505. private _updateCacheWhenTrackingDisabledObserver;
  108506. /**
  108507. * Initializes the controllers and their meshes
  108508. */
  108509. initControllers(): void;
  108510. }
  108511. }
  108512. declare module BABYLON {
  108513. /**
  108514. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  108515. *
  108516. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  108517. *
  108518. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  108519. */
  108520. export class MaterialHelper {
  108521. /**
  108522. * Bind the current view position to an effect.
  108523. * @param effect The effect to be bound
  108524. * @param scene The scene the eyes position is used from
  108525. * @param variableName name of the shader variable that will hold the eye position
  108526. */
  108527. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  108528. /**
  108529. * Helps preparing the defines values about the UVs in used in the effect.
  108530. * UVs are shared as much as we can accross channels in the shaders.
  108531. * @param texture The texture we are preparing the UVs for
  108532. * @param defines The defines to update
  108533. * @param key The channel key "diffuse", "specular"... used in the shader
  108534. */
  108535. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  108536. /**
  108537. * Binds a texture matrix value to its corrsponding uniform
  108538. * @param texture The texture to bind the matrix for
  108539. * @param uniformBuffer The uniform buffer receivin the data
  108540. * @param key The channel key "diffuse", "specular"... used in the shader
  108541. */
  108542. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  108543. /**
  108544. * Gets the current status of the fog (should it be enabled?)
  108545. * @param mesh defines the mesh to evaluate for fog support
  108546. * @param scene defines the hosting scene
  108547. * @returns true if fog must be enabled
  108548. */
  108549. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  108550. /**
  108551. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  108552. * @param mesh defines the current mesh
  108553. * @param scene defines the current scene
  108554. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  108555. * @param pointsCloud defines if point cloud rendering has to be turned on
  108556. * @param fogEnabled defines if fog has to be turned on
  108557. * @param alphaTest defines if alpha testing has to be turned on
  108558. * @param defines defines the current list of defines
  108559. */
  108560. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  108561. /**
  108562. * Helper used to prepare the list of defines associated with frame values for shader compilation
  108563. * @param scene defines the current scene
  108564. * @param engine defines the current engine
  108565. * @param defines specifies the list of active defines
  108566. * @param useInstances defines if instances have to be turned on
  108567. * @param useClipPlane defines if clip plane have to be turned on
  108568. * @param useInstances defines if instances have to be turned on
  108569. * @param useThinInstances defines if thin instances have to be turned on
  108570. */
  108571. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  108572. /**
  108573. * Prepares the defines for bones
  108574. * @param mesh The mesh containing the geometry data we will draw
  108575. * @param defines The defines to update
  108576. */
  108577. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  108578. /**
  108579. * Prepares the defines for morph targets
  108580. * @param mesh The mesh containing the geometry data we will draw
  108581. * @param defines The defines to update
  108582. */
  108583. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  108584. /**
  108585. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  108586. * @param mesh The mesh containing the geometry data we will draw
  108587. * @param defines The defines to update
  108588. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  108589. * @param useBones Precise whether bones should be used or not (override mesh info)
  108590. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  108591. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  108592. * @returns false if defines are considered not dirty and have not been checked
  108593. */
  108594. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  108595. /**
  108596. * Prepares the defines related to multiview
  108597. * @param scene The scene we are intending to draw
  108598. * @param defines The defines to update
  108599. */
  108600. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  108601. /**
  108602. * Prepares the defines related to the prepass
  108603. * @param scene The scene we are intending to draw
  108604. * @param defines The defines to update
  108605. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  108606. */
  108607. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  108608. /**
  108609. * Prepares the defines related to the light information passed in parameter
  108610. * @param scene The scene we are intending to draw
  108611. * @param mesh The mesh the effect is compiling for
  108612. * @param light The light the effect is compiling for
  108613. * @param lightIndex The index of the light
  108614. * @param defines The defines to update
  108615. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  108616. * @param state Defines the current state regarding what is needed (normals, etc...)
  108617. */
  108618. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  108619. needNormals: boolean;
  108620. needRebuild: boolean;
  108621. shadowEnabled: boolean;
  108622. specularEnabled: boolean;
  108623. lightmapMode: boolean;
  108624. }): void;
  108625. /**
  108626. * Prepares the defines related to the light information passed in parameter
  108627. * @param scene The scene we are intending to draw
  108628. * @param mesh The mesh the effect is compiling for
  108629. * @param defines The defines to update
  108630. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  108631. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  108632. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  108633. * @returns true if normals will be required for the rest of the effect
  108634. */
  108635. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  108636. /**
  108637. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  108638. * @param lightIndex defines the light index
  108639. * @param uniformsList The uniform list
  108640. * @param samplersList The sampler list
  108641. * @param projectedLightTexture defines if projected texture must be used
  108642. * @param uniformBuffersList defines an optional list of uniform buffers
  108643. */
  108644. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  108645. /**
  108646. * Prepares the uniforms and samplers list to be used in the effect
  108647. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  108648. * @param samplersList The sampler list
  108649. * @param defines The defines helping in the list generation
  108650. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  108651. */
  108652. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  108653. /**
  108654. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  108655. * @param defines The defines to update while falling back
  108656. * @param fallbacks The authorized effect fallbacks
  108657. * @param maxSimultaneousLights The maximum number of lights allowed
  108658. * @param rank the current rank of the Effect
  108659. * @returns The newly affected rank
  108660. */
  108661. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  108662. private static _TmpMorphInfluencers;
  108663. /**
  108664. * Prepares the list of attributes required for morph targets according to the effect defines.
  108665. * @param attribs The current list of supported attribs
  108666. * @param mesh The mesh to prepare the morph targets attributes for
  108667. * @param influencers The number of influencers
  108668. */
  108669. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  108670. /**
  108671. * Prepares the list of attributes required for morph targets according to the effect defines.
  108672. * @param attribs The current list of supported attribs
  108673. * @param mesh The mesh to prepare the morph targets attributes for
  108674. * @param defines The current Defines of the effect
  108675. */
  108676. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  108677. /**
  108678. * Prepares the list of attributes required for bones according to the effect defines.
  108679. * @param attribs The current list of supported attribs
  108680. * @param mesh The mesh to prepare the bones attributes for
  108681. * @param defines The current Defines of the effect
  108682. * @param fallbacks The current efffect fallback strategy
  108683. */
  108684. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  108685. /**
  108686. * Check and prepare the list of attributes required for instances according to the effect defines.
  108687. * @param attribs The current list of supported attribs
  108688. * @param defines The current MaterialDefines of the effect
  108689. */
  108690. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  108691. /**
  108692. * Add the list of attributes required for instances to the attribs array.
  108693. * @param attribs The current list of supported attribs
  108694. */
  108695. static PushAttributesForInstances(attribs: string[]): void;
  108696. /**
  108697. * Binds the light information to the effect.
  108698. * @param light The light containing the generator
  108699. * @param effect The effect we are binding the data to
  108700. * @param lightIndex The light index in the effect used to render
  108701. */
  108702. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  108703. /**
  108704. * Binds the lights information from the scene to the effect for the given mesh.
  108705. * @param light Light to bind
  108706. * @param lightIndex Light index
  108707. * @param scene The scene where the light belongs to
  108708. * @param effect The effect we are binding the data to
  108709. * @param useSpecular Defines if specular is supported
  108710. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  108711. */
  108712. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  108713. /**
  108714. * Binds the lights information from the scene to the effect for the given mesh.
  108715. * @param scene The scene the lights belongs to
  108716. * @param mesh The mesh we are binding the information to render
  108717. * @param effect The effect we are binding the data to
  108718. * @param defines The generated defines for the effect
  108719. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  108720. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  108721. */
  108722. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  108723. private static _tempFogColor;
  108724. /**
  108725. * Binds the fog information from the scene to the effect for the given mesh.
  108726. * @param scene The scene the lights belongs to
  108727. * @param mesh The mesh we are binding the information to render
  108728. * @param effect The effect we are binding the data to
  108729. * @param linearSpace Defines if the fog effect is applied in linear space
  108730. */
  108731. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  108732. /**
  108733. * Binds the bones information from the mesh to the effect.
  108734. * @param mesh The mesh we are binding the information to render
  108735. * @param effect The effect we are binding the data to
  108736. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  108737. */
  108738. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  108739. private static _CopyBonesTransformationMatrices;
  108740. /**
  108741. * Binds the morph targets information from the mesh to the effect.
  108742. * @param abstractMesh The mesh we are binding the information to render
  108743. * @param effect The effect we are binding the data to
  108744. */
  108745. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  108746. /**
  108747. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  108748. * @param defines The generated defines used in the effect
  108749. * @param effect The effect we are binding the data to
  108750. * @param scene The scene we are willing to render with logarithmic scale for
  108751. */
  108752. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  108753. /**
  108754. * Binds the clip plane information from the scene to the effect.
  108755. * @param scene The scene the clip plane information are extracted from
  108756. * @param effect The effect we are binding the data to
  108757. */
  108758. static BindClipPlane(effect: Effect, scene: Scene): void;
  108759. }
  108760. }
  108761. declare module BABYLON {
  108762. /** @hidden */
  108763. export var bayerDitherFunctions: {
  108764. name: string;
  108765. shader: string;
  108766. };
  108767. }
  108768. declare module BABYLON {
  108769. /** @hidden */
  108770. export var shadowMapFragmentDeclaration: {
  108771. name: string;
  108772. shader: string;
  108773. };
  108774. }
  108775. declare module BABYLON {
  108776. /** @hidden */
  108777. export var shadowMapFragment: {
  108778. name: string;
  108779. shader: string;
  108780. };
  108781. }
  108782. declare module BABYLON {
  108783. /** @hidden */
  108784. export var shadowMapPixelShader: {
  108785. name: string;
  108786. shader: string;
  108787. };
  108788. }
  108789. declare module BABYLON {
  108790. /** @hidden */
  108791. export var shadowMapVertexDeclaration: {
  108792. name: string;
  108793. shader: string;
  108794. };
  108795. }
  108796. declare module BABYLON {
  108797. /** @hidden */
  108798. export var shadowMapVertexNormalBias: {
  108799. name: string;
  108800. shader: string;
  108801. };
  108802. }
  108803. declare module BABYLON {
  108804. /** @hidden */
  108805. export var shadowMapVertexMetric: {
  108806. name: string;
  108807. shader: string;
  108808. };
  108809. }
  108810. declare module BABYLON {
  108811. /** @hidden */
  108812. export var shadowMapVertexShader: {
  108813. name: string;
  108814. shader: string;
  108815. };
  108816. }
  108817. declare module BABYLON {
  108818. /** @hidden */
  108819. export var depthBoxBlurPixelShader: {
  108820. name: string;
  108821. shader: string;
  108822. };
  108823. }
  108824. declare module BABYLON {
  108825. /** @hidden */
  108826. export var shadowMapFragmentSoftTransparentShadow: {
  108827. name: string;
  108828. shader: string;
  108829. };
  108830. }
  108831. declare module BABYLON {
  108832. /**
  108833. * Creates an instance based on a source mesh.
  108834. */
  108835. export class InstancedMesh extends AbstractMesh {
  108836. private _sourceMesh;
  108837. private _currentLOD;
  108838. /** @hidden */
  108839. _indexInSourceMeshInstanceArray: number;
  108840. constructor(name: string, source: Mesh);
  108841. /**
  108842. * Returns the string "InstancedMesh".
  108843. */
  108844. getClassName(): string;
  108845. /** Gets the list of lights affecting that mesh */
  108846. get lightSources(): Light[];
  108847. _resyncLightSources(): void;
  108848. _resyncLightSource(light: Light): void;
  108849. _removeLightSource(light: Light, dispose: boolean): void;
  108850. /**
  108851. * If the source mesh receives shadows
  108852. */
  108853. get receiveShadows(): boolean;
  108854. /**
  108855. * The material of the source mesh
  108856. */
  108857. get material(): Nullable<Material>;
  108858. /**
  108859. * Visibility of the source mesh
  108860. */
  108861. get visibility(): number;
  108862. /**
  108863. * Skeleton of the source mesh
  108864. */
  108865. get skeleton(): Nullable<Skeleton>;
  108866. /**
  108867. * Rendering ground id of the source mesh
  108868. */
  108869. get renderingGroupId(): number;
  108870. set renderingGroupId(value: number);
  108871. /**
  108872. * Returns the total number of vertices (integer).
  108873. */
  108874. getTotalVertices(): number;
  108875. /**
  108876. * Returns a positive integer : the total number of indices in this mesh geometry.
  108877. * @returns the numner of indices or zero if the mesh has no geometry.
  108878. */
  108879. getTotalIndices(): number;
  108880. /**
  108881. * The source mesh of the instance
  108882. */
  108883. get sourceMesh(): Mesh;
  108884. /**
  108885. * Creates a new InstancedMesh object from the mesh model.
  108886. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108887. * @param name defines the name of the new instance
  108888. * @returns a new InstancedMesh
  108889. */
  108890. createInstance(name: string): InstancedMesh;
  108891. /**
  108892. * Is this node ready to be used/rendered
  108893. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  108894. * @return {boolean} is it ready
  108895. */
  108896. isReady(completeCheck?: boolean): boolean;
  108897. /**
  108898. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  108899. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  108900. * @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.
  108901. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  108902. */
  108903. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  108904. /**
  108905. * Sets the vertex data of the mesh geometry for the requested `kind`.
  108906. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  108907. * The `data` are either a numeric array either a Float32Array.
  108908. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  108909. * 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).
  108910. * Note that a new underlying VertexBuffer object is created each call.
  108911. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  108912. *
  108913. * Possible `kind` values :
  108914. * - VertexBuffer.PositionKind
  108915. * - VertexBuffer.UVKind
  108916. * - VertexBuffer.UV2Kind
  108917. * - VertexBuffer.UV3Kind
  108918. * - VertexBuffer.UV4Kind
  108919. * - VertexBuffer.UV5Kind
  108920. * - VertexBuffer.UV6Kind
  108921. * - VertexBuffer.ColorKind
  108922. * - VertexBuffer.MatricesIndicesKind
  108923. * - VertexBuffer.MatricesIndicesExtraKind
  108924. * - VertexBuffer.MatricesWeightsKind
  108925. * - VertexBuffer.MatricesWeightsExtraKind
  108926. *
  108927. * Returns the Mesh.
  108928. */
  108929. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  108930. /**
  108931. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  108932. * If the mesh has no geometry, it is simply returned as it is.
  108933. * The `data` are either a numeric array either a Float32Array.
  108934. * No new underlying VertexBuffer object is created.
  108935. * 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.
  108936. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  108937. *
  108938. * Possible `kind` values :
  108939. * - VertexBuffer.PositionKind
  108940. * - VertexBuffer.UVKind
  108941. * - VertexBuffer.UV2Kind
  108942. * - VertexBuffer.UV3Kind
  108943. * - VertexBuffer.UV4Kind
  108944. * - VertexBuffer.UV5Kind
  108945. * - VertexBuffer.UV6Kind
  108946. * - VertexBuffer.ColorKind
  108947. * - VertexBuffer.MatricesIndicesKind
  108948. * - VertexBuffer.MatricesIndicesExtraKind
  108949. * - VertexBuffer.MatricesWeightsKind
  108950. * - VertexBuffer.MatricesWeightsExtraKind
  108951. *
  108952. * Returns the Mesh.
  108953. */
  108954. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  108955. /**
  108956. * Sets the mesh indices.
  108957. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  108958. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  108959. * This method creates a new index buffer each call.
  108960. * Returns the Mesh.
  108961. */
  108962. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  108963. /**
  108964. * Boolean : True if the mesh owns the requested kind of data.
  108965. */
  108966. isVerticesDataPresent(kind: string): boolean;
  108967. /**
  108968. * Returns an array of indices (IndicesArray).
  108969. */
  108970. getIndices(): Nullable<IndicesArray>;
  108971. get _positions(): Nullable<Vector3[]>;
  108972. /**
  108973. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  108974. * This means the mesh underlying bounding box and sphere are recomputed.
  108975. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  108976. * @returns the current mesh
  108977. */
  108978. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  108979. /** @hidden */
  108980. _preActivate(): InstancedMesh;
  108981. /** @hidden */
  108982. _activate(renderId: number, intermediateRendering: boolean): boolean;
  108983. /** @hidden */
  108984. _postActivate(): void;
  108985. getWorldMatrix(): Matrix;
  108986. get isAnInstance(): boolean;
  108987. /**
  108988. * Returns the current associated LOD AbstractMesh.
  108989. */
  108990. getLOD(camera: Camera): AbstractMesh;
  108991. /** @hidden */
  108992. _preActivateForIntermediateRendering(renderId: number): Mesh;
  108993. /** @hidden */
  108994. _syncSubMeshes(): InstancedMesh;
  108995. /** @hidden */
  108996. _generatePointsArray(): boolean;
  108997. /** @hidden */
  108998. _updateBoundingInfo(): AbstractMesh;
  108999. /**
  109000. * Creates a new InstancedMesh from the current mesh.
  109001. * - name (string) : the cloned mesh name
  109002. * - newParent (optional Node) : the optional Node to parent the clone to.
  109003. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  109004. *
  109005. * Returns the clone.
  109006. */
  109007. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  109008. /**
  109009. * Disposes the InstancedMesh.
  109010. * Returns nothing.
  109011. */
  109012. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109013. }
  109014. interface Mesh {
  109015. /**
  109016. * Register a custom buffer that will be instanced
  109017. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  109018. * @param kind defines the buffer kind
  109019. * @param stride defines the stride in floats
  109020. */
  109021. registerInstancedBuffer(kind: string, stride: number): void;
  109022. /**
  109023. * true to use the edge renderer for all instances of this mesh
  109024. */
  109025. edgesShareWithInstances: boolean;
  109026. /** @hidden */
  109027. _userInstancedBuffersStorage: {
  109028. data: {
  109029. [key: string]: Float32Array;
  109030. };
  109031. sizes: {
  109032. [key: string]: number;
  109033. };
  109034. vertexBuffers: {
  109035. [key: string]: Nullable<VertexBuffer>;
  109036. };
  109037. strides: {
  109038. [key: string]: number;
  109039. };
  109040. };
  109041. }
  109042. interface AbstractMesh {
  109043. /**
  109044. * Object used to store instanced buffers defined by user
  109045. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  109046. */
  109047. instancedBuffers: {
  109048. [key: string]: any;
  109049. };
  109050. }
  109051. }
  109052. declare module BABYLON {
  109053. /**
  109054. * Defines the options associated with the creation of a shader material.
  109055. */
  109056. export interface IShaderMaterialOptions {
  109057. /**
  109058. * Does the material work in alpha blend mode
  109059. */
  109060. needAlphaBlending: boolean;
  109061. /**
  109062. * Does the material work in alpha test mode
  109063. */
  109064. needAlphaTesting: boolean;
  109065. /**
  109066. * The list of attribute names used in the shader
  109067. */
  109068. attributes: string[];
  109069. /**
  109070. * The list of unifrom names used in the shader
  109071. */
  109072. uniforms: string[];
  109073. /**
  109074. * The list of UBO names used in the shader
  109075. */
  109076. uniformBuffers: string[];
  109077. /**
  109078. * The list of sampler names used in the shader
  109079. */
  109080. samplers: string[];
  109081. /**
  109082. * The list of defines used in the shader
  109083. */
  109084. defines: string[];
  109085. }
  109086. /**
  109087. * 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.
  109088. *
  109089. * This returned material effects how the mesh will look based on the code in the shaders.
  109090. *
  109091. * @see https://doc.babylonjs.com/how_to/shader_material
  109092. */
  109093. export class ShaderMaterial extends Material {
  109094. private _shaderPath;
  109095. private _options;
  109096. private _textures;
  109097. private _textureArrays;
  109098. private _floats;
  109099. private _ints;
  109100. private _floatsArrays;
  109101. private _colors3;
  109102. private _colors3Arrays;
  109103. private _colors4;
  109104. private _colors4Arrays;
  109105. private _vectors2;
  109106. private _vectors3;
  109107. private _vectors4;
  109108. private _matrices;
  109109. private _matrixArrays;
  109110. private _matrices3x3;
  109111. private _matrices2x2;
  109112. private _vectors2Arrays;
  109113. private _vectors3Arrays;
  109114. private _vectors4Arrays;
  109115. private _cachedWorldViewMatrix;
  109116. private _cachedWorldViewProjectionMatrix;
  109117. private _renderId;
  109118. private _multiview;
  109119. private _cachedDefines;
  109120. /** Define the Url to load snippets */
  109121. static SnippetUrl: string;
  109122. /** Snippet ID if the material was created from the snippet server */
  109123. snippetId: string;
  109124. /**
  109125. * Instantiate a new shader material.
  109126. * 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.
  109127. * This returned material effects how the mesh will look based on the code in the shaders.
  109128. * @see https://doc.babylonjs.com/how_to/shader_material
  109129. * @param name Define the name of the material in the scene
  109130. * @param scene Define the scene the material belongs to
  109131. * @param shaderPath Defines the route to the shader code in one of three ways:
  109132. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  109133. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  109134. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  109135. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  109136. * @param options Define the options used to create the shader
  109137. */
  109138. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  109139. /**
  109140. * Gets the shader path used to define the shader code
  109141. * It can be modified to trigger a new compilation
  109142. */
  109143. get shaderPath(): any;
  109144. /**
  109145. * Sets the shader path used to define the shader code
  109146. * It can be modified to trigger a new compilation
  109147. */
  109148. set shaderPath(shaderPath: any);
  109149. /**
  109150. * Gets the options used to compile the shader.
  109151. * They can be modified to trigger a new compilation
  109152. */
  109153. get options(): IShaderMaterialOptions;
  109154. /**
  109155. * Gets the current class name of the material e.g. "ShaderMaterial"
  109156. * Mainly use in serialization.
  109157. * @returns the class name
  109158. */
  109159. getClassName(): string;
  109160. /**
  109161. * Specifies if the material will require alpha blending
  109162. * @returns a boolean specifying if alpha blending is needed
  109163. */
  109164. needAlphaBlending(): boolean;
  109165. /**
  109166. * Specifies if this material should be rendered in alpha test mode
  109167. * @returns a boolean specifying if an alpha test is needed.
  109168. */
  109169. needAlphaTesting(): boolean;
  109170. private _checkUniform;
  109171. /**
  109172. * Set a texture in the shader.
  109173. * @param name Define the name of the uniform samplers as defined in the shader
  109174. * @param texture Define the texture to bind to this sampler
  109175. * @return the material itself allowing "fluent" like uniform updates
  109176. */
  109177. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  109178. /**
  109179. * Set a texture array in the shader.
  109180. * @param name Define the name of the uniform sampler array as defined in the shader
  109181. * @param textures Define the list of textures to bind to this sampler
  109182. * @return the material itself allowing "fluent" like uniform updates
  109183. */
  109184. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  109185. /**
  109186. * Set a float in the shader.
  109187. * @param name Define the name of the uniform as defined in the shader
  109188. * @param value Define the value to give to the uniform
  109189. * @return the material itself allowing "fluent" like uniform updates
  109190. */
  109191. setFloat(name: string, value: number): ShaderMaterial;
  109192. /**
  109193. * Set a int in the shader.
  109194. * @param name Define the name of the uniform as defined in the shader
  109195. * @param value Define the value to give to the uniform
  109196. * @return the material itself allowing "fluent" like uniform updates
  109197. */
  109198. setInt(name: string, value: number): ShaderMaterial;
  109199. /**
  109200. * Set an array of floats in the shader.
  109201. * @param name Define the name of the uniform as defined in the shader
  109202. * @param value Define the value to give to the uniform
  109203. * @return the material itself allowing "fluent" like uniform updates
  109204. */
  109205. setFloats(name: string, value: number[]): ShaderMaterial;
  109206. /**
  109207. * Set a vec3 in the shader from a Color3.
  109208. * @param name Define the name of the uniform as defined in the shader
  109209. * @param value Define the value to give to the uniform
  109210. * @return the material itself allowing "fluent" like uniform updates
  109211. */
  109212. setColor3(name: string, value: Color3): ShaderMaterial;
  109213. /**
  109214. * Set a vec3 array in the shader from a Color3 array.
  109215. * @param name Define the name of the uniform as defined in the shader
  109216. * @param value Define the value to give to the uniform
  109217. * @return the material itself allowing "fluent" like uniform updates
  109218. */
  109219. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  109220. /**
  109221. * Set a vec4 in the shader from a Color4.
  109222. * @param name Define the name of the uniform as defined in the shader
  109223. * @param value Define the value to give to the uniform
  109224. * @return the material itself allowing "fluent" like uniform updates
  109225. */
  109226. setColor4(name: string, value: Color4): ShaderMaterial;
  109227. /**
  109228. * Set a vec4 array in the shader from a Color4 array.
  109229. * @param name Define the name of the uniform as defined in the shader
  109230. * @param value Define the value to give to the uniform
  109231. * @return the material itself allowing "fluent" like uniform updates
  109232. */
  109233. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  109234. /**
  109235. * Set a vec2 in the shader from a Vector2.
  109236. * @param name Define the name of the uniform as defined in the shader
  109237. * @param value Define the value to give to the uniform
  109238. * @return the material itself allowing "fluent" like uniform updates
  109239. */
  109240. setVector2(name: string, value: Vector2): ShaderMaterial;
  109241. /**
  109242. * Set a vec3 in the shader from a Vector3.
  109243. * @param name Define the name of the uniform as defined in the shader
  109244. * @param value Define the value to give to the uniform
  109245. * @return the material itself allowing "fluent" like uniform updates
  109246. */
  109247. setVector3(name: string, value: Vector3): ShaderMaterial;
  109248. /**
  109249. * Set a vec4 in the shader from a Vector4.
  109250. * @param name Define the name of the uniform as defined in the shader
  109251. * @param value Define the value to give to the uniform
  109252. * @return the material itself allowing "fluent" like uniform updates
  109253. */
  109254. setVector4(name: string, value: Vector4): ShaderMaterial;
  109255. /**
  109256. * Set a mat4 in the shader from a Matrix.
  109257. * @param name Define the name of the uniform as defined in the shader
  109258. * @param value Define the value to give to the uniform
  109259. * @return the material itself allowing "fluent" like uniform updates
  109260. */
  109261. setMatrix(name: string, value: Matrix): ShaderMaterial;
  109262. /**
  109263. * Set a float32Array in the shader from a matrix array.
  109264. * @param name Define the name of the uniform as defined in the shader
  109265. * @param value Define the value to give to the uniform
  109266. * @return the material itself allowing "fluent" like uniform updates
  109267. */
  109268. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  109269. /**
  109270. * Set a mat3 in the shader from a Float32Array.
  109271. * @param name Define the name of the uniform as defined in the shader
  109272. * @param value Define the value to give to the uniform
  109273. * @return the material itself allowing "fluent" like uniform updates
  109274. */
  109275. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  109276. /**
  109277. * Set a mat2 in the shader from a Float32Array.
  109278. * @param name Define the name of the uniform as defined in the shader
  109279. * @param value Define the value to give to the uniform
  109280. * @return the material itself allowing "fluent" like uniform updates
  109281. */
  109282. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  109283. /**
  109284. * Set a vec2 array in the shader from a number array.
  109285. * @param name Define the name of the uniform as defined in the shader
  109286. * @param value Define the value to give to the uniform
  109287. * @return the material itself allowing "fluent" like uniform updates
  109288. */
  109289. setArray2(name: string, value: number[]): ShaderMaterial;
  109290. /**
  109291. * Set a vec3 array in the shader from a number array.
  109292. * @param name Define the name of the uniform as defined in the shader
  109293. * @param value Define the value to give to the uniform
  109294. * @return the material itself allowing "fluent" like uniform updates
  109295. */
  109296. setArray3(name: string, value: number[]): ShaderMaterial;
  109297. /**
  109298. * Set a vec4 array in the shader from a number array.
  109299. * @param name Define the name of the uniform as defined in the shader
  109300. * @param value Define the value to give to the uniform
  109301. * @return the material itself allowing "fluent" like uniform updates
  109302. */
  109303. setArray4(name: string, value: number[]): ShaderMaterial;
  109304. private _checkCache;
  109305. /**
  109306. * Specifies that the submesh is ready to be used
  109307. * @param mesh defines the mesh to check
  109308. * @param subMesh defines which submesh to check
  109309. * @param useInstances specifies that instances should be used
  109310. * @returns a boolean indicating that the submesh is ready or not
  109311. */
  109312. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109313. /**
  109314. * Checks if the material is ready to render the requested mesh
  109315. * @param mesh Define the mesh to render
  109316. * @param useInstances Define whether or not the material is used with instances
  109317. * @returns true if ready, otherwise false
  109318. */
  109319. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  109320. /**
  109321. * Binds the world matrix to the material
  109322. * @param world defines the world transformation matrix
  109323. * @param effectOverride - If provided, use this effect instead of internal effect
  109324. */
  109325. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  109326. /**
  109327. * Binds the submesh to this material by preparing the effect and shader to draw
  109328. * @param world defines the world transformation matrix
  109329. * @param mesh defines the mesh containing the submesh
  109330. * @param subMesh defines the submesh to bind the material to
  109331. */
  109332. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109333. /**
  109334. * Binds the material to the mesh
  109335. * @param world defines the world transformation matrix
  109336. * @param mesh defines the mesh to bind the material to
  109337. * @param effectOverride - If provided, use this effect instead of internal effect
  109338. */
  109339. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  109340. protected _afterBind(mesh?: Mesh): void;
  109341. /**
  109342. * Gets the active textures from the material
  109343. * @returns an array of textures
  109344. */
  109345. getActiveTextures(): BaseTexture[];
  109346. /**
  109347. * Specifies if the material uses a texture
  109348. * @param texture defines the texture to check against the material
  109349. * @returns a boolean specifying if the material uses the texture
  109350. */
  109351. hasTexture(texture: BaseTexture): boolean;
  109352. /**
  109353. * Makes a duplicate of the material, and gives it a new name
  109354. * @param name defines the new name for the duplicated material
  109355. * @returns the cloned material
  109356. */
  109357. clone(name: string): ShaderMaterial;
  109358. /**
  109359. * Disposes the material
  109360. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  109361. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  109362. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  109363. */
  109364. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  109365. /**
  109366. * Serializes this material in a JSON representation
  109367. * @returns the serialized material object
  109368. */
  109369. serialize(): any;
  109370. /**
  109371. * Creates a shader material from parsed shader material data
  109372. * @param source defines the JSON represnetation of the material
  109373. * @param scene defines the hosting scene
  109374. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109375. * @returns a new material
  109376. */
  109377. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  109378. /**
  109379. * Creates a new ShaderMaterial from a snippet saved in a remote file
  109380. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  109381. * @param url defines the url to load from
  109382. * @param scene defines the hosting scene
  109383. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109384. * @returns a promise that will resolve to the new ShaderMaterial
  109385. */
  109386. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  109387. /**
  109388. * Creates a ShaderMaterial from a snippet saved by the Inspector
  109389. * @param snippetId defines the snippet to load
  109390. * @param scene defines the hosting scene
  109391. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109392. * @returns a promise that will resolve to the new ShaderMaterial
  109393. */
  109394. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  109395. }
  109396. }
  109397. declare module BABYLON {
  109398. /** @hidden */
  109399. export var colorPixelShader: {
  109400. name: string;
  109401. shader: string;
  109402. };
  109403. }
  109404. declare module BABYLON {
  109405. /** @hidden */
  109406. export var colorVertexShader: {
  109407. name: string;
  109408. shader: string;
  109409. };
  109410. }
  109411. declare module BABYLON {
  109412. /**
  109413. * Line mesh
  109414. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  109415. */
  109416. export class LinesMesh extends Mesh {
  109417. /**
  109418. * If vertex color should be applied to the mesh
  109419. */
  109420. readonly useVertexColor?: boolean | undefined;
  109421. /**
  109422. * If vertex alpha should be applied to the mesh
  109423. */
  109424. readonly useVertexAlpha?: boolean | undefined;
  109425. /**
  109426. * Color of the line (Default: White)
  109427. */
  109428. color: Color3;
  109429. /**
  109430. * Alpha of the line (Default: 1)
  109431. */
  109432. alpha: number;
  109433. /**
  109434. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  109435. * This margin is expressed in world space coordinates, so its value may vary.
  109436. * Default value is 0.1
  109437. */
  109438. intersectionThreshold: number;
  109439. private _colorShader;
  109440. private color4;
  109441. /**
  109442. * Creates a new LinesMesh
  109443. * @param name defines the name
  109444. * @param scene defines the hosting scene
  109445. * @param parent defines the parent mesh if any
  109446. * @param source defines the optional source LinesMesh used to clone data from
  109447. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  109448. * When false, achieved by calling a clone(), also passing False.
  109449. * This will make creation of children, recursive.
  109450. * @param useVertexColor defines if this LinesMesh supports vertex color
  109451. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  109452. */
  109453. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  109454. /**
  109455. * If vertex color should be applied to the mesh
  109456. */
  109457. useVertexColor?: boolean | undefined,
  109458. /**
  109459. * If vertex alpha should be applied to the mesh
  109460. */
  109461. useVertexAlpha?: boolean | undefined);
  109462. private _addClipPlaneDefine;
  109463. private _removeClipPlaneDefine;
  109464. isReady(): boolean;
  109465. /**
  109466. * Returns the string "LineMesh"
  109467. */
  109468. getClassName(): string;
  109469. /**
  109470. * @hidden
  109471. */
  109472. get material(): Material;
  109473. /**
  109474. * @hidden
  109475. */
  109476. set material(value: Material);
  109477. /**
  109478. * @hidden
  109479. */
  109480. get checkCollisions(): boolean;
  109481. /** @hidden */
  109482. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  109483. /** @hidden */
  109484. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  109485. /**
  109486. * Disposes of the line mesh
  109487. * @param doNotRecurse If children should be disposed
  109488. */
  109489. dispose(doNotRecurse?: boolean): void;
  109490. /**
  109491. * Returns a new LineMesh object cloned from the current one.
  109492. */
  109493. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  109494. /**
  109495. * Creates a new InstancedLinesMesh object from the mesh model.
  109496. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  109497. * @param name defines the name of the new instance
  109498. * @returns a new InstancedLinesMesh
  109499. */
  109500. createInstance(name: string): InstancedLinesMesh;
  109501. }
  109502. /**
  109503. * Creates an instance based on a source LinesMesh
  109504. */
  109505. export class InstancedLinesMesh extends InstancedMesh {
  109506. /**
  109507. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  109508. * This margin is expressed in world space coordinates, so its value may vary.
  109509. * Initilized with the intersectionThreshold value of the source LinesMesh
  109510. */
  109511. intersectionThreshold: number;
  109512. constructor(name: string, source: LinesMesh);
  109513. /**
  109514. * Returns the string "InstancedLinesMesh".
  109515. */
  109516. getClassName(): string;
  109517. }
  109518. }
  109519. declare module BABYLON {
  109520. /** @hidden */
  109521. export var linePixelShader: {
  109522. name: string;
  109523. shader: string;
  109524. };
  109525. }
  109526. declare module BABYLON {
  109527. /** @hidden */
  109528. export var lineVertexShader: {
  109529. name: string;
  109530. shader: string;
  109531. };
  109532. }
  109533. declare module BABYLON {
  109534. interface Scene {
  109535. /** @hidden */
  109536. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  109537. }
  109538. interface AbstractMesh {
  109539. /**
  109540. * Gets the edgesRenderer associated with the mesh
  109541. */
  109542. edgesRenderer: Nullable<EdgesRenderer>;
  109543. }
  109544. interface LinesMesh {
  109545. /**
  109546. * Enables the edge rendering mode on the mesh.
  109547. * This mode makes the mesh edges visible
  109548. * @param epsilon defines the maximal distance between two angles to detect a face
  109549. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  109550. * @returns the currentAbstractMesh
  109551. * @see https://www.babylonjs-playground.com/#19O9TU#0
  109552. */
  109553. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  109554. }
  109555. interface InstancedLinesMesh {
  109556. /**
  109557. * Enables the edge rendering mode on the mesh.
  109558. * This mode makes the mesh edges visible
  109559. * @param epsilon defines the maximal distance between two angles to detect a face
  109560. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  109561. * @returns the current InstancedLinesMesh
  109562. * @see https://www.babylonjs-playground.com/#19O9TU#0
  109563. */
  109564. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  109565. }
  109566. /**
  109567. * Defines the minimum contract an Edges renderer should follow.
  109568. */
  109569. export interface IEdgesRenderer extends IDisposable {
  109570. /**
  109571. * Gets or sets a boolean indicating if the edgesRenderer is active
  109572. */
  109573. isEnabled: boolean;
  109574. /**
  109575. * Renders the edges of the attached mesh,
  109576. */
  109577. render(): void;
  109578. /**
  109579. * Checks wether or not the edges renderer is ready to render.
  109580. * @return true if ready, otherwise false.
  109581. */
  109582. isReady(): boolean;
  109583. /**
  109584. * List of instances to render in case the source mesh has instances
  109585. */
  109586. customInstances: SmartArray<Matrix>;
  109587. }
  109588. /**
  109589. * Defines the additional options of the edges renderer
  109590. */
  109591. export interface IEdgesRendererOptions {
  109592. /**
  109593. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  109594. * If not defined, the default value is true
  109595. */
  109596. useAlternateEdgeFinder?: boolean;
  109597. /**
  109598. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  109599. * If not defined, the default value is true.
  109600. * 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)
  109601. * This option is used only if useAlternateEdgeFinder = true
  109602. */
  109603. useFastVertexMerger?: boolean;
  109604. /**
  109605. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  109606. * The default value is 1e-6
  109607. * This option is used only if useAlternateEdgeFinder = true
  109608. */
  109609. epsilonVertexMerge?: number;
  109610. /**
  109611. * 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
  109612. * 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.
  109613. * This option is used only if useAlternateEdgeFinder = true
  109614. */
  109615. applyTessellation?: boolean;
  109616. /**
  109617. * 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
  109618. * The default value is 1e-6
  109619. * This option is used only if useAlternateEdgeFinder = true
  109620. */
  109621. epsilonVertexAligned?: number;
  109622. }
  109623. /**
  109624. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  109625. */
  109626. export class EdgesRenderer implements IEdgesRenderer {
  109627. /**
  109628. * Define the size of the edges with an orthographic camera
  109629. */
  109630. edgesWidthScalerForOrthographic: number;
  109631. /**
  109632. * Define the size of the edges with a perspective camera
  109633. */
  109634. edgesWidthScalerForPerspective: number;
  109635. protected _source: AbstractMesh;
  109636. protected _linesPositions: number[];
  109637. protected _linesNormals: number[];
  109638. protected _linesIndices: number[];
  109639. protected _epsilon: number;
  109640. protected _indicesCount: number;
  109641. protected _lineShader: ShaderMaterial;
  109642. protected _ib: DataBuffer;
  109643. protected _buffers: {
  109644. [key: string]: Nullable<VertexBuffer>;
  109645. };
  109646. protected _buffersForInstances: {
  109647. [key: string]: Nullable<VertexBuffer>;
  109648. };
  109649. protected _checkVerticesInsteadOfIndices: boolean;
  109650. protected _options: Nullable<IEdgesRendererOptions>;
  109651. private _meshRebuildObserver;
  109652. private _meshDisposeObserver;
  109653. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  109654. isEnabled: boolean;
  109655. /** Gets the vertices generated by the edge renderer */
  109656. get linesPositions(): Immutable<Array<number>>;
  109657. /** Gets the normals generated by the edge renderer */
  109658. get linesNormals(): Immutable<Array<number>>;
  109659. /** Gets the indices generated by the edge renderer */
  109660. get linesIndices(): Immutable<Array<number>>;
  109661. /**
  109662. * List of instances to render in case the source mesh has instances
  109663. */
  109664. customInstances: SmartArray<Matrix>;
  109665. private static GetShader;
  109666. /**
  109667. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  109668. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  109669. * @param source Mesh used to create edges
  109670. * @param epsilon sum of angles in adjacency to check for edge
  109671. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  109672. * @param generateEdgesLines - should generate Lines or only prepare resources.
  109673. * @param options The options to apply when generating the edges
  109674. */
  109675. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  109676. protected _prepareRessources(): void;
  109677. /** @hidden */
  109678. _rebuild(): void;
  109679. /**
  109680. * Releases the required resources for the edges renderer
  109681. */
  109682. dispose(): void;
  109683. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  109684. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  109685. /**
  109686. * Checks if the pair of p0 and p1 is en edge
  109687. * @param faceIndex
  109688. * @param edge
  109689. * @param faceNormals
  109690. * @param p0
  109691. * @param p1
  109692. * @private
  109693. */
  109694. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  109695. /**
  109696. * push line into the position, normal and index buffer
  109697. * @protected
  109698. */
  109699. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  109700. /**
  109701. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  109702. */
  109703. private _tessellateTriangle;
  109704. private _generateEdgesLinesAlternate;
  109705. /**
  109706. * Generates lines edges from adjacencjes
  109707. * @private
  109708. */
  109709. _generateEdgesLines(): void;
  109710. /**
  109711. * Checks wether or not the edges renderer is ready to render.
  109712. * @return true if ready, otherwise false.
  109713. */
  109714. isReady(): boolean;
  109715. /**
  109716. * Renders the edges of the attached mesh,
  109717. */
  109718. render(): void;
  109719. }
  109720. /**
  109721. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  109722. */
  109723. export class LineEdgesRenderer extends EdgesRenderer {
  109724. /**
  109725. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  109726. * @param source LineMesh used to generate edges
  109727. * @param epsilon not important (specified angle for edge detection)
  109728. * @param checkVerticesInsteadOfIndices not important for LineMesh
  109729. */
  109730. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  109731. /**
  109732. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  109733. */
  109734. _generateEdgesLines(): void;
  109735. }
  109736. }
  109737. declare module BABYLON {
  109738. /**
  109739. * This represents the object necessary to create a rendering group.
  109740. * This is exclusively used and created by the rendering manager.
  109741. * To modify the behavior, you use the available helpers in your scene or meshes.
  109742. * @hidden
  109743. */
  109744. export class RenderingGroup {
  109745. index: number;
  109746. private static _zeroVector;
  109747. private _scene;
  109748. private _opaqueSubMeshes;
  109749. private _transparentSubMeshes;
  109750. private _alphaTestSubMeshes;
  109751. private _depthOnlySubMeshes;
  109752. private _particleSystems;
  109753. private _spriteManagers;
  109754. private _opaqueSortCompareFn;
  109755. private _alphaTestSortCompareFn;
  109756. private _transparentSortCompareFn;
  109757. private _renderOpaque;
  109758. private _renderAlphaTest;
  109759. private _renderTransparent;
  109760. /** @hidden */
  109761. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  109762. onBeforeTransparentRendering: () => void;
  109763. /**
  109764. * Set the opaque sort comparison function.
  109765. * If null the sub meshes will be render in the order they were created
  109766. */
  109767. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  109768. /**
  109769. * Set the alpha test sort comparison function.
  109770. * If null the sub meshes will be render in the order they were created
  109771. */
  109772. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  109773. /**
  109774. * Set the transparent sort comparison function.
  109775. * If null the sub meshes will be render in the order they were created
  109776. */
  109777. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  109778. /**
  109779. * Creates a new rendering group.
  109780. * @param index The rendering group index
  109781. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  109782. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  109783. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  109784. */
  109785. 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>);
  109786. /**
  109787. * Render all the sub meshes contained in the group.
  109788. * @param customRenderFunction Used to override the default render behaviour of the group.
  109789. * @returns true if rendered some submeshes.
  109790. */
  109791. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  109792. /**
  109793. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  109794. * @param subMeshes The submeshes to render
  109795. */
  109796. private renderOpaqueSorted;
  109797. /**
  109798. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  109799. * @param subMeshes The submeshes to render
  109800. */
  109801. private renderAlphaTestSorted;
  109802. /**
  109803. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  109804. * @param subMeshes The submeshes to render
  109805. */
  109806. private renderTransparentSorted;
  109807. /**
  109808. * Renders the submeshes in a specified order.
  109809. * @param subMeshes The submeshes to sort before render
  109810. * @param sortCompareFn The comparison function use to sort
  109811. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  109812. * @param transparent Specifies to activate blending if true
  109813. */
  109814. private static renderSorted;
  109815. /**
  109816. * Renders the submeshes in the order they were dispatched (no sort applied).
  109817. * @param subMeshes The submeshes to render
  109818. */
  109819. private static renderUnsorted;
  109820. /**
  109821. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  109822. * are rendered back to front if in the same alpha index.
  109823. *
  109824. * @param a The first submesh
  109825. * @param b The second submesh
  109826. * @returns The result of the comparison
  109827. */
  109828. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  109829. /**
  109830. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  109831. * are rendered back to front.
  109832. *
  109833. * @param a The first submesh
  109834. * @param b The second submesh
  109835. * @returns The result of the comparison
  109836. */
  109837. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  109838. /**
  109839. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  109840. * are rendered front to back (prevent overdraw).
  109841. *
  109842. * @param a The first submesh
  109843. * @param b The second submesh
  109844. * @returns The result of the comparison
  109845. */
  109846. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  109847. /**
  109848. * Resets the different lists of submeshes to prepare a new frame.
  109849. */
  109850. prepare(): void;
  109851. dispose(): void;
  109852. /**
  109853. * Inserts the submesh in its correct queue depending on its material.
  109854. * @param subMesh The submesh to dispatch
  109855. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  109856. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  109857. */
  109858. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  109859. dispatchSprites(spriteManager: ISpriteManager): void;
  109860. dispatchParticles(particleSystem: IParticleSystem): void;
  109861. private _renderParticles;
  109862. private _renderSprites;
  109863. }
  109864. }
  109865. declare module BABYLON {
  109866. /**
  109867. * Interface describing the different options available in the rendering manager
  109868. * regarding Auto Clear between groups.
  109869. */
  109870. export interface IRenderingManagerAutoClearSetup {
  109871. /**
  109872. * Defines whether or not autoclear is enable.
  109873. */
  109874. autoClear: boolean;
  109875. /**
  109876. * Defines whether or not to autoclear the depth buffer.
  109877. */
  109878. depth: boolean;
  109879. /**
  109880. * Defines whether or not to autoclear the stencil buffer.
  109881. */
  109882. stencil: boolean;
  109883. }
  109884. /**
  109885. * This class is used by the onRenderingGroupObservable
  109886. */
  109887. export class RenderingGroupInfo {
  109888. /**
  109889. * The Scene that being rendered
  109890. */
  109891. scene: Scene;
  109892. /**
  109893. * The camera currently used for the rendering pass
  109894. */
  109895. camera: Nullable<Camera>;
  109896. /**
  109897. * The ID of the renderingGroup being processed
  109898. */
  109899. renderingGroupId: number;
  109900. }
  109901. /**
  109902. * This is the manager responsible of all the rendering for meshes sprites and particles.
  109903. * It is enable to manage the different groups as well as the different necessary sort functions.
  109904. * This should not be used directly aside of the few static configurations
  109905. */
  109906. export class RenderingManager {
  109907. /**
  109908. * The max id used for rendering groups (not included)
  109909. */
  109910. static MAX_RENDERINGGROUPS: number;
  109911. /**
  109912. * The min id used for rendering groups (included)
  109913. */
  109914. static MIN_RENDERINGGROUPS: number;
  109915. /**
  109916. * Used to globally prevent autoclearing scenes.
  109917. */
  109918. static AUTOCLEAR: boolean;
  109919. /**
  109920. * @hidden
  109921. */
  109922. _useSceneAutoClearSetup: boolean;
  109923. private _scene;
  109924. private _renderingGroups;
  109925. private _depthStencilBufferAlreadyCleaned;
  109926. private _autoClearDepthStencil;
  109927. private _customOpaqueSortCompareFn;
  109928. private _customAlphaTestSortCompareFn;
  109929. private _customTransparentSortCompareFn;
  109930. private _renderingGroupInfo;
  109931. /**
  109932. * Instantiates a new rendering group for a particular scene
  109933. * @param scene Defines the scene the groups belongs to
  109934. */
  109935. constructor(scene: Scene);
  109936. private _clearDepthStencilBuffer;
  109937. /**
  109938. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  109939. * @hidden
  109940. */
  109941. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  109942. /**
  109943. * Resets the different information of the group to prepare a new frame
  109944. * @hidden
  109945. */
  109946. reset(): void;
  109947. /**
  109948. * Dispose and release the group and its associated resources.
  109949. * @hidden
  109950. */
  109951. dispose(): void;
  109952. /**
  109953. * Clear the info related to rendering groups preventing retention points during dispose.
  109954. */
  109955. freeRenderingGroups(): void;
  109956. private _prepareRenderingGroup;
  109957. /**
  109958. * Add a sprite manager to the rendering manager in order to render it this frame.
  109959. * @param spriteManager Define the sprite manager to render
  109960. */
  109961. dispatchSprites(spriteManager: ISpriteManager): void;
  109962. /**
  109963. * Add a particle system to the rendering manager in order to render it this frame.
  109964. * @param particleSystem Define the particle system to render
  109965. */
  109966. dispatchParticles(particleSystem: IParticleSystem): void;
  109967. /**
  109968. * Add a submesh to the manager in order to render it this frame
  109969. * @param subMesh The submesh to dispatch
  109970. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  109971. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  109972. */
  109973. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  109974. /**
  109975. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  109976. * This allowed control for front to back rendering or reversly depending of the special needs.
  109977. *
  109978. * @param renderingGroupId The rendering group id corresponding to its index
  109979. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  109980. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  109981. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  109982. */
  109983. 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;
  109984. /**
  109985. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  109986. *
  109987. * @param renderingGroupId The rendering group id corresponding to its index
  109988. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  109989. * @param depth Automatically clears depth between groups if true and autoClear is true.
  109990. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  109991. */
  109992. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  109993. /**
  109994. * Gets the current auto clear configuration for one rendering group of the rendering
  109995. * manager.
  109996. * @param index the rendering group index to get the information for
  109997. * @returns The auto clear setup for the requested rendering group
  109998. */
  109999. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110000. }
  110001. }
  110002. declare module BABYLON {
  110003. /**
  110004. * Defines the options associated with the creation of a custom shader for a shadow generator.
  110005. */
  110006. export interface ICustomShaderOptions {
  110007. /**
  110008. * Gets or sets the custom shader name to use
  110009. */
  110010. shaderName: string;
  110011. /**
  110012. * The list of attribute names used in the shader
  110013. */
  110014. attributes?: string[];
  110015. /**
  110016. * The list of unifrom names used in the shader
  110017. */
  110018. uniforms?: string[];
  110019. /**
  110020. * The list of sampler names used in the shader
  110021. */
  110022. samplers?: string[];
  110023. /**
  110024. * The list of defines used in the shader
  110025. */
  110026. defines?: string[];
  110027. }
  110028. /**
  110029. * Interface to implement to create a shadow generator compatible with BJS.
  110030. */
  110031. export interface IShadowGenerator {
  110032. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  110033. id: string;
  110034. /**
  110035. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  110036. * @returns The render target texture if present otherwise, null
  110037. */
  110038. getShadowMap(): Nullable<RenderTargetTexture>;
  110039. /**
  110040. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  110041. * @param subMesh The submesh we want to render in the shadow map
  110042. * @param useInstances Defines wether will draw in the map using instances
  110043. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  110044. * @returns true if ready otherwise, false
  110045. */
  110046. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  110047. /**
  110048. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  110049. * @param defines Defines of the material we want to update
  110050. * @param lightIndex Index of the light in the enabled light list of the material
  110051. */
  110052. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  110053. /**
  110054. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  110055. * defined in the generator but impacting the effect).
  110056. * It implies the unifroms available on the materials are the standard BJS ones.
  110057. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  110058. * @param effect The effect we are binfing the information for
  110059. */
  110060. bindShadowLight(lightIndex: string, effect: Effect): void;
  110061. /**
  110062. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  110063. * (eq to shadow prjection matrix * light transform matrix)
  110064. * @returns The transform matrix used to create the shadow map
  110065. */
  110066. getTransformMatrix(): Matrix;
  110067. /**
  110068. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  110069. * Cube and 2D textures for instance.
  110070. */
  110071. recreateShadowMap(): void;
  110072. /**
  110073. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  110074. * @param onCompiled Callback triggered at the and of the effects compilation
  110075. * @param options Sets of optional options forcing the compilation with different modes
  110076. */
  110077. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  110078. useInstances: boolean;
  110079. }>): void;
  110080. /**
  110081. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  110082. * @param options Sets of optional options forcing the compilation with different modes
  110083. * @returns A promise that resolves when the compilation completes
  110084. */
  110085. forceCompilationAsync(options?: Partial<{
  110086. useInstances: boolean;
  110087. }>): Promise<void>;
  110088. /**
  110089. * Serializes the shadow generator setup to a json object.
  110090. * @returns The serialized JSON object
  110091. */
  110092. serialize(): any;
  110093. /**
  110094. * Disposes the Shadow map and related Textures and effects.
  110095. */
  110096. dispose(): void;
  110097. }
  110098. /**
  110099. * Default implementation IShadowGenerator.
  110100. * This is the main object responsible of generating shadows in the framework.
  110101. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  110102. */
  110103. export class ShadowGenerator implements IShadowGenerator {
  110104. /**
  110105. * Name of the shadow generator class
  110106. */
  110107. static CLASSNAME: string;
  110108. /**
  110109. * Shadow generator mode None: no filtering applied.
  110110. */
  110111. static readonly FILTER_NONE: number;
  110112. /**
  110113. * Shadow generator mode ESM: Exponential Shadow Mapping.
  110114. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  110115. */
  110116. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  110117. /**
  110118. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  110119. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  110120. */
  110121. static readonly FILTER_POISSONSAMPLING: number;
  110122. /**
  110123. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  110124. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  110125. */
  110126. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  110127. /**
  110128. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  110129. * edge artifacts on steep falloff.
  110130. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  110131. */
  110132. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  110133. /**
  110134. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  110135. * edge artifacts on steep falloff.
  110136. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  110137. */
  110138. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  110139. /**
  110140. * Shadow generator mode PCF: Percentage Closer Filtering
  110141. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  110142. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  110143. */
  110144. static readonly FILTER_PCF: number;
  110145. /**
  110146. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  110147. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  110148. * Contact Hardening
  110149. */
  110150. static readonly FILTER_PCSS: number;
  110151. /**
  110152. * Reserved for PCF and PCSS
  110153. * Highest Quality.
  110154. *
  110155. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  110156. *
  110157. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  110158. */
  110159. static readonly QUALITY_HIGH: number;
  110160. /**
  110161. * Reserved for PCF and PCSS
  110162. * Good tradeoff for quality/perf cross devices
  110163. *
  110164. * Execute PCF on a 3*3 kernel.
  110165. *
  110166. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  110167. */
  110168. static readonly QUALITY_MEDIUM: number;
  110169. /**
  110170. * Reserved for PCF and PCSS
  110171. * The lowest quality but the fastest.
  110172. *
  110173. * Execute PCF on a 1*1 kernel.
  110174. *
  110175. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  110176. */
  110177. static readonly QUALITY_LOW: number;
  110178. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  110179. id: string;
  110180. /** Gets or sets the custom shader name to use */
  110181. customShaderOptions: ICustomShaderOptions;
  110182. /**
  110183. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  110184. */
  110185. onBeforeShadowMapRenderObservable: Observable<Effect>;
  110186. /**
  110187. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  110188. */
  110189. onAfterShadowMapRenderObservable: Observable<Effect>;
  110190. /**
  110191. * Observable triggered before a mesh is rendered in the shadow map.
  110192. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  110193. */
  110194. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  110195. /**
  110196. * Observable triggered after a mesh is rendered in the shadow map.
  110197. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  110198. */
  110199. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  110200. protected _bias: number;
  110201. /**
  110202. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  110203. */
  110204. get bias(): number;
  110205. /**
  110206. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  110207. */
  110208. set bias(bias: number);
  110209. protected _normalBias: number;
  110210. /**
  110211. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  110212. */
  110213. get normalBias(): number;
  110214. /**
  110215. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  110216. */
  110217. set normalBias(normalBias: number);
  110218. protected _blurBoxOffset: number;
  110219. /**
  110220. * Gets the blur box offset: offset applied during the blur pass.
  110221. * Only useful if useKernelBlur = false
  110222. */
  110223. get blurBoxOffset(): number;
  110224. /**
  110225. * Sets the blur box offset: offset applied during the blur pass.
  110226. * Only useful if useKernelBlur = false
  110227. */
  110228. set blurBoxOffset(value: number);
  110229. protected _blurScale: number;
  110230. /**
  110231. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  110232. * 2 means half of the size.
  110233. */
  110234. get blurScale(): number;
  110235. /**
  110236. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  110237. * 2 means half of the size.
  110238. */
  110239. set blurScale(value: number);
  110240. protected _blurKernel: number;
  110241. /**
  110242. * Gets the blur kernel: kernel size of the blur pass.
  110243. * Only useful if useKernelBlur = true
  110244. */
  110245. get blurKernel(): number;
  110246. /**
  110247. * Sets the blur kernel: kernel size of the blur pass.
  110248. * Only useful if useKernelBlur = true
  110249. */
  110250. set blurKernel(value: number);
  110251. protected _useKernelBlur: boolean;
  110252. /**
  110253. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  110254. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  110255. */
  110256. get useKernelBlur(): boolean;
  110257. /**
  110258. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  110259. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  110260. */
  110261. set useKernelBlur(value: boolean);
  110262. protected _depthScale: number;
  110263. /**
  110264. * Gets the depth scale used in ESM mode.
  110265. */
  110266. get depthScale(): number;
  110267. /**
  110268. * Sets the depth scale used in ESM mode.
  110269. * This can override the scale stored on the light.
  110270. */
  110271. set depthScale(value: number);
  110272. protected _validateFilter(filter: number): number;
  110273. protected _filter: number;
  110274. /**
  110275. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  110276. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  110277. */
  110278. get filter(): number;
  110279. /**
  110280. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  110281. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  110282. */
  110283. set filter(value: number);
  110284. /**
  110285. * Gets if the current filter is set to Poisson Sampling.
  110286. */
  110287. get usePoissonSampling(): boolean;
  110288. /**
  110289. * Sets the current filter to Poisson Sampling.
  110290. */
  110291. set usePoissonSampling(value: boolean);
  110292. /**
  110293. * Gets if the current filter is set to ESM.
  110294. */
  110295. get useExponentialShadowMap(): boolean;
  110296. /**
  110297. * Sets the current filter is to ESM.
  110298. */
  110299. set useExponentialShadowMap(value: boolean);
  110300. /**
  110301. * Gets if the current filter is set to filtered ESM.
  110302. */
  110303. get useBlurExponentialShadowMap(): boolean;
  110304. /**
  110305. * Gets if the current filter is set to filtered ESM.
  110306. */
  110307. set useBlurExponentialShadowMap(value: boolean);
  110308. /**
  110309. * Gets if the current filter is set to "close ESM" (using the inverse of the
  110310. * exponential to prevent steep falloff artifacts).
  110311. */
  110312. get useCloseExponentialShadowMap(): boolean;
  110313. /**
  110314. * Sets the current filter to "close ESM" (using the inverse of the
  110315. * exponential to prevent steep falloff artifacts).
  110316. */
  110317. set useCloseExponentialShadowMap(value: boolean);
  110318. /**
  110319. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  110320. * exponential to prevent steep falloff artifacts).
  110321. */
  110322. get useBlurCloseExponentialShadowMap(): boolean;
  110323. /**
  110324. * Sets the current filter to filtered "close ESM" (using the inverse of the
  110325. * exponential to prevent steep falloff artifacts).
  110326. */
  110327. set useBlurCloseExponentialShadowMap(value: boolean);
  110328. /**
  110329. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  110330. */
  110331. get usePercentageCloserFiltering(): boolean;
  110332. /**
  110333. * Sets the current filter to "PCF" (percentage closer filtering).
  110334. */
  110335. set usePercentageCloserFiltering(value: boolean);
  110336. protected _filteringQuality: number;
  110337. /**
  110338. * Gets the PCF or PCSS Quality.
  110339. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  110340. */
  110341. get filteringQuality(): number;
  110342. /**
  110343. * Sets the PCF or PCSS Quality.
  110344. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  110345. */
  110346. set filteringQuality(filteringQuality: number);
  110347. /**
  110348. * Gets if the current filter is set to "PCSS" (contact hardening).
  110349. */
  110350. get useContactHardeningShadow(): boolean;
  110351. /**
  110352. * Sets the current filter to "PCSS" (contact hardening).
  110353. */
  110354. set useContactHardeningShadow(value: boolean);
  110355. protected _contactHardeningLightSizeUVRatio: number;
  110356. /**
  110357. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  110358. * Using a ratio helps keeping shape stability independently of the map size.
  110359. *
  110360. * It does not account for the light projection as it was having too much
  110361. * instability during the light setup or during light position changes.
  110362. *
  110363. * Only valid if useContactHardeningShadow is true.
  110364. */
  110365. get contactHardeningLightSizeUVRatio(): number;
  110366. /**
  110367. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  110368. * Using a ratio helps keeping shape stability independently of the map size.
  110369. *
  110370. * It does not account for the light projection as it was having too much
  110371. * instability during the light setup or during light position changes.
  110372. *
  110373. * Only valid if useContactHardeningShadow is true.
  110374. */
  110375. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  110376. protected _darkness: number;
  110377. /** Gets or sets the actual darkness of a shadow */
  110378. get darkness(): number;
  110379. set darkness(value: number);
  110380. /**
  110381. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  110382. * 0 means strongest and 1 would means no shadow.
  110383. * @returns the darkness.
  110384. */
  110385. getDarkness(): number;
  110386. /**
  110387. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  110388. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  110389. * @returns the shadow generator allowing fluent coding.
  110390. */
  110391. setDarkness(darkness: number): ShadowGenerator;
  110392. protected _transparencyShadow: boolean;
  110393. /** Gets or sets the ability to have transparent shadow */
  110394. get transparencyShadow(): boolean;
  110395. set transparencyShadow(value: boolean);
  110396. /**
  110397. * Sets the ability to have transparent shadow (boolean).
  110398. * @param transparent True if transparent else False
  110399. * @returns the shadow generator allowing fluent coding
  110400. */
  110401. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  110402. /**
  110403. * Enables or disables shadows with varying strength based on the transparency
  110404. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  110405. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  110406. * mesh.visibility * alphaTexture.a
  110407. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  110408. */
  110409. enableSoftTransparentShadow: boolean;
  110410. protected _shadowMap: Nullable<RenderTargetTexture>;
  110411. protected _shadowMap2: Nullable<RenderTargetTexture>;
  110412. /**
  110413. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  110414. * @returns The render target texture if present otherwise, null
  110415. */
  110416. getShadowMap(): Nullable<RenderTargetTexture>;
  110417. /**
  110418. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  110419. * @returns The render target texture if the shadow map is present otherwise, null
  110420. */
  110421. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  110422. /**
  110423. * Gets the class name of that object
  110424. * @returns "ShadowGenerator"
  110425. */
  110426. getClassName(): string;
  110427. /**
  110428. * Helper function to add a mesh and its descendants to the list of shadow casters.
  110429. * @param mesh Mesh to add
  110430. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  110431. * @returns the Shadow Generator itself
  110432. */
  110433. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  110434. /**
  110435. * Helper function to remove a mesh and its descendants from the list of shadow casters
  110436. * @param mesh Mesh to remove
  110437. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  110438. * @returns the Shadow Generator itself
  110439. */
  110440. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  110441. /**
  110442. * Controls the extent to which the shadows fade out at the edge of the frustum
  110443. */
  110444. frustumEdgeFalloff: number;
  110445. protected _light: IShadowLight;
  110446. /**
  110447. * Returns the associated light object.
  110448. * @returns the light generating the shadow
  110449. */
  110450. getLight(): IShadowLight;
  110451. /**
  110452. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  110453. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  110454. * It might on the other hand introduce peter panning.
  110455. */
  110456. forceBackFacesOnly: boolean;
  110457. protected _scene: Scene;
  110458. protected _lightDirection: Vector3;
  110459. protected _effect: Effect;
  110460. protected _viewMatrix: Matrix;
  110461. protected _projectionMatrix: Matrix;
  110462. protected _transformMatrix: Matrix;
  110463. protected _cachedPosition: Vector3;
  110464. protected _cachedDirection: Vector3;
  110465. protected _cachedDefines: string;
  110466. protected _currentRenderID: number;
  110467. protected _boxBlurPostprocess: Nullable<PostProcess>;
  110468. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  110469. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  110470. protected _blurPostProcesses: PostProcess[];
  110471. protected _mapSize: number;
  110472. protected _currentFaceIndex: number;
  110473. protected _currentFaceIndexCache: number;
  110474. protected _textureType: number;
  110475. protected _defaultTextureMatrix: Matrix;
  110476. protected _storedUniqueId: Nullable<number>;
  110477. /** @hidden */
  110478. static _SceneComponentInitialization: (scene: Scene) => void;
  110479. /**
  110480. * Gets or sets the size of the texture what stores the shadows
  110481. */
  110482. get mapSize(): number;
  110483. set mapSize(size: number);
  110484. /**
  110485. * Creates a ShadowGenerator object.
  110486. * A ShadowGenerator is the required tool to use the shadows.
  110487. * Each light casting shadows needs to use its own ShadowGenerator.
  110488. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  110489. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  110490. * @param light The light object generating the shadows.
  110491. * @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.
  110492. */
  110493. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  110494. protected _initializeGenerator(): void;
  110495. protected _createTargetRenderTexture(): void;
  110496. protected _initializeShadowMap(): void;
  110497. protected _initializeBlurRTTAndPostProcesses(): void;
  110498. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  110499. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  110500. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  110501. protected _applyFilterValues(): void;
  110502. /**
  110503. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  110504. * @param onCompiled Callback triggered at the and of the effects compilation
  110505. * @param options Sets of optional options forcing the compilation with different modes
  110506. */
  110507. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  110508. useInstances: boolean;
  110509. }>): void;
  110510. /**
  110511. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  110512. * @param options Sets of optional options forcing the compilation with different modes
  110513. * @returns A promise that resolves when the compilation completes
  110514. */
  110515. forceCompilationAsync(options?: Partial<{
  110516. useInstances: boolean;
  110517. }>): Promise<void>;
  110518. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  110519. private _prepareShadowDefines;
  110520. /**
  110521. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  110522. * @param subMesh The submesh we want to render in the shadow map
  110523. * @param useInstances Defines wether will draw in the map using instances
  110524. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  110525. * @returns true if ready otherwise, false
  110526. */
  110527. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  110528. /**
  110529. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  110530. * @param defines Defines of the material we want to update
  110531. * @param lightIndex Index of the light in the enabled light list of the material
  110532. */
  110533. prepareDefines(defines: any, lightIndex: number): void;
  110534. /**
  110535. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  110536. * defined in the generator but impacting the effect).
  110537. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  110538. * @param effect The effect we are binfing the information for
  110539. */
  110540. bindShadowLight(lightIndex: string, effect: Effect): void;
  110541. /**
  110542. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  110543. * (eq to shadow prjection matrix * light transform matrix)
  110544. * @returns The transform matrix used to create the shadow map
  110545. */
  110546. getTransformMatrix(): Matrix;
  110547. /**
  110548. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  110549. * Cube and 2D textures for instance.
  110550. */
  110551. recreateShadowMap(): void;
  110552. protected _disposeBlurPostProcesses(): void;
  110553. protected _disposeRTTandPostProcesses(): void;
  110554. /**
  110555. * Disposes the ShadowGenerator.
  110556. * Returns nothing.
  110557. */
  110558. dispose(): void;
  110559. /**
  110560. * Serializes the shadow generator setup to a json object.
  110561. * @returns The serialized JSON object
  110562. */
  110563. serialize(): any;
  110564. /**
  110565. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  110566. * @param parsedShadowGenerator The JSON object to parse
  110567. * @param scene The scene to create the shadow map for
  110568. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  110569. * @returns The parsed shadow generator
  110570. */
  110571. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  110572. }
  110573. }
  110574. declare module BABYLON {
  110575. /**
  110576. * Options to be used when creating a shadow depth material
  110577. */
  110578. export interface IIOptionShadowDepthMaterial {
  110579. /** Variables in the vertex shader code that need to have their names remapped.
  110580. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  110581. * "var_name" should be either: worldPos or vNormalW
  110582. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  110583. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  110584. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  110585. */
  110586. remappedVariables?: string[];
  110587. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  110588. standalone?: boolean;
  110589. }
  110590. /**
  110591. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  110592. */
  110593. export class ShadowDepthWrapper {
  110594. private _scene;
  110595. private _options?;
  110596. private _baseMaterial;
  110597. private _onEffectCreatedObserver;
  110598. private _subMeshToEffect;
  110599. private _subMeshToDepthEffect;
  110600. private _meshes;
  110601. /** @hidden */
  110602. _matriceNames: any;
  110603. /** Gets the standalone status of the wrapper */
  110604. get standalone(): boolean;
  110605. /** Gets the base material the wrapper is built upon */
  110606. get baseMaterial(): Material;
  110607. /**
  110608. * Instantiate a new shadow depth wrapper.
  110609. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  110610. * generate the shadow depth map. For more information, please refer to the documentation:
  110611. * https://doc.babylonjs.com/babylon101/shadows
  110612. * @param baseMaterial Material to wrap
  110613. * @param scene Define the scene the material belongs to
  110614. * @param options Options used to create the wrapper
  110615. */
  110616. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  110617. /**
  110618. * Gets the effect to use to generate the depth map
  110619. * @param subMesh subMesh to get the effect for
  110620. * @param shadowGenerator shadow generator to get the effect for
  110621. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  110622. */
  110623. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  110624. /**
  110625. * Specifies that the submesh is ready to be used for depth rendering
  110626. * @param subMesh submesh to check
  110627. * @param defines the list of defines to take into account when checking the effect
  110628. * @param shadowGenerator combined with subMesh, it defines the effect to check
  110629. * @param useInstances specifies that instances should be used
  110630. * @returns a boolean indicating that the submesh is ready or not
  110631. */
  110632. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  110633. /**
  110634. * Disposes the resources
  110635. */
  110636. dispose(): void;
  110637. private _makeEffect;
  110638. }
  110639. }
  110640. declare module BABYLON {
  110641. /**
  110642. * Options for compiling materials.
  110643. */
  110644. export interface IMaterialCompilationOptions {
  110645. /**
  110646. * Defines whether clip planes are enabled.
  110647. */
  110648. clipPlane: boolean;
  110649. /**
  110650. * Defines whether instances are enabled.
  110651. */
  110652. useInstances: boolean;
  110653. }
  110654. /**
  110655. * Options passed when calling customShaderNameResolve
  110656. */
  110657. export interface ICustomShaderNameResolveOptions {
  110658. /**
  110659. * 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
  110660. */
  110661. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  110662. }
  110663. /**
  110664. * Base class for the main features of a material in Babylon.js
  110665. */
  110666. export class Material implements IAnimatable {
  110667. /**
  110668. * Returns the triangle fill mode
  110669. */
  110670. static readonly TriangleFillMode: number;
  110671. /**
  110672. * Returns the wireframe mode
  110673. */
  110674. static readonly WireFrameFillMode: number;
  110675. /**
  110676. * Returns the point fill mode
  110677. */
  110678. static readonly PointFillMode: number;
  110679. /**
  110680. * Returns the point list draw mode
  110681. */
  110682. static readonly PointListDrawMode: number;
  110683. /**
  110684. * Returns the line list draw mode
  110685. */
  110686. static readonly LineListDrawMode: number;
  110687. /**
  110688. * Returns the line loop draw mode
  110689. */
  110690. static readonly LineLoopDrawMode: number;
  110691. /**
  110692. * Returns the line strip draw mode
  110693. */
  110694. static readonly LineStripDrawMode: number;
  110695. /**
  110696. * Returns the triangle strip draw mode
  110697. */
  110698. static readonly TriangleStripDrawMode: number;
  110699. /**
  110700. * Returns the triangle fan draw mode
  110701. */
  110702. static readonly TriangleFanDrawMode: number;
  110703. /**
  110704. * Stores the clock-wise side orientation
  110705. */
  110706. static readonly ClockWiseSideOrientation: number;
  110707. /**
  110708. * Stores the counter clock-wise side orientation
  110709. */
  110710. static readonly CounterClockWiseSideOrientation: number;
  110711. /**
  110712. * The dirty texture flag value
  110713. */
  110714. static readonly TextureDirtyFlag: number;
  110715. /**
  110716. * The dirty light flag value
  110717. */
  110718. static readonly LightDirtyFlag: number;
  110719. /**
  110720. * The dirty fresnel flag value
  110721. */
  110722. static readonly FresnelDirtyFlag: number;
  110723. /**
  110724. * The dirty attribute flag value
  110725. */
  110726. static readonly AttributesDirtyFlag: number;
  110727. /**
  110728. * The dirty misc flag value
  110729. */
  110730. static readonly MiscDirtyFlag: number;
  110731. /**
  110732. * The dirty prepass flag value
  110733. */
  110734. static readonly PrePassDirtyFlag: number;
  110735. /**
  110736. * The all dirty flag value
  110737. */
  110738. static readonly AllDirtyFlag: number;
  110739. /**
  110740. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  110741. */
  110742. static readonly MATERIAL_OPAQUE: number;
  110743. /**
  110744. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  110745. */
  110746. static readonly MATERIAL_ALPHATEST: number;
  110747. /**
  110748. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110749. */
  110750. static readonly MATERIAL_ALPHABLEND: number;
  110751. /**
  110752. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110753. * They are also discarded below the alpha cutoff threshold to improve performances.
  110754. */
  110755. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  110756. /**
  110757. * The Whiteout method is used to blend normals.
  110758. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  110759. */
  110760. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  110761. /**
  110762. * The Reoriented Normal Mapping method is used to blend normals.
  110763. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  110764. */
  110765. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  110766. /**
  110767. * Custom callback helping to override the default shader used in the material.
  110768. */
  110769. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  110770. /**
  110771. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  110772. */
  110773. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  110774. /**
  110775. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  110776. * This means that the material can keep using a previous shader while a new one is being compiled.
  110777. * This is mostly used when shader parallel compilation is supported (true by default)
  110778. */
  110779. allowShaderHotSwapping: boolean;
  110780. /**
  110781. * The ID of the material
  110782. */
  110783. id: string;
  110784. /**
  110785. * Gets or sets the unique id of the material
  110786. */
  110787. uniqueId: number;
  110788. /**
  110789. * The name of the material
  110790. */
  110791. name: string;
  110792. /**
  110793. * Gets or sets user defined metadata
  110794. */
  110795. metadata: any;
  110796. /**
  110797. * For internal use only. Please do not use.
  110798. */
  110799. reservedDataStore: any;
  110800. /**
  110801. * Specifies if the ready state should be checked on each call
  110802. */
  110803. checkReadyOnEveryCall: boolean;
  110804. /**
  110805. * Specifies if the ready state should be checked once
  110806. */
  110807. checkReadyOnlyOnce: boolean;
  110808. /**
  110809. * The state of the material
  110810. */
  110811. state: string;
  110812. /**
  110813. * If the material can be rendered to several textures with MRT extension
  110814. */
  110815. get canRenderToMRT(): boolean;
  110816. /**
  110817. * The alpha value of the material
  110818. */
  110819. protected _alpha: number;
  110820. /**
  110821. * List of inspectable custom properties (used by the Inspector)
  110822. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110823. */
  110824. inspectableCustomProperties: IInspectable[];
  110825. /**
  110826. * Sets the alpha value of the material
  110827. */
  110828. set alpha(value: number);
  110829. /**
  110830. * Gets the alpha value of the material
  110831. */
  110832. get alpha(): number;
  110833. /**
  110834. * Specifies if back face culling is enabled
  110835. */
  110836. protected _backFaceCulling: boolean;
  110837. /**
  110838. * Sets the back-face culling state
  110839. */
  110840. set backFaceCulling(value: boolean);
  110841. /**
  110842. * Gets the back-face culling state
  110843. */
  110844. get backFaceCulling(): boolean;
  110845. /**
  110846. * Stores the value for side orientation
  110847. */
  110848. sideOrientation: number;
  110849. /**
  110850. * Callback triggered when the material is compiled
  110851. */
  110852. onCompiled: Nullable<(effect: Effect) => void>;
  110853. /**
  110854. * Callback triggered when an error occurs
  110855. */
  110856. onError: Nullable<(effect: Effect, errors: string) => void>;
  110857. /**
  110858. * Callback triggered to get the render target textures
  110859. */
  110860. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  110861. /**
  110862. * Gets a boolean indicating that current material needs to register RTT
  110863. */
  110864. get hasRenderTargetTextures(): boolean;
  110865. /**
  110866. * Specifies if the material should be serialized
  110867. */
  110868. doNotSerialize: boolean;
  110869. /**
  110870. * @hidden
  110871. */
  110872. _storeEffectOnSubMeshes: boolean;
  110873. /**
  110874. * Stores the animations for the material
  110875. */
  110876. animations: Nullable<Array<Animation>>;
  110877. /**
  110878. * An event triggered when the material is disposed
  110879. */
  110880. onDisposeObservable: Observable<Material>;
  110881. /**
  110882. * An observer which watches for dispose events
  110883. */
  110884. private _onDisposeObserver;
  110885. private _onUnBindObservable;
  110886. /**
  110887. * Called during a dispose event
  110888. */
  110889. set onDispose(callback: () => void);
  110890. private _onBindObservable;
  110891. /**
  110892. * An event triggered when the material is bound
  110893. */
  110894. get onBindObservable(): Observable<AbstractMesh>;
  110895. /**
  110896. * An observer which watches for bind events
  110897. */
  110898. private _onBindObserver;
  110899. /**
  110900. * Called during a bind event
  110901. */
  110902. set onBind(callback: (Mesh: AbstractMesh) => void);
  110903. /**
  110904. * An event triggered when the material is unbound
  110905. */
  110906. get onUnBindObservable(): Observable<Material>;
  110907. protected _onEffectCreatedObservable: Nullable<Observable<{
  110908. effect: Effect;
  110909. subMesh: Nullable<SubMesh>;
  110910. }>>;
  110911. /**
  110912. * An event triggered when the effect is (re)created
  110913. */
  110914. get onEffectCreatedObservable(): Observable<{
  110915. effect: Effect;
  110916. subMesh: Nullable<SubMesh>;
  110917. }>;
  110918. /**
  110919. * Stores the value of the alpha mode
  110920. */
  110921. private _alphaMode;
  110922. /**
  110923. * Sets the value of the alpha mode.
  110924. *
  110925. * | Value | Type | Description |
  110926. * | --- | --- | --- |
  110927. * | 0 | ALPHA_DISABLE | |
  110928. * | 1 | ALPHA_ADD | |
  110929. * | 2 | ALPHA_COMBINE | |
  110930. * | 3 | ALPHA_SUBTRACT | |
  110931. * | 4 | ALPHA_MULTIPLY | |
  110932. * | 5 | ALPHA_MAXIMIZED | |
  110933. * | 6 | ALPHA_ONEONE | |
  110934. * | 7 | ALPHA_PREMULTIPLIED | |
  110935. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  110936. * | 9 | ALPHA_INTERPOLATE | |
  110937. * | 10 | ALPHA_SCREENMODE | |
  110938. *
  110939. */
  110940. set alphaMode(value: number);
  110941. /**
  110942. * Gets the value of the alpha mode
  110943. */
  110944. get alphaMode(): number;
  110945. /**
  110946. * Stores the state of the need depth pre-pass value
  110947. */
  110948. private _needDepthPrePass;
  110949. /**
  110950. * Sets the need depth pre-pass value
  110951. */
  110952. set needDepthPrePass(value: boolean);
  110953. /**
  110954. * Gets the depth pre-pass value
  110955. */
  110956. get needDepthPrePass(): boolean;
  110957. /**
  110958. * Specifies if depth writing should be disabled
  110959. */
  110960. disableDepthWrite: boolean;
  110961. /**
  110962. * Specifies if color writing should be disabled
  110963. */
  110964. disableColorWrite: boolean;
  110965. /**
  110966. * Specifies if depth writing should be forced
  110967. */
  110968. forceDepthWrite: boolean;
  110969. /**
  110970. * Specifies the depth function that should be used. 0 means the default engine function
  110971. */
  110972. depthFunction: number;
  110973. /**
  110974. * Specifies if there should be a separate pass for culling
  110975. */
  110976. separateCullingPass: boolean;
  110977. /**
  110978. * Stores the state specifing if fog should be enabled
  110979. */
  110980. private _fogEnabled;
  110981. /**
  110982. * Sets the state for enabling fog
  110983. */
  110984. set fogEnabled(value: boolean);
  110985. /**
  110986. * Gets the value of the fog enabled state
  110987. */
  110988. get fogEnabled(): boolean;
  110989. /**
  110990. * Stores the size of points
  110991. */
  110992. pointSize: number;
  110993. /**
  110994. * Stores the z offset value
  110995. */
  110996. zOffset: number;
  110997. get wireframe(): boolean;
  110998. /**
  110999. * Sets the state of wireframe mode
  111000. */
  111001. set wireframe(value: boolean);
  111002. /**
  111003. * Gets the value specifying if point clouds are enabled
  111004. */
  111005. get pointsCloud(): boolean;
  111006. /**
  111007. * Sets the state of point cloud mode
  111008. */
  111009. set pointsCloud(value: boolean);
  111010. /**
  111011. * Gets the material fill mode
  111012. */
  111013. get fillMode(): number;
  111014. /**
  111015. * Sets the material fill mode
  111016. */
  111017. set fillMode(value: number);
  111018. /**
  111019. * @hidden
  111020. * Stores the effects for the material
  111021. */
  111022. _effect: Nullable<Effect>;
  111023. /**
  111024. * Specifies if uniform buffers should be used
  111025. */
  111026. private _useUBO;
  111027. /**
  111028. * Stores a reference to the scene
  111029. */
  111030. private _scene;
  111031. /**
  111032. * Stores the fill mode state
  111033. */
  111034. private _fillMode;
  111035. /**
  111036. * Specifies if the depth write state should be cached
  111037. */
  111038. private _cachedDepthWriteState;
  111039. /**
  111040. * Specifies if the color write state should be cached
  111041. */
  111042. private _cachedColorWriteState;
  111043. /**
  111044. * Specifies if the depth function state should be cached
  111045. */
  111046. private _cachedDepthFunctionState;
  111047. /**
  111048. * Stores the uniform buffer
  111049. */
  111050. protected _uniformBuffer: UniformBuffer;
  111051. /** @hidden */
  111052. _indexInSceneMaterialArray: number;
  111053. /** @hidden */
  111054. meshMap: Nullable<{
  111055. [id: string]: AbstractMesh | undefined;
  111056. }>;
  111057. /**
  111058. * Creates a material instance
  111059. * @param name defines the name of the material
  111060. * @param scene defines the scene to reference
  111061. * @param doNotAdd specifies if the material should be added to the scene
  111062. */
  111063. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  111064. /**
  111065. * Returns a string representation of the current material
  111066. * @param fullDetails defines a boolean indicating which levels of logging is desired
  111067. * @returns a string with material information
  111068. */
  111069. toString(fullDetails?: boolean): string;
  111070. /**
  111071. * Gets the class name of the material
  111072. * @returns a string with the class name of the material
  111073. */
  111074. getClassName(): string;
  111075. /**
  111076. * Specifies if updates for the material been locked
  111077. */
  111078. get isFrozen(): boolean;
  111079. /**
  111080. * Locks updates for the material
  111081. */
  111082. freeze(): void;
  111083. /**
  111084. * Unlocks updates for the material
  111085. */
  111086. unfreeze(): void;
  111087. /**
  111088. * Specifies if the material is ready to be used
  111089. * @param mesh defines the mesh to check
  111090. * @param useInstances specifies if instances should be used
  111091. * @returns a boolean indicating if the material is ready to be used
  111092. */
  111093. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  111094. /**
  111095. * Specifies that the submesh is ready to be used
  111096. * @param mesh defines the mesh to check
  111097. * @param subMesh defines which submesh to check
  111098. * @param useInstances specifies that instances should be used
  111099. * @returns a boolean indicating that the submesh is ready or not
  111100. */
  111101. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111102. /**
  111103. * Returns the material effect
  111104. * @returns the effect associated with the material
  111105. */
  111106. getEffect(): Nullable<Effect>;
  111107. /**
  111108. * Returns the current scene
  111109. * @returns a Scene
  111110. */
  111111. getScene(): Scene;
  111112. /**
  111113. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  111114. */
  111115. protected _forceAlphaTest: boolean;
  111116. /**
  111117. * The transparency mode of the material.
  111118. */
  111119. protected _transparencyMode: Nullable<number>;
  111120. /**
  111121. * Gets the current transparency mode.
  111122. */
  111123. get transparencyMode(): Nullable<number>;
  111124. /**
  111125. * Sets the transparency mode of the material.
  111126. *
  111127. * | Value | Type | Description |
  111128. * | ----- | ----------------------------------- | ----------- |
  111129. * | 0 | OPAQUE | |
  111130. * | 1 | ALPHATEST | |
  111131. * | 2 | ALPHABLEND | |
  111132. * | 3 | ALPHATESTANDBLEND | |
  111133. *
  111134. */
  111135. set transparencyMode(value: Nullable<number>);
  111136. /**
  111137. * Returns true if alpha blending should be disabled.
  111138. */
  111139. protected get _disableAlphaBlending(): boolean;
  111140. /**
  111141. * Specifies whether or not this material should be rendered in alpha blend mode.
  111142. * @returns a boolean specifying if alpha blending is needed
  111143. */
  111144. needAlphaBlending(): boolean;
  111145. /**
  111146. * Specifies if the mesh will require alpha blending
  111147. * @param mesh defines the mesh to check
  111148. * @returns a boolean specifying if alpha blending is needed for the mesh
  111149. */
  111150. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  111151. /**
  111152. * Specifies whether or not this material should be rendered in alpha test mode.
  111153. * @returns a boolean specifying if an alpha test is needed.
  111154. */
  111155. needAlphaTesting(): boolean;
  111156. /**
  111157. * Specifies if material alpha testing should be turned on for the mesh
  111158. * @param mesh defines the mesh to check
  111159. */
  111160. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  111161. /**
  111162. * Gets the texture used for the alpha test
  111163. * @returns the texture to use for alpha testing
  111164. */
  111165. getAlphaTestTexture(): Nullable<BaseTexture>;
  111166. /**
  111167. * Marks the material to indicate that it needs to be re-calculated
  111168. */
  111169. markDirty(): void;
  111170. /** @hidden */
  111171. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  111172. /**
  111173. * Binds the material to the mesh
  111174. * @param world defines the world transformation matrix
  111175. * @param mesh defines the mesh to bind the material to
  111176. */
  111177. bind(world: Matrix, mesh?: Mesh): void;
  111178. /**
  111179. * Binds the submesh to the material
  111180. * @param world defines the world transformation matrix
  111181. * @param mesh defines the mesh containing the submesh
  111182. * @param subMesh defines the submesh to bind the material to
  111183. */
  111184. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111185. /**
  111186. * Binds the world matrix to the material
  111187. * @param world defines the world transformation matrix
  111188. */
  111189. bindOnlyWorldMatrix(world: Matrix): void;
  111190. /**
  111191. * Binds the scene's uniform buffer to the effect.
  111192. * @param effect defines the effect to bind to the scene uniform buffer
  111193. * @param sceneUbo defines the uniform buffer storing scene data
  111194. */
  111195. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  111196. /**
  111197. * Binds the view matrix to the effect
  111198. * @param effect defines the effect to bind the view matrix to
  111199. */
  111200. bindView(effect: Effect): void;
  111201. /**
  111202. * Binds the view projection matrix to the effect
  111203. * @param effect defines the effect to bind the view projection matrix to
  111204. */
  111205. bindViewProjection(effect: Effect): void;
  111206. /**
  111207. * Processes to execute after binding the material to a mesh
  111208. * @param mesh defines the rendered mesh
  111209. */
  111210. protected _afterBind(mesh?: Mesh): void;
  111211. /**
  111212. * Unbinds the material from the mesh
  111213. */
  111214. unbind(): void;
  111215. /**
  111216. * Gets the active textures from the material
  111217. * @returns an array of textures
  111218. */
  111219. getActiveTextures(): BaseTexture[];
  111220. /**
  111221. * Specifies if the material uses a texture
  111222. * @param texture defines the texture to check against the material
  111223. * @returns a boolean specifying if the material uses the texture
  111224. */
  111225. hasTexture(texture: BaseTexture): boolean;
  111226. /**
  111227. * Makes a duplicate of the material, and gives it a new name
  111228. * @param name defines the new name for the duplicated material
  111229. * @returns the cloned material
  111230. */
  111231. clone(name: string): Nullable<Material>;
  111232. /**
  111233. * Gets the meshes bound to the material
  111234. * @returns an array of meshes bound to the material
  111235. */
  111236. getBindedMeshes(): AbstractMesh[];
  111237. /**
  111238. * Force shader compilation
  111239. * @param mesh defines the mesh associated with this material
  111240. * @param onCompiled defines a function to execute once the material is compiled
  111241. * @param options defines the options to configure the compilation
  111242. * @param onError defines a function to execute if the material fails compiling
  111243. */
  111244. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  111245. /**
  111246. * Force shader compilation
  111247. * @param mesh defines the mesh that will use this material
  111248. * @param options defines additional options for compiling the shaders
  111249. * @returns a promise that resolves when the compilation completes
  111250. */
  111251. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  111252. private static readonly _AllDirtyCallBack;
  111253. private static readonly _ImageProcessingDirtyCallBack;
  111254. private static readonly _TextureDirtyCallBack;
  111255. private static readonly _FresnelDirtyCallBack;
  111256. private static readonly _MiscDirtyCallBack;
  111257. private static readonly _PrePassDirtyCallBack;
  111258. private static readonly _LightsDirtyCallBack;
  111259. private static readonly _AttributeDirtyCallBack;
  111260. private static _FresnelAndMiscDirtyCallBack;
  111261. private static _TextureAndMiscDirtyCallBack;
  111262. private static readonly _DirtyCallbackArray;
  111263. private static readonly _RunDirtyCallBacks;
  111264. /**
  111265. * Marks a define in the material to indicate that it needs to be re-computed
  111266. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  111267. */
  111268. markAsDirty(flag: number): void;
  111269. /**
  111270. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  111271. * @param func defines a function which checks material defines against the submeshes
  111272. */
  111273. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  111274. /**
  111275. * Indicates that the scene should check if the rendering now needs a prepass
  111276. */
  111277. protected _markScenePrePassDirty(): void;
  111278. /**
  111279. * Indicates that we need to re-calculated for all submeshes
  111280. */
  111281. protected _markAllSubMeshesAsAllDirty(): void;
  111282. /**
  111283. * Indicates that image processing needs to be re-calculated for all submeshes
  111284. */
  111285. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  111286. /**
  111287. * Indicates that textures need to be re-calculated for all submeshes
  111288. */
  111289. protected _markAllSubMeshesAsTexturesDirty(): void;
  111290. /**
  111291. * Indicates that fresnel needs to be re-calculated for all submeshes
  111292. */
  111293. protected _markAllSubMeshesAsFresnelDirty(): void;
  111294. /**
  111295. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  111296. */
  111297. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  111298. /**
  111299. * Indicates that lights need to be re-calculated for all submeshes
  111300. */
  111301. protected _markAllSubMeshesAsLightsDirty(): void;
  111302. /**
  111303. * Indicates that attributes need to be re-calculated for all submeshes
  111304. */
  111305. protected _markAllSubMeshesAsAttributesDirty(): void;
  111306. /**
  111307. * Indicates that misc needs to be re-calculated for all submeshes
  111308. */
  111309. protected _markAllSubMeshesAsMiscDirty(): void;
  111310. /**
  111311. * Indicates that prepass needs to be re-calculated for all submeshes
  111312. */
  111313. protected _markAllSubMeshesAsPrePassDirty(): void;
  111314. /**
  111315. * Indicates that textures and misc need to be re-calculated for all submeshes
  111316. */
  111317. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  111318. /**
  111319. * Sets the required values to the prepass renderer.
  111320. * @param prePassRenderer defines the prepass renderer to setup.
  111321. * @returns true if the pre pass is needed.
  111322. */
  111323. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  111324. /**
  111325. * Disposes the material
  111326. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  111327. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  111328. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  111329. */
  111330. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  111331. /** @hidden */
  111332. private releaseVertexArrayObject;
  111333. /**
  111334. * Serializes this material
  111335. * @returns the serialized material object
  111336. */
  111337. serialize(): any;
  111338. /**
  111339. * Creates a material from parsed material data
  111340. * @param parsedMaterial defines parsed material data
  111341. * @param scene defines the hosting scene
  111342. * @param rootUrl defines the root URL to use to load textures
  111343. * @returns a new material
  111344. */
  111345. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  111346. }
  111347. }
  111348. declare module BABYLON {
  111349. /**
  111350. * A multi-material is used to apply different materials to different parts of the same object without the need of
  111351. * separate meshes. This can be use to improve performances.
  111352. * @see https://doc.babylonjs.com/how_to/multi_materials
  111353. */
  111354. export class MultiMaterial extends Material {
  111355. private _subMaterials;
  111356. /**
  111357. * Gets or Sets the list of Materials used within the multi material.
  111358. * They need to be ordered according to the submeshes order in the associated mesh
  111359. */
  111360. get subMaterials(): Nullable<Material>[];
  111361. set subMaterials(value: Nullable<Material>[]);
  111362. /**
  111363. * Function used to align with Node.getChildren()
  111364. * @returns the list of Materials used within the multi material
  111365. */
  111366. getChildren(): Nullable<Material>[];
  111367. /**
  111368. * Instantiates a new Multi Material
  111369. * A multi-material is used to apply different materials to different parts of the same object without the need of
  111370. * separate meshes. This can be use to improve performances.
  111371. * @see https://doc.babylonjs.com/how_to/multi_materials
  111372. * @param name Define the name in the scene
  111373. * @param scene Define the scene the material belongs to
  111374. */
  111375. constructor(name: string, scene: Scene);
  111376. private _hookArray;
  111377. /**
  111378. * Get one of the submaterial by its index in the submaterials array
  111379. * @param index The index to look the sub material at
  111380. * @returns The Material if the index has been defined
  111381. */
  111382. getSubMaterial(index: number): Nullable<Material>;
  111383. /**
  111384. * Get the list of active textures for the whole sub materials list.
  111385. * @returns All the textures that will be used during the rendering
  111386. */
  111387. getActiveTextures(): BaseTexture[];
  111388. /**
  111389. * Gets the current class name of the material e.g. "MultiMaterial"
  111390. * Mainly use in serialization.
  111391. * @returns the class name
  111392. */
  111393. getClassName(): string;
  111394. /**
  111395. * Checks if the material is ready to render the requested sub mesh
  111396. * @param mesh Define the mesh the submesh belongs to
  111397. * @param subMesh Define the sub mesh to look readyness for
  111398. * @param useInstances Define whether or not the material is used with instances
  111399. * @returns true if ready, otherwise false
  111400. */
  111401. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111402. /**
  111403. * Clones the current material and its related sub materials
  111404. * @param name Define the name of the newly cloned material
  111405. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  111406. * @returns the cloned material
  111407. */
  111408. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  111409. /**
  111410. * Serializes the materials into a JSON representation.
  111411. * @returns the JSON representation
  111412. */
  111413. serialize(): any;
  111414. /**
  111415. * Dispose the material and release its associated resources
  111416. * @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)
  111417. * @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)
  111418. * @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)
  111419. */
  111420. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  111421. /**
  111422. * Creates a MultiMaterial from parsed MultiMaterial data.
  111423. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  111424. * @param scene defines the hosting scene
  111425. * @returns a new MultiMaterial
  111426. */
  111427. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  111428. }
  111429. }
  111430. declare module BABYLON {
  111431. /**
  111432. * Defines a subdivision inside a mesh
  111433. */
  111434. export class SubMesh implements ICullable {
  111435. /** the material index to use */
  111436. materialIndex: number;
  111437. /** vertex index start */
  111438. verticesStart: number;
  111439. /** vertices count */
  111440. verticesCount: number;
  111441. /** index start */
  111442. indexStart: number;
  111443. /** indices count */
  111444. indexCount: number;
  111445. /** @hidden */
  111446. _materialDefines: Nullable<MaterialDefines>;
  111447. /** @hidden */
  111448. _materialEffect: Nullable<Effect>;
  111449. /** @hidden */
  111450. _effectOverride: Nullable<Effect>;
  111451. /**
  111452. * Gets material defines used by the effect associated to the sub mesh
  111453. */
  111454. get materialDefines(): Nullable<MaterialDefines>;
  111455. /**
  111456. * Sets material defines used by the effect associated to the sub mesh
  111457. */
  111458. set materialDefines(defines: Nullable<MaterialDefines>);
  111459. /**
  111460. * Gets associated effect
  111461. */
  111462. get effect(): Nullable<Effect>;
  111463. /**
  111464. * Sets associated effect (effect used to render this submesh)
  111465. * @param effect defines the effect to associate with
  111466. * @param defines defines the set of defines used to compile this effect
  111467. */
  111468. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  111469. /** @hidden */
  111470. _linesIndexCount: number;
  111471. private _mesh;
  111472. private _renderingMesh;
  111473. private _boundingInfo;
  111474. private _linesIndexBuffer;
  111475. /** @hidden */
  111476. _lastColliderWorldVertices: Nullable<Vector3[]>;
  111477. /** @hidden */
  111478. _trianglePlanes: Plane[];
  111479. /** @hidden */
  111480. _lastColliderTransformMatrix: Nullable<Matrix>;
  111481. /** @hidden */
  111482. _renderId: number;
  111483. /** @hidden */
  111484. _alphaIndex: number;
  111485. /** @hidden */
  111486. _distanceToCamera: number;
  111487. /** @hidden */
  111488. _id: number;
  111489. private _currentMaterial;
  111490. /**
  111491. * Add a new submesh to a mesh
  111492. * @param materialIndex defines the material index to use
  111493. * @param verticesStart defines vertex index start
  111494. * @param verticesCount defines vertices count
  111495. * @param indexStart defines index start
  111496. * @param indexCount defines indices count
  111497. * @param mesh defines the parent mesh
  111498. * @param renderingMesh defines an optional rendering mesh
  111499. * @param createBoundingBox defines if bounding box should be created for this submesh
  111500. * @returns the new submesh
  111501. */
  111502. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  111503. /**
  111504. * Creates a new submesh
  111505. * @param materialIndex defines the material index to use
  111506. * @param verticesStart defines vertex index start
  111507. * @param verticesCount defines vertices count
  111508. * @param indexStart defines index start
  111509. * @param indexCount defines indices count
  111510. * @param mesh defines the parent mesh
  111511. * @param renderingMesh defines an optional rendering mesh
  111512. * @param createBoundingBox defines if bounding box should be created for this submesh
  111513. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  111514. */
  111515. constructor(
  111516. /** the material index to use */
  111517. materialIndex: number,
  111518. /** vertex index start */
  111519. verticesStart: number,
  111520. /** vertices count */
  111521. verticesCount: number,
  111522. /** index start */
  111523. indexStart: number,
  111524. /** indices count */
  111525. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  111526. /**
  111527. * Returns true if this submesh covers the entire parent mesh
  111528. * @ignorenaming
  111529. */
  111530. get IsGlobal(): boolean;
  111531. /**
  111532. * Returns the submesh BoudingInfo object
  111533. * @returns current bounding info (or mesh's one if the submesh is global)
  111534. */
  111535. getBoundingInfo(): BoundingInfo;
  111536. /**
  111537. * Sets the submesh BoundingInfo
  111538. * @param boundingInfo defines the new bounding info to use
  111539. * @returns the SubMesh
  111540. */
  111541. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  111542. /**
  111543. * Returns the mesh of the current submesh
  111544. * @return the parent mesh
  111545. */
  111546. getMesh(): AbstractMesh;
  111547. /**
  111548. * Returns the rendering mesh of the submesh
  111549. * @returns the rendering mesh (could be different from parent mesh)
  111550. */
  111551. getRenderingMesh(): Mesh;
  111552. /**
  111553. * Returns the replacement mesh of the submesh
  111554. * @returns the replacement mesh (could be different from parent mesh)
  111555. */
  111556. getReplacementMesh(): Nullable<AbstractMesh>;
  111557. /**
  111558. * Returns the effective mesh of the submesh
  111559. * @returns the effective mesh (could be different from parent mesh)
  111560. */
  111561. getEffectiveMesh(): AbstractMesh;
  111562. /**
  111563. * Returns the submesh material
  111564. * @returns null or the current material
  111565. */
  111566. getMaterial(): Nullable<Material>;
  111567. private _IsMultiMaterial;
  111568. /**
  111569. * Sets a new updated BoundingInfo object to the submesh
  111570. * @param data defines an optional position array to use to determine the bounding info
  111571. * @returns the SubMesh
  111572. */
  111573. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  111574. /** @hidden */
  111575. _checkCollision(collider: Collider): boolean;
  111576. /**
  111577. * Updates the submesh BoundingInfo
  111578. * @param world defines the world matrix to use to update the bounding info
  111579. * @returns the submesh
  111580. */
  111581. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  111582. /**
  111583. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  111584. * @param frustumPlanes defines the frustum planes
  111585. * @returns true if the submesh is intersecting with the frustum
  111586. */
  111587. isInFrustum(frustumPlanes: Plane[]): boolean;
  111588. /**
  111589. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  111590. * @param frustumPlanes defines the frustum planes
  111591. * @returns true if the submesh is inside the frustum
  111592. */
  111593. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  111594. /**
  111595. * Renders the submesh
  111596. * @param enableAlphaMode defines if alpha needs to be used
  111597. * @returns the submesh
  111598. */
  111599. render(enableAlphaMode: boolean): SubMesh;
  111600. /**
  111601. * @hidden
  111602. */
  111603. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  111604. /**
  111605. * Checks if the submesh intersects with a ray
  111606. * @param ray defines the ray to test
  111607. * @returns true is the passed ray intersects the submesh bounding box
  111608. */
  111609. canIntersects(ray: Ray): boolean;
  111610. /**
  111611. * Intersects current submesh with a ray
  111612. * @param ray defines the ray to test
  111613. * @param positions defines mesh's positions array
  111614. * @param indices defines mesh's indices array
  111615. * @param fastCheck defines if the first intersection will be used (and not the closest)
  111616. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111617. * @returns intersection info or null if no intersection
  111618. */
  111619. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  111620. /** @hidden */
  111621. private _intersectLines;
  111622. /** @hidden */
  111623. private _intersectUnIndexedLines;
  111624. /** @hidden */
  111625. private _intersectTriangles;
  111626. /** @hidden */
  111627. private _intersectUnIndexedTriangles;
  111628. /** @hidden */
  111629. _rebuild(): void;
  111630. /**
  111631. * Creates a new submesh from the passed mesh
  111632. * @param newMesh defines the new hosting mesh
  111633. * @param newRenderingMesh defines an optional rendering mesh
  111634. * @returns the new submesh
  111635. */
  111636. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  111637. /**
  111638. * Release associated resources
  111639. */
  111640. dispose(): void;
  111641. /**
  111642. * Gets the class name
  111643. * @returns the string "SubMesh".
  111644. */
  111645. getClassName(): string;
  111646. /**
  111647. * Creates a new submesh from indices data
  111648. * @param materialIndex the index of the main mesh material
  111649. * @param startIndex the index where to start the copy in the mesh indices array
  111650. * @param indexCount the number of indices to copy then from the startIndex
  111651. * @param mesh the main mesh to create the submesh from
  111652. * @param renderingMesh the optional rendering mesh
  111653. * @returns a new submesh
  111654. */
  111655. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  111656. }
  111657. }
  111658. declare module BABYLON {
  111659. /**
  111660. * Class used to represent data loading progression
  111661. */
  111662. export class SceneLoaderFlags {
  111663. private static _ForceFullSceneLoadingForIncremental;
  111664. private static _ShowLoadingScreen;
  111665. private static _CleanBoneMatrixWeights;
  111666. private static _loggingLevel;
  111667. /**
  111668. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  111669. */
  111670. static get ForceFullSceneLoadingForIncremental(): boolean;
  111671. static set ForceFullSceneLoadingForIncremental(value: boolean);
  111672. /**
  111673. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  111674. */
  111675. static get ShowLoadingScreen(): boolean;
  111676. static set ShowLoadingScreen(value: boolean);
  111677. /**
  111678. * Defines the current logging level (while loading the scene)
  111679. * @ignorenaming
  111680. */
  111681. static get loggingLevel(): number;
  111682. static set loggingLevel(value: number);
  111683. /**
  111684. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  111685. */
  111686. static get CleanBoneMatrixWeights(): boolean;
  111687. static set CleanBoneMatrixWeights(value: boolean);
  111688. }
  111689. }
  111690. declare module BABYLON {
  111691. /**
  111692. * Class used to store geometry data (vertex buffers + index buffer)
  111693. */
  111694. export class Geometry implements IGetSetVerticesData {
  111695. /**
  111696. * Gets or sets the ID of the geometry
  111697. */
  111698. id: string;
  111699. /**
  111700. * Gets or sets the unique ID of the geometry
  111701. */
  111702. uniqueId: number;
  111703. /**
  111704. * Gets the delay loading state of the geometry (none by default which means not delayed)
  111705. */
  111706. delayLoadState: number;
  111707. /**
  111708. * Gets the file containing the data to load when running in delay load state
  111709. */
  111710. delayLoadingFile: Nullable<string>;
  111711. /**
  111712. * Callback called when the geometry is updated
  111713. */
  111714. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  111715. private _scene;
  111716. private _engine;
  111717. private _meshes;
  111718. private _totalVertices;
  111719. /** @hidden */
  111720. _indices: IndicesArray;
  111721. /** @hidden */
  111722. _vertexBuffers: {
  111723. [key: string]: VertexBuffer;
  111724. };
  111725. private _isDisposed;
  111726. private _extend;
  111727. private _boundingBias;
  111728. /** @hidden */
  111729. _delayInfo: Array<string>;
  111730. private _indexBuffer;
  111731. private _indexBufferIsUpdatable;
  111732. /** @hidden */
  111733. _boundingInfo: Nullable<BoundingInfo>;
  111734. /** @hidden */
  111735. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  111736. /** @hidden */
  111737. _softwareSkinningFrameId: number;
  111738. private _vertexArrayObjects;
  111739. private _updatable;
  111740. /** @hidden */
  111741. _positions: Nullable<Vector3[]>;
  111742. private _positionsCache;
  111743. /**
  111744. * 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
  111745. */
  111746. get boundingBias(): Vector2;
  111747. /**
  111748. * 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
  111749. */
  111750. set boundingBias(value: Vector2);
  111751. /**
  111752. * Static function used to attach a new empty geometry to a mesh
  111753. * @param mesh defines the mesh to attach the geometry to
  111754. * @returns the new Geometry
  111755. */
  111756. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  111757. /** Get the list of meshes using this geometry */
  111758. get meshes(): Mesh[];
  111759. /**
  111760. * 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
  111761. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  111762. */
  111763. useBoundingInfoFromGeometry: boolean;
  111764. /**
  111765. * Creates a new geometry
  111766. * @param id defines the unique ID
  111767. * @param scene defines the hosting scene
  111768. * @param vertexData defines the VertexData used to get geometry data
  111769. * @param updatable defines if geometry must be updatable (false by default)
  111770. * @param mesh defines the mesh that will be associated with the geometry
  111771. */
  111772. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  111773. /**
  111774. * Gets the current extend of the geometry
  111775. */
  111776. get extend(): {
  111777. minimum: Vector3;
  111778. maximum: Vector3;
  111779. };
  111780. /**
  111781. * Gets the hosting scene
  111782. * @returns the hosting Scene
  111783. */
  111784. getScene(): Scene;
  111785. /**
  111786. * Gets the hosting engine
  111787. * @returns the hosting Engine
  111788. */
  111789. getEngine(): Engine;
  111790. /**
  111791. * Defines if the geometry is ready to use
  111792. * @returns true if the geometry is ready to be used
  111793. */
  111794. isReady(): boolean;
  111795. /**
  111796. * Gets a value indicating that the geometry should not be serialized
  111797. */
  111798. get doNotSerialize(): boolean;
  111799. /** @hidden */
  111800. _rebuild(): void;
  111801. /**
  111802. * Affects all geometry data in one call
  111803. * @param vertexData defines the geometry data
  111804. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  111805. */
  111806. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  111807. /**
  111808. * Set specific vertex data
  111809. * @param kind defines the data kind (Position, normal, etc...)
  111810. * @param data defines the vertex data to use
  111811. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  111812. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  111813. */
  111814. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  111815. /**
  111816. * Removes a specific vertex data
  111817. * @param kind defines the data kind (Position, normal, etc...)
  111818. */
  111819. removeVerticesData(kind: string): void;
  111820. /**
  111821. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  111822. * @param buffer defines the vertex buffer to use
  111823. * @param totalVertices defines the total number of vertices for position kind (could be null)
  111824. */
  111825. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  111826. /**
  111827. * Update a specific vertex buffer
  111828. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  111829. * It will do nothing if the buffer is not updatable
  111830. * @param kind defines the data kind (Position, normal, etc...)
  111831. * @param data defines the data to use
  111832. * @param offset defines the offset in the target buffer where to store the data
  111833. * @param useBytes set to true if the offset is in bytes
  111834. */
  111835. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  111836. /**
  111837. * Update a specific vertex buffer
  111838. * This function will create a new buffer if the current one is not updatable
  111839. * @param kind defines the data kind (Position, normal, etc...)
  111840. * @param data defines the data to use
  111841. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  111842. */
  111843. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  111844. private _updateBoundingInfo;
  111845. /** @hidden */
  111846. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  111847. /**
  111848. * Gets total number of vertices
  111849. * @returns the total number of vertices
  111850. */
  111851. getTotalVertices(): number;
  111852. /**
  111853. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  111854. * @param kind defines the data kind (Position, normal, etc...)
  111855. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  111856. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111857. * @returns a float array containing vertex data
  111858. */
  111859. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  111860. /**
  111861. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  111862. * @param kind defines the data kind (Position, normal, etc...)
  111863. * @returns true if the vertex buffer with the specified kind is updatable
  111864. */
  111865. isVertexBufferUpdatable(kind: string): boolean;
  111866. /**
  111867. * Gets a specific vertex buffer
  111868. * @param kind defines the data kind (Position, normal, etc...)
  111869. * @returns a VertexBuffer
  111870. */
  111871. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  111872. /**
  111873. * Returns all vertex buffers
  111874. * @return an object holding all vertex buffers indexed by kind
  111875. */
  111876. getVertexBuffers(): Nullable<{
  111877. [key: string]: VertexBuffer;
  111878. }>;
  111879. /**
  111880. * Gets a boolean indicating if specific vertex buffer is present
  111881. * @param kind defines the data kind (Position, normal, etc...)
  111882. * @returns true if data is present
  111883. */
  111884. isVerticesDataPresent(kind: string): boolean;
  111885. /**
  111886. * Gets a list of all attached data kinds (Position, normal, etc...)
  111887. * @returns a list of string containing all kinds
  111888. */
  111889. getVerticesDataKinds(): string[];
  111890. /**
  111891. * Update index buffer
  111892. * @param indices defines the indices to store in the index buffer
  111893. * @param offset defines the offset in the target buffer where to store the data
  111894. * @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)
  111895. */
  111896. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  111897. /**
  111898. * Creates a new index buffer
  111899. * @param indices defines the indices to store in the index buffer
  111900. * @param totalVertices defines the total number of vertices (could be null)
  111901. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  111902. */
  111903. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  111904. /**
  111905. * Return the total number of indices
  111906. * @returns the total number of indices
  111907. */
  111908. getTotalIndices(): number;
  111909. /**
  111910. * Gets the index buffer array
  111911. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  111912. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111913. * @returns the index buffer array
  111914. */
  111915. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  111916. /**
  111917. * Gets the index buffer
  111918. * @return the index buffer
  111919. */
  111920. getIndexBuffer(): Nullable<DataBuffer>;
  111921. /** @hidden */
  111922. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  111923. /**
  111924. * Release the associated resources for a specific mesh
  111925. * @param mesh defines the source mesh
  111926. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  111927. */
  111928. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  111929. /**
  111930. * Apply current geometry to a given mesh
  111931. * @param mesh defines the mesh to apply geometry to
  111932. */
  111933. applyToMesh(mesh: Mesh): void;
  111934. private _updateExtend;
  111935. private _applyToMesh;
  111936. private notifyUpdate;
  111937. /**
  111938. * Load the geometry if it was flagged as delay loaded
  111939. * @param scene defines the hosting scene
  111940. * @param onLoaded defines a callback called when the geometry is loaded
  111941. */
  111942. load(scene: Scene, onLoaded?: () => void): void;
  111943. private _queueLoad;
  111944. /**
  111945. * Invert the geometry to move from a right handed system to a left handed one.
  111946. */
  111947. toLeftHanded(): void;
  111948. /** @hidden */
  111949. _resetPointsArrayCache(): void;
  111950. /** @hidden */
  111951. _generatePointsArray(): boolean;
  111952. /**
  111953. * Gets a value indicating if the geometry is disposed
  111954. * @returns true if the geometry was disposed
  111955. */
  111956. isDisposed(): boolean;
  111957. private _disposeVertexArrayObjects;
  111958. /**
  111959. * Free all associated resources
  111960. */
  111961. dispose(): void;
  111962. /**
  111963. * Clone the current geometry into a new geometry
  111964. * @param id defines the unique ID of the new geometry
  111965. * @returns a new geometry object
  111966. */
  111967. copy(id: string): Geometry;
  111968. /**
  111969. * Serialize the current geometry info (and not the vertices data) into a JSON object
  111970. * @return a JSON representation of the current geometry data (without the vertices data)
  111971. */
  111972. serialize(): any;
  111973. private toNumberArray;
  111974. /**
  111975. * Serialize all vertices data into a JSON oject
  111976. * @returns a JSON representation of the current geometry data
  111977. */
  111978. serializeVerticeData(): any;
  111979. /**
  111980. * Extracts a clone of a mesh geometry
  111981. * @param mesh defines the source mesh
  111982. * @param id defines the unique ID of the new geometry object
  111983. * @returns the new geometry object
  111984. */
  111985. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  111986. /**
  111987. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  111988. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  111989. * Be aware Math.random() could cause collisions, but:
  111990. * "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"
  111991. * @returns a string containing a new GUID
  111992. */
  111993. static RandomId(): string;
  111994. /** @hidden */
  111995. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  111996. private static _CleanMatricesWeights;
  111997. /**
  111998. * Create a new geometry from persisted data (Using .babylon file format)
  111999. * @param parsedVertexData defines the persisted data
  112000. * @param scene defines the hosting scene
  112001. * @param rootUrl defines the root url to use to load assets (like delayed data)
  112002. * @returns the new geometry object
  112003. */
  112004. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  112005. }
  112006. }
  112007. declare module BABYLON {
  112008. /**
  112009. * Defines a target to use with MorphTargetManager
  112010. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  112011. */
  112012. export class MorphTarget implements IAnimatable {
  112013. /** defines the name of the target */
  112014. name: string;
  112015. /**
  112016. * Gets or sets the list of animations
  112017. */
  112018. animations: Animation[];
  112019. private _scene;
  112020. private _positions;
  112021. private _normals;
  112022. private _tangents;
  112023. private _uvs;
  112024. private _influence;
  112025. private _uniqueId;
  112026. /**
  112027. * Observable raised when the influence changes
  112028. */
  112029. onInfluenceChanged: Observable<boolean>;
  112030. /** @hidden */
  112031. _onDataLayoutChanged: Observable<void>;
  112032. /**
  112033. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  112034. */
  112035. get influence(): number;
  112036. set influence(influence: number);
  112037. /**
  112038. * Gets or sets the id of the morph Target
  112039. */
  112040. id: string;
  112041. private _animationPropertiesOverride;
  112042. /**
  112043. * Gets or sets the animation properties override
  112044. */
  112045. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  112046. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  112047. /**
  112048. * Creates a new MorphTarget
  112049. * @param name defines the name of the target
  112050. * @param influence defines the influence to use
  112051. * @param scene defines the scene the morphtarget belongs to
  112052. */
  112053. constructor(
  112054. /** defines the name of the target */
  112055. name: string, influence?: number, scene?: Nullable<Scene>);
  112056. /**
  112057. * Gets the unique ID of this manager
  112058. */
  112059. get uniqueId(): number;
  112060. /**
  112061. * Gets a boolean defining if the target contains position data
  112062. */
  112063. get hasPositions(): boolean;
  112064. /**
  112065. * Gets a boolean defining if the target contains normal data
  112066. */
  112067. get hasNormals(): boolean;
  112068. /**
  112069. * Gets a boolean defining if the target contains tangent data
  112070. */
  112071. get hasTangents(): boolean;
  112072. /**
  112073. * Gets a boolean defining if the target contains texture coordinates data
  112074. */
  112075. get hasUVs(): boolean;
  112076. /**
  112077. * Affects position data to this target
  112078. * @param data defines the position data to use
  112079. */
  112080. setPositions(data: Nullable<FloatArray>): void;
  112081. /**
  112082. * Gets the position data stored in this target
  112083. * @returns a FloatArray containing the position data (or null if not present)
  112084. */
  112085. getPositions(): Nullable<FloatArray>;
  112086. /**
  112087. * Affects normal data to this target
  112088. * @param data defines the normal data to use
  112089. */
  112090. setNormals(data: Nullable<FloatArray>): void;
  112091. /**
  112092. * Gets the normal data stored in this target
  112093. * @returns a FloatArray containing the normal data (or null if not present)
  112094. */
  112095. getNormals(): Nullable<FloatArray>;
  112096. /**
  112097. * Affects tangent data to this target
  112098. * @param data defines the tangent data to use
  112099. */
  112100. setTangents(data: Nullable<FloatArray>): void;
  112101. /**
  112102. * Gets the tangent data stored in this target
  112103. * @returns a FloatArray containing the tangent data (or null if not present)
  112104. */
  112105. getTangents(): Nullable<FloatArray>;
  112106. /**
  112107. * Affects texture coordinates data to this target
  112108. * @param data defines the texture coordinates data to use
  112109. */
  112110. setUVs(data: Nullable<FloatArray>): void;
  112111. /**
  112112. * Gets the texture coordinates data stored in this target
  112113. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  112114. */
  112115. getUVs(): Nullable<FloatArray>;
  112116. /**
  112117. * Clone the current target
  112118. * @returns a new MorphTarget
  112119. */
  112120. clone(): MorphTarget;
  112121. /**
  112122. * Serializes the current target into a Serialization object
  112123. * @returns the serialized object
  112124. */
  112125. serialize(): any;
  112126. /**
  112127. * Returns the string "MorphTarget"
  112128. * @returns "MorphTarget"
  112129. */
  112130. getClassName(): string;
  112131. /**
  112132. * Creates a new target from serialized data
  112133. * @param serializationObject defines the serialized data to use
  112134. * @returns a new MorphTarget
  112135. */
  112136. static Parse(serializationObject: any): MorphTarget;
  112137. /**
  112138. * Creates a MorphTarget from mesh data
  112139. * @param mesh defines the source mesh
  112140. * @param name defines the name to use for the new target
  112141. * @param influence defines the influence to attach to the target
  112142. * @returns a new MorphTarget
  112143. */
  112144. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  112145. }
  112146. }
  112147. declare module BABYLON {
  112148. /**
  112149. * This class is used to deform meshes using morphing between different targets
  112150. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  112151. */
  112152. export class MorphTargetManager {
  112153. private _targets;
  112154. private _targetInfluenceChangedObservers;
  112155. private _targetDataLayoutChangedObservers;
  112156. private _activeTargets;
  112157. private _scene;
  112158. private _influences;
  112159. private _supportsNormals;
  112160. private _supportsTangents;
  112161. private _supportsUVs;
  112162. private _vertexCount;
  112163. private _uniqueId;
  112164. private _tempInfluences;
  112165. /**
  112166. * Gets or sets a boolean indicating if normals must be morphed
  112167. */
  112168. enableNormalMorphing: boolean;
  112169. /**
  112170. * Gets or sets a boolean indicating if tangents must be morphed
  112171. */
  112172. enableTangentMorphing: boolean;
  112173. /**
  112174. * Gets or sets a boolean indicating if UV must be morphed
  112175. */
  112176. enableUVMorphing: boolean;
  112177. /**
  112178. * Creates a new MorphTargetManager
  112179. * @param scene defines the current scene
  112180. */
  112181. constructor(scene?: Nullable<Scene>);
  112182. /**
  112183. * Gets the unique ID of this manager
  112184. */
  112185. get uniqueId(): number;
  112186. /**
  112187. * Gets the number of vertices handled by this manager
  112188. */
  112189. get vertexCount(): number;
  112190. /**
  112191. * Gets a boolean indicating if this manager supports morphing of normals
  112192. */
  112193. get supportsNormals(): boolean;
  112194. /**
  112195. * Gets a boolean indicating if this manager supports morphing of tangents
  112196. */
  112197. get supportsTangents(): boolean;
  112198. /**
  112199. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  112200. */
  112201. get supportsUVs(): boolean;
  112202. /**
  112203. * Gets the number of targets stored in this manager
  112204. */
  112205. get numTargets(): number;
  112206. /**
  112207. * Gets the number of influencers (ie. the number of targets with influences > 0)
  112208. */
  112209. get numInfluencers(): number;
  112210. /**
  112211. * Gets the list of influences (one per target)
  112212. */
  112213. get influences(): Float32Array;
  112214. /**
  112215. * Gets the active target at specified index. An active target is a target with an influence > 0
  112216. * @param index defines the index to check
  112217. * @returns the requested target
  112218. */
  112219. getActiveTarget(index: number): MorphTarget;
  112220. /**
  112221. * Gets the target at specified index
  112222. * @param index defines the index to check
  112223. * @returns the requested target
  112224. */
  112225. getTarget(index: number): MorphTarget;
  112226. /**
  112227. * Add a new target to this manager
  112228. * @param target defines the target to add
  112229. */
  112230. addTarget(target: MorphTarget): void;
  112231. /**
  112232. * Removes a target from the manager
  112233. * @param target defines the target to remove
  112234. */
  112235. removeTarget(target: MorphTarget): void;
  112236. /**
  112237. * Clone the current manager
  112238. * @returns a new MorphTargetManager
  112239. */
  112240. clone(): MorphTargetManager;
  112241. /**
  112242. * Serializes the current manager into a Serialization object
  112243. * @returns the serialized object
  112244. */
  112245. serialize(): any;
  112246. private _syncActiveTargets;
  112247. /**
  112248. * Syncrhonize the targets with all the meshes using this morph target manager
  112249. */
  112250. synchronize(): void;
  112251. /**
  112252. * Creates a new MorphTargetManager from serialized data
  112253. * @param serializationObject defines the serialized data
  112254. * @param scene defines the hosting scene
  112255. * @returns the new MorphTargetManager
  112256. */
  112257. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  112258. }
  112259. }
  112260. declare module BABYLON {
  112261. /**
  112262. * Class used to represent a specific level of detail of a mesh
  112263. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  112264. */
  112265. export class MeshLODLevel {
  112266. /** Defines the distance where this level should start being displayed */
  112267. distance: number;
  112268. /** Defines the mesh to use to render this level */
  112269. mesh: Nullable<Mesh>;
  112270. /**
  112271. * Creates a new LOD level
  112272. * @param distance defines the distance where this level should star being displayed
  112273. * @param mesh defines the mesh to use to render this level
  112274. */
  112275. constructor(
  112276. /** Defines the distance where this level should start being displayed */
  112277. distance: number,
  112278. /** Defines the mesh to use to render this level */
  112279. mesh: Nullable<Mesh>);
  112280. }
  112281. }
  112282. declare module BABYLON {
  112283. /**
  112284. * Helper class used to generate a canvas to manipulate images
  112285. */
  112286. export class CanvasGenerator {
  112287. /**
  112288. * Create a new canvas (or offscreen canvas depending on the context)
  112289. * @param width defines the expected width
  112290. * @param height defines the expected height
  112291. * @return a new canvas or offscreen canvas
  112292. */
  112293. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  112294. }
  112295. }
  112296. declare module BABYLON {
  112297. /**
  112298. * Mesh representing the gorund
  112299. */
  112300. export class GroundMesh extends Mesh {
  112301. /** If octree should be generated */
  112302. generateOctree: boolean;
  112303. private _heightQuads;
  112304. /** @hidden */
  112305. _subdivisionsX: number;
  112306. /** @hidden */
  112307. _subdivisionsY: number;
  112308. /** @hidden */
  112309. _width: number;
  112310. /** @hidden */
  112311. _height: number;
  112312. /** @hidden */
  112313. _minX: number;
  112314. /** @hidden */
  112315. _maxX: number;
  112316. /** @hidden */
  112317. _minZ: number;
  112318. /** @hidden */
  112319. _maxZ: number;
  112320. constructor(name: string, scene: Scene);
  112321. /**
  112322. * "GroundMesh"
  112323. * @returns "GroundMesh"
  112324. */
  112325. getClassName(): string;
  112326. /**
  112327. * The minimum of x and y subdivisions
  112328. */
  112329. get subdivisions(): number;
  112330. /**
  112331. * X subdivisions
  112332. */
  112333. get subdivisionsX(): number;
  112334. /**
  112335. * Y subdivisions
  112336. */
  112337. get subdivisionsY(): number;
  112338. /**
  112339. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  112340. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  112341. * @param chunksCount the number of subdivisions for x and y
  112342. * @param octreeBlocksSize (Default: 32)
  112343. */
  112344. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  112345. /**
  112346. * Returns a height (y) value in the Worl system :
  112347. * the ground altitude at the coordinates (x, z) expressed in the World system.
  112348. * @param x x coordinate
  112349. * @param z z coordinate
  112350. * @returns the ground y position if (x, z) are outside the ground surface.
  112351. */
  112352. getHeightAtCoordinates(x: number, z: number): number;
  112353. /**
  112354. * Returns a normalized vector (Vector3) orthogonal to the ground
  112355. * at the ground coordinates (x, z) expressed in the World system.
  112356. * @param x x coordinate
  112357. * @param z z coordinate
  112358. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  112359. */
  112360. getNormalAtCoordinates(x: number, z: number): Vector3;
  112361. /**
  112362. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  112363. * at the ground coordinates (x, z) expressed in the World system.
  112364. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  112365. * @param x x coordinate
  112366. * @param z z coordinate
  112367. * @param ref vector to store the result
  112368. * @returns the GroundMesh.
  112369. */
  112370. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  112371. /**
  112372. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  112373. * if the ground has been updated.
  112374. * This can be used in the render loop.
  112375. * @returns the GroundMesh.
  112376. */
  112377. updateCoordinateHeights(): GroundMesh;
  112378. private _getFacetAt;
  112379. private _initHeightQuads;
  112380. private _computeHeightQuads;
  112381. /**
  112382. * Serializes this ground mesh
  112383. * @param serializationObject object to write serialization to
  112384. */
  112385. serialize(serializationObject: any): void;
  112386. /**
  112387. * Parses a serialized ground mesh
  112388. * @param parsedMesh the serialized mesh
  112389. * @param scene the scene to create the ground mesh in
  112390. * @returns the created ground mesh
  112391. */
  112392. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  112393. }
  112394. }
  112395. declare module BABYLON {
  112396. /**
  112397. * Interface for Physics-Joint data
  112398. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112399. */
  112400. export interface PhysicsJointData {
  112401. /**
  112402. * The main pivot of the joint
  112403. */
  112404. mainPivot?: Vector3;
  112405. /**
  112406. * The connected pivot of the joint
  112407. */
  112408. connectedPivot?: Vector3;
  112409. /**
  112410. * The main axis of the joint
  112411. */
  112412. mainAxis?: Vector3;
  112413. /**
  112414. * The connected axis of the joint
  112415. */
  112416. connectedAxis?: Vector3;
  112417. /**
  112418. * The collision of the joint
  112419. */
  112420. collision?: boolean;
  112421. /**
  112422. * Native Oimo/Cannon/Energy data
  112423. */
  112424. nativeParams?: any;
  112425. }
  112426. /**
  112427. * This is a holder class for the physics joint created by the physics plugin
  112428. * It holds a set of functions to control the underlying joint
  112429. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112430. */
  112431. export class PhysicsJoint {
  112432. /**
  112433. * The type of the physics joint
  112434. */
  112435. type: number;
  112436. /**
  112437. * The data for the physics joint
  112438. */
  112439. jointData: PhysicsJointData;
  112440. private _physicsJoint;
  112441. protected _physicsPlugin: IPhysicsEnginePlugin;
  112442. /**
  112443. * Initializes the physics joint
  112444. * @param type The type of the physics joint
  112445. * @param jointData The data for the physics joint
  112446. */
  112447. constructor(
  112448. /**
  112449. * The type of the physics joint
  112450. */
  112451. type: number,
  112452. /**
  112453. * The data for the physics joint
  112454. */
  112455. jointData: PhysicsJointData);
  112456. /**
  112457. * Gets the physics joint
  112458. */
  112459. get physicsJoint(): any;
  112460. /**
  112461. * Sets the physics joint
  112462. */
  112463. set physicsJoint(newJoint: any);
  112464. /**
  112465. * Sets the physics plugin
  112466. */
  112467. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  112468. /**
  112469. * Execute a function that is physics-plugin specific.
  112470. * @param {Function} func the function that will be executed.
  112471. * It accepts two parameters: the physics world and the physics joint
  112472. */
  112473. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  112474. /**
  112475. * Distance-Joint type
  112476. */
  112477. static DistanceJoint: number;
  112478. /**
  112479. * Hinge-Joint type
  112480. */
  112481. static HingeJoint: number;
  112482. /**
  112483. * Ball-and-Socket joint type
  112484. */
  112485. static BallAndSocketJoint: number;
  112486. /**
  112487. * Wheel-Joint type
  112488. */
  112489. static WheelJoint: number;
  112490. /**
  112491. * Slider-Joint type
  112492. */
  112493. static SliderJoint: number;
  112494. /**
  112495. * Prismatic-Joint type
  112496. */
  112497. static PrismaticJoint: number;
  112498. /**
  112499. * Universal-Joint type
  112500. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  112501. */
  112502. static UniversalJoint: number;
  112503. /**
  112504. * Hinge-Joint 2 type
  112505. */
  112506. static Hinge2Joint: number;
  112507. /**
  112508. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  112509. */
  112510. static PointToPointJoint: number;
  112511. /**
  112512. * Spring-Joint type
  112513. */
  112514. static SpringJoint: number;
  112515. /**
  112516. * Lock-Joint type
  112517. */
  112518. static LockJoint: number;
  112519. }
  112520. /**
  112521. * A class representing a physics distance joint
  112522. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112523. */
  112524. export class DistanceJoint extends PhysicsJoint {
  112525. /**
  112526. *
  112527. * @param jointData The data for the Distance-Joint
  112528. */
  112529. constructor(jointData: DistanceJointData);
  112530. /**
  112531. * Update the predefined distance.
  112532. * @param maxDistance The maximum preferred distance
  112533. * @param minDistance The minimum preferred distance
  112534. */
  112535. updateDistance(maxDistance: number, minDistance?: number): void;
  112536. }
  112537. /**
  112538. * Represents a Motor-Enabled Joint
  112539. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112540. */
  112541. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  112542. /**
  112543. * Initializes the Motor-Enabled Joint
  112544. * @param type The type of the joint
  112545. * @param jointData The physica joint data for the joint
  112546. */
  112547. constructor(type: number, jointData: PhysicsJointData);
  112548. /**
  112549. * Set the motor values.
  112550. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112551. * @param force the force to apply
  112552. * @param maxForce max force for this motor.
  112553. */
  112554. setMotor(force?: number, maxForce?: number): void;
  112555. /**
  112556. * Set the motor's limits.
  112557. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112558. * @param upperLimit The upper limit of the motor
  112559. * @param lowerLimit The lower limit of the motor
  112560. */
  112561. setLimit(upperLimit: number, lowerLimit?: number): void;
  112562. }
  112563. /**
  112564. * This class represents a single physics Hinge-Joint
  112565. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112566. */
  112567. export class HingeJoint extends MotorEnabledJoint {
  112568. /**
  112569. * Initializes the Hinge-Joint
  112570. * @param jointData The joint data for the Hinge-Joint
  112571. */
  112572. constructor(jointData: PhysicsJointData);
  112573. /**
  112574. * Set the motor values.
  112575. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112576. * @param {number} force the force to apply
  112577. * @param {number} maxForce max force for this motor.
  112578. */
  112579. setMotor(force?: number, maxForce?: number): void;
  112580. /**
  112581. * Set the motor's limits.
  112582. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112583. * @param upperLimit The upper limit of the motor
  112584. * @param lowerLimit The lower limit of the motor
  112585. */
  112586. setLimit(upperLimit: number, lowerLimit?: number): void;
  112587. }
  112588. /**
  112589. * This class represents a dual hinge physics joint (same as wheel joint)
  112590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112591. */
  112592. export class Hinge2Joint extends MotorEnabledJoint {
  112593. /**
  112594. * Initializes the Hinge2-Joint
  112595. * @param jointData The joint data for the Hinge2-Joint
  112596. */
  112597. constructor(jointData: PhysicsJointData);
  112598. /**
  112599. * Set the motor values.
  112600. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112601. * @param {number} targetSpeed the speed the motor is to reach
  112602. * @param {number} maxForce max force for this motor.
  112603. * @param {motorIndex} the motor's index, 0 or 1.
  112604. */
  112605. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  112606. /**
  112607. * Set the motor limits.
  112608. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112609. * @param {number} upperLimit the upper limit
  112610. * @param {number} lowerLimit lower limit
  112611. * @param {motorIndex} the motor's index, 0 or 1.
  112612. */
  112613. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112614. }
  112615. /**
  112616. * Interface for a motor enabled joint
  112617. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112618. */
  112619. export interface IMotorEnabledJoint {
  112620. /**
  112621. * Physics joint
  112622. */
  112623. physicsJoint: any;
  112624. /**
  112625. * Sets the motor of the motor-enabled joint
  112626. * @param force The force of the motor
  112627. * @param maxForce The maximum force of the motor
  112628. * @param motorIndex The index of the motor
  112629. */
  112630. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  112631. /**
  112632. * Sets the limit of the motor
  112633. * @param upperLimit The upper limit of the motor
  112634. * @param lowerLimit The lower limit of the motor
  112635. * @param motorIndex The index of the motor
  112636. */
  112637. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112638. }
  112639. /**
  112640. * Joint data for a Distance-Joint
  112641. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112642. */
  112643. export interface DistanceJointData extends PhysicsJointData {
  112644. /**
  112645. * Max distance the 2 joint objects can be apart
  112646. */
  112647. maxDistance: number;
  112648. }
  112649. /**
  112650. * Joint data from a spring joint
  112651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112652. */
  112653. export interface SpringJointData extends PhysicsJointData {
  112654. /**
  112655. * Length of the spring
  112656. */
  112657. length: number;
  112658. /**
  112659. * Stiffness of the spring
  112660. */
  112661. stiffness: number;
  112662. /**
  112663. * Damping of the spring
  112664. */
  112665. damping: number;
  112666. /** this callback will be called when applying the force to the impostors. */
  112667. forceApplicationCallback: () => void;
  112668. }
  112669. }
  112670. declare module BABYLON {
  112671. /**
  112672. * Holds the data for the raycast result
  112673. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112674. */
  112675. export class PhysicsRaycastResult {
  112676. private _hasHit;
  112677. private _hitDistance;
  112678. private _hitNormalWorld;
  112679. private _hitPointWorld;
  112680. private _rayFromWorld;
  112681. private _rayToWorld;
  112682. /**
  112683. * Gets if there was a hit
  112684. */
  112685. get hasHit(): boolean;
  112686. /**
  112687. * Gets the distance from the hit
  112688. */
  112689. get hitDistance(): number;
  112690. /**
  112691. * Gets the hit normal/direction in the world
  112692. */
  112693. get hitNormalWorld(): Vector3;
  112694. /**
  112695. * Gets the hit point in the world
  112696. */
  112697. get hitPointWorld(): Vector3;
  112698. /**
  112699. * Gets the ray "start point" of the ray in the world
  112700. */
  112701. get rayFromWorld(): Vector3;
  112702. /**
  112703. * Gets the ray "end point" of the ray in the world
  112704. */
  112705. get rayToWorld(): Vector3;
  112706. /**
  112707. * Sets the hit data (normal & point in world space)
  112708. * @param hitNormalWorld defines the normal in world space
  112709. * @param hitPointWorld defines the point in world space
  112710. */
  112711. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  112712. /**
  112713. * Sets the distance from the start point to the hit point
  112714. * @param distance
  112715. */
  112716. setHitDistance(distance: number): void;
  112717. /**
  112718. * Calculates the distance manually
  112719. */
  112720. calculateHitDistance(): void;
  112721. /**
  112722. * Resets all the values to default
  112723. * @param from The from point on world space
  112724. * @param to The to point on world space
  112725. */
  112726. reset(from?: Vector3, to?: Vector3): void;
  112727. }
  112728. /**
  112729. * Interface for the size containing width and height
  112730. */
  112731. interface IXYZ {
  112732. /**
  112733. * X
  112734. */
  112735. x: number;
  112736. /**
  112737. * Y
  112738. */
  112739. y: number;
  112740. /**
  112741. * Z
  112742. */
  112743. z: number;
  112744. }
  112745. }
  112746. declare module BABYLON {
  112747. /**
  112748. * Interface used to describe a physics joint
  112749. */
  112750. export interface PhysicsImpostorJoint {
  112751. /** Defines the main impostor to which the joint is linked */
  112752. mainImpostor: PhysicsImpostor;
  112753. /** Defines the impostor that is connected to the main impostor using this joint */
  112754. connectedImpostor: PhysicsImpostor;
  112755. /** Defines the joint itself */
  112756. joint: PhysicsJoint;
  112757. }
  112758. /** @hidden */
  112759. export interface IPhysicsEnginePlugin {
  112760. world: any;
  112761. name: string;
  112762. setGravity(gravity: Vector3): void;
  112763. setTimeStep(timeStep: number): void;
  112764. getTimeStep(): number;
  112765. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112766. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112767. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112768. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112769. removePhysicsBody(impostor: PhysicsImpostor): void;
  112770. generateJoint(joint: PhysicsImpostorJoint): void;
  112771. removeJoint(joint: PhysicsImpostorJoint): void;
  112772. isSupported(): boolean;
  112773. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112774. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112775. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  112776. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  112777. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112778. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112779. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112780. getBodyMass(impostor: PhysicsImpostor): number;
  112781. getBodyFriction(impostor: PhysicsImpostor): number;
  112782. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112783. getBodyRestitution(impostor: PhysicsImpostor): number;
  112784. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112785. getBodyPressure?(impostor: PhysicsImpostor): number;
  112786. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  112787. getBodyStiffness?(impostor: PhysicsImpostor): number;
  112788. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  112789. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  112790. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  112791. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  112792. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  112793. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  112794. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  112795. sleepBody(impostor: PhysicsImpostor): void;
  112796. wakeUpBody(impostor: PhysicsImpostor): void;
  112797. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112798. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112799. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  112800. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112801. getRadius(impostor: PhysicsImpostor): number;
  112802. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112803. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112804. dispose(): void;
  112805. }
  112806. /**
  112807. * Interface used to define a physics engine
  112808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112809. */
  112810. export interface IPhysicsEngine {
  112811. /**
  112812. * Gets the gravity vector used by the simulation
  112813. */
  112814. gravity: Vector3;
  112815. /**
  112816. * Sets the gravity vector used by the simulation
  112817. * @param gravity defines the gravity vector to use
  112818. */
  112819. setGravity(gravity: Vector3): void;
  112820. /**
  112821. * Set the time step of the physics engine.
  112822. * Default is 1/60.
  112823. * To slow it down, enter 1/600 for example.
  112824. * To speed it up, 1/30
  112825. * @param newTimeStep the new timestep to apply to this world.
  112826. */
  112827. setTimeStep(newTimeStep: number): void;
  112828. /**
  112829. * Get the time step of the physics engine.
  112830. * @returns the current time step
  112831. */
  112832. getTimeStep(): number;
  112833. /**
  112834. * Set the sub time step of the physics engine.
  112835. * Default is 0 meaning there is no sub steps
  112836. * To increase physics resolution precision, set a small value (like 1 ms)
  112837. * @param subTimeStep defines the new sub timestep used for physics resolution.
  112838. */
  112839. setSubTimeStep(subTimeStep: number): void;
  112840. /**
  112841. * Get the sub time step of the physics engine.
  112842. * @returns the current sub time step
  112843. */
  112844. getSubTimeStep(): number;
  112845. /**
  112846. * Release all resources
  112847. */
  112848. dispose(): void;
  112849. /**
  112850. * Gets the name of the current physics plugin
  112851. * @returns the name of the plugin
  112852. */
  112853. getPhysicsPluginName(): string;
  112854. /**
  112855. * Adding a new impostor for the impostor tracking.
  112856. * This will be done by the impostor itself.
  112857. * @param impostor the impostor to add
  112858. */
  112859. addImpostor(impostor: PhysicsImpostor): void;
  112860. /**
  112861. * Remove an impostor from the engine.
  112862. * This impostor and its mesh will not longer be updated by the physics engine.
  112863. * @param impostor the impostor to remove
  112864. */
  112865. removeImpostor(impostor: PhysicsImpostor): void;
  112866. /**
  112867. * Add a joint to the physics engine
  112868. * @param mainImpostor defines the main impostor to which the joint is added.
  112869. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  112870. * @param joint defines the joint that will connect both impostors.
  112871. */
  112872. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112873. /**
  112874. * Removes a joint from the simulation
  112875. * @param mainImpostor defines the impostor used with the joint
  112876. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  112877. * @param joint defines the joint to remove
  112878. */
  112879. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112880. /**
  112881. * Gets the current plugin used to run the simulation
  112882. * @returns current plugin
  112883. */
  112884. getPhysicsPlugin(): IPhysicsEnginePlugin;
  112885. /**
  112886. * Gets the list of physic impostors
  112887. * @returns an array of PhysicsImpostor
  112888. */
  112889. getImpostors(): Array<PhysicsImpostor>;
  112890. /**
  112891. * Gets the impostor for a physics enabled object
  112892. * @param object defines the object impersonated by the impostor
  112893. * @returns the PhysicsImpostor or null if not found
  112894. */
  112895. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  112896. /**
  112897. * Gets the impostor for a physics body object
  112898. * @param body defines physics body used by the impostor
  112899. * @returns the PhysicsImpostor or null if not found
  112900. */
  112901. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  112902. /**
  112903. * Does a raycast in the physics world
  112904. * @param from when should the ray start?
  112905. * @param to when should the ray end?
  112906. * @returns PhysicsRaycastResult
  112907. */
  112908. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112909. /**
  112910. * Called by the scene. No need to call it.
  112911. * @param delta defines the timespam between frames
  112912. */
  112913. _step(delta: number): void;
  112914. }
  112915. }
  112916. declare module BABYLON {
  112917. /**
  112918. * The interface for the physics imposter parameters
  112919. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112920. */
  112921. export interface PhysicsImpostorParameters {
  112922. /**
  112923. * The mass of the physics imposter
  112924. */
  112925. mass: number;
  112926. /**
  112927. * The friction of the physics imposter
  112928. */
  112929. friction?: number;
  112930. /**
  112931. * The coefficient of restitution of the physics imposter
  112932. */
  112933. restitution?: number;
  112934. /**
  112935. * The native options of the physics imposter
  112936. */
  112937. nativeOptions?: any;
  112938. /**
  112939. * Specifies if the parent should be ignored
  112940. */
  112941. ignoreParent?: boolean;
  112942. /**
  112943. * Specifies if bi-directional transformations should be disabled
  112944. */
  112945. disableBidirectionalTransformation?: boolean;
  112946. /**
  112947. * The pressure inside the physics imposter, soft object only
  112948. */
  112949. pressure?: number;
  112950. /**
  112951. * The stiffness the physics imposter, soft object only
  112952. */
  112953. stiffness?: number;
  112954. /**
  112955. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  112956. */
  112957. velocityIterations?: number;
  112958. /**
  112959. * The number of iterations used in maintaining consistent vertex positions, soft object only
  112960. */
  112961. positionIterations?: number;
  112962. /**
  112963. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  112964. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  112965. * Add to fix multiple points
  112966. */
  112967. fixedPoints?: number;
  112968. /**
  112969. * The collision margin around a soft object
  112970. */
  112971. margin?: number;
  112972. /**
  112973. * The collision margin around a soft object
  112974. */
  112975. damping?: number;
  112976. /**
  112977. * The path for a rope based on an extrusion
  112978. */
  112979. path?: any;
  112980. /**
  112981. * The shape of an extrusion used for a rope based on an extrusion
  112982. */
  112983. shape?: any;
  112984. }
  112985. /**
  112986. * Interface for a physics-enabled object
  112987. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112988. */
  112989. export interface IPhysicsEnabledObject {
  112990. /**
  112991. * The position of the physics-enabled object
  112992. */
  112993. position: Vector3;
  112994. /**
  112995. * The rotation of the physics-enabled object
  112996. */
  112997. rotationQuaternion: Nullable<Quaternion>;
  112998. /**
  112999. * The scale of the physics-enabled object
  113000. */
  113001. scaling: Vector3;
  113002. /**
  113003. * The rotation of the physics-enabled object
  113004. */
  113005. rotation?: Vector3;
  113006. /**
  113007. * The parent of the physics-enabled object
  113008. */
  113009. parent?: any;
  113010. /**
  113011. * The bounding info of the physics-enabled object
  113012. * @returns The bounding info of the physics-enabled object
  113013. */
  113014. getBoundingInfo(): BoundingInfo;
  113015. /**
  113016. * Computes the world matrix
  113017. * @param force Specifies if the world matrix should be computed by force
  113018. * @returns A world matrix
  113019. */
  113020. computeWorldMatrix(force: boolean): Matrix;
  113021. /**
  113022. * Gets the world matrix
  113023. * @returns A world matrix
  113024. */
  113025. getWorldMatrix?(): Matrix;
  113026. /**
  113027. * Gets the child meshes
  113028. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  113029. * @returns An array of abstract meshes
  113030. */
  113031. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  113032. /**
  113033. * Gets the vertex data
  113034. * @param kind The type of vertex data
  113035. * @returns A nullable array of numbers, or a float32 array
  113036. */
  113037. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  113038. /**
  113039. * Gets the indices from the mesh
  113040. * @returns A nullable array of index arrays
  113041. */
  113042. getIndices?(): Nullable<IndicesArray>;
  113043. /**
  113044. * Gets the scene from the mesh
  113045. * @returns the indices array or null
  113046. */
  113047. getScene?(): Scene;
  113048. /**
  113049. * Gets the absolute position from the mesh
  113050. * @returns the absolute position
  113051. */
  113052. getAbsolutePosition(): Vector3;
  113053. /**
  113054. * Gets the absolute pivot point from the mesh
  113055. * @returns the absolute pivot point
  113056. */
  113057. getAbsolutePivotPoint(): Vector3;
  113058. /**
  113059. * Rotates the mesh
  113060. * @param axis The axis of rotation
  113061. * @param amount The amount of rotation
  113062. * @param space The space of the rotation
  113063. * @returns The rotation transform node
  113064. */
  113065. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  113066. /**
  113067. * Translates the mesh
  113068. * @param axis The axis of translation
  113069. * @param distance The distance of translation
  113070. * @param space The space of the translation
  113071. * @returns The transform node
  113072. */
  113073. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  113074. /**
  113075. * Sets the absolute position of the mesh
  113076. * @param absolutePosition The absolute position of the mesh
  113077. * @returns The transform node
  113078. */
  113079. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  113080. /**
  113081. * Gets the class name of the mesh
  113082. * @returns The class name
  113083. */
  113084. getClassName(): string;
  113085. }
  113086. /**
  113087. * Represents a physics imposter
  113088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113089. */
  113090. export class PhysicsImpostor {
  113091. /**
  113092. * The physics-enabled object used as the physics imposter
  113093. */
  113094. object: IPhysicsEnabledObject;
  113095. /**
  113096. * The type of the physics imposter
  113097. */
  113098. type: number;
  113099. private _options;
  113100. private _scene?;
  113101. /**
  113102. * The default object size of the imposter
  113103. */
  113104. static DEFAULT_OBJECT_SIZE: Vector3;
  113105. /**
  113106. * The identity quaternion of the imposter
  113107. */
  113108. static IDENTITY_QUATERNION: Quaternion;
  113109. /** @hidden */
  113110. _pluginData: any;
  113111. private _physicsEngine;
  113112. private _physicsBody;
  113113. private _bodyUpdateRequired;
  113114. private _onBeforePhysicsStepCallbacks;
  113115. private _onAfterPhysicsStepCallbacks;
  113116. /** @hidden */
  113117. _onPhysicsCollideCallbacks: Array<{
  113118. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  113119. otherImpostors: Array<PhysicsImpostor>;
  113120. }>;
  113121. private _deltaPosition;
  113122. private _deltaRotation;
  113123. private _deltaRotationConjugated;
  113124. /** @hidden */
  113125. _isFromLine: boolean;
  113126. private _parent;
  113127. private _isDisposed;
  113128. private static _tmpVecs;
  113129. private static _tmpQuat;
  113130. /**
  113131. * Specifies if the physics imposter is disposed
  113132. */
  113133. get isDisposed(): boolean;
  113134. /**
  113135. * Gets the mass of the physics imposter
  113136. */
  113137. get mass(): number;
  113138. set mass(value: number);
  113139. /**
  113140. * Gets the coefficient of friction
  113141. */
  113142. get friction(): number;
  113143. /**
  113144. * Sets the coefficient of friction
  113145. */
  113146. set friction(value: number);
  113147. /**
  113148. * Gets the coefficient of restitution
  113149. */
  113150. get restitution(): number;
  113151. /**
  113152. * Sets the coefficient of restitution
  113153. */
  113154. set restitution(value: number);
  113155. /**
  113156. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  113157. */
  113158. get pressure(): number;
  113159. /**
  113160. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  113161. */
  113162. set pressure(value: number);
  113163. /**
  113164. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  113165. */
  113166. get stiffness(): number;
  113167. /**
  113168. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  113169. */
  113170. set stiffness(value: number);
  113171. /**
  113172. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  113173. */
  113174. get velocityIterations(): number;
  113175. /**
  113176. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  113177. */
  113178. set velocityIterations(value: number);
  113179. /**
  113180. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  113181. */
  113182. get positionIterations(): number;
  113183. /**
  113184. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  113185. */
  113186. set positionIterations(value: number);
  113187. /**
  113188. * The unique id of the physics imposter
  113189. * set by the physics engine when adding this impostor to the array
  113190. */
  113191. uniqueId: number;
  113192. /**
  113193. * @hidden
  113194. */
  113195. soft: boolean;
  113196. /**
  113197. * @hidden
  113198. */
  113199. segments: number;
  113200. private _joints;
  113201. /**
  113202. * Initializes the physics imposter
  113203. * @param object The physics-enabled object used as the physics imposter
  113204. * @param type The type of the physics imposter
  113205. * @param _options The options for the physics imposter
  113206. * @param _scene The Babylon scene
  113207. */
  113208. constructor(
  113209. /**
  113210. * The physics-enabled object used as the physics imposter
  113211. */
  113212. object: IPhysicsEnabledObject,
  113213. /**
  113214. * The type of the physics imposter
  113215. */
  113216. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  113217. /**
  113218. * This function will completly initialize this impostor.
  113219. * It will create a new body - but only if this mesh has no parent.
  113220. * If it has, this impostor will not be used other than to define the impostor
  113221. * of the child mesh.
  113222. * @hidden
  113223. */
  113224. _init(): void;
  113225. private _getPhysicsParent;
  113226. /**
  113227. * Should a new body be generated.
  113228. * @returns boolean specifying if body initialization is required
  113229. */
  113230. isBodyInitRequired(): boolean;
  113231. /**
  113232. * Sets the updated scaling
  113233. * @param updated Specifies if the scaling is updated
  113234. */
  113235. setScalingUpdated(): void;
  113236. /**
  113237. * Force a regeneration of this or the parent's impostor's body.
  113238. * Use under cautious - This will remove all joints already implemented.
  113239. */
  113240. forceUpdate(): void;
  113241. /**
  113242. * Gets the body that holds this impostor. Either its own, or its parent.
  113243. */
  113244. get physicsBody(): any;
  113245. /**
  113246. * Get the parent of the physics imposter
  113247. * @returns Physics imposter or null
  113248. */
  113249. get parent(): Nullable<PhysicsImpostor>;
  113250. /**
  113251. * Sets the parent of the physics imposter
  113252. */
  113253. set parent(value: Nullable<PhysicsImpostor>);
  113254. /**
  113255. * Set the physics body. Used mainly by the physics engine/plugin
  113256. */
  113257. set physicsBody(physicsBody: any);
  113258. /**
  113259. * Resets the update flags
  113260. */
  113261. resetUpdateFlags(): void;
  113262. /**
  113263. * Gets the object extend size
  113264. * @returns the object extend size
  113265. */
  113266. getObjectExtendSize(): Vector3;
  113267. /**
  113268. * Gets the object center
  113269. * @returns The object center
  113270. */
  113271. getObjectCenter(): Vector3;
  113272. /**
  113273. * Get a specific parameter from the options parameters
  113274. * @param paramName The object parameter name
  113275. * @returns The object parameter
  113276. */
  113277. getParam(paramName: string): any;
  113278. /**
  113279. * Sets a specific parameter in the options given to the physics plugin
  113280. * @param paramName The parameter name
  113281. * @param value The value of the parameter
  113282. */
  113283. setParam(paramName: string, value: number): void;
  113284. /**
  113285. * Specifically change the body's mass option. Won't recreate the physics body object
  113286. * @param mass The mass of the physics imposter
  113287. */
  113288. setMass(mass: number): void;
  113289. /**
  113290. * Gets the linear velocity
  113291. * @returns linear velocity or null
  113292. */
  113293. getLinearVelocity(): Nullable<Vector3>;
  113294. /**
  113295. * Sets the linear velocity
  113296. * @param velocity linear velocity or null
  113297. */
  113298. setLinearVelocity(velocity: Nullable<Vector3>): void;
  113299. /**
  113300. * Gets the angular velocity
  113301. * @returns angular velocity or null
  113302. */
  113303. getAngularVelocity(): Nullable<Vector3>;
  113304. /**
  113305. * Sets the angular velocity
  113306. * @param velocity The velocity or null
  113307. */
  113308. setAngularVelocity(velocity: Nullable<Vector3>): void;
  113309. /**
  113310. * Execute a function with the physics plugin native code
  113311. * Provide a function the will have two variables - the world object and the physics body object
  113312. * @param func The function to execute with the physics plugin native code
  113313. */
  113314. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  113315. /**
  113316. * Register a function that will be executed before the physics world is stepping forward
  113317. * @param func The function to execute before the physics world is stepped forward
  113318. */
  113319. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113320. /**
  113321. * Unregister a function that will be executed before the physics world is stepping forward
  113322. * @param func The function to execute before the physics world is stepped forward
  113323. */
  113324. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113325. /**
  113326. * Register a function that will be executed after the physics step
  113327. * @param func The function to execute after physics step
  113328. */
  113329. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113330. /**
  113331. * Unregisters a function that will be executed after the physics step
  113332. * @param func The function to execute after physics step
  113333. */
  113334. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113335. /**
  113336. * register a function that will be executed when this impostor collides against a different body
  113337. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  113338. * @param func Callback that is executed on collision
  113339. */
  113340. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  113341. /**
  113342. * Unregisters the physics imposter on contact
  113343. * @param collideAgainst The physics object to collide against
  113344. * @param func Callback to execute on collision
  113345. */
  113346. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  113347. private _tmpQuat;
  113348. private _tmpQuat2;
  113349. /**
  113350. * Get the parent rotation
  113351. * @returns The parent rotation
  113352. */
  113353. getParentsRotation(): Quaternion;
  113354. /**
  113355. * this function is executed by the physics engine.
  113356. */
  113357. beforeStep: () => void;
  113358. /**
  113359. * this function is executed by the physics engine
  113360. */
  113361. afterStep: () => void;
  113362. /**
  113363. * Legacy collision detection event support
  113364. */
  113365. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  113366. /**
  113367. * event and body object due to cannon's event-based architecture.
  113368. */
  113369. onCollide: (e: {
  113370. body: any;
  113371. point: Nullable<Vector3>;
  113372. }) => void;
  113373. /**
  113374. * Apply a force
  113375. * @param force The force to apply
  113376. * @param contactPoint The contact point for the force
  113377. * @returns The physics imposter
  113378. */
  113379. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113380. /**
  113381. * Apply an impulse
  113382. * @param force The impulse force
  113383. * @param contactPoint The contact point for the impulse force
  113384. * @returns The physics imposter
  113385. */
  113386. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113387. /**
  113388. * A help function to create a joint
  113389. * @param otherImpostor A physics imposter used to create a joint
  113390. * @param jointType The type of joint
  113391. * @param jointData The data for the joint
  113392. * @returns The physics imposter
  113393. */
  113394. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  113395. /**
  113396. * Add a joint to this impostor with a different impostor
  113397. * @param otherImpostor A physics imposter used to add a joint
  113398. * @param joint The joint to add
  113399. * @returns The physics imposter
  113400. */
  113401. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  113402. /**
  113403. * Add an anchor to a cloth impostor
  113404. * @param otherImpostor rigid impostor to anchor to
  113405. * @param width ratio across width from 0 to 1
  113406. * @param height ratio up height from 0 to 1
  113407. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  113408. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  113409. * @returns impostor the soft imposter
  113410. */
  113411. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113412. /**
  113413. * Add a hook to a rope impostor
  113414. * @param otherImpostor rigid impostor to anchor to
  113415. * @param length ratio across rope from 0 to 1
  113416. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  113417. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113418. * @returns impostor the rope imposter
  113419. */
  113420. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113421. /**
  113422. * Will keep this body still, in a sleep mode.
  113423. * @returns the physics imposter
  113424. */
  113425. sleep(): PhysicsImpostor;
  113426. /**
  113427. * Wake the body up.
  113428. * @returns The physics imposter
  113429. */
  113430. wakeUp(): PhysicsImpostor;
  113431. /**
  113432. * Clones the physics imposter
  113433. * @param newObject The physics imposter clones to this physics-enabled object
  113434. * @returns A nullable physics imposter
  113435. */
  113436. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113437. /**
  113438. * Disposes the physics imposter
  113439. */
  113440. dispose(): void;
  113441. /**
  113442. * Sets the delta position
  113443. * @param position The delta position amount
  113444. */
  113445. setDeltaPosition(position: Vector3): void;
  113446. /**
  113447. * Sets the delta rotation
  113448. * @param rotation The delta rotation amount
  113449. */
  113450. setDeltaRotation(rotation: Quaternion): void;
  113451. /**
  113452. * Gets the box size of the physics imposter and stores the result in the input parameter
  113453. * @param result Stores the box size
  113454. * @returns The physics imposter
  113455. */
  113456. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  113457. /**
  113458. * Gets the radius of the physics imposter
  113459. * @returns Radius of the physics imposter
  113460. */
  113461. getRadius(): number;
  113462. /**
  113463. * Sync a bone with this impostor
  113464. * @param bone The bone to sync to the impostor.
  113465. * @param boneMesh The mesh that the bone is influencing.
  113466. * @param jointPivot The pivot of the joint / bone in local space.
  113467. * @param distToJoint Optional distance from the impostor to the joint.
  113468. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113469. */
  113470. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  113471. /**
  113472. * Sync impostor to a bone
  113473. * @param bone The bone that the impostor will be synced to.
  113474. * @param boneMesh The mesh that the bone is influencing.
  113475. * @param jointPivot The pivot of the joint / bone in local space.
  113476. * @param distToJoint Optional distance from the impostor to the joint.
  113477. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113478. * @param boneAxis Optional vector3 axis the bone is aligned with
  113479. */
  113480. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  113481. /**
  113482. * No-Imposter type
  113483. */
  113484. static NoImpostor: number;
  113485. /**
  113486. * Sphere-Imposter type
  113487. */
  113488. static SphereImpostor: number;
  113489. /**
  113490. * Box-Imposter type
  113491. */
  113492. static BoxImpostor: number;
  113493. /**
  113494. * Plane-Imposter type
  113495. */
  113496. static PlaneImpostor: number;
  113497. /**
  113498. * Mesh-imposter type
  113499. */
  113500. static MeshImpostor: number;
  113501. /**
  113502. * Capsule-Impostor type (Ammo.js plugin only)
  113503. */
  113504. static CapsuleImpostor: number;
  113505. /**
  113506. * Cylinder-Imposter type
  113507. */
  113508. static CylinderImpostor: number;
  113509. /**
  113510. * Particle-Imposter type
  113511. */
  113512. static ParticleImpostor: number;
  113513. /**
  113514. * Heightmap-Imposter type
  113515. */
  113516. static HeightmapImpostor: number;
  113517. /**
  113518. * ConvexHull-Impostor type (Ammo.js plugin only)
  113519. */
  113520. static ConvexHullImpostor: number;
  113521. /**
  113522. * Custom-Imposter type (Ammo.js plugin only)
  113523. */
  113524. static CustomImpostor: number;
  113525. /**
  113526. * Rope-Imposter type
  113527. */
  113528. static RopeImpostor: number;
  113529. /**
  113530. * Cloth-Imposter type
  113531. */
  113532. static ClothImpostor: number;
  113533. /**
  113534. * Softbody-Imposter type
  113535. */
  113536. static SoftbodyImpostor: number;
  113537. }
  113538. }
  113539. declare module BABYLON {
  113540. /**
  113541. * @hidden
  113542. **/
  113543. export class _CreationDataStorage {
  113544. closePath?: boolean;
  113545. closeArray?: boolean;
  113546. idx: number[];
  113547. dashSize: number;
  113548. gapSize: number;
  113549. path3D: Path3D;
  113550. pathArray: Vector3[][];
  113551. arc: number;
  113552. radius: number;
  113553. cap: number;
  113554. tessellation: number;
  113555. }
  113556. /**
  113557. * @hidden
  113558. **/
  113559. class _InstanceDataStorage {
  113560. visibleInstances: any;
  113561. batchCache: _InstancesBatch;
  113562. instancesBufferSize: number;
  113563. instancesBuffer: Nullable<Buffer>;
  113564. instancesData: Float32Array;
  113565. overridenInstanceCount: number;
  113566. isFrozen: boolean;
  113567. previousBatch: Nullable<_InstancesBatch>;
  113568. hardwareInstancedRendering: boolean;
  113569. sideOrientation: number;
  113570. manualUpdate: boolean;
  113571. previousRenderId: number;
  113572. }
  113573. /**
  113574. * @hidden
  113575. **/
  113576. export class _InstancesBatch {
  113577. mustReturn: boolean;
  113578. visibleInstances: Nullable<InstancedMesh[]>[];
  113579. renderSelf: boolean[];
  113580. hardwareInstancedRendering: boolean[];
  113581. }
  113582. /**
  113583. * @hidden
  113584. **/
  113585. class _ThinInstanceDataStorage {
  113586. instancesCount: number;
  113587. matrixBuffer: Nullable<Buffer>;
  113588. matrixBufferSize: number;
  113589. matrixData: Nullable<Float32Array>;
  113590. boundingVectors: Array<Vector3>;
  113591. worldMatrices: Nullable<Matrix[]>;
  113592. }
  113593. /**
  113594. * Class used to represent renderable models
  113595. */
  113596. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  113597. /**
  113598. * Mesh side orientation : usually the external or front surface
  113599. */
  113600. static readonly FRONTSIDE: number;
  113601. /**
  113602. * Mesh side orientation : usually the internal or back surface
  113603. */
  113604. static readonly BACKSIDE: number;
  113605. /**
  113606. * Mesh side orientation : both internal and external or front and back surfaces
  113607. */
  113608. static readonly DOUBLESIDE: number;
  113609. /**
  113610. * Mesh side orientation : by default, `FRONTSIDE`
  113611. */
  113612. static readonly DEFAULTSIDE: number;
  113613. /**
  113614. * Mesh cap setting : no cap
  113615. */
  113616. static readonly NO_CAP: number;
  113617. /**
  113618. * Mesh cap setting : one cap at the beginning of the mesh
  113619. */
  113620. static readonly CAP_START: number;
  113621. /**
  113622. * Mesh cap setting : one cap at the end of the mesh
  113623. */
  113624. static readonly CAP_END: number;
  113625. /**
  113626. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  113627. */
  113628. static readonly CAP_ALL: number;
  113629. /**
  113630. * Mesh pattern setting : no flip or rotate
  113631. */
  113632. static readonly NO_FLIP: number;
  113633. /**
  113634. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  113635. */
  113636. static readonly FLIP_TILE: number;
  113637. /**
  113638. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  113639. */
  113640. static readonly ROTATE_TILE: number;
  113641. /**
  113642. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  113643. */
  113644. static readonly FLIP_ROW: number;
  113645. /**
  113646. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  113647. */
  113648. static readonly ROTATE_ROW: number;
  113649. /**
  113650. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  113651. */
  113652. static readonly FLIP_N_ROTATE_TILE: number;
  113653. /**
  113654. * Mesh pattern setting : rotate pattern and rotate
  113655. */
  113656. static readonly FLIP_N_ROTATE_ROW: number;
  113657. /**
  113658. * Mesh tile positioning : part tiles same on left/right or top/bottom
  113659. */
  113660. static readonly CENTER: number;
  113661. /**
  113662. * Mesh tile positioning : part tiles on left
  113663. */
  113664. static readonly LEFT: number;
  113665. /**
  113666. * Mesh tile positioning : part tiles on right
  113667. */
  113668. static readonly RIGHT: number;
  113669. /**
  113670. * Mesh tile positioning : part tiles on top
  113671. */
  113672. static readonly TOP: number;
  113673. /**
  113674. * Mesh tile positioning : part tiles on bottom
  113675. */
  113676. static readonly BOTTOM: number;
  113677. /**
  113678. * Gets the default side orientation.
  113679. * @param orientation the orientation to value to attempt to get
  113680. * @returns the default orientation
  113681. * @hidden
  113682. */
  113683. static _GetDefaultSideOrientation(orientation?: number): number;
  113684. private _internalMeshDataInfo;
  113685. get computeBonesUsingShaders(): boolean;
  113686. set computeBonesUsingShaders(value: boolean);
  113687. /**
  113688. * An event triggered before rendering the mesh
  113689. */
  113690. get onBeforeRenderObservable(): Observable<Mesh>;
  113691. /**
  113692. * An event triggered before binding the mesh
  113693. */
  113694. get onBeforeBindObservable(): Observable<Mesh>;
  113695. /**
  113696. * An event triggered after rendering the mesh
  113697. */
  113698. get onAfterRenderObservable(): Observable<Mesh>;
  113699. /**
  113700. * An event triggered before drawing the mesh
  113701. */
  113702. get onBeforeDrawObservable(): Observable<Mesh>;
  113703. private _onBeforeDrawObserver;
  113704. /**
  113705. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  113706. */
  113707. set onBeforeDraw(callback: () => void);
  113708. get hasInstances(): boolean;
  113709. get hasThinInstances(): boolean;
  113710. /**
  113711. * Gets the delay loading state of the mesh (when delay loading is turned on)
  113712. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  113713. */
  113714. delayLoadState: number;
  113715. /**
  113716. * Gets the list of instances created from this mesh
  113717. * it is not supposed to be modified manually.
  113718. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  113719. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113720. */
  113721. instances: InstancedMesh[];
  113722. /**
  113723. * Gets the file containing delay loading data for this mesh
  113724. */
  113725. delayLoadingFile: string;
  113726. /** @hidden */
  113727. _binaryInfo: any;
  113728. /**
  113729. * User defined function used to change how LOD level selection is done
  113730. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113731. */
  113732. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  113733. /**
  113734. * Gets or sets the morph target manager
  113735. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  113736. */
  113737. get morphTargetManager(): Nullable<MorphTargetManager>;
  113738. set morphTargetManager(value: Nullable<MorphTargetManager>);
  113739. /** @hidden */
  113740. _creationDataStorage: Nullable<_CreationDataStorage>;
  113741. /** @hidden */
  113742. _geometry: Nullable<Geometry>;
  113743. /** @hidden */
  113744. _delayInfo: Array<string>;
  113745. /** @hidden */
  113746. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  113747. /** @hidden */
  113748. _instanceDataStorage: _InstanceDataStorage;
  113749. /** @hidden */
  113750. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  113751. private _effectiveMaterial;
  113752. /** @hidden */
  113753. _shouldGenerateFlatShading: boolean;
  113754. /** @hidden */
  113755. _originalBuilderSideOrientation: number;
  113756. /**
  113757. * Use this property to change the original side orientation defined at construction time
  113758. */
  113759. overrideMaterialSideOrientation: Nullable<number>;
  113760. /**
  113761. * Gets the source mesh (the one used to clone this one from)
  113762. */
  113763. get source(): Nullable<Mesh>;
  113764. /**
  113765. * Gets the list of clones of this mesh
  113766. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  113767. * Note that useClonedMeshMap=true is the default setting
  113768. */
  113769. get cloneMeshMap(): Nullable<{
  113770. [id: string]: Mesh | undefined;
  113771. }>;
  113772. /**
  113773. * Gets or sets a boolean indicating that this mesh does not use index buffer
  113774. */
  113775. get isUnIndexed(): boolean;
  113776. set isUnIndexed(value: boolean);
  113777. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  113778. get worldMatrixInstancedBuffer(): Float32Array;
  113779. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  113780. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  113781. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  113782. /**
  113783. * @constructor
  113784. * @param name The value used by scene.getMeshByName() to do a lookup.
  113785. * @param scene The scene to add this mesh to.
  113786. * @param parent The parent of this mesh, if it has one
  113787. * @param source An optional Mesh from which geometry is shared, cloned.
  113788. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  113789. * When false, achieved by calling a clone(), also passing False.
  113790. * This will make creation of children, recursive.
  113791. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  113792. */
  113793. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  113794. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  113795. doNotInstantiate: boolean;
  113796. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  113797. /**
  113798. * Gets the class name
  113799. * @returns the string "Mesh".
  113800. */
  113801. getClassName(): string;
  113802. /** @hidden */
  113803. get _isMesh(): boolean;
  113804. /**
  113805. * Returns a description of this mesh
  113806. * @param fullDetails define if full details about this mesh must be used
  113807. * @returns a descriptive string representing this mesh
  113808. */
  113809. toString(fullDetails?: boolean): string;
  113810. /** @hidden */
  113811. _unBindEffect(): void;
  113812. /**
  113813. * Gets a boolean indicating if this mesh has LOD
  113814. */
  113815. get hasLODLevels(): boolean;
  113816. /**
  113817. * Gets the list of MeshLODLevel associated with the current mesh
  113818. * @returns an array of MeshLODLevel
  113819. */
  113820. getLODLevels(): MeshLODLevel[];
  113821. private _sortLODLevels;
  113822. /**
  113823. * Add a mesh as LOD level triggered at the given distance.
  113824. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113825. * @param distance The distance from the center of the object to show this level
  113826. * @param mesh The mesh to be added as LOD level (can be null)
  113827. * @return This mesh (for chaining)
  113828. */
  113829. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  113830. /**
  113831. * Returns the LOD level mesh at the passed distance or null if not found.
  113832. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113833. * @param distance The distance from the center of the object to show this level
  113834. * @returns a Mesh or `null`
  113835. */
  113836. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  113837. /**
  113838. * Remove a mesh from the LOD array
  113839. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113840. * @param mesh defines the mesh to be removed
  113841. * @return This mesh (for chaining)
  113842. */
  113843. removeLODLevel(mesh: Mesh): Mesh;
  113844. /**
  113845. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  113846. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113847. * @param camera defines the camera to use to compute distance
  113848. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  113849. * @return This mesh (for chaining)
  113850. */
  113851. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  113852. /**
  113853. * Gets the mesh internal Geometry object
  113854. */
  113855. get geometry(): Nullable<Geometry>;
  113856. /**
  113857. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  113858. * @returns the total number of vertices
  113859. */
  113860. getTotalVertices(): number;
  113861. /**
  113862. * Returns the content of an associated vertex buffer
  113863. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113864. * - VertexBuffer.PositionKind
  113865. * - VertexBuffer.UVKind
  113866. * - VertexBuffer.UV2Kind
  113867. * - VertexBuffer.UV3Kind
  113868. * - VertexBuffer.UV4Kind
  113869. * - VertexBuffer.UV5Kind
  113870. * - VertexBuffer.UV6Kind
  113871. * - VertexBuffer.ColorKind
  113872. * - VertexBuffer.MatricesIndicesKind
  113873. * - VertexBuffer.MatricesIndicesExtraKind
  113874. * - VertexBuffer.MatricesWeightsKind
  113875. * - VertexBuffer.MatricesWeightsExtraKind
  113876. * @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
  113877. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  113878. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  113879. */
  113880. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  113881. /**
  113882. * Returns the mesh VertexBuffer object from the requested `kind`
  113883. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113884. * - VertexBuffer.PositionKind
  113885. * - VertexBuffer.NormalKind
  113886. * - VertexBuffer.UVKind
  113887. * - VertexBuffer.UV2Kind
  113888. * - VertexBuffer.UV3Kind
  113889. * - VertexBuffer.UV4Kind
  113890. * - VertexBuffer.UV5Kind
  113891. * - VertexBuffer.UV6Kind
  113892. * - VertexBuffer.ColorKind
  113893. * - VertexBuffer.MatricesIndicesKind
  113894. * - VertexBuffer.MatricesIndicesExtraKind
  113895. * - VertexBuffer.MatricesWeightsKind
  113896. * - VertexBuffer.MatricesWeightsExtraKind
  113897. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  113898. */
  113899. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  113900. /**
  113901. * Tests if a specific vertex buffer is associated with this mesh
  113902. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  113903. * - VertexBuffer.PositionKind
  113904. * - VertexBuffer.NormalKind
  113905. * - VertexBuffer.UVKind
  113906. * - VertexBuffer.UV2Kind
  113907. * - VertexBuffer.UV3Kind
  113908. * - VertexBuffer.UV4Kind
  113909. * - VertexBuffer.UV5Kind
  113910. * - VertexBuffer.UV6Kind
  113911. * - VertexBuffer.ColorKind
  113912. * - VertexBuffer.MatricesIndicesKind
  113913. * - VertexBuffer.MatricesIndicesExtraKind
  113914. * - VertexBuffer.MatricesWeightsKind
  113915. * - VertexBuffer.MatricesWeightsExtraKind
  113916. * @returns a boolean
  113917. */
  113918. isVerticesDataPresent(kind: string): boolean;
  113919. /**
  113920. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  113921. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  113922. * - VertexBuffer.PositionKind
  113923. * - VertexBuffer.UVKind
  113924. * - VertexBuffer.UV2Kind
  113925. * - VertexBuffer.UV3Kind
  113926. * - VertexBuffer.UV4Kind
  113927. * - VertexBuffer.UV5Kind
  113928. * - VertexBuffer.UV6Kind
  113929. * - VertexBuffer.ColorKind
  113930. * - VertexBuffer.MatricesIndicesKind
  113931. * - VertexBuffer.MatricesIndicesExtraKind
  113932. * - VertexBuffer.MatricesWeightsKind
  113933. * - VertexBuffer.MatricesWeightsExtraKind
  113934. * @returns a boolean
  113935. */
  113936. isVertexBufferUpdatable(kind: string): boolean;
  113937. /**
  113938. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  113939. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113940. * - VertexBuffer.PositionKind
  113941. * - VertexBuffer.NormalKind
  113942. * - VertexBuffer.UVKind
  113943. * - VertexBuffer.UV2Kind
  113944. * - VertexBuffer.UV3Kind
  113945. * - VertexBuffer.UV4Kind
  113946. * - VertexBuffer.UV5Kind
  113947. * - VertexBuffer.UV6Kind
  113948. * - VertexBuffer.ColorKind
  113949. * - VertexBuffer.MatricesIndicesKind
  113950. * - VertexBuffer.MatricesIndicesExtraKind
  113951. * - VertexBuffer.MatricesWeightsKind
  113952. * - VertexBuffer.MatricesWeightsExtraKind
  113953. * @returns an array of strings
  113954. */
  113955. getVerticesDataKinds(): string[];
  113956. /**
  113957. * Returns a positive integer : the total number of indices in this mesh geometry.
  113958. * @returns the numner of indices or zero if the mesh has no geometry.
  113959. */
  113960. getTotalIndices(): number;
  113961. /**
  113962. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  113963. * @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.
  113964. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  113965. * @returns the indices array or an empty array if the mesh has no geometry
  113966. */
  113967. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  113968. get isBlocked(): boolean;
  113969. /**
  113970. * Determine if the current mesh is ready to be rendered
  113971. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113972. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  113973. * @returns true if all associated assets are ready (material, textures, shaders)
  113974. */
  113975. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  113976. /**
  113977. * 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.
  113978. */
  113979. get areNormalsFrozen(): boolean;
  113980. /**
  113981. * 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.
  113982. * @returns the current mesh
  113983. */
  113984. freezeNormals(): Mesh;
  113985. /**
  113986. * 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
  113987. * @returns the current mesh
  113988. */
  113989. unfreezeNormals(): Mesh;
  113990. /**
  113991. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  113992. */
  113993. set overridenInstanceCount(count: number);
  113994. /** @hidden */
  113995. _preActivate(): Mesh;
  113996. /** @hidden */
  113997. _preActivateForIntermediateRendering(renderId: number): Mesh;
  113998. /** @hidden */
  113999. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  114000. protected _afterComputeWorldMatrix(): void;
  114001. /** @hidden */
  114002. _postActivate(): void;
  114003. /**
  114004. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  114005. * This means the mesh underlying bounding box and sphere are recomputed.
  114006. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  114007. * @returns the current mesh
  114008. */
  114009. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  114010. /** @hidden */
  114011. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  114012. /**
  114013. * This function will subdivide the mesh into multiple submeshes
  114014. * @param count defines the expected number of submeshes
  114015. */
  114016. subdivide(count: number): void;
  114017. /**
  114018. * Copy a FloatArray into a specific associated vertex buffer
  114019. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  114020. * - VertexBuffer.PositionKind
  114021. * - VertexBuffer.UVKind
  114022. * - VertexBuffer.UV2Kind
  114023. * - VertexBuffer.UV3Kind
  114024. * - VertexBuffer.UV4Kind
  114025. * - VertexBuffer.UV5Kind
  114026. * - VertexBuffer.UV6Kind
  114027. * - VertexBuffer.ColorKind
  114028. * - VertexBuffer.MatricesIndicesKind
  114029. * - VertexBuffer.MatricesIndicesExtraKind
  114030. * - VertexBuffer.MatricesWeightsKind
  114031. * - VertexBuffer.MatricesWeightsExtraKind
  114032. * @param data defines the data source
  114033. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  114034. * @param stride defines the data stride size (can be null)
  114035. * @returns the current mesh
  114036. */
  114037. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  114038. /**
  114039. * Delete a vertex buffer associated with this mesh
  114040. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  114041. * - VertexBuffer.PositionKind
  114042. * - VertexBuffer.UVKind
  114043. * - VertexBuffer.UV2Kind
  114044. * - VertexBuffer.UV3Kind
  114045. * - VertexBuffer.UV4Kind
  114046. * - VertexBuffer.UV5Kind
  114047. * - VertexBuffer.UV6Kind
  114048. * - VertexBuffer.ColorKind
  114049. * - VertexBuffer.MatricesIndicesKind
  114050. * - VertexBuffer.MatricesIndicesExtraKind
  114051. * - VertexBuffer.MatricesWeightsKind
  114052. * - VertexBuffer.MatricesWeightsExtraKind
  114053. */
  114054. removeVerticesData(kind: string): void;
  114055. /**
  114056. * Flags an associated vertex buffer as updatable
  114057. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  114058. * - VertexBuffer.PositionKind
  114059. * - VertexBuffer.UVKind
  114060. * - VertexBuffer.UV2Kind
  114061. * - VertexBuffer.UV3Kind
  114062. * - VertexBuffer.UV4Kind
  114063. * - VertexBuffer.UV5Kind
  114064. * - VertexBuffer.UV6Kind
  114065. * - VertexBuffer.ColorKind
  114066. * - VertexBuffer.MatricesIndicesKind
  114067. * - VertexBuffer.MatricesIndicesExtraKind
  114068. * - VertexBuffer.MatricesWeightsKind
  114069. * - VertexBuffer.MatricesWeightsExtraKind
  114070. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  114071. */
  114072. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  114073. /**
  114074. * Sets the mesh global Vertex Buffer
  114075. * @param buffer defines the buffer to use
  114076. * @returns the current mesh
  114077. */
  114078. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  114079. /**
  114080. * Update a specific associated vertex buffer
  114081. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  114082. * - VertexBuffer.PositionKind
  114083. * - VertexBuffer.UVKind
  114084. * - VertexBuffer.UV2Kind
  114085. * - VertexBuffer.UV3Kind
  114086. * - VertexBuffer.UV4Kind
  114087. * - VertexBuffer.UV5Kind
  114088. * - VertexBuffer.UV6Kind
  114089. * - VertexBuffer.ColorKind
  114090. * - VertexBuffer.MatricesIndicesKind
  114091. * - VertexBuffer.MatricesIndicesExtraKind
  114092. * - VertexBuffer.MatricesWeightsKind
  114093. * - VertexBuffer.MatricesWeightsExtraKind
  114094. * @param data defines the data source
  114095. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  114096. * @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)
  114097. * @returns the current mesh
  114098. */
  114099. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  114100. /**
  114101. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  114102. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  114103. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  114104. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  114105. * @returns the current mesh
  114106. */
  114107. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  114108. /**
  114109. * Creates a un-shared specific occurence of the geometry for the mesh.
  114110. * @returns the current mesh
  114111. */
  114112. makeGeometryUnique(): Mesh;
  114113. /**
  114114. * Set the index buffer of this mesh
  114115. * @param indices defines the source data
  114116. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  114117. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  114118. * @returns the current mesh
  114119. */
  114120. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  114121. /**
  114122. * Update the current index buffer
  114123. * @param indices defines the source data
  114124. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  114125. * @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)
  114126. * @returns the current mesh
  114127. */
  114128. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  114129. /**
  114130. * Invert the geometry to move from a right handed system to a left handed one.
  114131. * @returns the current mesh
  114132. */
  114133. toLeftHanded(): Mesh;
  114134. /** @hidden */
  114135. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  114136. /** @hidden */
  114137. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  114138. /**
  114139. * Registers for this mesh a javascript function called just before the rendering process
  114140. * @param func defines the function to call before rendering this mesh
  114141. * @returns the current mesh
  114142. */
  114143. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  114144. /**
  114145. * Disposes a previously registered javascript function called before the rendering
  114146. * @param func defines the function to remove
  114147. * @returns the current mesh
  114148. */
  114149. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  114150. /**
  114151. * Registers for this mesh a javascript function called just after the rendering is complete
  114152. * @param func defines the function to call after rendering this mesh
  114153. * @returns the current mesh
  114154. */
  114155. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  114156. /**
  114157. * Disposes a previously registered javascript function called after the rendering.
  114158. * @param func defines the function to remove
  114159. * @returns the current mesh
  114160. */
  114161. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  114162. /** @hidden */
  114163. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  114164. /** @hidden */
  114165. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  114166. /** @hidden */
  114167. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  114168. /** @hidden */
  114169. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  114170. /** @hidden */
  114171. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  114172. /** @hidden */
  114173. _rebuild(): void;
  114174. /** @hidden */
  114175. _freeze(): void;
  114176. /** @hidden */
  114177. _unFreeze(): void;
  114178. /**
  114179. * 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
  114180. * @param subMesh defines the subMesh to render
  114181. * @param enableAlphaMode defines if alpha mode can be changed
  114182. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  114183. * @returns the current mesh
  114184. */
  114185. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  114186. private _onBeforeDraw;
  114187. /**
  114188. * Renormalize the mesh and patch it up if there are no weights
  114189. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  114190. * However in the case of zero weights then we set just a single influence to 1.
  114191. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  114192. */
  114193. cleanMatrixWeights(): void;
  114194. private normalizeSkinFourWeights;
  114195. private normalizeSkinWeightsAndExtra;
  114196. /**
  114197. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  114198. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  114199. * the user know there was an issue with importing the mesh
  114200. * @returns a validation object with skinned, valid and report string
  114201. */
  114202. validateSkinning(): {
  114203. skinned: boolean;
  114204. valid: boolean;
  114205. report: string;
  114206. };
  114207. /** @hidden */
  114208. _checkDelayState(): Mesh;
  114209. private _queueLoad;
  114210. /**
  114211. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  114212. * A mesh is in the frustum if its bounding box intersects the frustum
  114213. * @param frustumPlanes defines the frustum to test
  114214. * @returns true if the mesh is in the frustum planes
  114215. */
  114216. isInFrustum(frustumPlanes: Plane[]): boolean;
  114217. /**
  114218. * Sets the mesh material by the material or multiMaterial `id` property
  114219. * @param id is a string identifying the material or the multiMaterial
  114220. * @returns the current mesh
  114221. */
  114222. setMaterialByID(id: string): Mesh;
  114223. /**
  114224. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  114225. * @returns an array of IAnimatable
  114226. */
  114227. getAnimatables(): IAnimatable[];
  114228. /**
  114229. * Modifies the mesh geometry according to the passed transformation matrix.
  114230. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  114231. * The mesh normals are modified using the same transformation.
  114232. * Note that, under the hood, this method sets a new VertexBuffer each call.
  114233. * @param transform defines the transform matrix to use
  114234. * @see https://doc.babylonjs.com/resources/baking_transformations
  114235. * @returns the current mesh
  114236. */
  114237. bakeTransformIntoVertices(transform: Matrix): Mesh;
  114238. /**
  114239. * Modifies the mesh geometry according to its own current World Matrix.
  114240. * The mesh World Matrix is then reset.
  114241. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  114242. * Note that, under the hood, this method sets a new VertexBuffer each call.
  114243. * @see https://doc.babylonjs.com/resources/baking_transformations
  114244. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  114245. * @returns the current mesh
  114246. */
  114247. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  114248. /** @hidden */
  114249. get _positions(): Nullable<Vector3[]>;
  114250. /** @hidden */
  114251. _resetPointsArrayCache(): Mesh;
  114252. /** @hidden */
  114253. _generatePointsArray(): boolean;
  114254. /**
  114255. * Returns a new Mesh object generated from the current mesh properties.
  114256. * This method must not get confused with createInstance()
  114257. * @param name is a string, the name given to the new mesh
  114258. * @param newParent can be any Node object (default `null`)
  114259. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  114260. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  114261. * @returns a new mesh
  114262. */
  114263. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  114264. /**
  114265. * Releases resources associated with this mesh.
  114266. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114267. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114268. */
  114269. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114270. /** @hidden */
  114271. _disposeInstanceSpecificData(): void;
  114272. /** @hidden */
  114273. _disposeThinInstanceSpecificData(): void;
  114274. /**
  114275. * Modifies the mesh geometry according to a displacement map.
  114276. * 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.
  114277. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  114278. * @param url is a string, the URL from the image file is to be downloaded.
  114279. * @param minHeight is the lower limit of the displacement.
  114280. * @param maxHeight is the upper limit of the displacement.
  114281. * @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.
  114282. * @param uvOffset is an optional vector2 used to offset UV.
  114283. * @param uvScale is an optional vector2 used to scale UV.
  114284. * @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.
  114285. * @returns the Mesh.
  114286. */
  114287. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  114288. /**
  114289. * Modifies the mesh geometry according to a displacementMap buffer.
  114290. * 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.
  114291. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  114292. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  114293. * @param heightMapWidth is the width of the buffer image.
  114294. * @param heightMapHeight is the height of the buffer image.
  114295. * @param minHeight is the lower limit of the displacement.
  114296. * @param maxHeight is the upper limit of the displacement.
  114297. * @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.
  114298. * @param uvOffset is an optional vector2 used to offset UV.
  114299. * @param uvScale is an optional vector2 used to scale UV.
  114300. * @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.
  114301. * @returns the Mesh.
  114302. */
  114303. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  114304. /**
  114305. * Modify the mesh to get a flat shading rendering.
  114306. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  114307. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  114308. * @returns current mesh
  114309. */
  114310. convertToFlatShadedMesh(): Mesh;
  114311. /**
  114312. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  114313. * In other words, more vertices, no more indices and a single bigger VBO.
  114314. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  114315. * @returns current mesh
  114316. */
  114317. convertToUnIndexedMesh(): Mesh;
  114318. /**
  114319. * Inverses facet orientations.
  114320. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114321. * @param flipNormals will also inverts the normals
  114322. * @returns current mesh
  114323. */
  114324. flipFaces(flipNormals?: boolean): Mesh;
  114325. /**
  114326. * Increase the number of facets and hence vertices in a mesh
  114327. * Vertex normals are interpolated from existing vertex normals
  114328. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114329. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  114330. */
  114331. increaseVertices(numberPerEdge: number): void;
  114332. /**
  114333. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  114334. * This will undo any application of covertToFlatShadedMesh
  114335. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114336. */
  114337. forceSharedVertices(): void;
  114338. /** @hidden */
  114339. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  114340. /** @hidden */
  114341. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  114342. /**
  114343. * Creates a new InstancedMesh object from the mesh model.
  114344. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114345. * @param name defines the name of the new instance
  114346. * @returns a new InstancedMesh
  114347. */
  114348. createInstance(name: string): InstancedMesh;
  114349. /**
  114350. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  114351. * After this call, all the mesh instances have the same submeshes than the current mesh.
  114352. * @returns the current mesh
  114353. */
  114354. synchronizeInstances(): Mesh;
  114355. /**
  114356. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  114357. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  114358. * This should be used together with the simplification to avoid disappearing triangles.
  114359. * @param successCallback an optional success callback to be called after the optimization finished.
  114360. * @returns the current mesh
  114361. */
  114362. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  114363. /**
  114364. * Serialize current mesh
  114365. * @param serializationObject defines the object which will receive the serialization data
  114366. */
  114367. serialize(serializationObject: any): void;
  114368. /** @hidden */
  114369. _syncGeometryWithMorphTargetManager(): void;
  114370. /** @hidden */
  114371. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  114372. /**
  114373. * Returns a new Mesh object parsed from the source provided.
  114374. * @param parsedMesh is the source
  114375. * @param scene defines the hosting scene
  114376. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  114377. * @returns a new Mesh
  114378. */
  114379. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  114380. /**
  114381. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  114382. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114383. * @param name defines the name of the mesh to create
  114384. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  114385. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  114386. * @param closePath creates a seam between the first and the last points of each path of the path array
  114387. * @param offset is taken in account only if the `pathArray` is containing a single path
  114388. * @param scene defines the hosting scene
  114389. * @param updatable defines if the mesh must be flagged as updatable
  114390. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114391. * @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)
  114392. * @returns a new Mesh
  114393. */
  114394. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114395. /**
  114396. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  114397. * @param name defines the name of the mesh to create
  114398. * @param radius sets the radius size (float) of the polygon (default 0.5)
  114399. * @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
  114400. * @param scene defines the hosting scene
  114401. * @param updatable defines if the mesh must be flagged as updatable
  114402. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114403. * @returns a new Mesh
  114404. */
  114405. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114406. /**
  114407. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  114408. * @param name defines the name of the mesh to create
  114409. * @param size sets the size (float) of each box side (default 1)
  114410. * @param scene defines the hosting scene
  114411. * @param updatable defines if the mesh must be flagged as updatable
  114412. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114413. * @returns a new Mesh
  114414. */
  114415. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114416. /**
  114417. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  114418. * @param name defines the name of the mesh to create
  114419. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114420. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114421. * @param scene defines the hosting scene
  114422. * @param updatable defines if the mesh must be flagged as updatable
  114423. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114424. * @returns a new Mesh
  114425. */
  114426. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114427. /**
  114428. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  114429. * @param name defines the name of the mesh to create
  114430. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114431. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114432. * @param scene defines the hosting scene
  114433. * @returns a new Mesh
  114434. */
  114435. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  114436. /**
  114437. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  114438. * @param name defines the name of the mesh to create
  114439. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  114440. * @param diameterTop set the top cap diameter (floats, default 1)
  114441. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  114442. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  114443. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  114444. * @param scene defines the hosting scene
  114445. * @param updatable defines if the mesh must be flagged as updatable
  114446. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114447. * @returns a new Mesh
  114448. */
  114449. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  114450. /**
  114451. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  114452. * @param name defines the name of the mesh to create
  114453. * @param diameter sets the diameter size (float) of the torus (default 1)
  114454. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  114455. * @param tessellation sets the number of torus sides (postive integer, default 16)
  114456. * @param scene defines the hosting scene
  114457. * @param updatable defines if the mesh must be flagged as updatable
  114458. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114459. * @returns a new Mesh
  114460. */
  114461. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114462. /**
  114463. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  114464. * @param name defines the name of the mesh to create
  114465. * @param radius sets the global radius size (float) of the torus knot (default 2)
  114466. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  114467. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  114468. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  114469. * @param p the number of windings on X axis (positive integers, default 2)
  114470. * @param q the number of windings on Y axis (positive integers, default 3)
  114471. * @param scene defines the hosting scene
  114472. * @param updatable defines if the mesh must be flagged as updatable
  114473. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114474. * @returns a new Mesh
  114475. */
  114476. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114477. /**
  114478. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  114479. * @param name defines the name of the mesh to create
  114480. * @param points is an array successive Vector3
  114481. * @param scene defines the hosting scene
  114482. * @param updatable defines if the mesh must be flagged as updatable
  114483. * @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).
  114484. * @returns a new Mesh
  114485. */
  114486. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  114487. /**
  114488. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  114489. * @param name defines the name of the mesh to create
  114490. * @param points is an array successive Vector3
  114491. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  114492. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  114493. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  114494. * @param scene defines the hosting scene
  114495. * @param updatable defines if the mesh must be flagged as updatable
  114496. * @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)
  114497. * @returns a new Mesh
  114498. */
  114499. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  114500. /**
  114501. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  114502. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  114503. * 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.
  114504. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114505. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114506. * Remember you can only change the shape positions, not their number when updating a polygon.
  114507. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  114508. * @param name defines the name of the mesh to create
  114509. * @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
  114510. * @param scene defines the hosting scene
  114511. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114512. * @param updatable defines if the mesh must be flagged as updatable
  114513. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114514. * @param earcutInjection can be used to inject your own earcut reference
  114515. * @returns a new Mesh
  114516. */
  114517. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114518. /**
  114519. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  114520. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  114521. * @param name defines the name of the mesh to create
  114522. * @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
  114523. * @param depth defines the height of extrusion
  114524. * @param scene defines the hosting scene
  114525. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114526. * @param updatable defines if the mesh must be flagged as updatable
  114527. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114528. * @param earcutInjection can be used to inject your own earcut reference
  114529. * @returns a new Mesh
  114530. */
  114531. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114532. /**
  114533. * Creates an extruded shape mesh.
  114534. * 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
  114535. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114536. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114537. * @param name defines the name of the mesh to create
  114538. * @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
  114539. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114540. * @param scale is the value to scale the shape
  114541. * @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
  114542. * @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
  114543. * @param scene defines the hosting scene
  114544. * @param updatable defines if the mesh must be flagged as updatable
  114545. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114546. * @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)
  114547. * @returns a new Mesh
  114548. */
  114549. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114550. /**
  114551. * Creates an custom extruded shape mesh.
  114552. * The custom extrusion is a parametric shape.
  114553. * It has no predefined shape. Its final shape will depend on the input parameters.
  114554. * Please consider using the same method from the MeshBuilder class instead
  114555. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114556. * @param name defines the name of the mesh to create
  114557. * @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
  114558. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114559. * @param scaleFunction is a custom Javascript function called on each path point
  114560. * @param rotationFunction is a custom Javascript function called on each path point
  114561. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  114562. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  114563. * @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
  114564. * @param scene defines the hosting scene
  114565. * @param updatable defines if the mesh must be flagged as updatable
  114566. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114567. * @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)
  114568. * @returns a new Mesh
  114569. */
  114570. 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;
  114571. /**
  114572. * Creates lathe mesh.
  114573. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  114574. * Please consider using the same method from the MeshBuilder class instead
  114575. * @param name defines the name of the mesh to create
  114576. * @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
  114577. * @param radius is the radius value of the lathe
  114578. * @param tessellation is the side number of the lathe.
  114579. * @param scene defines the hosting scene
  114580. * @param updatable defines if the mesh must be flagged as updatable
  114581. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114582. * @returns a new Mesh
  114583. */
  114584. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114585. /**
  114586. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  114587. * @param name defines the name of the mesh to create
  114588. * @param size sets the size (float) of both sides of the plane at once (default 1)
  114589. * @param scene defines the hosting scene
  114590. * @param updatable defines if the mesh must be flagged as updatable
  114591. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114592. * @returns a new Mesh
  114593. */
  114594. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114595. /**
  114596. * Creates a ground mesh.
  114597. * Please consider using the same method from the MeshBuilder class instead
  114598. * @param name defines the name of the mesh to create
  114599. * @param width set the width of the ground
  114600. * @param height set the height of the ground
  114601. * @param subdivisions sets the number of subdivisions per side
  114602. * @param scene defines the hosting scene
  114603. * @param updatable defines if the mesh must be flagged as updatable
  114604. * @returns a new Mesh
  114605. */
  114606. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  114607. /**
  114608. * Creates a tiled ground mesh.
  114609. * Please consider using the same method from the MeshBuilder class instead
  114610. * @param name defines the name of the mesh to create
  114611. * @param xmin set the ground minimum X coordinate
  114612. * @param zmin set the ground minimum Y coordinate
  114613. * @param xmax set the ground maximum X coordinate
  114614. * @param zmax set the ground maximum Z coordinate
  114615. * @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
  114616. * @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
  114617. * @param scene defines the hosting scene
  114618. * @param updatable defines if the mesh must be flagged as updatable
  114619. * @returns a new Mesh
  114620. */
  114621. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  114622. w: number;
  114623. h: number;
  114624. }, precision: {
  114625. w: number;
  114626. h: number;
  114627. }, scene: Scene, updatable?: boolean): Mesh;
  114628. /**
  114629. * Creates a ground mesh from a height map.
  114630. * Please consider using the same method from the MeshBuilder class instead
  114631. * @see https://doc.babylonjs.com/babylon101/height_map
  114632. * @param name defines the name of the mesh to create
  114633. * @param url sets the URL of the height map image resource
  114634. * @param width set the ground width size
  114635. * @param height set the ground height size
  114636. * @param subdivisions sets the number of subdivision per side
  114637. * @param minHeight is the minimum altitude on the ground
  114638. * @param maxHeight is the maximum altitude on the ground
  114639. * @param scene defines the hosting scene
  114640. * @param updatable defines if the mesh must be flagged as updatable
  114641. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  114642. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  114643. * @returns a new Mesh
  114644. */
  114645. 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;
  114646. /**
  114647. * Creates a tube mesh.
  114648. * The tube is a parametric shape.
  114649. * It has no predefined shape. Its final shape will depend on the input parameters.
  114650. * Please consider using the same method from the MeshBuilder class instead
  114651. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114652. * @param name defines the name of the mesh to create
  114653. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  114654. * @param radius sets the tube radius size
  114655. * @param tessellation is the number of sides on the tubular surface
  114656. * @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
  114657. * @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
  114658. * @param scene defines the hosting scene
  114659. * @param updatable defines if the mesh must be flagged as updatable
  114660. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114661. * @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)
  114662. * @returns a new Mesh
  114663. */
  114664. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  114665. (i: number, distance: number): number;
  114666. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114667. /**
  114668. * Creates a polyhedron mesh.
  114669. * Please consider using the same method from the MeshBuilder class instead.
  114670. * * 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
  114671. * * The parameter `size` (positive float, default 1) sets the polygon size
  114672. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  114673. * * 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`
  114674. * * 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
  114675. * * 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)`)
  114676. * * 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
  114677. * * 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
  114678. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114679. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114681. * @param name defines the name of the mesh to create
  114682. * @param options defines the options used to create the mesh
  114683. * @param scene defines the hosting scene
  114684. * @returns a new Mesh
  114685. */
  114686. static CreatePolyhedron(name: string, options: {
  114687. type?: number;
  114688. size?: number;
  114689. sizeX?: number;
  114690. sizeY?: number;
  114691. sizeZ?: number;
  114692. custom?: any;
  114693. faceUV?: Vector4[];
  114694. faceColors?: Color4[];
  114695. updatable?: boolean;
  114696. sideOrientation?: number;
  114697. }, scene: Scene): Mesh;
  114698. /**
  114699. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114700. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114701. * * 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`)
  114702. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114703. * * 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
  114704. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114705. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114707. * @param name defines the name of the mesh
  114708. * @param options defines the options used to create the mesh
  114709. * @param scene defines the hosting scene
  114710. * @returns a new Mesh
  114711. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114712. */
  114713. static CreateIcoSphere(name: string, options: {
  114714. radius?: number;
  114715. flat?: boolean;
  114716. subdivisions?: number;
  114717. sideOrientation?: number;
  114718. updatable?: boolean;
  114719. }, scene: Scene): Mesh;
  114720. /**
  114721. * Creates a decal mesh.
  114722. * Please consider using the same method from the MeshBuilder class instead.
  114723. * A decal is a mesh usually applied as a model onto the surface of another mesh
  114724. * @param name defines the name of the mesh
  114725. * @param sourceMesh defines the mesh receiving the decal
  114726. * @param position sets the position of the decal in world coordinates
  114727. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  114728. * @param size sets the decal scaling
  114729. * @param angle sets the angle to rotate the decal
  114730. * @returns a new Mesh
  114731. */
  114732. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  114733. /** Creates a Capsule Mesh
  114734. * @param name defines the name of the mesh.
  114735. * @param options the constructors options used to shape the mesh.
  114736. * @param scene defines the scene the mesh is scoped to.
  114737. * @returns the capsule mesh
  114738. * @see https://doc.babylonjs.com/how_to/capsule_shape
  114739. */
  114740. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  114741. /**
  114742. * Prepare internal position array for software CPU skinning
  114743. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  114744. */
  114745. setPositionsForCPUSkinning(): Float32Array;
  114746. /**
  114747. * Prepare internal normal array for software CPU skinning
  114748. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  114749. */
  114750. setNormalsForCPUSkinning(): Float32Array;
  114751. /**
  114752. * Updates the vertex buffer by applying transformation from the bones
  114753. * @param skeleton defines the skeleton to apply to current mesh
  114754. * @returns the current mesh
  114755. */
  114756. applySkeleton(skeleton: Skeleton): Mesh;
  114757. /**
  114758. * 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
  114759. * @param meshes defines the list of meshes to scan
  114760. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  114761. */
  114762. static MinMax(meshes: AbstractMesh[]): {
  114763. min: Vector3;
  114764. max: Vector3;
  114765. };
  114766. /**
  114767. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  114768. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  114769. * @returns a vector3
  114770. */
  114771. static Center(meshesOrMinMaxVector: {
  114772. min: Vector3;
  114773. max: Vector3;
  114774. } | AbstractMesh[]): Vector3;
  114775. /**
  114776. * Merge the array of meshes into a single mesh for performance reasons.
  114777. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  114778. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  114779. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  114780. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  114781. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  114782. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  114783. * @returns a new mesh
  114784. */
  114785. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  114786. /** @hidden */
  114787. addInstance(instance: InstancedMesh): void;
  114788. /** @hidden */
  114789. removeInstance(instance: InstancedMesh): void;
  114790. }
  114791. }
  114792. declare module BABYLON {
  114793. /**
  114794. * The options Interface for creating a Capsule Mesh
  114795. */
  114796. export interface ICreateCapsuleOptions {
  114797. /** The Orientation of the capsule. Default : Vector3.Up() */
  114798. orientation?: Vector3;
  114799. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  114800. subdivisions: number;
  114801. /** Number of cylindrical segments on the capsule. */
  114802. tessellation: number;
  114803. /** Height or Length of the capsule. */
  114804. height: number;
  114805. /** Radius of the capsule. */
  114806. radius: number;
  114807. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  114808. capSubdivisions: number;
  114809. /** Overwrite for the top radius. */
  114810. radiusTop?: number;
  114811. /** Overwrite for the bottom radius. */
  114812. radiusBottom?: number;
  114813. /** Overwrite for the top capSubdivisions. */
  114814. topCapSubdivisions?: number;
  114815. /** Overwrite for the bottom capSubdivisions. */
  114816. bottomCapSubdivisions?: number;
  114817. }
  114818. /**
  114819. * Class containing static functions to help procedurally build meshes
  114820. */
  114821. export class CapsuleBuilder {
  114822. /**
  114823. * Creates a capsule or a pill mesh
  114824. * @param name defines the name of the mesh
  114825. * @param options The constructors options.
  114826. * @param scene The scene the mesh is scoped to.
  114827. * @returns Capsule Mesh
  114828. */
  114829. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  114830. }
  114831. }
  114832. declare module BABYLON {
  114833. /**
  114834. * Define an interface for all classes that will get and set the data on vertices
  114835. */
  114836. export interface IGetSetVerticesData {
  114837. /**
  114838. * Gets a boolean indicating if specific vertex data is present
  114839. * @param kind defines the vertex data kind to use
  114840. * @returns true is data kind is present
  114841. */
  114842. isVerticesDataPresent(kind: string): boolean;
  114843. /**
  114844. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  114845. * @param kind defines the data kind (Position, normal, etc...)
  114846. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  114847. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  114848. * @returns a float array containing vertex data
  114849. */
  114850. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  114851. /**
  114852. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  114853. * @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.
  114854. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  114855. * @returns the indices array or an empty array if the mesh has no geometry
  114856. */
  114857. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  114858. /**
  114859. * Set specific vertex data
  114860. * @param kind defines the data kind (Position, normal, etc...)
  114861. * @param data defines the vertex data to use
  114862. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  114863. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  114864. */
  114865. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  114866. /**
  114867. * Update a specific associated vertex buffer
  114868. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  114869. * - VertexBuffer.PositionKind
  114870. * - VertexBuffer.UVKind
  114871. * - VertexBuffer.UV2Kind
  114872. * - VertexBuffer.UV3Kind
  114873. * - VertexBuffer.UV4Kind
  114874. * - VertexBuffer.UV5Kind
  114875. * - VertexBuffer.UV6Kind
  114876. * - VertexBuffer.ColorKind
  114877. * - VertexBuffer.MatricesIndicesKind
  114878. * - VertexBuffer.MatricesIndicesExtraKind
  114879. * - VertexBuffer.MatricesWeightsKind
  114880. * - VertexBuffer.MatricesWeightsExtraKind
  114881. * @param data defines the data source
  114882. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  114883. * @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)
  114884. */
  114885. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  114886. /**
  114887. * Creates a new index buffer
  114888. * @param indices defines the indices to store in the index buffer
  114889. * @param totalVertices defines the total number of vertices (could be null)
  114890. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  114891. */
  114892. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  114893. }
  114894. /**
  114895. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  114896. */
  114897. export class VertexData {
  114898. /**
  114899. * Mesh side orientation : usually the external or front surface
  114900. */
  114901. static readonly FRONTSIDE: number;
  114902. /**
  114903. * Mesh side orientation : usually the internal or back surface
  114904. */
  114905. static readonly BACKSIDE: number;
  114906. /**
  114907. * Mesh side orientation : both internal and external or front and back surfaces
  114908. */
  114909. static readonly DOUBLESIDE: number;
  114910. /**
  114911. * Mesh side orientation : by default, `FRONTSIDE`
  114912. */
  114913. static readonly DEFAULTSIDE: number;
  114914. /**
  114915. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  114916. */
  114917. positions: Nullable<FloatArray>;
  114918. /**
  114919. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  114920. */
  114921. normals: Nullable<FloatArray>;
  114922. /**
  114923. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  114924. */
  114925. tangents: Nullable<FloatArray>;
  114926. /**
  114927. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  114928. */
  114929. uvs: Nullable<FloatArray>;
  114930. /**
  114931. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  114932. */
  114933. uvs2: Nullable<FloatArray>;
  114934. /**
  114935. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  114936. */
  114937. uvs3: Nullable<FloatArray>;
  114938. /**
  114939. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  114940. */
  114941. uvs4: Nullable<FloatArray>;
  114942. /**
  114943. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  114944. */
  114945. uvs5: Nullable<FloatArray>;
  114946. /**
  114947. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  114948. */
  114949. uvs6: Nullable<FloatArray>;
  114950. /**
  114951. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  114952. */
  114953. colors: Nullable<FloatArray>;
  114954. /**
  114955. * 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).
  114956. */
  114957. matricesIndices: Nullable<FloatArray>;
  114958. /**
  114959. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  114960. */
  114961. matricesWeights: Nullable<FloatArray>;
  114962. /**
  114963. * An array extending the number of possible indices
  114964. */
  114965. matricesIndicesExtra: Nullable<FloatArray>;
  114966. /**
  114967. * An array extending the number of possible weights when the number of indices is extended
  114968. */
  114969. matricesWeightsExtra: Nullable<FloatArray>;
  114970. /**
  114971. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  114972. */
  114973. indices: Nullable<IndicesArray>;
  114974. /**
  114975. * Uses the passed data array to set the set the values for the specified kind of data
  114976. * @param data a linear array of floating numbers
  114977. * @param kind the type of data that is being set, eg positions, colors etc
  114978. */
  114979. set(data: FloatArray, kind: string): void;
  114980. /**
  114981. * Associates the vertexData to the passed Mesh.
  114982. * Sets it as updatable or not (default `false`)
  114983. * @param mesh the mesh the vertexData is applied to
  114984. * @param updatable when used and having the value true allows new data to update the vertexData
  114985. * @returns the VertexData
  114986. */
  114987. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  114988. /**
  114989. * Associates the vertexData to the passed Geometry.
  114990. * Sets it as updatable or not (default `false`)
  114991. * @param geometry the geometry the vertexData is applied to
  114992. * @param updatable when used and having the value true allows new data to update the vertexData
  114993. * @returns VertexData
  114994. */
  114995. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  114996. /**
  114997. * Updates the associated mesh
  114998. * @param mesh the mesh to be updated
  114999. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  115000. * @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
  115001. * @returns VertexData
  115002. */
  115003. updateMesh(mesh: Mesh): VertexData;
  115004. /**
  115005. * Updates the associated geometry
  115006. * @param geometry the geometry to be updated
  115007. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  115008. * @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
  115009. * @returns VertexData.
  115010. */
  115011. updateGeometry(geometry: Geometry): VertexData;
  115012. private _applyTo;
  115013. private _update;
  115014. /**
  115015. * Transforms each position and each normal of the vertexData according to the passed Matrix
  115016. * @param matrix the transforming matrix
  115017. * @returns the VertexData
  115018. */
  115019. transform(matrix: Matrix): VertexData;
  115020. /**
  115021. * Merges the passed VertexData into the current one
  115022. * @param other the VertexData to be merged into the current one
  115023. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  115024. * @returns the modified VertexData
  115025. */
  115026. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  115027. private _mergeElement;
  115028. private _validate;
  115029. /**
  115030. * Serializes the VertexData
  115031. * @returns a serialized object
  115032. */
  115033. serialize(): any;
  115034. /**
  115035. * Extracts the vertexData from a mesh
  115036. * @param mesh the mesh from which to extract the VertexData
  115037. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  115038. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  115039. * @returns the object VertexData associated to the passed mesh
  115040. */
  115041. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  115042. /**
  115043. * Extracts the vertexData from the geometry
  115044. * @param geometry the geometry from which to extract the VertexData
  115045. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  115046. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  115047. * @returns the object VertexData associated to the passed mesh
  115048. */
  115049. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  115050. private static _ExtractFrom;
  115051. /**
  115052. * Creates the VertexData for a Ribbon
  115053. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  115054. * * pathArray array of paths, each of which an array of successive Vector3
  115055. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  115056. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  115057. * * 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
  115058. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115059. * * 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)
  115060. * * 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)
  115061. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  115062. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  115063. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  115064. * @returns the VertexData of the ribbon
  115065. */
  115066. static CreateRibbon(options: {
  115067. pathArray: Vector3[][];
  115068. closeArray?: boolean;
  115069. closePath?: boolean;
  115070. offset?: number;
  115071. sideOrientation?: number;
  115072. frontUVs?: Vector4;
  115073. backUVs?: Vector4;
  115074. invertUV?: boolean;
  115075. uvs?: Vector2[];
  115076. colors?: Color4[];
  115077. }): VertexData;
  115078. /**
  115079. * Creates the VertexData for a box
  115080. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115081. * * size sets the width, height and depth of the box to the value of size, optional default 1
  115082. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  115083. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  115084. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  115085. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  115086. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  115087. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115088. * * 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)
  115089. * * 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)
  115090. * @returns the VertexData of the box
  115091. */
  115092. static CreateBox(options: {
  115093. size?: number;
  115094. width?: number;
  115095. height?: number;
  115096. depth?: number;
  115097. faceUV?: Vector4[];
  115098. faceColors?: Color4[];
  115099. sideOrientation?: number;
  115100. frontUVs?: Vector4;
  115101. backUVs?: Vector4;
  115102. }): VertexData;
  115103. /**
  115104. * Creates the VertexData for a tiled box
  115105. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115106. * * faceTiles sets the pattern, tile size and number of tiles for a face
  115107. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  115108. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  115109. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115110. * @returns the VertexData of the box
  115111. */
  115112. static CreateTiledBox(options: {
  115113. pattern?: number;
  115114. width?: number;
  115115. height?: number;
  115116. depth?: number;
  115117. tileSize?: number;
  115118. tileWidth?: number;
  115119. tileHeight?: number;
  115120. alignHorizontal?: number;
  115121. alignVertical?: number;
  115122. faceUV?: Vector4[];
  115123. faceColors?: Color4[];
  115124. sideOrientation?: number;
  115125. }): VertexData;
  115126. /**
  115127. * Creates the VertexData for a tiled plane
  115128. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115129. * * pattern a limited pattern arrangement depending on the number
  115130. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  115131. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  115132. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  115133. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115134. * * 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)
  115135. * * 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)
  115136. * @returns the VertexData of the tiled plane
  115137. */
  115138. static CreateTiledPlane(options: {
  115139. pattern?: number;
  115140. tileSize?: number;
  115141. tileWidth?: number;
  115142. tileHeight?: number;
  115143. size?: number;
  115144. width?: number;
  115145. height?: number;
  115146. alignHorizontal?: number;
  115147. alignVertical?: number;
  115148. sideOrientation?: number;
  115149. frontUVs?: Vector4;
  115150. backUVs?: Vector4;
  115151. }): VertexData;
  115152. /**
  115153. * Creates the VertexData for an ellipsoid, defaults to a sphere
  115154. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115155. * * segments sets the number of horizontal strips optional, default 32
  115156. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  115157. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  115158. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  115159. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  115160. * * 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
  115161. * * 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
  115162. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115163. * * 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)
  115164. * * 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)
  115165. * @returns the VertexData of the ellipsoid
  115166. */
  115167. static CreateSphere(options: {
  115168. segments?: number;
  115169. diameter?: number;
  115170. diameterX?: number;
  115171. diameterY?: number;
  115172. diameterZ?: number;
  115173. arc?: number;
  115174. slice?: number;
  115175. sideOrientation?: number;
  115176. frontUVs?: Vector4;
  115177. backUVs?: Vector4;
  115178. }): VertexData;
  115179. /**
  115180. * Creates the VertexData for a cylinder, cone or prism
  115181. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115182. * * height sets the height (y direction) of the cylinder, optional, default 2
  115183. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  115184. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  115185. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  115186. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  115187. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  115188. * * 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
  115189. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  115190. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  115191. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  115192. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  115193. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115194. * * 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)
  115195. * * 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)
  115196. * @returns the VertexData of the cylinder, cone or prism
  115197. */
  115198. static CreateCylinder(options: {
  115199. height?: number;
  115200. diameterTop?: number;
  115201. diameterBottom?: number;
  115202. diameter?: number;
  115203. tessellation?: number;
  115204. subdivisions?: number;
  115205. arc?: number;
  115206. faceColors?: Color4[];
  115207. faceUV?: Vector4[];
  115208. hasRings?: boolean;
  115209. enclose?: boolean;
  115210. sideOrientation?: number;
  115211. frontUVs?: Vector4;
  115212. backUVs?: Vector4;
  115213. }): VertexData;
  115214. /**
  115215. * Creates the VertexData for a torus
  115216. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115217. * * diameter the diameter of the torus, optional default 1
  115218. * * thickness the diameter of the tube forming the torus, optional default 0.5
  115219. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  115220. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115221. * * 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)
  115222. * * 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)
  115223. * @returns the VertexData of the torus
  115224. */
  115225. static CreateTorus(options: {
  115226. diameter?: number;
  115227. thickness?: number;
  115228. tessellation?: number;
  115229. sideOrientation?: number;
  115230. frontUVs?: Vector4;
  115231. backUVs?: Vector4;
  115232. }): VertexData;
  115233. /**
  115234. * Creates the VertexData of the LineSystem
  115235. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  115236. * - lines an array of lines, each line being an array of successive Vector3
  115237. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  115238. * @returns the VertexData of the LineSystem
  115239. */
  115240. static CreateLineSystem(options: {
  115241. lines: Vector3[][];
  115242. colors?: Nullable<Color4[][]>;
  115243. }): VertexData;
  115244. /**
  115245. * Create the VertexData for a DashedLines
  115246. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  115247. * - points an array successive Vector3
  115248. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  115249. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  115250. * - dashNb the intended total number of dashes, optional, default 200
  115251. * @returns the VertexData for the DashedLines
  115252. */
  115253. static CreateDashedLines(options: {
  115254. points: Vector3[];
  115255. dashSize?: number;
  115256. gapSize?: number;
  115257. dashNb?: number;
  115258. }): VertexData;
  115259. /**
  115260. * Creates the VertexData for a Ground
  115261. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  115262. * - width the width (x direction) of the ground, optional, default 1
  115263. * - height the height (z direction) of the ground, optional, default 1
  115264. * - subdivisions the number of subdivisions per side, optional, default 1
  115265. * @returns the VertexData of the Ground
  115266. */
  115267. static CreateGround(options: {
  115268. width?: number;
  115269. height?: number;
  115270. subdivisions?: number;
  115271. subdivisionsX?: number;
  115272. subdivisionsY?: number;
  115273. }): VertexData;
  115274. /**
  115275. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  115276. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  115277. * * xmin the ground minimum X coordinate, optional, default -1
  115278. * * zmin the ground minimum Z coordinate, optional, default -1
  115279. * * xmax the ground maximum X coordinate, optional, default 1
  115280. * * zmax the ground maximum Z coordinate, optional, default 1
  115281. * * 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}
  115282. * * 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}
  115283. * @returns the VertexData of the TiledGround
  115284. */
  115285. static CreateTiledGround(options: {
  115286. xmin: number;
  115287. zmin: number;
  115288. xmax: number;
  115289. zmax: number;
  115290. subdivisions?: {
  115291. w: number;
  115292. h: number;
  115293. };
  115294. precision?: {
  115295. w: number;
  115296. h: number;
  115297. };
  115298. }): VertexData;
  115299. /**
  115300. * Creates the VertexData of the Ground designed from a heightmap
  115301. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  115302. * * width the width (x direction) of the ground
  115303. * * height the height (z direction) of the ground
  115304. * * subdivisions the number of subdivisions per side
  115305. * * minHeight the minimum altitude on the ground, optional, default 0
  115306. * * maxHeight the maximum altitude on the ground, optional default 1
  115307. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  115308. * * buffer the array holding the image color data
  115309. * * bufferWidth the width of image
  115310. * * bufferHeight the height of image
  115311. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  115312. * @returns the VertexData of the Ground designed from a heightmap
  115313. */
  115314. static CreateGroundFromHeightMap(options: {
  115315. width: number;
  115316. height: number;
  115317. subdivisions: number;
  115318. minHeight: number;
  115319. maxHeight: number;
  115320. colorFilter: Color3;
  115321. buffer: Uint8Array;
  115322. bufferWidth: number;
  115323. bufferHeight: number;
  115324. alphaFilter: number;
  115325. }): VertexData;
  115326. /**
  115327. * Creates the VertexData for a Plane
  115328. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  115329. * * size sets the width and height of the plane to the value of size, optional default 1
  115330. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  115331. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  115332. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115333. * * 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)
  115334. * * 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)
  115335. * @returns the VertexData of the box
  115336. */
  115337. static CreatePlane(options: {
  115338. size?: number;
  115339. width?: number;
  115340. height?: number;
  115341. sideOrientation?: number;
  115342. frontUVs?: Vector4;
  115343. backUVs?: Vector4;
  115344. }): VertexData;
  115345. /**
  115346. * Creates the VertexData of the Disc or regular Polygon
  115347. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  115348. * * radius the radius of the disc, optional default 0.5
  115349. * * tessellation the number of polygon sides, optional, default 64
  115350. * * 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
  115351. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115352. * * 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)
  115353. * * 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)
  115354. * @returns the VertexData of the box
  115355. */
  115356. static CreateDisc(options: {
  115357. radius?: number;
  115358. tessellation?: number;
  115359. arc?: number;
  115360. sideOrientation?: number;
  115361. frontUVs?: Vector4;
  115362. backUVs?: Vector4;
  115363. }): VertexData;
  115364. /**
  115365. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  115366. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  115367. * @param polygon a mesh built from polygonTriangulation.build()
  115368. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115369. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  115370. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  115371. * @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)
  115372. * @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)
  115373. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  115374. * @returns the VertexData of the Polygon
  115375. */
  115376. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  115377. /**
  115378. * Creates the VertexData of the IcoSphere
  115379. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  115380. * * radius the radius of the IcoSphere, optional default 1
  115381. * * radiusX allows stretching in the x direction, optional, default radius
  115382. * * radiusY allows stretching in the y direction, optional, default radius
  115383. * * radiusZ allows stretching in the z direction, optional, default radius
  115384. * * flat when true creates a flat shaded mesh, optional, default true
  115385. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  115386. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115387. * * 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)
  115388. * * 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)
  115389. * @returns the VertexData of the IcoSphere
  115390. */
  115391. static CreateIcoSphere(options: {
  115392. radius?: number;
  115393. radiusX?: number;
  115394. radiusY?: number;
  115395. radiusZ?: number;
  115396. flat?: boolean;
  115397. subdivisions?: number;
  115398. sideOrientation?: number;
  115399. frontUVs?: Vector4;
  115400. backUVs?: Vector4;
  115401. }): VertexData;
  115402. /**
  115403. * Creates the VertexData for a Polyhedron
  115404. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  115405. * * type provided types are:
  115406. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  115407. * * 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)
  115408. * * size the size of the IcoSphere, optional default 1
  115409. * * sizeX allows stretching in the x direction, optional, default size
  115410. * * sizeY allows stretching in the y direction, optional, default size
  115411. * * sizeZ allows stretching in the z direction, optional, default size
  115412. * * 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
  115413. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  115414. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  115415. * * flat when true creates a flat shaded mesh, optional, default true
  115416. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  115417. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115418. * * 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)
  115419. * * 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)
  115420. * @returns the VertexData of the Polyhedron
  115421. */
  115422. static CreatePolyhedron(options: {
  115423. type?: number;
  115424. size?: number;
  115425. sizeX?: number;
  115426. sizeY?: number;
  115427. sizeZ?: number;
  115428. custom?: any;
  115429. faceUV?: Vector4[];
  115430. faceColors?: Color4[];
  115431. flat?: boolean;
  115432. sideOrientation?: number;
  115433. frontUVs?: Vector4;
  115434. backUVs?: Vector4;
  115435. }): VertexData;
  115436. /**
  115437. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  115438. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  115439. * @returns the VertexData of the Capsule
  115440. */
  115441. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  115442. /**
  115443. * Creates the VertexData for a TorusKnot
  115444. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  115445. * * radius the radius of the torus knot, optional, default 2
  115446. * * tube the thickness of the tube, optional, default 0.5
  115447. * * radialSegments the number of sides on each tube segments, optional, default 32
  115448. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  115449. * * p the number of windings around the z axis, optional, default 2
  115450. * * q the number of windings around the x axis, optional, default 3
  115451. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115452. * * 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)
  115453. * * 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)
  115454. * @returns the VertexData of the Torus Knot
  115455. */
  115456. static CreateTorusKnot(options: {
  115457. radius?: number;
  115458. tube?: number;
  115459. radialSegments?: number;
  115460. tubularSegments?: number;
  115461. p?: number;
  115462. q?: number;
  115463. sideOrientation?: number;
  115464. frontUVs?: Vector4;
  115465. backUVs?: Vector4;
  115466. }): VertexData;
  115467. /**
  115468. * Compute normals for given positions and indices
  115469. * @param positions an array of vertex positions, [...., x, y, z, ......]
  115470. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  115471. * @param normals an array of vertex normals, [...., x, y, z, ......]
  115472. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  115473. * * facetNormals : optional array of facet normals (vector3)
  115474. * * facetPositions : optional array of facet positions (vector3)
  115475. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  115476. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  115477. * * bInfo : optional bounding info, required for facetPartitioning computation
  115478. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  115479. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  115480. * * useRightHandedSystem: optional boolean to for right handed system computation
  115481. * * depthSort : optional boolean to enable the facet depth sort computation
  115482. * * distanceTo : optional Vector3 to compute the facet depth from this location
  115483. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  115484. */
  115485. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  115486. facetNormals?: any;
  115487. facetPositions?: any;
  115488. facetPartitioning?: any;
  115489. ratio?: number;
  115490. bInfo?: any;
  115491. bbSize?: Vector3;
  115492. subDiv?: any;
  115493. useRightHandedSystem?: boolean;
  115494. depthSort?: boolean;
  115495. distanceTo?: Vector3;
  115496. depthSortedFacets?: any;
  115497. }): void;
  115498. /** @hidden */
  115499. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  115500. /**
  115501. * Applies VertexData created from the imported parameters to the geometry
  115502. * @param parsedVertexData the parsed data from an imported file
  115503. * @param geometry the geometry to apply the VertexData to
  115504. */
  115505. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  115506. }
  115507. }
  115508. declare module BABYLON {
  115509. /**
  115510. * Class containing static functions to help procedurally build meshes
  115511. */
  115512. export class DiscBuilder {
  115513. /**
  115514. * Creates a plane polygonal mesh. By default, this is a disc
  115515. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  115516. * * 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
  115517. * * 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
  115518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115519. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115521. * @param name defines the name of the mesh
  115522. * @param options defines the options used to create the mesh
  115523. * @param scene defines the hosting scene
  115524. * @returns the plane polygonal mesh
  115525. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  115526. */
  115527. static CreateDisc(name: string, options: {
  115528. radius?: number;
  115529. tessellation?: number;
  115530. arc?: number;
  115531. updatable?: boolean;
  115532. sideOrientation?: number;
  115533. frontUVs?: Vector4;
  115534. backUVs?: Vector4;
  115535. }, scene?: Nullable<Scene>): Mesh;
  115536. }
  115537. }
  115538. declare module BABYLON {
  115539. /**
  115540. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  115541. *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.
  115542. * The SPS is also a particle system. It provides some methods to manage the particles.
  115543. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  115544. *
  115545. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  115546. */
  115547. export class SolidParticleSystem implements IDisposable {
  115548. /**
  115549. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  115550. * Example : var p = SPS.particles[i];
  115551. */
  115552. particles: SolidParticle[];
  115553. /**
  115554. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  115555. */
  115556. nbParticles: number;
  115557. /**
  115558. * If the particles must ever face the camera (default false). Useful for planar particles.
  115559. */
  115560. billboard: boolean;
  115561. /**
  115562. * Recompute normals when adding a shape
  115563. */
  115564. recomputeNormals: boolean;
  115565. /**
  115566. * This a counter ofr your own usage. It's not set by any SPS functions.
  115567. */
  115568. counter: number;
  115569. /**
  115570. * The SPS name. This name is also given to the underlying mesh.
  115571. */
  115572. name: string;
  115573. /**
  115574. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  115575. */
  115576. mesh: Mesh;
  115577. /**
  115578. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  115579. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  115580. */
  115581. vars: any;
  115582. /**
  115583. * This array is populated when the SPS is set as 'pickable'.
  115584. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  115585. * Each element of this array is an object `{idx: int, faceId: int}`.
  115586. * `idx` is the picked particle index in the `SPS.particles` array
  115587. * `faceId` is the picked face index counted within this particle.
  115588. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  115589. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  115590. * Use the method SPS.pickedParticle(pickingInfo) instead.
  115591. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115592. */
  115593. pickedParticles: {
  115594. idx: number;
  115595. faceId: number;
  115596. }[];
  115597. /**
  115598. * This array is populated when the SPS is set as 'pickable'
  115599. * Each key of this array is a submesh index.
  115600. * Each element of this array is a second array defined like this :
  115601. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  115602. * Each element of this second array is an object `{idx: int, faceId: int}`.
  115603. * `idx` is the picked particle index in the `SPS.particles` array
  115604. * `faceId` is the picked face index counted within this particle.
  115605. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  115606. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115607. */
  115608. pickedBySubMesh: {
  115609. idx: number;
  115610. faceId: number;
  115611. }[][];
  115612. /**
  115613. * This array is populated when `enableDepthSort` is set to true.
  115614. * Each element of this array is an instance of the class DepthSortedParticle.
  115615. */
  115616. depthSortedParticles: DepthSortedParticle[];
  115617. /**
  115618. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  115619. * @hidden
  115620. */
  115621. _bSphereOnly: boolean;
  115622. /**
  115623. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  115624. * @hidden
  115625. */
  115626. _bSphereRadiusFactor: number;
  115627. private _scene;
  115628. private _positions;
  115629. private _indices;
  115630. private _normals;
  115631. private _colors;
  115632. private _uvs;
  115633. private _indices32;
  115634. private _positions32;
  115635. private _normals32;
  115636. private _fixedNormal32;
  115637. private _colors32;
  115638. private _uvs32;
  115639. private _index;
  115640. private _updatable;
  115641. private _pickable;
  115642. private _isVisibilityBoxLocked;
  115643. private _alwaysVisible;
  115644. private _depthSort;
  115645. private _expandable;
  115646. private _shapeCounter;
  115647. private _copy;
  115648. private _color;
  115649. private _computeParticleColor;
  115650. private _computeParticleTexture;
  115651. private _computeParticleRotation;
  115652. private _computeParticleVertex;
  115653. private _computeBoundingBox;
  115654. private _depthSortParticles;
  115655. private _camera;
  115656. private _mustUnrotateFixedNormals;
  115657. private _particlesIntersect;
  115658. private _needs32Bits;
  115659. private _isNotBuilt;
  115660. private _lastParticleId;
  115661. private _idxOfId;
  115662. private _multimaterialEnabled;
  115663. private _useModelMaterial;
  115664. private _indicesByMaterial;
  115665. private _materialIndexes;
  115666. private _depthSortFunction;
  115667. private _materialSortFunction;
  115668. private _materials;
  115669. private _multimaterial;
  115670. private _materialIndexesById;
  115671. private _defaultMaterial;
  115672. private _autoUpdateSubMeshes;
  115673. private _tmpVertex;
  115674. /**
  115675. * Creates a SPS (Solid Particle System) object.
  115676. * @param name (String) is the SPS name, this will be the underlying mesh name.
  115677. * @param scene (Scene) is the scene in which the SPS is added.
  115678. * @param options defines the options of the sps e.g.
  115679. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  115680. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  115681. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  115682. * * 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.
  115683. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  115684. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  115685. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  115686. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  115687. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  115688. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  115689. */
  115690. constructor(name: string, scene: Scene, options?: {
  115691. updatable?: boolean;
  115692. isPickable?: boolean;
  115693. enableDepthSort?: boolean;
  115694. particleIntersection?: boolean;
  115695. boundingSphereOnly?: boolean;
  115696. bSphereRadiusFactor?: number;
  115697. expandable?: boolean;
  115698. useModelMaterial?: boolean;
  115699. enableMultiMaterial?: boolean;
  115700. });
  115701. /**
  115702. * Builds the SPS underlying mesh. Returns a standard Mesh.
  115703. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  115704. * @returns the created mesh
  115705. */
  115706. buildMesh(): Mesh;
  115707. /**
  115708. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  115709. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  115710. * Thus the particles generated from `digest()` have their property `position` set yet.
  115711. * @param mesh ( Mesh ) is the mesh to be digested
  115712. * @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
  115713. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  115714. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  115715. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115716. * @returns the current SPS
  115717. */
  115718. digest(mesh: Mesh, options?: {
  115719. facetNb?: number;
  115720. number?: number;
  115721. delta?: number;
  115722. storage?: [];
  115723. }): SolidParticleSystem;
  115724. /**
  115725. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  115726. * @hidden
  115727. */
  115728. private _unrotateFixedNormals;
  115729. /**
  115730. * Resets the temporary working copy particle
  115731. * @hidden
  115732. */
  115733. private _resetCopy;
  115734. /**
  115735. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  115736. * @param p the current index in the positions array to be updated
  115737. * @param ind the current index in the indices array
  115738. * @param shape a Vector3 array, the shape geometry
  115739. * @param positions the positions array to be updated
  115740. * @param meshInd the shape indices array
  115741. * @param indices the indices array to be updated
  115742. * @param meshUV the shape uv array
  115743. * @param uvs the uv array to be updated
  115744. * @param meshCol the shape color array
  115745. * @param colors the color array to be updated
  115746. * @param meshNor the shape normals array
  115747. * @param normals the normals array to be updated
  115748. * @param idx the particle index
  115749. * @param idxInShape the particle index in its shape
  115750. * @param options the addShape() method passed options
  115751. * @model the particle model
  115752. * @hidden
  115753. */
  115754. private _meshBuilder;
  115755. /**
  115756. * Returns a shape Vector3 array from positions float array
  115757. * @param positions float array
  115758. * @returns a vector3 array
  115759. * @hidden
  115760. */
  115761. private _posToShape;
  115762. /**
  115763. * Returns a shapeUV array from a float uvs (array deep copy)
  115764. * @param uvs as a float array
  115765. * @returns a shapeUV array
  115766. * @hidden
  115767. */
  115768. private _uvsToShapeUV;
  115769. /**
  115770. * Adds a new particle object in the particles array
  115771. * @param idx particle index in particles array
  115772. * @param id particle id
  115773. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  115774. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  115775. * @param model particle ModelShape object
  115776. * @param shapeId model shape identifier
  115777. * @param idxInShape index of the particle in the current model
  115778. * @param bInfo model bounding info object
  115779. * @param storage target storage array, if any
  115780. * @hidden
  115781. */
  115782. private _addParticle;
  115783. /**
  115784. * Adds some particles to the SPS from the model shape. Returns the shape id.
  115785. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  115786. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  115787. * @param nb (positive integer) the number of particles to be created from this model
  115788. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  115789. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  115790. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115791. * @returns the number of shapes in the system
  115792. */
  115793. addShape(mesh: Mesh, nb: number, options?: {
  115794. positionFunction?: any;
  115795. vertexFunction?: any;
  115796. storage?: [];
  115797. }): number;
  115798. /**
  115799. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  115800. * @hidden
  115801. */
  115802. private _rebuildParticle;
  115803. /**
  115804. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  115805. * @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.
  115806. * @returns the SPS.
  115807. */
  115808. rebuildMesh(reset?: boolean): SolidParticleSystem;
  115809. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  115810. * Returns an array with the removed particles.
  115811. * 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.
  115812. * The SPS can't be empty so at least one particle needs to remain in place.
  115813. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  115814. * @param start index of the first particle to remove
  115815. * @param end index of the last particle to remove (included)
  115816. * @returns an array populated with the removed particles
  115817. */
  115818. removeParticles(start: number, end: number): SolidParticle[];
  115819. /**
  115820. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  115821. * @param solidParticleArray an array populated with Solid Particles objects
  115822. * @returns the SPS
  115823. */
  115824. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  115825. /**
  115826. * Creates a new particle and modifies the SPS mesh geometry :
  115827. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  115828. * - calls _addParticle() to populate the particle array
  115829. * factorized code from addShape() and insertParticlesFromArray()
  115830. * @param idx particle index in the particles array
  115831. * @param i particle index in its shape
  115832. * @param modelShape particle ModelShape object
  115833. * @param shape shape vertex array
  115834. * @param meshInd shape indices array
  115835. * @param meshUV shape uv array
  115836. * @param meshCol shape color array
  115837. * @param meshNor shape normals array
  115838. * @param bbInfo shape bounding info
  115839. * @param storage target particle storage
  115840. * @options addShape() passed options
  115841. * @hidden
  115842. */
  115843. private _insertNewParticle;
  115844. /**
  115845. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  115846. * This method calls `updateParticle()` for each particle of the SPS.
  115847. * For an animated SPS, it is usually called within the render loop.
  115848. * 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.
  115849. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  115850. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  115851. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  115852. * @returns the SPS.
  115853. */
  115854. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  115855. /**
  115856. * Disposes the SPS.
  115857. */
  115858. dispose(): void;
  115859. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  115860. * idx is the particle index in the SPS
  115861. * faceId is the picked face index counted within this particle.
  115862. * Returns null if the pickInfo can't identify a picked particle.
  115863. * @param pickingInfo (PickingInfo object)
  115864. * @returns {idx: number, faceId: number} or null
  115865. */
  115866. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  115867. idx: number;
  115868. faceId: number;
  115869. }>;
  115870. /**
  115871. * Returns a SolidParticle object from its identifier : particle.id
  115872. * @param id (integer) the particle Id
  115873. * @returns the searched particle or null if not found in the SPS.
  115874. */
  115875. getParticleById(id: number): Nullable<SolidParticle>;
  115876. /**
  115877. * Returns a new array populated with the particles having the passed shapeId.
  115878. * @param shapeId (integer) the shape identifier
  115879. * @returns a new solid particle array
  115880. */
  115881. getParticlesByShapeId(shapeId: number): SolidParticle[];
  115882. /**
  115883. * Populates the passed array "ref" with the particles having the passed shapeId.
  115884. * @param shapeId the shape identifier
  115885. * @returns the SPS
  115886. * @param ref
  115887. */
  115888. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  115889. /**
  115890. * Computes the required SubMeshes according the materials assigned to the particles.
  115891. * @returns the solid particle system.
  115892. * Does nothing if called before the SPS mesh is built.
  115893. */
  115894. computeSubMeshes(): SolidParticleSystem;
  115895. /**
  115896. * Sorts the solid particles by material when MultiMaterial is enabled.
  115897. * Updates the indices32 array.
  115898. * Updates the indicesByMaterial array.
  115899. * Updates the mesh indices array.
  115900. * @returns the SPS
  115901. * @hidden
  115902. */
  115903. private _sortParticlesByMaterial;
  115904. /**
  115905. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  115906. * @hidden
  115907. */
  115908. private _setMaterialIndexesById;
  115909. /**
  115910. * Returns an array with unique values of Materials from the passed array
  115911. * @param array the material array to be checked and filtered
  115912. * @hidden
  115913. */
  115914. private _filterUniqueMaterialId;
  115915. /**
  115916. * Sets a new Standard Material as _defaultMaterial if not already set.
  115917. * @hidden
  115918. */
  115919. private _setDefaultMaterial;
  115920. /**
  115921. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  115922. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115923. * @returns the SPS.
  115924. */
  115925. refreshVisibleSize(): SolidParticleSystem;
  115926. /**
  115927. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  115928. * @param size the size (float) of the visibility box
  115929. * note : this doesn't lock the SPS mesh bounding box.
  115930. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115931. */
  115932. setVisibilityBox(size: number): void;
  115933. /**
  115934. * Gets whether the SPS as always visible or not
  115935. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115936. */
  115937. get isAlwaysVisible(): boolean;
  115938. /**
  115939. * Sets the SPS as always visible or not
  115940. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115941. */
  115942. set isAlwaysVisible(val: boolean);
  115943. /**
  115944. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  115945. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115946. */
  115947. set isVisibilityBoxLocked(val: boolean);
  115948. /**
  115949. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  115950. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115951. */
  115952. get isVisibilityBoxLocked(): boolean;
  115953. /**
  115954. * Tells to `setParticles()` to compute the particle rotations or not.
  115955. * Default value : true. The SPS is faster when it's set to false.
  115956. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  115957. */
  115958. set computeParticleRotation(val: boolean);
  115959. /**
  115960. * Tells to `setParticles()` to compute the particle colors or not.
  115961. * Default value : true. The SPS is faster when it's set to false.
  115962. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  115963. */
  115964. set computeParticleColor(val: boolean);
  115965. set computeParticleTexture(val: boolean);
  115966. /**
  115967. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  115968. * Default value : false. The SPS is faster when it's set to false.
  115969. * Note : the particle custom vertex positions aren't stored values.
  115970. */
  115971. set computeParticleVertex(val: boolean);
  115972. /**
  115973. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  115974. */
  115975. set computeBoundingBox(val: boolean);
  115976. /**
  115977. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  115978. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  115979. * Default : `true`
  115980. */
  115981. set depthSortParticles(val: boolean);
  115982. /**
  115983. * Gets if `setParticles()` computes the particle rotations or not.
  115984. * Default value : true. The SPS is faster when it's set to false.
  115985. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  115986. */
  115987. get computeParticleRotation(): boolean;
  115988. /**
  115989. * Gets if `setParticles()` computes the particle colors or not.
  115990. * Default value : true. The SPS is faster when it's set to false.
  115991. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  115992. */
  115993. get computeParticleColor(): boolean;
  115994. /**
  115995. * Gets if `setParticles()` computes the particle textures or not.
  115996. * Default value : true. The SPS is faster when it's set to false.
  115997. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  115998. */
  115999. get computeParticleTexture(): boolean;
  116000. /**
  116001. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  116002. * Default value : false. The SPS is faster when it's set to false.
  116003. * Note : the particle custom vertex positions aren't stored values.
  116004. */
  116005. get computeParticleVertex(): boolean;
  116006. /**
  116007. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  116008. */
  116009. get computeBoundingBox(): boolean;
  116010. /**
  116011. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  116012. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  116013. * Default : `true`
  116014. */
  116015. get depthSortParticles(): boolean;
  116016. /**
  116017. * Gets if the SPS is created as expandable at construction time.
  116018. * Default : `false`
  116019. */
  116020. get expandable(): boolean;
  116021. /**
  116022. * Gets if the SPS supports the Multi Materials
  116023. */
  116024. get multimaterialEnabled(): boolean;
  116025. /**
  116026. * Gets if the SPS uses the model materials for its own multimaterial.
  116027. */
  116028. get useModelMaterial(): boolean;
  116029. /**
  116030. * The SPS used material array.
  116031. */
  116032. get materials(): Material[];
  116033. /**
  116034. * Sets the SPS MultiMaterial from the passed materials.
  116035. * Note : the passed array is internally copied and not used then by reference.
  116036. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  116037. */
  116038. setMultiMaterial(materials: Material[]): void;
  116039. /**
  116040. * The SPS computed multimaterial object
  116041. */
  116042. get multimaterial(): MultiMaterial;
  116043. set multimaterial(mm: MultiMaterial);
  116044. /**
  116045. * If the subMeshes must be updated on the next call to setParticles()
  116046. */
  116047. get autoUpdateSubMeshes(): boolean;
  116048. set autoUpdateSubMeshes(val: boolean);
  116049. /**
  116050. * This function does nothing. It may be overwritten to set all the particle first values.
  116051. * The SPS doesn't call this function, you may have to call it by your own.
  116052. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116053. */
  116054. initParticles(): void;
  116055. /**
  116056. * This function does nothing. It may be overwritten to recycle a particle.
  116057. * The SPS doesn't call this function, you may have to call it by your own.
  116058. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116059. * @param particle The particle to recycle
  116060. * @returns the recycled particle
  116061. */
  116062. recycleParticle(particle: SolidParticle): SolidParticle;
  116063. /**
  116064. * Updates a particle : this function should be overwritten by the user.
  116065. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  116066. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116067. * @example : just set a particle position or velocity and recycle conditions
  116068. * @param particle The particle to update
  116069. * @returns the updated particle
  116070. */
  116071. updateParticle(particle: SolidParticle): SolidParticle;
  116072. /**
  116073. * Updates a vertex of a particle : it can be overwritten by the user.
  116074. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  116075. * @param particle the current particle
  116076. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  116077. * @param pt the index of the current vertex in the particle shape
  116078. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  116079. * @example : just set a vertex particle position or color
  116080. * @returns the sps
  116081. */
  116082. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  116083. /**
  116084. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  116085. * This does nothing and may be overwritten by the user.
  116086. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116087. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116088. * @param update the boolean update value actually passed to setParticles()
  116089. */
  116090. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  116091. /**
  116092. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  116093. * This will be passed three parameters.
  116094. * This does nothing and may be overwritten by the user.
  116095. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116096. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116097. * @param update the boolean update value actually passed to setParticles()
  116098. */
  116099. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  116100. }
  116101. }
  116102. declare module BABYLON {
  116103. /**
  116104. * Represents one particle of a solid particle system.
  116105. */
  116106. export class SolidParticle {
  116107. /**
  116108. * particle global index
  116109. */
  116110. idx: number;
  116111. /**
  116112. * particle identifier
  116113. */
  116114. id: number;
  116115. /**
  116116. * The color of the particle
  116117. */
  116118. color: Nullable<Color4>;
  116119. /**
  116120. * The world space position of the particle.
  116121. */
  116122. position: Vector3;
  116123. /**
  116124. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  116125. */
  116126. rotation: Vector3;
  116127. /**
  116128. * The world space rotation quaternion of the particle.
  116129. */
  116130. rotationQuaternion: Nullable<Quaternion>;
  116131. /**
  116132. * The scaling of the particle.
  116133. */
  116134. scaling: Vector3;
  116135. /**
  116136. * The uvs of the particle.
  116137. */
  116138. uvs: Vector4;
  116139. /**
  116140. * The current speed of the particle.
  116141. */
  116142. velocity: Vector3;
  116143. /**
  116144. * The pivot point in the particle local space.
  116145. */
  116146. pivot: Vector3;
  116147. /**
  116148. * Must the particle be translated from its pivot point in its local space ?
  116149. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  116150. * Default : false
  116151. */
  116152. translateFromPivot: boolean;
  116153. /**
  116154. * Is the particle active or not ?
  116155. */
  116156. alive: boolean;
  116157. /**
  116158. * Is the particle visible or not ?
  116159. */
  116160. isVisible: boolean;
  116161. /**
  116162. * Index of this particle in the global "positions" array (Internal use)
  116163. * @hidden
  116164. */
  116165. _pos: number;
  116166. /**
  116167. * @hidden Index of this particle in the global "indices" array (Internal use)
  116168. */
  116169. _ind: number;
  116170. /**
  116171. * @hidden ModelShape of this particle (Internal use)
  116172. */
  116173. _model: ModelShape;
  116174. /**
  116175. * ModelShape id of this particle
  116176. */
  116177. shapeId: number;
  116178. /**
  116179. * Index of the particle in its shape id
  116180. */
  116181. idxInShape: number;
  116182. /**
  116183. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  116184. */
  116185. _modelBoundingInfo: BoundingInfo;
  116186. /**
  116187. * @hidden Particle BoundingInfo object (Internal use)
  116188. */
  116189. _boundingInfo: BoundingInfo;
  116190. /**
  116191. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  116192. */
  116193. _sps: SolidParticleSystem;
  116194. /**
  116195. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  116196. */
  116197. _stillInvisible: boolean;
  116198. /**
  116199. * @hidden Last computed particle rotation matrix
  116200. */
  116201. _rotationMatrix: number[];
  116202. /**
  116203. * Parent particle Id, if any.
  116204. * Default null.
  116205. */
  116206. parentId: Nullable<number>;
  116207. /**
  116208. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  116209. */
  116210. materialIndex: Nullable<number>;
  116211. /**
  116212. * Custom object or properties.
  116213. */
  116214. props: Nullable<any>;
  116215. /**
  116216. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  116217. * The possible values are :
  116218. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  116219. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116220. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  116221. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  116222. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116223. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  116224. * */
  116225. cullingStrategy: number;
  116226. /**
  116227. * @hidden Internal global position in the SPS.
  116228. */
  116229. _globalPosition: Vector3;
  116230. /**
  116231. * Creates a Solid Particle object.
  116232. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  116233. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  116234. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  116235. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  116236. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  116237. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  116238. * @param shapeId (integer) is the model shape identifier in the SPS.
  116239. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  116240. * @param sps defines the sps it is associated to
  116241. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  116242. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  116243. */
  116244. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  116245. /**
  116246. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  116247. * @param target the particle target
  116248. * @returns the current particle
  116249. */
  116250. copyToRef(target: SolidParticle): SolidParticle;
  116251. /**
  116252. * Legacy support, changed scale to scaling
  116253. */
  116254. get scale(): Vector3;
  116255. /**
  116256. * Legacy support, changed scale to scaling
  116257. */
  116258. set scale(scale: Vector3);
  116259. /**
  116260. * Legacy support, changed quaternion to rotationQuaternion
  116261. */
  116262. get quaternion(): Nullable<Quaternion>;
  116263. /**
  116264. * Legacy support, changed quaternion to rotationQuaternion
  116265. */
  116266. set quaternion(q: Nullable<Quaternion>);
  116267. /**
  116268. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  116269. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  116270. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  116271. * @returns true if it intersects
  116272. */
  116273. intersectsMesh(target: Mesh | SolidParticle): boolean;
  116274. /**
  116275. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  116276. * A particle is in the frustum if its bounding box intersects the frustum
  116277. * @param frustumPlanes defines the frustum to test
  116278. * @returns true if the particle is in the frustum planes
  116279. */
  116280. isInFrustum(frustumPlanes: Plane[]): boolean;
  116281. /**
  116282. * get the rotation matrix of the particle
  116283. * @hidden
  116284. */
  116285. getRotationMatrix(m: Matrix): void;
  116286. }
  116287. /**
  116288. * Represents the shape of the model used by one particle of a solid particle system.
  116289. * SPS internal tool, don't use it manually.
  116290. */
  116291. export class ModelShape {
  116292. /**
  116293. * The shape id
  116294. * @hidden
  116295. */
  116296. shapeID: number;
  116297. /**
  116298. * flat array of model positions (internal use)
  116299. * @hidden
  116300. */
  116301. _shape: Vector3[];
  116302. /**
  116303. * flat array of model UVs (internal use)
  116304. * @hidden
  116305. */
  116306. _shapeUV: number[];
  116307. /**
  116308. * color array of the model
  116309. * @hidden
  116310. */
  116311. _shapeColors: number[];
  116312. /**
  116313. * indices array of the model
  116314. * @hidden
  116315. */
  116316. _indices: number[];
  116317. /**
  116318. * normals array of the model
  116319. * @hidden
  116320. */
  116321. _normals: number[];
  116322. /**
  116323. * length of the shape in the model indices array (internal use)
  116324. * @hidden
  116325. */
  116326. _indicesLength: number;
  116327. /**
  116328. * Custom position function (internal use)
  116329. * @hidden
  116330. */
  116331. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  116332. /**
  116333. * Custom vertex function (internal use)
  116334. * @hidden
  116335. */
  116336. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  116337. /**
  116338. * Model material (internal use)
  116339. * @hidden
  116340. */
  116341. _material: Nullable<Material>;
  116342. /**
  116343. * 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.
  116344. * SPS internal tool, don't use it manually.
  116345. * @hidden
  116346. */
  116347. 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>);
  116348. }
  116349. /**
  116350. * Represents a Depth Sorted Particle in the solid particle system.
  116351. * @hidden
  116352. */
  116353. export class DepthSortedParticle {
  116354. /**
  116355. * Particle index
  116356. */
  116357. idx: number;
  116358. /**
  116359. * Index of the particle in the "indices" array
  116360. */
  116361. ind: number;
  116362. /**
  116363. * Length of the particle shape in the "indices" array
  116364. */
  116365. indicesLength: number;
  116366. /**
  116367. * Squared distance from the particle to the camera
  116368. */
  116369. sqDistance: number;
  116370. /**
  116371. * Material index when used with MultiMaterials
  116372. */
  116373. materialIndex: number;
  116374. /**
  116375. * Creates a new sorted particle
  116376. * @param materialIndex
  116377. */
  116378. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  116379. }
  116380. /**
  116381. * Represents a solid particle vertex
  116382. */
  116383. export class SolidParticleVertex {
  116384. /**
  116385. * Vertex position
  116386. */
  116387. position: Vector3;
  116388. /**
  116389. * Vertex color
  116390. */
  116391. color: Color4;
  116392. /**
  116393. * Vertex UV
  116394. */
  116395. uv: Vector2;
  116396. /**
  116397. * Creates a new solid particle vertex
  116398. */
  116399. constructor();
  116400. /** Vertex x coordinate */
  116401. get x(): number;
  116402. set x(val: number);
  116403. /** Vertex y coordinate */
  116404. get y(): number;
  116405. set y(val: number);
  116406. /** Vertex z coordinate */
  116407. get z(): number;
  116408. set z(val: number);
  116409. }
  116410. }
  116411. declare module BABYLON {
  116412. /**
  116413. * @hidden
  116414. */
  116415. export class _MeshCollisionData {
  116416. _checkCollisions: boolean;
  116417. _collisionMask: number;
  116418. _collisionGroup: number;
  116419. _surroundingMeshes: Nullable<AbstractMesh[]>;
  116420. _collider: Nullable<Collider>;
  116421. _oldPositionForCollisions: Vector3;
  116422. _diffPositionForCollisions: Vector3;
  116423. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  116424. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  116425. _collisionResponse: boolean;
  116426. }
  116427. }
  116428. declare module BABYLON {
  116429. /** @hidden */
  116430. class _FacetDataStorage {
  116431. facetPositions: Vector3[];
  116432. facetNormals: Vector3[];
  116433. facetPartitioning: number[][];
  116434. facetNb: number;
  116435. partitioningSubdivisions: number;
  116436. partitioningBBoxRatio: number;
  116437. facetDataEnabled: boolean;
  116438. facetParameters: any;
  116439. bbSize: Vector3;
  116440. subDiv: {
  116441. max: number;
  116442. X: number;
  116443. Y: number;
  116444. Z: number;
  116445. };
  116446. facetDepthSort: boolean;
  116447. facetDepthSortEnabled: boolean;
  116448. depthSortedIndices: IndicesArray;
  116449. depthSortedFacets: {
  116450. ind: number;
  116451. sqDistance: number;
  116452. }[];
  116453. facetDepthSortFunction: (f1: {
  116454. ind: number;
  116455. sqDistance: number;
  116456. }, f2: {
  116457. ind: number;
  116458. sqDistance: number;
  116459. }) => number;
  116460. facetDepthSortFrom: Vector3;
  116461. facetDepthSortOrigin: Vector3;
  116462. invertedMatrix: Matrix;
  116463. }
  116464. /**
  116465. * @hidden
  116466. **/
  116467. class _InternalAbstractMeshDataInfo {
  116468. _hasVertexAlpha: boolean;
  116469. _useVertexColors: boolean;
  116470. _numBoneInfluencers: number;
  116471. _applyFog: boolean;
  116472. _receiveShadows: boolean;
  116473. _facetData: _FacetDataStorage;
  116474. _visibility: number;
  116475. _skeleton: Nullable<Skeleton>;
  116476. _layerMask: number;
  116477. _computeBonesUsingShaders: boolean;
  116478. _isActive: boolean;
  116479. _onlyForInstances: boolean;
  116480. _isActiveIntermediate: boolean;
  116481. _onlyForInstancesIntermediate: boolean;
  116482. _actAsRegularMesh: boolean;
  116483. _currentLOD: Nullable<AbstractMesh>;
  116484. }
  116485. /**
  116486. * Class used to store all common mesh properties
  116487. */
  116488. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  116489. /** No occlusion */
  116490. static OCCLUSION_TYPE_NONE: number;
  116491. /** Occlusion set to optimisitic */
  116492. static OCCLUSION_TYPE_OPTIMISTIC: number;
  116493. /** Occlusion set to strict */
  116494. static OCCLUSION_TYPE_STRICT: number;
  116495. /** Use an accurante occlusion algorithm */
  116496. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  116497. /** Use a conservative occlusion algorithm */
  116498. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  116499. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  116500. * Test order :
  116501. * Is the bounding sphere outside the frustum ?
  116502. * If not, are the bounding box vertices outside the frustum ?
  116503. * It not, then the cullable object is in the frustum.
  116504. */
  116505. static readonly CULLINGSTRATEGY_STANDARD: number;
  116506. /** Culling strategy : Bounding Sphere Only.
  116507. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  116508. * It's also less accurate than the standard because some not visible objects can still be selected.
  116509. * Test : is the bounding sphere outside the frustum ?
  116510. * If not, then the cullable object is in the frustum.
  116511. */
  116512. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  116513. /** Culling strategy : Optimistic Inclusion.
  116514. * This in an inclusion test first, then the standard exclusion test.
  116515. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  116516. * 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.
  116517. * Anyway, it's as accurate as the standard strategy.
  116518. * Test :
  116519. * Is the cullable object bounding sphere center in the frustum ?
  116520. * If not, apply the default culling strategy.
  116521. */
  116522. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  116523. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  116524. * This in an inclusion test first, then the bounding sphere only exclusion test.
  116525. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  116526. * 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.
  116527. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  116528. * Test :
  116529. * Is the cullable object bounding sphere center in the frustum ?
  116530. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  116531. */
  116532. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  116533. /**
  116534. * No billboard
  116535. */
  116536. static get BILLBOARDMODE_NONE(): number;
  116537. /** Billboard on X axis */
  116538. static get BILLBOARDMODE_X(): number;
  116539. /** Billboard on Y axis */
  116540. static get BILLBOARDMODE_Y(): number;
  116541. /** Billboard on Z axis */
  116542. static get BILLBOARDMODE_Z(): number;
  116543. /** Billboard on all axes */
  116544. static get BILLBOARDMODE_ALL(): number;
  116545. /** Billboard on using position instead of orientation */
  116546. static get BILLBOARDMODE_USE_POSITION(): number;
  116547. /** @hidden */
  116548. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  116549. /**
  116550. * The culling strategy to use to check whether the mesh must be rendered or not.
  116551. * This value can be changed at any time and will be used on the next render mesh selection.
  116552. * The possible values are :
  116553. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  116554. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116555. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  116556. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  116557. * Please read each static variable documentation to get details about the culling process.
  116558. * */
  116559. cullingStrategy: number;
  116560. /**
  116561. * Gets the number of facets in the mesh
  116562. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116563. */
  116564. get facetNb(): number;
  116565. /**
  116566. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  116567. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116568. */
  116569. get partitioningSubdivisions(): number;
  116570. set partitioningSubdivisions(nb: number);
  116571. /**
  116572. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  116573. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  116574. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116575. */
  116576. get partitioningBBoxRatio(): number;
  116577. set partitioningBBoxRatio(ratio: number);
  116578. /**
  116579. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  116580. * Works only for updatable meshes.
  116581. * Doesn't work with multi-materials
  116582. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116583. */
  116584. get mustDepthSortFacets(): boolean;
  116585. set mustDepthSortFacets(sort: boolean);
  116586. /**
  116587. * The location (Vector3) where the facet depth sort must be computed from.
  116588. * By default, the active camera position.
  116589. * Used only when facet depth sort is enabled
  116590. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116591. */
  116592. get facetDepthSortFrom(): Vector3;
  116593. set facetDepthSortFrom(location: Vector3);
  116594. /**
  116595. * gets a boolean indicating if facetData is enabled
  116596. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116597. */
  116598. get isFacetDataEnabled(): boolean;
  116599. /** @hidden */
  116600. _updateNonUniformScalingState(value: boolean): boolean;
  116601. /**
  116602. * An event triggered when this mesh collides with another one
  116603. */
  116604. onCollideObservable: Observable<AbstractMesh>;
  116605. /** Set a function to call when this mesh collides with another one */
  116606. set onCollide(callback: () => void);
  116607. /**
  116608. * An event triggered when the collision's position changes
  116609. */
  116610. onCollisionPositionChangeObservable: Observable<Vector3>;
  116611. /** Set a function to call when the collision's position changes */
  116612. set onCollisionPositionChange(callback: () => void);
  116613. /**
  116614. * An event triggered when material is changed
  116615. */
  116616. onMaterialChangedObservable: Observable<AbstractMesh>;
  116617. /**
  116618. * Gets or sets the orientation for POV movement & rotation
  116619. */
  116620. definedFacingForward: boolean;
  116621. /** @hidden */
  116622. _occlusionQuery: Nullable<WebGLQuery>;
  116623. /** @hidden */
  116624. _renderingGroup: Nullable<RenderingGroup>;
  116625. /**
  116626. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116627. */
  116628. get visibility(): number;
  116629. /**
  116630. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116631. */
  116632. set visibility(value: number);
  116633. /** Gets or sets the alpha index used to sort transparent meshes
  116634. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  116635. */
  116636. alphaIndex: number;
  116637. /**
  116638. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  116639. */
  116640. isVisible: boolean;
  116641. /**
  116642. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  116643. */
  116644. isPickable: boolean;
  116645. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  116646. showSubMeshesBoundingBox: boolean;
  116647. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  116648. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116649. */
  116650. isBlocker: boolean;
  116651. /**
  116652. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  116653. */
  116654. enablePointerMoveEvents: boolean;
  116655. private _renderingGroupId;
  116656. /**
  116657. * Specifies the rendering group id for this mesh (0 by default)
  116658. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  116659. */
  116660. get renderingGroupId(): number;
  116661. set renderingGroupId(value: number);
  116662. private _material;
  116663. /** Gets or sets current material */
  116664. get material(): Nullable<Material>;
  116665. set material(value: Nullable<Material>);
  116666. /**
  116667. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  116668. * @see https://doc.babylonjs.com/babylon101/shadows
  116669. */
  116670. get receiveShadows(): boolean;
  116671. set receiveShadows(value: boolean);
  116672. /** Defines color to use when rendering outline */
  116673. outlineColor: Color3;
  116674. /** Define width to use when rendering outline */
  116675. outlineWidth: number;
  116676. /** Defines color to use when rendering overlay */
  116677. overlayColor: Color3;
  116678. /** Defines alpha to use when rendering overlay */
  116679. overlayAlpha: number;
  116680. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  116681. get hasVertexAlpha(): boolean;
  116682. set hasVertexAlpha(value: boolean);
  116683. /** 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) */
  116684. get useVertexColors(): boolean;
  116685. set useVertexColors(value: boolean);
  116686. /**
  116687. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  116688. */
  116689. get computeBonesUsingShaders(): boolean;
  116690. set computeBonesUsingShaders(value: boolean);
  116691. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  116692. get numBoneInfluencers(): number;
  116693. set numBoneInfluencers(value: number);
  116694. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  116695. get applyFog(): boolean;
  116696. set applyFog(value: boolean);
  116697. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  116698. useOctreeForRenderingSelection: boolean;
  116699. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  116700. useOctreeForPicking: boolean;
  116701. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  116702. useOctreeForCollisions: boolean;
  116703. /**
  116704. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  116705. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  116706. */
  116707. get layerMask(): number;
  116708. set layerMask(value: number);
  116709. /**
  116710. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  116711. */
  116712. alwaysSelectAsActiveMesh: boolean;
  116713. /**
  116714. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  116715. */
  116716. doNotSyncBoundingInfo: boolean;
  116717. /**
  116718. * Gets or sets the current action manager
  116719. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  116720. */
  116721. actionManager: Nullable<AbstractActionManager>;
  116722. private _meshCollisionData;
  116723. /**
  116724. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  116725. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116726. */
  116727. ellipsoid: Vector3;
  116728. /**
  116729. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  116730. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116731. */
  116732. ellipsoidOffset: Vector3;
  116733. /**
  116734. * Gets or sets a collision mask used to mask collisions (default is -1).
  116735. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116736. */
  116737. get collisionMask(): number;
  116738. set collisionMask(mask: number);
  116739. /**
  116740. * Gets or sets a collision response flag (default is true).
  116741. * when collisionResponse is false, events are still triggered but colliding entity has no response
  116742. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  116743. * to respond to the collision.
  116744. */
  116745. get collisionResponse(): boolean;
  116746. set collisionResponse(response: boolean);
  116747. /**
  116748. * Gets or sets the current collision group mask (-1 by default).
  116749. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116750. */
  116751. get collisionGroup(): number;
  116752. set collisionGroup(mask: number);
  116753. /**
  116754. * Gets or sets current surrounding meshes (null by default).
  116755. *
  116756. * By default collision detection is tested against every mesh in the scene.
  116757. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  116758. * meshes will be tested for the collision.
  116759. *
  116760. * Note: if set to an empty array no collision will happen when this mesh is moved.
  116761. */
  116762. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  116763. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  116764. /**
  116765. * Defines edge width used when edgesRenderer is enabled
  116766. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116767. */
  116768. edgesWidth: number;
  116769. /**
  116770. * Defines edge color used when edgesRenderer is enabled
  116771. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116772. */
  116773. edgesColor: Color4;
  116774. /** @hidden */
  116775. _edgesRenderer: Nullable<IEdgesRenderer>;
  116776. /** @hidden */
  116777. _masterMesh: Nullable<AbstractMesh>;
  116778. /** @hidden */
  116779. _boundingInfo: Nullable<BoundingInfo>;
  116780. /** @hidden */
  116781. _renderId: number;
  116782. /**
  116783. * Gets or sets the list of subMeshes
  116784. * @see https://doc.babylonjs.com/how_to/multi_materials
  116785. */
  116786. subMeshes: SubMesh[];
  116787. /** @hidden */
  116788. _intersectionsInProgress: AbstractMesh[];
  116789. /** @hidden */
  116790. _unIndexed: boolean;
  116791. /** @hidden */
  116792. _lightSources: Light[];
  116793. /** Gets the list of lights affecting that mesh */
  116794. get lightSources(): Light[];
  116795. /** @hidden */
  116796. get _positions(): Nullable<Vector3[]>;
  116797. /** @hidden */
  116798. _waitingData: {
  116799. lods: Nullable<any>;
  116800. actions: Nullable<any>;
  116801. freezeWorldMatrix: Nullable<boolean>;
  116802. };
  116803. /** @hidden */
  116804. _bonesTransformMatrices: Nullable<Float32Array>;
  116805. /** @hidden */
  116806. _transformMatrixTexture: Nullable<RawTexture>;
  116807. /**
  116808. * Gets or sets a skeleton to apply skining transformations
  116809. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  116810. */
  116811. set skeleton(value: Nullable<Skeleton>);
  116812. get skeleton(): Nullable<Skeleton>;
  116813. /**
  116814. * An event triggered when the mesh is rebuilt.
  116815. */
  116816. onRebuildObservable: Observable<AbstractMesh>;
  116817. /**
  116818. * Creates a new AbstractMesh
  116819. * @param name defines the name of the mesh
  116820. * @param scene defines the hosting scene
  116821. */
  116822. constructor(name: string, scene?: Nullable<Scene>);
  116823. /**
  116824. * Returns the string "AbstractMesh"
  116825. * @returns "AbstractMesh"
  116826. */
  116827. getClassName(): string;
  116828. /**
  116829. * Gets a string representation of the current mesh
  116830. * @param fullDetails defines a boolean indicating if full details must be included
  116831. * @returns a string representation of the current mesh
  116832. */
  116833. toString(fullDetails?: boolean): string;
  116834. /**
  116835. * @hidden
  116836. */
  116837. protected _getEffectiveParent(): Nullable<Node>;
  116838. /** @hidden */
  116839. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  116840. /** @hidden */
  116841. _rebuild(): void;
  116842. /** @hidden */
  116843. _resyncLightSources(): void;
  116844. /** @hidden */
  116845. _resyncLightSource(light: Light): void;
  116846. /** @hidden */
  116847. _unBindEffect(): void;
  116848. /** @hidden */
  116849. _removeLightSource(light: Light, dispose: boolean): void;
  116850. private _markSubMeshesAsDirty;
  116851. /** @hidden */
  116852. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  116853. /** @hidden */
  116854. _markSubMeshesAsAttributesDirty(): void;
  116855. /** @hidden */
  116856. _markSubMeshesAsMiscDirty(): void;
  116857. /**
  116858. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  116859. */
  116860. get scaling(): Vector3;
  116861. set scaling(newScaling: Vector3);
  116862. /**
  116863. * Returns true if the mesh is blocked. Implemented by child classes
  116864. */
  116865. get isBlocked(): boolean;
  116866. /**
  116867. * Returns the mesh itself by default. Implemented by child classes
  116868. * @param camera defines the camera to use to pick the right LOD level
  116869. * @returns the currentAbstractMesh
  116870. */
  116871. getLOD(camera: Camera): Nullable<AbstractMesh>;
  116872. /**
  116873. * Returns 0 by default. Implemented by child classes
  116874. * @returns an integer
  116875. */
  116876. getTotalVertices(): number;
  116877. /**
  116878. * Returns a positive integer : the total number of indices in this mesh geometry.
  116879. * @returns the numner of indices or zero if the mesh has no geometry.
  116880. */
  116881. getTotalIndices(): number;
  116882. /**
  116883. * Returns null by default. Implemented by child classes
  116884. * @returns null
  116885. */
  116886. getIndices(): Nullable<IndicesArray>;
  116887. /**
  116888. * Returns the array of the requested vertex data kind. Implemented by child classes
  116889. * @param kind defines the vertex data kind to use
  116890. * @returns null
  116891. */
  116892. getVerticesData(kind: string): Nullable<FloatArray>;
  116893. /**
  116894. * Sets the vertex data of the mesh geometry for the requested `kind`.
  116895. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  116896. * Note that a new underlying VertexBuffer object is created each call.
  116897. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  116898. * @param kind defines vertex data kind:
  116899. * * VertexBuffer.PositionKind
  116900. * * VertexBuffer.UVKind
  116901. * * VertexBuffer.UV2Kind
  116902. * * VertexBuffer.UV3Kind
  116903. * * VertexBuffer.UV4Kind
  116904. * * VertexBuffer.UV5Kind
  116905. * * VertexBuffer.UV6Kind
  116906. * * VertexBuffer.ColorKind
  116907. * * VertexBuffer.MatricesIndicesKind
  116908. * * VertexBuffer.MatricesIndicesExtraKind
  116909. * * VertexBuffer.MatricesWeightsKind
  116910. * * VertexBuffer.MatricesWeightsExtraKind
  116911. * @param data defines the data source
  116912. * @param updatable defines if the data must be flagged as updatable (or static)
  116913. * @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
  116914. * @returns the current mesh
  116915. */
  116916. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  116917. /**
  116918. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  116919. * If the mesh has no geometry, it is simply returned as it is.
  116920. * @param kind defines vertex data kind:
  116921. * * VertexBuffer.PositionKind
  116922. * * VertexBuffer.UVKind
  116923. * * VertexBuffer.UV2Kind
  116924. * * VertexBuffer.UV3Kind
  116925. * * VertexBuffer.UV4Kind
  116926. * * VertexBuffer.UV5Kind
  116927. * * VertexBuffer.UV6Kind
  116928. * * VertexBuffer.ColorKind
  116929. * * VertexBuffer.MatricesIndicesKind
  116930. * * VertexBuffer.MatricesIndicesExtraKind
  116931. * * VertexBuffer.MatricesWeightsKind
  116932. * * VertexBuffer.MatricesWeightsExtraKind
  116933. * @param data defines the data source
  116934. * @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
  116935. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  116936. * @returns the current mesh
  116937. */
  116938. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  116939. /**
  116940. * Sets the mesh indices,
  116941. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  116942. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  116943. * @param totalVertices Defines the total number of vertices
  116944. * @returns the current mesh
  116945. */
  116946. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  116947. /**
  116948. * Gets a boolean indicating if specific vertex data is present
  116949. * @param kind defines the vertex data kind to use
  116950. * @returns true is data kind is present
  116951. */
  116952. isVerticesDataPresent(kind: string): boolean;
  116953. /**
  116954. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  116955. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  116956. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  116957. * @returns a BoundingInfo
  116958. */
  116959. getBoundingInfo(): BoundingInfo;
  116960. /**
  116961. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  116962. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  116963. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  116964. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  116965. * @returns the current mesh
  116966. */
  116967. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  116968. /**
  116969. * Overwrite the current bounding info
  116970. * @param boundingInfo defines the new bounding info
  116971. * @returns the current mesh
  116972. */
  116973. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  116974. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  116975. get useBones(): boolean;
  116976. /** @hidden */
  116977. _preActivate(): void;
  116978. /** @hidden */
  116979. _preActivateForIntermediateRendering(renderId: number): void;
  116980. /** @hidden */
  116981. _activate(renderId: number, intermediateRendering: boolean): boolean;
  116982. /** @hidden */
  116983. _postActivate(): void;
  116984. /** @hidden */
  116985. _freeze(): void;
  116986. /** @hidden */
  116987. _unFreeze(): void;
  116988. /**
  116989. * Gets the current world matrix
  116990. * @returns a Matrix
  116991. */
  116992. getWorldMatrix(): Matrix;
  116993. /** @hidden */
  116994. _getWorldMatrixDeterminant(): number;
  116995. /**
  116996. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  116997. */
  116998. get isAnInstance(): boolean;
  116999. /**
  117000. * Gets a boolean indicating if this mesh has instances
  117001. */
  117002. get hasInstances(): boolean;
  117003. /**
  117004. * Gets a boolean indicating if this mesh has thin instances
  117005. */
  117006. get hasThinInstances(): boolean;
  117007. /**
  117008. * Perform relative position change from the point of view of behind the front of the mesh.
  117009. * This is performed taking into account the meshes current rotation, so you do not have to care.
  117010. * Supports definition of mesh facing forward or backward
  117011. * @param amountRight defines the distance on the right axis
  117012. * @param amountUp defines the distance on the up axis
  117013. * @param amountForward defines the distance on the forward axis
  117014. * @returns the current mesh
  117015. */
  117016. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  117017. /**
  117018. * Calculate relative position change from the point of view of behind the front of the mesh.
  117019. * This is performed taking into account the meshes current rotation, so you do not have to care.
  117020. * Supports definition of mesh facing forward or backward
  117021. * @param amountRight defines the distance on the right axis
  117022. * @param amountUp defines the distance on the up axis
  117023. * @param amountForward defines the distance on the forward axis
  117024. * @returns the new displacement vector
  117025. */
  117026. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  117027. /**
  117028. * Perform relative rotation change from the point of view of behind the front of the mesh.
  117029. * Supports definition of mesh facing forward or backward
  117030. * @param flipBack defines the flip
  117031. * @param twirlClockwise defines the twirl
  117032. * @param tiltRight defines the tilt
  117033. * @returns the current mesh
  117034. */
  117035. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  117036. /**
  117037. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  117038. * Supports definition of mesh facing forward or backward.
  117039. * @param flipBack defines the flip
  117040. * @param twirlClockwise defines the twirl
  117041. * @param tiltRight defines the tilt
  117042. * @returns the new rotation vector
  117043. */
  117044. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  117045. /**
  117046. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  117047. * This means the mesh underlying bounding box and sphere are recomputed.
  117048. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  117049. * @returns the current mesh
  117050. */
  117051. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  117052. /** @hidden */
  117053. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  117054. /** @hidden */
  117055. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  117056. /** @hidden */
  117057. _updateBoundingInfo(): AbstractMesh;
  117058. /** @hidden */
  117059. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  117060. /** @hidden */
  117061. protected _afterComputeWorldMatrix(): void;
  117062. /** @hidden */
  117063. get _effectiveMesh(): AbstractMesh;
  117064. /**
  117065. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  117066. * A mesh is in the frustum if its bounding box intersects the frustum
  117067. * @param frustumPlanes defines the frustum to test
  117068. * @returns true if the mesh is in the frustum planes
  117069. */
  117070. isInFrustum(frustumPlanes: Plane[]): boolean;
  117071. /**
  117072. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  117073. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  117074. * @param frustumPlanes defines the frustum to test
  117075. * @returns true if the mesh is completely in the frustum planes
  117076. */
  117077. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  117078. /**
  117079. * True if the mesh intersects another mesh or a SolidParticle object
  117080. * @param mesh defines a target mesh or SolidParticle to test
  117081. * @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)
  117082. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  117083. * @returns true if there is an intersection
  117084. */
  117085. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  117086. /**
  117087. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  117088. * @param point defines the point to test
  117089. * @returns true if there is an intersection
  117090. */
  117091. intersectsPoint(point: Vector3): boolean;
  117092. /**
  117093. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  117094. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117095. */
  117096. get checkCollisions(): boolean;
  117097. set checkCollisions(collisionEnabled: boolean);
  117098. /**
  117099. * Gets Collider object used to compute collisions (not physics)
  117100. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117101. */
  117102. get collider(): Nullable<Collider>;
  117103. /**
  117104. * Move the mesh using collision engine
  117105. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117106. * @param displacement defines the requested displacement vector
  117107. * @returns the current mesh
  117108. */
  117109. moveWithCollisions(displacement: Vector3): AbstractMesh;
  117110. private _onCollisionPositionChange;
  117111. /** @hidden */
  117112. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  117113. /** @hidden */
  117114. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  117115. /** @hidden */
  117116. _checkCollision(collider: Collider): AbstractMesh;
  117117. /** @hidden */
  117118. _generatePointsArray(): boolean;
  117119. /**
  117120. * Checks if the passed Ray intersects with the mesh
  117121. * @param ray defines the ray to use
  117122. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  117123. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117124. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  117125. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  117126. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  117127. * @returns the picking info
  117128. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  117129. */
  117130. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  117131. /**
  117132. * Clones the current mesh
  117133. * @param name defines the mesh name
  117134. * @param newParent defines the new mesh parent
  117135. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  117136. * @returns the new mesh
  117137. */
  117138. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  117139. /**
  117140. * Disposes all the submeshes of the current meshnp
  117141. * @returns the current mesh
  117142. */
  117143. releaseSubMeshes(): AbstractMesh;
  117144. /**
  117145. * Releases resources associated with this abstract mesh.
  117146. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117147. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117148. */
  117149. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117150. /**
  117151. * Adds the passed mesh as a child to the current mesh
  117152. * @param mesh defines the child mesh
  117153. * @returns the current mesh
  117154. */
  117155. addChild(mesh: AbstractMesh): AbstractMesh;
  117156. /**
  117157. * Removes the passed mesh from the current mesh children list
  117158. * @param mesh defines the child mesh
  117159. * @returns the current mesh
  117160. */
  117161. removeChild(mesh: AbstractMesh): AbstractMesh;
  117162. /** @hidden */
  117163. private _initFacetData;
  117164. /**
  117165. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  117166. * This method can be called within the render loop.
  117167. * 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
  117168. * @returns the current mesh
  117169. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117170. */
  117171. updateFacetData(): AbstractMesh;
  117172. /**
  117173. * Returns the facetLocalNormals array.
  117174. * The normals are expressed in the mesh local spac
  117175. * @returns an array of Vector3
  117176. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117177. */
  117178. getFacetLocalNormals(): Vector3[];
  117179. /**
  117180. * Returns the facetLocalPositions array.
  117181. * The facet positions are expressed in the mesh local space
  117182. * @returns an array of Vector3
  117183. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117184. */
  117185. getFacetLocalPositions(): Vector3[];
  117186. /**
  117187. * Returns the facetLocalPartioning array
  117188. * @returns an array of array of numbers
  117189. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117190. */
  117191. getFacetLocalPartitioning(): number[][];
  117192. /**
  117193. * Returns the i-th facet position in the world system.
  117194. * This method allocates a new Vector3 per call
  117195. * @param i defines the facet index
  117196. * @returns a new Vector3
  117197. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117198. */
  117199. getFacetPosition(i: number): Vector3;
  117200. /**
  117201. * Sets the reference Vector3 with the i-th facet position in the world system
  117202. * @param i defines the facet index
  117203. * @param ref defines the target vector
  117204. * @returns the current mesh
  117205. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117206. */
  117207. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  117208. /**
  117209. * Returns the i-th facet normal in the world system.
  117210. * This method allocates a new Vector3 per call
  117211. * @param i defines the facet index
  117212. * @returns a new Vector3
  117213. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117214. */
  117215. getFacetNormal(i: number): Vector3;
  117216. /**
  117217. * Sets the reference Vector3 with the i-th facet normal in the world system
  117218. * @param i defines the facet index
  117219. * @param ref defines the target vector
  117220. * @returns the current mesh
  117221. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117222. */
  117223. getFacetNormalToRef(i: number, ref: Vector3): this;
  117224. /**
  117225. * 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)
  117226. * @param x defines x coordinate
  117227. * @param y defines y coordinate
  117228. * @param z defines z coordinate
  117229. * @returns the array of facet indexes
  117230. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117231. */
  117232. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  117233. /**
  117234. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  117235. * @param projected sets as the (x,y,z) world projection on the facet
  117236. * @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
  117237. * @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
  117238. * @param x defines x coordinate
  117239. * @param y defines y coordinate
  117240. * @param z defines z coordinate
  117241. * @returns the face index if found (or null instead)
  117242. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117243. */
  117244. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  117245. /**
  117246. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  117247. * @param projected sets as the (x,y,z) local projection on the facet
  117248. * @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
  117249. * @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
  117250. * @param x defines x coordinate
  117251. * @param y defines y coordinate
  117252. * @param z defines z coordinate
  117253. * @returns the face index if found (or null instead)
  117254. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117255. */
  117256. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  117257. /**
  117258. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  117259. * @returns the parameters
  117260. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117261. */
  117262. getFacetDataParameters(): any;
  117263. /**
  117264. * Disables the feature FacetData and frees the related memory
  117265. * @returns the current mesh
  117266. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117267. */
  117268. disableFacetData(): AbstractMesh;
  117269. /**
  117270. * Updates the AbstractMesh indices array
  117271. * @param indices defines the data source
  117272. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  117273. * @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)
  117274. * @returns the current mesh
  117275. */
  117276. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  117277. /**
  117278. * Creates new normals data for the mesh
  117279. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  117280. * @returns the current mesh
  117281. */
  117282. createNormals(updatable: boolean): AbstractMesh;
  117283. /**
  117284. * Align the mesh with a normal
  117285. * @param normal defines the normal to use
  117286. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  117287. * @returns the current mesh
  117288. */
  117289. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  117290. /** @hidden */
  117291. _checkOcclusionQuery(): boolean;
  117292. /**
  117293. * Disables the mesh edge rendering mode
  117294. * @returns the currentAbstractMesh
  117295. */
  117296. disableEdgesRendering(): AbstractMesh;
  117297. /**
  117298. * Enables the edge rendering mode on the mesh.
  117299. * This mode makes the mesh edges visible
  117300. * @param epsilon defines the maximal distance between two angles to detect a face
  117301. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  117302. * @param options options to the edge renderer
  117303. * @returns the currentAbstractMesh
  117304. * @see https://www.babylonjs-playground.com/#19O9TU#0
  117305. */
  117306. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  117307. /**
  117308. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  117309. * @returns an array of particle systems in the scene that use the mesh as an emitter
  117310. */
  117311. getConnectedParticleSystems(): IParticleSystem[];
  117312. }
  117313. }
  117314. declare module BABYLON {
  117315. /**
  117316. * Interface used to define ActionEvent
  117317. */
  117318. export interface IActionEvent {
  117319. /** The mesh or sprite that triggered the action */
  117320. source: any;
  117321. /** The X mouse cursor position at the time of the event */
  117322. pointerX: number;
  117323. /** The Y mouse cursor position at the time of the event */
  117324. pointerY: number;
  117325. /** The mesh that is currently pointed at (can be null) */
  117326. meshUnderPointer: Nullable<AbstractMesh>;
  117327. /** the original (browser) event that triggered the ActionEvent */
  117328. sourceEvent?: any;
  117329. /** additional data for the event */
  117330. additionalData?: any;
  117331. }
  117332. /**
  117333. * ActionEvent is the event being sent when an action is triggered.
  117334. */
  117335. export class ActionEvent implements IActionEvent {
  117336. /** The mesh or sprite that triggered the action */
  117337. source: any;
  117338. /** The X mouse cursor position at the time of the event */
  117339. pointerX: number;
  117340. /** The Y mouse cursor position at the time of the event */
  117341. pointerY: number;
  117342. /** The mesh that is currently pointed at (can be null) */
  117343. meshUnderPointer: Nullable<AbstractMesh>;
  117344. /** the original (browser) event that triggered the ActionEvent */
  117345. sourceEvent?: any;
  117346. /** additional data for the event */
  117347. additionalData?: any;
  117348. /**
  117349. * Creates a new ActionEvent
  117350. * @param source The mesh or sprite that triggered the action
  117351. * @param pointerX The X mouse cursor position at the time of the event
  117352. * @param pointerY The Y mouse cursor position at the time of the event
  117353. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  117354. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  117355. * @param additionalData additional data for the event
  117356. */
  117357. constructor(
  117358. /** The mesh or sprite that triggered the action */
  117359. source: any,
  117360. /** The X mouse cursor position at the time of the event */
  117361. pointerX: number,
  117362. /** The Y mouse cursor position at the time of the event */
  117363. pointerY: number,
  117364. /** The mesh that is currently pointed at (can be null) */
  117365. meshUnderPointer: Nullable<AbstractMesh>,
  117366. /** the original (browser) event that triggered the ActionEvent */
  117367. sourceEvent?: any,
  117368. /** additional data for the event */
  117369. additionalData?: any);
  117370. /**
  117371. * Helper function to auto-create an ActionEvent from a source mesh.
  117372. * @param source The source mesh that triggered the event
  117373. * @param evt The original (browser) event
  117374. * @param additionalData additional data for the event
  117375. * @returns the new ActionEvent
  117376. */
  117377. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  117378. /**
  117379. * Helper function to auto-create an ActionEvent from a source sprite
  117380. * @param source The source sprite that triggered the event
  117381. * @param scene Scene associated with the sprite
  117382. * @param evt The original (browser) event
  117383. * @param additionalData additional data for the event
  117384. * @returns the new ActionEvent
  117385. */
  117386. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  117387. /**
  117388. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  117389. * @param scene the scene where the event occurred
  117390. * @param evt The original (browser) event
  117391. * @returns the new ActionEvent
  117392. */
  117393. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  117394. /**
  117395. * Helper function to auto-create an ActionEvent from a primitive
  117396. * @param prim defines the target primitive
  117397. * @param pointerPos defines the pointer position
  117398. * @param evt The original (browser) event
  117399. * @param additionalData additional data for the event
  117400. * @returns the new ActionEvent
  117401. */
  117402. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  117403. }
  117404. }
  117405. declare module BABYLON {
  117406. /**
  117407. * Abstract class used to decouple action Manager from scene and meshes.
  117408. * Do not instantiate.
  117409. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  117410. */
  117411. export abstract class AbstractActionManager implements IDisposable {
  117412. /** Gets the list of active triggers */
  117413. static Triggers: {
  117414. [key: string]: number;
  117415. };
  117416. /** Gets the cursor to use when hovering items */
  117417. hoverCursor: string;
  117418. /** Gets the list of actions */
  117419. actions: IAction[];
  117420. /**
  117421. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  117422. */
  117423. isRecursive: boolean;
  117424. /**
  117425. * Releases all associated resources
  117426. */
  117427. abstract dispose(): void;
  117428. /**
  117429. * Does this action manager has pointer triggers
  117430. */
  117431. abstract get hasPointerTriggers(): boolean;
  117432. /**
  117433. * Does this action manager has pick triggers
  117434. */
  117435. abstract get hasPickTriggers(): boolean;
  117436. /**
  117437. * Process a specific trigger
  117438. * @param trigger defines the trigger to process
  117439. * @param evt defines the event details to be processed
  117440. */
  117441. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  117442. /**
  117443. * Does this action manager handles actions of any of the given triggers
  117444. * @param triggers defines the triggers to be tested
  117445. * @return a boolean indicating whether one (or more) of the triggers is handled
  117446. */
  117447. abstract hasSpecificTriggers(triggers: number[]): boolean;
  117448. /**
  117449. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  117450. * speed.
  117451. * @param triggerA defines the trigger to be tested
  117452. * @param triggerB defines the trigger to be tested
  117453. * @return a boolean indicating whether one (or more) of the triggers is handled
  117454. */
  117455. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  117456. /**
  117457. * Does this action manager handles actions of a given trigger
  117458. * @param trigger defines the trigger to be tested
  117459. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  117460. * @return whether the trigger is handled
  117461. */
  117462. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  117463. /**
  117464. * Serialize this manager to a JSON object
  117465. * @param name defines the property name to store this manager
  117466. * @returns a JSON representation of this manager
  117467. */
  117468. abstract serialize(name: string): any;
  117469. /**
  117470. * Registers an action to this action manager
  117471. * @param action defines the action to be registered
  117472. * @return the action amended (prepared) after registration
  117473. */
  117474. abstract registerAction(action: IAction): Nullable<IAction>;
  117475. /**
  117476. * Unregisters an action to this action manager
  117477. * @param action defines the action to be unregistered
  117478. * @return a boolean indicating whether the action has been unregistered
  117479. */
  117480. abstract unregisterAction(action: IAction): Boolean;
  117481. /**
  117482. * Does exist one action manager with at least one trigger
  117483. **/
  117484. static get HasTriggers(): boolean;
  117485. /**
  117486. * Does exist one action manager with at least one pick trigger
  117487. **/
  117488. static get HasPickTriggers(): boolean;
  117489. /**
  117490. * Does exist one action manager that handles actions of a given trigger
  117491. * @param trigger defines the trigger to be tested
  117492. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  117493. **/
  117494. static HasSpecificTrigger(trigger: number): boolean;
  117495. }
  117496. }
  117497. declare module BABYLON {
  117498. /**
  117499. * Defines how a node can be built from a string name.
  117500. */
  117501. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  117502. /**
  117503. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  117504. */
  117505. export class Node implements IBehaviorAware<Node> {
  117506. /** @hidden */
  117507. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  117508. private static _NodeConstructors;
  117509. /**
  117510. * Add a new node constructor
  117511. * @param type defines the type name of the node to construct
  117512. * @param constructorFunc defines the constructor function
  117513. */
  117514. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  117515. /**
  117516. * Returns a node constructor based on type name
  117517. * @param type defines the type name
  117518. * @param name defines the new node name
  117519. * @param scene defines the hosting scene
  117520. * @param options defines optional options to transmit to constructors
  117521. * @returns the new constructor or null
  117522. */
  117523. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  117524. /**
  117525. * Gets or sets the name of the node
  117526. */
  117527. name: string;
  117528. /**
  117529. * Gets or sets the id of the node
  117530. */
  117531. id: string;
  117532. /**
  117533. * Gets or sets the unique id of the node
  117534. */
  117535. uniqueId: number;
  117536. /**
  117537. * Gets or sets a string used to store user defined state for the node
  117538. */
  117539. state: string;
  117540. /**
  117541. * Gets or sets an object used to store user defined information for the node
  117542. */
  117543. metadata: any;
  117544. /**
  117545. * For internal use only. Please do not use.
  117546. */
  117547. reservedDataStore: any;
  117548. /**
  117549. * List of inspectable custom properties (used by the Inspector)
  117550. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  117551. */
  117552. inspectableCustomProperties: IInspectable[];
  117553. private _doNotSerialize;
  117554. /**
  117555. * Gets or sets a boolean used to define if the node must be serialized
  117556. */
  117557. get doNotSerialize(): boolean;
  117558. set doNotSerialize(value: boolean);
  117559. /** @hidden */
  117560. _isDisposed: boolean;
  117561. /**
  117562. * Gets a list of Animations associated with the node
  117563. */
  117564. animations: Animation[];
  117565. protected _ranges: {
  117566. [name: string]: Nullable<AnimationRange>;
  117567. };
  117568. /**
  117569. * Callback raised when the node is ready to be used
  117570. */
  117571. onReady: Nullable<(node: Node) => void>;
  117572. private _isEnabled;
  117573. private _isParentEnabled;
  117574. private _isReady;
  117575. /** @hidden */
  117576. _currentRenderId: number;
  117577. private _parentUpdateId;
  117578. /** @hidden */
  117579. _childUpdateId: number;
  117580. /** @hidden */
  117581. _waitingParentId: Nullable<string>;
  117582. /** @hidden */
  117583. _scene: Scene;
  117584. /** @hidden */
  117585. _cache: any;
  117586. private _parentNode;
  117587. private _children;
  117588. /** @hidden */
  117589. _worldMatrix: Matrix;
  117590. /** @hidden */
  117591. _worldMatrixDeterminant: number;
  117592. /** @hidden */
  117593. _worldMatrixDeterminantIsDirty: boolean;
  117594. /** @hidden */
  117595. private _sceneRootNodesIndex;
  117596. /**
  117597. * Gets a boolean indicating if the node has been disposed
  117598. * @returns true if the node was disposed
  117599. */
  117600. isDisposed(): boolean;
  117601. /**
  117602. * Gets or sets the parent of the node (without keeping the current position in the scene)
  117603. * @see https://doc.babylonjs.com/how_to/parenting
  117604. */
  117605. set parent(parent: Nullable<Node>);
  117606. get parent(): Nullable<Node>;
  117607. /** @hidden */
  117608. _addToSceneRootNodes(): void;
  117609. /** @hidden */
  117610. _removeFromSceneRootNodes(): void;
  117611. private _animationPropertiesOverride;
  117612. /**
  117613. * Gets or sets the animation properties override
  117614. */
  117615. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  117616. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  117617. /**
  117618. * Gets a string identifying the name of the class
  117619. * @returns "Node" string
  117620. */
  117621. getClassName(): string;
  117622. /** @hidden */
  117623. readonly _isNode: boolean;
  117624. /**
  117625. * An event triggered when the mesh is disposed
  117626. */
  117627. onDisposeObservable: Observable<Node>;
  117628. private _onDisposeObserver;
  117629. /**
  117630. * Sets a callback that will be raised when the node will be disposed
  117631. */
  117632. set onDispose(callback: () => void);
  117633. /**
  117634. * Creates a new Node
  117635. * @param name the name and id to be given to this node
  117636. * @param scene the scene this node will be added to
  117637. */
  117638. constructor(name: string, scene?: Nullable<Scene>);
  117639. /**
  117640. * Gets the scene of the node
  117641. * @returns a scene
  117642. */
  117643. getScene(): Scene;
  117644. /**
  117645. * Gets the engine of the node
  117646. * @returns a Engine
  117647. */
  117648. getEngine(): Engine;
  117649. private _behaviors;
  117650. /**
  117651. * Attach a behavior to the node
  117652. * @see https://doc.babylonjs.com/features/behaviour
  117653. * @param behavior defines the behavior to attach
  117654. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  117655. * @returns the current Node
  117656. */
  117657. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  117658. /**
  117659. * Remove an attached behavior
  117660. * @see https://doc.babylonjs.com/features/behaviour
  117661. * @param behavior defines the behavior to attach
  117662. * @returns the current Node
  117663. */
  117664. removeBehavior(behavior: Behavior<Node>): Node;
  117665. /**
  117666. * Gets the list of attached behaviors
  117667. * @see https://doc.babylonjs.com/features/behaviour
  117668. */
  117669. get behaviors(): Behavior<Node>[];
  117670. /**
  117671. * Gets an attached behavior by name
  117672. * @param name defines the name of the behavior to look for
  117673. * @see https://doc.babylonjs.com/features/behaviour
  117674. * @returns null if behavior was not found else the requested behavior
  117675. */
  117676. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  117677. /**
  117678. * Returns the latest update of the World matrix
  117679. * @returns a Matrix
  117680. */
  117681. getWorldMatrix(): Matrix;
  117682. /** @hidden */
  117683. _getWorldMatrixDeterminant(): number;
  117684. /**
  117685. * Returns directly the latest state of the mesh World matrix.
  117686. * A Matrix is returned.
  117687. */
  117688. get worldMatrixFromCache(): Matrix;
  117689. /** @hidden */
  117690. _initCache(): void;
  117691. /** @hidden */
  117692. updateCache(force?: boolean): void;
  117693. /** @hidden */
  117694. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  117695. /** @hidden */
  117696. _updateCache(ignoreParentClass?: boolean): void;
  117697. /** @hidden */
  117698. _isSynchronized(): boolean;
  117699. /** @hidden */
  117700. _markSyncedWithParent(): void;
  117701. /** @hidden */
  117702. isSynchronizedWithParent(): boolean;
  117703. /** @hidden */
  117704. isSynchronized(): boolean;
  117705. /**
  117706. * Is this node ready to be used/rendered
  117707. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  117708. * @return true if the node is ready
  117709. */
  117710. isReady(completeCheck?: boolean): boolean;
  117711. /**
  117712. * Is this node enabled?
  117713. * 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
  117714. * @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
  117715. * @return whether this node (and its parent) is enabled
  117716. */
  117717. isEnabled(checkAncestors?: boolean): boolean;
  117718. /** @hidden */
  117719. protected _syncParentEnabledState(): void;
  117720. /**
  117721. * Set the enabled state of this node
  117722. * @param value defines the new enabled state
  117723. */
  117724. setEnabled(value: boolean): void;
  117725. /**
  117726. * Is this node a descendant of the given node?
  117727. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  117728. * @param ancestor defines the parent node to inspect
  117729. * @returns a boolean indicating if this node is a descendant of the given node
  117730. */
  117731. isDescendantOf(ancestor: Node): boolean;
  117732. /** @hidden */
  117733. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  117734. /**
  117735. * Will return all nodes that have this node as ascendant
  117736. * @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
  117737. * @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
  117738. * @return all children nodes of all types
  117739. */
  117740. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  117741. /**
  117742. * Get all child-meshes of this node
  117743. * @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)
  117744. * @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
  117745. * @returns an array of AbstractMesh
  117746. */
  117747. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  117748. /**
  117749. * Get all direct children of this node
  117750. * @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
  117751. * @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)
  117752. * @returns an array of Node
  117753. */
  117754. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  117755. /** @hidden */
  117756. _setReady(state: boolean): void;
  117757. /**
  117758. * Get an animation by name
  117759. * @param name defines the name of the animation to look for
  117760. * @returns null if not found else the requested animation
  117761. */
  117762. getAnimationByName(name: string): Nullable<Animation>;
  117763. /**
  117764. * Creates an animation range for this node
  117765. * @param name defines the name of the range
  117766. * @param from defines the starting key
  117767. * @param to defines the end key
  117768. */
  117769. createAnimationRange(name: string, from: number, to: number): void;
  117770. /**
  117771. * Delete a specific animation range
  117772. * @param name defines the name of the range to delete
  117773. * @param deleteFrames defines if animation frames from the range must be deleted as well
  117774. */
  117775. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  117776. /**
  117777. * Get an animation range by name
  117778. * @param name defines the name of the animation range to look for
  117779. * @returns null if not found else the requested animation range
  117780. */
  117781. getAnimationRange(name: string): Nullable<AnimationRange>;
  117782. /**
  117783. * Gets the list of all animation ranges defined on this node
  117784. * @returns an array
  117785. */
  117786. getAnimationRanges(): Nullable<AnimationRange>[];
  117787. /**
  117788. * Will start the animation sequence
  117789. * @param name defines the range frames for animation sequence
  117790. * @param loop defines if the animation should loop (false by default)
  117791. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  117792. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  117793. * @returns the object created for this animation. If range does not exist, it will return null
  117794. */
  117795. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  117796. /**
  117797. * Serialize animation ranges into a JSON compatible object
  117798. * @returns serialization object
  117799. */
  117800. serializeAnimationRanges(): any;
  117801. /**
  117802. * Computes the world matrix of the node
  117803. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  117804. * @returns the world matrix
  117805. */
  117806. computeWorldMatrix(force?: boolean): Matrix;
  117807. /**
  117808. * Releases resources associated with this node.
  117809. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117810. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117811. */
  117812. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117813. /**
  117814. * Parse animation range data from a serialization object and store them into a given node
  117815. * @param node defines where to store the animation ranges
  117816. * @param parsedNode defines the serialization object to read data from
  117817. * @param scene defines the hosting scene
  117818. */
  117819. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  117820. /**
  117821. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  117822. * @param includeDescendants Include bounding info from descendants as well (true by default)
  117823. * @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
  117824. * @returns the new bounding vectors
  117825. */
  117826. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  117827. min: Vector3;
  117828. max: Vector3;
  117829. };
  117830. }
  117831. }
  117832. declare module BABYLON {
  117833. /**
  117834. * @hidden
  117835. */
  117836. export class _IAnimationState {
  117837. key: number;
  117838. repeatCount: number;
  117839. workValue?: any;
  117840. loopMode?: number;
  117841. offsetValue?: any;
  117842. highLimitValue?: any;
  117843. }
  117844. /**
  117845. * Class used to store any kind of animation
  117846. */
  117847. export class Animation {
  117848. /**Name of the animation */
  117849. name: string;
  117850. /**Property to animate */
  117851. targetProperty: string;
  117852. /**The frames per second of the animation */
  117853. framePerSecond: number;
  117854. /**The data type of the animation */
  117855. dataType: number;
  117856. /**The loop mode of the animation */
  117857. loopMode?: number | undefined;
  117858. /**Specifies if blending should be enabled */
  117859. enableBlending?: boolean | undefined;
  117860. /**
  117861. * Use matrix interpolation instead of using direct key value when animating matrices
  117862. */
  117863. static AllowMatricesInterpolation: boolean;
  117864. /**
  117865. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  117866. */
  117867. static AllowMatrixDecomposeForInterpolation: boolean;
  117868. /** Define the Url to load snippets */
  117869. static SnippetUrl: string;
  117870. /** Snippet ID if the animation was created from the snippet server */
  117871. snippetId: string;
  117872. /**
  117873. * Stores the key frames of the animation
  117874. */
  117875. private _keys;
  117876. /**
  117877. * Stores the easing function of the animation
  117878. */
  117879. private _easingFunction;
  117880. /**
  117881. * @hidden Internal use only
  117882. */
  117883. _runtimeAnimations: RuntimeAnimation[];
  117884. /**
  117885. * The set of event that will be linked to this animation
  117886. */
  117887. private _events;
  117888. /**
  117889. * Stores an array of target property paths
  117890. */
  117891. targetPropertyPath: string[];
  117892. /**
  117893. * Stores the blending speed of the animation
  117894. */
  117895. blendingSpeed: number;
  117896. /**
  117897. * Stores the animation ranges for the animation
  117898. */
  117899. private _ranges;
  117900. /**
  117901. * @hidden Internal use
  117902. */
  117903. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  117904. /**
  117905. * Sets up an animation
  117906. * @param property The property to animate
  117907. * @param animationType The animation type to apply
  117908. * @param framePerSecond The frames per second of the animation
  117909. * @param easingFunction The easing function used in the animation
  117910. * @returns The created animation
  117911. */
  117912. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  117913. /**
  117914. * Create and start an animation on a node
  117915. * @param name defines the name of the global animation that will be run on all nodes
  117916. * @param node defines the root node where the animation will take place
  117917. * @param targetProperty defines property to animate
  117918. * @param framePerSecond defines the number of frame per second yo use
  117919. * @param totalFrame defines the number of frames in total
  117920. * @param from defines the initial value
  117921. * @param to defines the final value
  117922. * @param loopMode defines which loop mode you want to use (off by default)
  117923. * @param easingFunction defines the easing function to use (linear by default)
  117924. * @param onAnimationEnd defines the callback to call when animation end
  117925. * @returns the animatable created for this animation
  117926. */
  117927. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  117928. /**
  117929. * Create and start an animation on a node and its descendants
  117930. * @param name defines the name of the global animation that will be run on all nodes
  117931. * @param node defines the root node where the animation will take place
  117932. * @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
  117933. * @param targetProperty defines property to animate
  117934. * @param framePerSecond defines the number of frame per second to use
  117935. * @param totalFrame defines the number of frames in total
  117936. * @param from defines the initial value
  117937. * @param to defines the final value
  117938. * @param loopMode defines which loop mode you want to use (off by default)
  117939. * @param easingFunction defines the easing function to use (linear by default)
  117940. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  117941. * @returns the list of animatables created for all nodes
  117942. * @example https://www.babylonjs-playground.com/#MH0VLI
  117943. */
  117944. 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[]>;
  117945. /**
  117946. * Creates a new animation, merges it with the existing animations and starts it
  117947. * @param name Name of the animation
  117948. * @param node Node which contains the scene that begins the animations
  117949. * @param targetProperty Specifies which property to animate
  117950. * @param framePerSecond The frames per second of the animation
  117951. * @param totalFrame The total number of frames
  117952. * @param from The frame at the beginning of the animation
  117953. * @param to The frame at the end of the animation
  117954. * @param loopMode Specifies the loop mode of the animation
  117955. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  117956. * @param onAnimationEnd Callback to run once the animation is complete
  117957. * @returns Nullable animation
  117958. */
  117959. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  117960. /**
  117961. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  117962. * @param sourceAnimation defines the Animation containing keyframes to convert
  117963. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  117964. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  117965. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  117966. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  117967. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  117968. */
  117969. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  117970. /**
  117971. * Transition property of an host to the target Value
  117972. * @param property The property to transition
  117973. * @param targetValue The target Value of the property
  117974. * @param host The object where the property to animate belongs
  117975. * @param scene Scene used to run the animation
  117976. * @param frameRate Framerate (in frame/s) to use
  117977. * @param transition The transition type we want to use
  117978. * @param duration The duration of the animation, in milliseconds
  117979. * @param onAnimationEnd Callback trigger at the end of the animation
  117980. * @returns Nullable animation
  117981. */
  117982. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  117983. /**
  117984. * Return the array of runtime animations currently using this animation
  117985. */
  117986. get runtimeAnimations(): RuntimeAnimation[];
  117987. /**
  117988. * Specifies if any of the runtime animations are currently running
  117989. */
  117990. get hasRunningRuntimeAnimations(): boolean;
  117991. /**
  117992. * Initializes the animation
  117993. * @param name Name of the animation
  117994. * @param targetProperty Property to animate
  117995. * @param framePerSecond The frames per second of the animation
  117996. * @param dataType The data type of the animation
  117997. * @param loopMode The loop mode of the animation
  117998. * @param enableBlending Specifies if blending should be enabled
  117999. */
  118000. constructor(
  118001. /**Name of the animation */
  118002. name: string,
  118003. /**Property to animate */
  118004. targetProperty: string,
  118005. /**The frames per second of the animation */
  118006. framePerSecond: number,
  118007. /**The data type of the animation */
  118008. dataType: number,
  118009. /**The loop mode of the animation */
  118010. loopMode?: number | undefined,
  118011. /**Specifies if blending should be enabled */
  118012. enableBlending?: boolean | undefined);
  118013. /**
  118014. * Converts the animation to a string
  118015. * @param fullDetails support for multiple levels of logging within scene loading
  118016. * @returns String form of the animation
  118017. */
  118018. toString(fullDetails?: boolean): string;
  118019. /**
  118020. * Add an event to this animation
  118021. * @param event Event to add
  118022. */
  118023. addEvent(event: AnimationEvent): void;
  118024. /**
  118025. * Remove all events found at the given frame
  118026. * @param frame The frame to remove events from
  118027. */
  118028. removeEvents(frame: number): void;
  118029. /**
  118030. * Retrieves all the events from the animation
  118031. * @returns Events from the animation
  118032. */
  118033. getEvents(): AnimationEvent[];
  118034. /**
  118035. * Creates an animation range
  118036. * @param name Name of the animation range
  118037. * @param from Starting frame of the animation range
  118038. * @param to Ending frame of the animation
  118039. */
  118040. createRange(name: string, from: number, to: number): void;
  118041. /**
  118042. * Deletes an animation range by name
  118043. * @param name Name of the animation range to delete
  118044. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  118045. */
  118046. deleteRange(name: string, deleteFrames?: boolean): void;
  118047. /**
  118048. * Gets the animation range by name, or null if not defined
  118049. * @param name Name of the animation range
  118050. * @returns Nullable animation range
  118051. */
  118052. getRange(name: string): Nullable<AnimationRange>;
  118053. /**
  118054. * Gets the key frames from the animation
  118055. * @returns The key frames of the animation
  118056. */
  118057. getKeys(): Array<IAnimationKey>;
  118058. /**
  118059. * Gets the highest frame rate of the animation
  118060. * @returns Highest frame rate of the animation
  118061. */
  118062. getHighestFrame(): number;
  118063. /**
  118064. * Gets the easing function of the animation
  118065. * @returns Easing function of the animation
  118066. */
  118067. getEasingFunction(): IEasingFunction;
  118068. /**
  118069. * Sets the easing function of the animation
  118070. * @param easingFunction A custom mathematical formula for animation
  118071. */
  118072. setEasingFunction(easingFunction: EasingFunction): void;
  118073. /**
  118074. * Interpolates a scalar linearly
  118075. * @param startValue Start value of the animation curve
  118076. * @param endValue End value of the animation curve
  118077. * @param gradient Scalar amount to interpolate
  118078. * @returns Interpolated scalar value
  118079. */
  118080. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  118081. /**
  118082. * Interpolates a scalar cubically
  118083. * @param startValue Start value of the animation curve
  118084. * @param outTangent End tangent of the animation
  118085. * @param endValue End value of the animation curve
  118086. * @param inTangent Start tangent of the animation curve
  118087. * @param gradient Scalar amount to interpolate
  118088. * @returns Interpolated scalar value
  118089. */
  118090. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  118091. /**
  118092. * Interpolates a quaternion using a spherical linear interpolation
  118093. * @param startValue Start value of the animation curve
  118094. * @param endValue End value of the animation curve
  118095. * @param gradient Scalar amount to interpolate
  118096. * @returns Interpolated quaternion value
  118097. */
  118098. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  118099. /**
  118100. * Interpolates a quaternion cubically
  118101. * @param startValue Start value of the animation curve
  118102. * @param outTangent End tangent of the animation curve
  118103. * @param endValue End value of the animation curve
  118104. * @param inTangent Start tangent of the animation curve
  118105. * @param gradient Scalar amount to interpolate
  118106. * @returns Interpolated quaternion value
  118107. */
  118108. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  118109. /**
  118110. * Interpolates a Vector3 linearl
  118111. * @param startValue Start value of the animation curve
  118112. * @param endValue End value of the animation curve
  118113. * @param gradient Scalar amount to interpolate
  118114. * @returns Interpolated scalar value
  118115. */
  118116. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  118117. /**
  118118. * Interpolates a Vector3 cubically
  118119. * @param startValue Start value of the animation curve
  118120. * @param outTangent End tangent of the animation
  118121. * @param endValue End value of the animation curve
  118122. * @param inTangent Start tangent of the animation curve
  118123. * @param gradient Scalar amount to interpolate
  118124. * @returns InterpolatedVector3 value
  118125. */
  118126. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  118127. /**
  118128. * Interpolates a Vector2 linearly
  118129. * @param startValue Start value of the animation curve
  118130. * @param endValue End value of the animation curve
  118131. * @param gradient Scalar amount to interpolate
  118132. * @returns Interpolated Vector2 value
  118133. */
  118134. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  118135. /**
  118136. * Interpolates a Vector2 cubically
  118137. * @param startValue Start value of the animation curve
  118138. * @param outTangent End tangent of the animation
  118139. * @param endValue End value of the animation curve
  118140. * @param inTangent Start tangent of the animation curve
  118141. * @param gradient Scalar amount to interpolate
  118142. * @returns Interpolated Vector2 value
  118143. */
  118144. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  118145. /**
  118146. * Interpolates a size linearly
  118147. * @param startValue Start value of the animation curve
  118148. * @param endValue End value of the animation curve
  118149. * @param gradient Scalar amount to interpolate
  118150. * @returns Interpolated Size value
  118151. */
  118152. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  118153. /**
  118154. * Interpolates a Color3 linearly
  118155. * @param startValue Start value of the animation curve
  118156. * @param endValue End value of the animation curve
  118157. * @param gradient Scalar amount to interpolate
  118158. * @returns Interpolated Color3 value
  118159. */
  118160. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  118161. /**
  118162. * Interpolates a Color4 linearly
  118163. * @param startValue Start value of the animation curve
  118164. * @param endValue End value of the animation curve
  118165. * @param gradient Scalar amount to interpolate
  118166. * @returns Interpolated Color3 value
  118167. */
  118168. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  118169. /**
  118170. * @hidden Internal use only
  118171. */
  118172. _getKeyValue(value: any): any;
  118173. /**
  118174. * @hidden Internal use only
  118175. */
  118176. _interpolate(currentFrame: number, state: _IAnimationState): any;
  118177. /**
  118178. * Defines the function to use to interpolate matrices
  118179. * @param startValue defines the start matrix
  118180. * @param endValue defines the end matrix
  118181. * @param gradient defines the gradient between both matrices
  118182. * @param result defines an optional target matrix where to store the interpolation
  118183. * @returns the interpolated matrix
  118184. */
  118185. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  118186. /**
  118187. * Makes a copy of the animation
  118188. * @returns Cloned animation
  118189. */
  118190. clone(): Animation;
  118191. /**
  118192. * Sets the key frames of the animation
  118193. * @param values The animation key frames to set
  118194. */
  118195. setKeys(values: Array<IAnimationKey>): void;
  118196. /**
  118197. * Serializes the animation to an object
  118198. * @returns Serialized object
  118199. */
  118200. serialize(): any;
  118201. /**
  118202. * Float animation type
  118203. */
  118204. static readonly ANIMATIONTYPE_FLOAT: number;
  118205. /**
  118206. * Vector3 animation type
  118207. */
  118208. static readonly ANIMATIONTYPE_VECTOR3: number;
  118209. /**
  118210. * Quaternion animation type
  118211. */
  118212. static readonly ANIMATIONTYPE_QUATERNION: number;
  118213. /**
  118214. * Matrix animation type
  118215. */
  118216. static readonly ANIMATIONTYPE_MATRIX: number;
  118217. /**
  118218. * Color3 animation type
  118219. */
  118220. static readonly ANIMATIONTYPE_COLOR3: number;
  118221. /**
  118222. * Color3 animation type
  118223. */
  118224. static readonly ANIMATIONTYPE_COLOR4: number;
  118225. /**
  118226. * Vector2 animation type
  118227. */
  118228. static readonly ANIMATIONTYPE_VECTOR2: number;
  118229. /**
  118230. * Size animation type
  118231. */
  118232. static readonly ANIMATIONTYPE_SIZE: number;
  118233. /**
  118234. * Relative Loop Mode
  118235. */
  118236. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  118237. /**
  118238. * Cycle Loop Mode
  118239. */
  118240. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  118241. /**
  118242. * Constant Loop Mode
  118243. */
  118244. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  118245. /** @hidden */
  118246. static _UniversalLerp(left: any, right: any, amount: number): any;
  118247. /**
  118248. * Parses an animation object and creates an animation
  118249. * @param parsedAnimation Parsed animation object
  118250. * @returns Animation object
  118251. */
  118252. static Parse(parsedAnimation: any): Animation;
  118253. /**
  118254. * Appends the serialized animations from the source animations
  118255. * @param source Source containing the animations
  118256. * @param destination Target to store the animations
  118257. */
  118258. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  118259. /**
  118260. * Creates a new animation or an array of animations from a snippet saved in a remote file
  118261. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  118262. * @param url defines the url to load from
  118263. * @returns a promise that will resolve to the new animation or an array of animations
  118264. */
  118265. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  118266. /**
  118267. * Creates an animation or an array of animations from a snippet saved by the Inspector
  118268. * @param snippetId defines the snippet to load
  118269. * @returns a promise that will resolve to the new animation or a new array of animations
  118270. */
  118271. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  118272. }
  118273. }
  118274. declare module BABYLON {
  118275. /**
  118276. * Interface containing an array of animations
  118277. */
  118278. export interface IAnimatable {
  118279. /**
  118280. * Array of animations
  118281. */
  118282. animations: Nullable<Array<Animation>>;
  118283. }
  118284. }
  118285. declare module BABYLON {
  118286. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  118287. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118288. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118289. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118290. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118291. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118292. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118293. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118294. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118295. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118296. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118297. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118298. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118299. /**
  118300. * Decorator used to define property that can be serialized as reference to a camera
  118301. * @param sourceName defines the name of the property to decorate
  118302. */
  118303. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118304. /**
  118305. * Class used to help serialization objects
  118306. */
  118307. export class SerializationHelper {
  118308. /** @hidden */
  118309. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  118310. /** @hidden */
  118311. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  118312. /** @hidden */
  118313. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  118314. /** @hidden */
  118315. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  118316. /**
  118317. * Appends the serialized animations from the source animations
  118318. * @param source Source containing the animations
  118319. * @param destination Target to store the animations
  118320. */
  118321. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  118322. /**
  118323. * Static function used to serialized a specific entity
  118324. * @param entity defines the entity to serialize
  118325. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  118326. * @returns a JSON compatible object representing the serialization of the entity
  118327. */
  118328. static Serialize<T>(entity: T, serializationObject?: any): any;
  118329. /**
  118330. * Creates a new entity from a serialization data object
  118331. * @param creationFunction defines a function used to instanciated the new entity
  118332. * @param source defines the source serialization data
  118333. * @param scene defines the hosting scene
  118334. * @param rootUrl defines the root url for resources
  118335. * @returns a new entity
  118336. */
  118337. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  118338. /**
  118339. * Clones an object
  118340. * @param creationFunction defines the function used to instanciate the new object
  118341. * @param source defines the source object
  118342. * @returns the cloned object
  118343. */
  118344. static Clone<T>(creationFunction: () => T, source: T): T;
  118345. /**
  118346. * Instanciates a new object based on a source one (some data will be shared between both object)
  118347. * @param creationFunction defines the function used to instanciate the new object
  118348. * @param source defines the source object
  118349. * @returns the new object
  118350. */
  118351. static Instanciate<T>(creationFunction: () => T, source: T): T;
  118352. }
  118353. }
  118354. declare module BABYLON {
  118355. /**
  118356. * This is the base class of all the camera used in the application.
  118357. * @see https://doc.babylonjs.com/features/cameras
  118358. */
  118359. export class Camera extends Node {
  118360. /** @hidden */
  118361. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  118362. /**
  118363. * This is the default projection mode used by the cameras.
  118364. * It helps recreating a feeling of perspective and better appreciate depth.
  118365. * This is the best way to simulate real life cameras.
  118366. */
  118367. static readonly PERSPECTIVE_CAMERA: number;
  118368. /**
  118369. * This helps creating camera with an orthographic mode.
  118370. * 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.
  118371. */
  118372. static readonly ORTHOGRAPHIC_CAMERA: number;
  118373. /**
  118374. * This is the default FOV mode for perspective cameras.
  118375. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  118376. */
  118377. static readonly FOVMODE_VERTICAL_FIXED: number;
  118378. /**
  118379. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  118380. */
  118381. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  118382. /**
  118383. * This specifies ther is no need for a camera rig.
  118384. * Basically only one eye is rendered corresponding to the camera.
  118385. */
  118386. static readonly RIG_MODE_NONE: number;
  118387. /**
  118388. * Simulates a camera Rig with one blue eye and one red eye.
  118389. * This can be use with 3d blue and red glasses.
  118390. */
  118391. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  118392. /**
  118393. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  118394. */
  118395. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  118396. /**
  118397. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  118398. */
  118399. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  118400. /**
  118401. * Defines that both eyes of the camera will be rendered over under each other.
  118402. */
  118403. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  118404. /**
  118405. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  118406. */
  118407. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  118408. /**
  118409. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  118410. */
  118411. static readonly RIG_MODE_VR: number;
  118412. /**
  118413. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  118414. */
  118415. static readonly RIG_MODE_WEBVR: number;
  118416. /**
  118417. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  118418. */
  118419. static readonly RIG_MODE_CUSTOM: number;
  118420. /**
  118421. * Defines if by default attaching controls should prevent the default javascript event to continue.
  118422. */
  118423. static ForceAttachControlToAlwaysPreventDefault: boolean;
  118424. /**
  118425. * Define the input manager associated with the camera.
  118426. */
  118427. inputs: CameraInputsManager<Camera>;
  118428. /** @hidden */
  118429. _position: Vector3;
  118430. /**
  118431. * Define the current local position of the camera in the scene
  118432. */
  118433. get position(): Vector3;
  118434. set position(newPosition: Vector3);
  118435. protected _upVector: Vector3;
  118436. /**
  118437. * The vector the camera should consider as up.
  118438. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  118439. */
  118440. set upVector(vec: Vector3);
  118441. get upVector(): Vector3;
  118442. /**
  118443. * Define the current limit on the left side for an orthographic camera
  118444. * In scene unit
  118445. */
  118446. orthoLeft: Nullable<number>;
  118447. /**
  118448. * Define the current limit on the right side for an orthographic camera
  118449. * In scene unit
  118450. */
  118451. orthoRight: Nullable<number>;
  118452. /**
  118453. * Define the current limit on the bottom side for an orthographic camera
  118454. * In scene unit
  118455. */
  118456. orthoBottom: Nullable<number>;
  118457. /**
  118458. * Define the current limit on the top side for an orthographic camera
  118459. * In scene unit
  118460. */
  118461. orthoTop: Nullable<number>;
  118462. /**
  118463. * Field Of View is set in Radians. (default is 0.8)
  118464. */
  118465. fov: number;
  118466. /**
  118467. * Define the minimum distance the camera can see from.
  118468. * This is important to note that the depth buffer are not infinite and the closer it starts
  118469. * the more your scene might encounter depth fighting issue.
  118470. */
  118471. minZ: number;
  118472. /**
  118473. * Define the maximum distance the camera can see to.
  118474. * This is important to note that the depth buffer are not infinite and the further it end
  118475. * the more your scene might encounter depth fighting issue.
  118476. */
  118477. maxZ: number;
  118478. /**
  118479. * Define the default inertia of the camera.
  118480. * This helps giving a smooth feeling to the camera movement.
  118481. */
  118482. inertia: number;
  118483. /**
  118484. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  118485. */
  118486. mode: number;
  118487. /**
  118488. * Define whether the camera is intermediate.
  118489. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  118490. */
  118491. isIntermediate: boolean;
  118492. /**
  118493. * Define the viewport of the camera.
  118494. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  118495. */
  118496. viewport: Viewport;
  118497. /**
  118498. * Restricts the camera to viewing objects with the same layerMask.
  118499. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  118500. */
  118501. layerMask: number;
  118502. /**
  118503. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  118504. */
  118505. fovMode: number;
  118506. /**
  118507. * Rig mode of the camera.
  118508. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  118509. * This is normally controlled byt the camera themselves as internal use.
  118510. */
  118511. cameraRigMode: number;
  118512. /**
  118513. * Defines the distance between both "eyes" in case of a RIG
  118514. */
  118515. interaxialDistance: number;
  118516. /**
  118517. * Defines if stereoscopic rendering is done side by side or over under.
  118518. */
  118519. isStereoscopicSideBySide: boolean;
  118520. /**
  118521. * 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
  118522. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  118523. * else in the scene. (Eg. security camera)
  118524. *
  118525. * 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)
  118526. */
  118527. customRenderTargets: RenderTargetTexture[];
  118528. /**
  118529. * When set, the camera will render to this render target instead of the default canvas
  118530. *
  118531. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  118532. */
  118533. outputRenderTarget: Nullable<RenderTargetTexture>;
  118534. /**
  118535. * Observable triggered when the camera view matrix has changed.
  118536. */
  118537. onViewMatrixChangedObservable: Observable<Camera>;
  118538. /**
  118539. * Observable triggered when the camera Projection matrix has changed.
  118540. */
  118541. onProjectionMatrixChangedObservable: Observable<Camera>;
  118542. /**
  118543. * Observable triggered when the inputs have been processed.
  118544. */
  118545. onAfterCheckInputsObservable: Observable<Camera>;
  118546. /**
  118547. * Observable triggered when reset has been called and applied to the camera.
  118548. */
  118549. onRestoreStateObservable: Observable<Camera>;
  118550. /**
  118551. * Is this camera a part of a rig system?
  118552. */
  118553. isRigCamera: boolean;
  118554. /**
  118555. * If isRigCamera set to true this will be set with the parent camera.
  118556. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  118557. */
  118558. rigParent?: Camera;
  118559. /** @hidden */
  118560. _cameraRigParams: any;
  118561. /** @hidden */
  118562. _rigCameras: Camera[];
  118563. /** @hidden */
  118564. _rigPostProcess: Nullable<PostProcess>;
  118565. protected _webvrViewMatrix: Matrix;
  118566. /** @hidden */
  118567. _skipRendering: boolean;
  118568. /** @hidden */
  118569. _projectionMatrix: Matrix;
  118570. /** @hidden */
  118571. _postProcesses: Nullable<PostProcess>[];
  118572. /** @hidden */
  118573. _activeMeshes: SmartArray<AbstractMesh>;
  118574. protected _globalPosition: Vector3;
  118575. /** @hidden */
  118576. _computedViewMatrix: Matrix;
  118577. private _doNotComputeProjectionMatrix;
  118578. private _transformMatrix;
  118579. private _frustumPlanes;
  118580. private _refreshFrustumPlanes;
  118581. private _storedFov;
  118582. private _stateStored;
  118583. /**
  118584. * Instantiates a new camera object.
  118585. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  118586. * @see https://doc.babylonjs.com/features/cameras
  118587. * @param name Defines the name of the camera in the scene
  118588. * @param position Defines the position of the camera
  118589. * @param scene Defines the scene the camera belongs too
  118590. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  118591. */
  118592. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  118593. /**
  118594. * Store current camera state (fov, position, etc..)
  118595. * @returns the camera
  118596. */
  118597. storeState(): Camera;
  118598. /**
  118599. * Restores the camera state values if it has been stored. You must call storeState() first
  118600. */
  118601. protected _restoreStateValues(): boolean;
  118602. /**
  118603. * Restored camera state. You must call storeState() first.
  118604. * @returns true if restored and false otherwise
  118605. */
  118606. restoreState(): boolean;
  118607. /**
  118608. * Gets the class name of the camera.
  118609. * @returns the class name
  118610. */
  118611. getClassName(): string;
  118612. /** @hidden */
  118613. readonly _isCamera: boolean;
  118614. /**
  118615. * Gets a string representation of the camera useful for debug purpose.
  118616. * @param fullDetails Defines that a more verboe level of logging is required
  118617. * @returns the string representation
  118618. */
  118619. toString(fullDetails?: boolean): string;
  118620. /**
  118621. * Gets the current world space position of the camera.
  118622. */
  118623. get globalPosition(): Vector3;
  118624. /**
  118625. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  118626. * @returns the active meshe list
  118627. */
  118628. getActiveMeshes(): SmartArray<AbstractMesh>;
  118629. /**
  118630. * Check whether a mesh is part of the current active mesh list of the camera
  118631. * @param mesh Defines the mesh to check
  118632. * @returns true if active, false otherwise
  118633. */
  118634. isActiveMesh(mesh: Mesh): boolean;
  118635. /**
  118636. * Is this camera ready to be used/rendered
  118637. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  118638. * @return true if the camera is ready
  118639. */
  118640. isReady(completeCheck?: boolean): boolean;
  118641. /** @hidden */
  118642. _initCache(): void;
  118643. /** @hidden */
  118644. _updateCache(ignoreParentClass?: boolean): void;
  118645. /** @hidden */
  118646. _isSynchronized(): boolean;
  118647. /** @hidden */
  118648. _isSynchronizedViewMatrix(): boolean;
  118649. /** @hidden */
  118650. _isSynchronizedProjectionMatrix(): boolean;
  118651. /**
  118652. * Attach the input controls to a specific dom element to get the input from.
  118653. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118654. */
  118655. attachControl(noPreventDefault?: boolean): void;
  118656. /**
  118657. * Attach the input controls to a specific dom element to get the input from.
  118658. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  118659. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118660. * BACK COMPAT SIGNATURE ONLY.
  118661. */
  118662. attachControl(ignored: any, noPreventDefault?: boolean): void;
  118663. /**
  118664. * Detach the current controls from the specified dom element.
  118665. */
  118666. detachControl(): void;
  118667. /**
  118668. * Detach the current controls from the specified dom element.
  118669. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  118670. */
  118671. detachControl(ignored: any): void;
  118672. /**
  118673. * Update the camera state according to the different inputs gathered during the frame.
  118674. */
  118675. update(): void;
  118676. /** @hidden */
  118677. _checkInputs(): void;
  118678. /** @hidden */
  118679. get rigCameras(): Camera[];
  118680. /**
  118681. * Gets the post process used by the rig cameras
  118682. */
  118683. get rigPostProcess(): Nullable<PostProcess>;
  118684. /**
  118685. * Internal, gets the first post proces.
  118686. * @returns the first post process to be run on this camera.
  118687. */
  118688. _getFirstPostProcess(): Nullable<PostProcess>;
  118689. private _cascadePostProcessesToRigCams;
  118690. /**
  118691. * Attach a post process to the camera.
  118692. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  118693. * @param postProcess The post process to attach to the camera
  118694. * @param insertAt The position of the post process in case several of them are in use in the scene
  118695. * @returns the position the post process has been inserted at
  118696. */
  118697. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  118698. /**
  118699. * Detach a post process to the camera.
  118700. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  118701. * @param postProcess The post process to detach from the camera
  118702. */
  118703. detachPostProcess(postProcess: PostProcess): void;
  118704. /**
  118705. * Gets the current world matrix of the camera
  118706. */
  118707. getWorldMatrix(): Matrix;
  118708. /** @hidden */
  118709. _getViewMatrix(): Matrix;
  118710. /**
  118711. * Gets the current view matrix of the camera.
  118712. * @param force forces the camera to recompute the matrix without looking at the cached state
  118713. * @returns the view matrix
  118714. */
  118715. getViewMatrix(force?: boolean): Matrix;
  118716. /**
  118717. * Freeze the projection matrix.
  118718. * It will prevent the cache check of the camera projection compute and can speed up perf
  118719. * if no parameter of the camera are meant to change
  118720. * @param projection Defines manually a projection if necessary
  118721. */
  118722. freezeProjectionMatrix(projection?: Matrix): void;
  118723. /**
  118724. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  118725. */
  118726. unfreezeProjectionMatrix(): void;
  118727. /**
  118728. * Gets the current projection matrix of the camera.
  118729. * @param force forces the camera to recompute the matrix without looking at the cached state
  118730. * @returns the projection matrix
  118731. */
  118732. getProjectionMatrix(force?: boolean): Matrix;
  118733. /**
  118734. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  118735. * @returns a Matrix
  118736. */
  118737. getTransformationMatrix(): Matrix;
  118738. private _updateFrustumPlanes;
  118739. /**
  118740. * Checks if a cullable object (mesh...) is in the camera frustum
  118741. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  118742. * @param target The object to check
  118743. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  118744. * @returns true if the object is in frustum otherwise false
  118745. */
  118746. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  118747. /**
  118748. * Checks if a cullable object (mesh...) is in the camera frustum
  118749. * Unlike isInFrustum this cheks the full bounding box
  118750. * @param target The object to check
  118751. * @returns true if the object is in frustum otherwise false
  118752. */
  118753. isCompletelyInFrustum(target: ICullable): boolean;
  118754. /**
  118755. * Gets a ray in the forward direction from the camera.
  118756. * @param length Defines the length of the ray to create
  118757. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  118758. * @param origin Defines the start point of the ray which defaults to the camera position
  118759. * @returns the forward ray
  118760. */
  118761. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  118762. /**
  118763. * Gets a ray in the forward direction from the camera.
  118764. * @param refRay the ray to (re)use when setting the values
  118765. * @param length Defines the length of the ray to create
  118766. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  118767. * @param origin Defines the start point of the ray which defaults to the camera position
  118768. * @returns the forward ray
  118769. */
  118770. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  118771. /**
  118772. * Releases resources associated with this node.
  118773. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  118774. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  118775. */
  118776. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  118777. /** @hidden */
  118778. _isLeftCamera: boolean;
  118779. /**
  118780. * Gets the left camera of a rig setup in case of Rigged Camera
  118781. */
  118782. get isLeftCamera(): boolean;
  118783. /** @hidden */
  118784. _isRightCamera: boolean;
  118785. /**
  118786. * Gets the right camera of a rig setup in case of Rigged Camera
  118787. */
  118788. get isRightCamera(): boolean;
  118789. /**
  118790. * Gets the left camera of a rig setup in case of Rigged Camera
  118791. */
  118792. get leftCamera(): Nullable<FreeCamera>;
  118793. /**
  118794. * Gets the right camera of a rig setup in case of Rigged Camera
  118795. */
  118796. get rightCamera(): Nullable<FreeCamera>;
  118797. /**
  118798. * Gets the left camera target of a rig setup in case of Rigged Camera
  118799. * @returns the target position
  118800. */
  118801. getLeftTarget(): Nullable<Vector3>;
  118802. /**
  118803. * Gets the right camera target of a rig setup in case of Rigged Camera
  118804. * @returns the target position
  118805. */
  118806. getRightTarget(): Nullable<Vector3>;
  118807. /**
  118808. * @hidden
  118809. */
  118810. setCameraRigMode(mode: number, rigParams: any): void;
  118811. /** @hidden */
  118812. static _setStereoscopicRigMode(camera: Camera): void;
  118813. /** @hidden */
  118814. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  118815. /** @hidden */
  118816. static _setVRRigMode(camera: Camera, rigParams: any): void;
  118817. /** @hidden */
  118818. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  118819. /** @hidden */
  118820. _getVRProjectionMatrix(): Matrix;
  118821. protected _updateCameraRotationMatrix(): void;
  118822. protected _updateWebVRCameraRotationMatrix(): void;
  118823. /**
  118824. * This function MUST be overwritten by the different WebVR cameras available.
  118825. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  118826. * @hidden
  118827. */
  118828. _getWebVRProjectionMatrix(): Matrix;
  118829. /**
  118830. * This function MUST be overwritten by the different WebVR cameras available.
  118831. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  118832. * @hidden
  118833. */
  118834. _getWebVRViewMatrix(): Matrix;
  118835. /** @hidden */
  118836. setCameraRigParameter(name: string, value: any): void;
  118837. /**
  118838. * needs to be overridden by children so sub has required properties to be copied
  118839. * @hidden
  118840. */
  118841. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  118842. /**
  118843. * May need to be overridden by children
  118844. * @hidden
  118845. */
  118846. _updateRigCameras(): void;
  118847. /** @hidden */
  118848. _setupInputs(): void;
  118849. /**
  118850. * Serialiaze the camera setup to a json represention
  118851. * @returns the JSON representation
  118852. */
  118853. serialize(): any;
  118854. /**
  118855. * Clones the current camera.
  118856. * @param name The cloned camera name
  118857. * @returns the cloned camera
  118858. */
  118859. clone(name: string): Camera;
  118860. /**
  118861. * Gets the direction of the camera relative to a given local axis.
  118862. * @param localAxis Defines the reference axis to provide a relative direction.
  118863. * @return the direction
  118864. */
  118865. getDirection(localAxis: Vector3): Vector3;
  118866. /**
  118867. * Returns the current camera absolute rotation
  118868. */
  118869. get absoluteRotation(): Quaternion;
  118870. /**
  118871. * Gets the direction of the camera relative to a given local axis into a passed vector.
  118872. * @param localAxis Defines the reference axis to provide a relative direction.
  118873. * @param result Defines the vector to store the result in
  118874. */
  118875. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  118876. /**
  118877. * Gets a camera constructor for a given camera type
  118878. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  118879. * @param name The name of the camera the result will be able to instantiate
  118880. * @param scene The scene the result will construct the camera in
  118881. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  118882. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  118883. * @returns a factory method to construc the camera
  118884. */
  118885. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  118886. /**
  118887. * Compute the world matrix of the camera.
  118888. * @returns the camera world matrix
  118889. */
  118890. computeWorldMatrix(): Matrix;
  118891. /**
  118892. * Parse a JSON and creates the camera from the parsed information
  118893. * @param parsedCamera The JSON to parse
  118894. * @param scene The scene to instantiate the camera in
  118895. * @returns the newly constructed camera
  118896. */
  118897. static Parse(parsedCamera: any, scene: Scene): Camera;
  118898. }
  118899. }
  118900. declare module BABYLON {
  118901. /**
  118902. * PostProcessManager is used to manage one or more post processes or post process pipelines
  118903. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118904. */
  118905. export class PostProcessManager {
  118906. private _scene;
  118907. private _indexBuffer;
  118908. private _vertexBuffers;
  118909. /**
  118910. * Creates a new instance PostProcess
  118911. * @param scene The scene that the post process is associated with.
  118912. */
  118913. constructor(scene: Scene);
  118914. private _prepareBuffers;
  118915. private _buildIndexBuffer;
  118916. /**
  118917. * Rebuilds the vertex buffers of the manager.
  118918. * @hidden
  118919. */
  118920. _rebuild(): void;
  118921. /**
  118922. * Prepares a frame to be run through a post process.
  118923. * @param sourceTexture The input texture to the post procesess. (default: null)
  118924. * @param postProcesses An array of post processes to be run. (default: null)
  118925. * @returns True if the post processes were able to be run.
  118926. * @hidden
  118927. */
  118928. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  118929. /**
  118930. * Manually render a set of post processes to a texture.
  118931. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  118932. * @param postProcesses An array of post processes to be run.
  118933. * @param targetTexture The target texture to render to.
  118934. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  118935. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  118936. * @param lodLevel defines which lod of the texture to render to
  118937. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  118938. */
  118939. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  118940. /**
  118941. * Finalize the result of the output of the postprocesses.
  118942. * @param doNotPresent If true the result will not be displayed to the screen.
  118943. * @param targetTexture The target texture to render to.
  118944. * @param faceIndex The index of the face to bind the target texture to.
  118945. * @param postProcesses The array of post processes to render.
  118946. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  118947. * @hidden
  118948. */
  118949. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  118950. /**
  118951. * Disposes of the post process manager.
  118952. */
  118953. dispose(): void;
  118954. }
  118955. }
  118956. declare module BABYLON {
  118957. /**
  118958. * This Helps creating a texture that will be created from a camera in your scene.
  118959. * It is basically a dynamic texture that could be used to create special effects for instance.
  118960. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  118961. */
  118962. export class RenderTargetTexture extends Texture {
  118963. /**
  118964. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  118965. */
  118966. static readonly REFRESHRATE_RENDER_ONCE: number;
  118967. /**
  118968. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  118969. */
  118970. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  118971. /**
  118972. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  118973. * the central point of your effect and can save a lot of performances.
  118974. */
  118975. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  118976. /**
  118977. * Use this predicate to dynamically define the list of mesh you want to render.
  118978. * If set, the renderList property will be overwritten.
  118979. */
  118980. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  118981. private _renderList;
  118982. /**
  118983. * Use this list to define the list of mesh you want to render.
  118984. */
  118985. get renderList(): Nullable<Array<AbstractMesh>>;
  118986. set renderList(value: Nullable<Array<AbstractMesh>>);
  118987. /**
  118988. * Use this function to overload the renderList array at rendering time.
  118989. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  118990. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  118991. * the cube (if the RTT is a cube, else layerOrFace=0).
  118992. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  118993. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  118994. * hold dummy elements!
  118995. */
  118996. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  118997. private _hookArray;
  118998. /**
  118999. * Define if particles should be rendered in your texture.
  119000. */
  119001. renderParticles: boolean;
  119002. /**
  119003. * Define if sprites should be rendered in your texture.
  119004. */
  119005. renderSprites: boolean;
  119006. /**
  119007. * Define the camera used to render the texture.
  119008. */
  119009. activeCamera: Nullable<Camera>;
  119010. /**
  119011. * Override the mesh isReady function with your own one.
  119012. */
  119013. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  119014. /**
  119015. * Override the render function of the texture with your own one.
  119016. */
  119017. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  119018. /**
  119019. * Define if camera post processes should be use while rendering the texture.
  119020. */
  119021. useCameraPostProcesses: boolean;
  119022. /**
  119023. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  119024. */
  119025. ignoreCameraViewport: boolean;
  119026. private _postProcessManager;
  119027. private _postProcesses;
  119028. private _resizeObserver;
  119029. /**
  119030. * An event triggered when the texture is unbind.
  119031. */
  119032. onBeforeBindObservable: Observable<RenderTargetTexture>;
  119033. /**
  119034. * An event triggered when the texture is unbind.
  119035. */
  119036. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  119037. private _onAfterUnbindObserver;
  119038. /**
  119039. * Set a after unbind callback in the texture.
  119040. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  119041. */
  119042. set onAfterUnbind(callback: () => void);
  119043. /**
  119044. * An event triggered before rendering the texture
  119045. */
  119046. onBeforeRenderObservable: Observable<number>;
  119047. private _onBeforeRenderObserver;
  119048. /**
  119049. * Set a before render callback in the texture.
  119050. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  119051. */
  119052. set onBeforeRender(callback: (faceIndex: number) => void);
  119053. /**
  119054. * An event triggered after rendering the texture
  119055. */
  119056. onAfterRenderObservable: Observable<number>;
  119057. private _onAfterRenderObserver;
  119058. /**
  119059. * Set a after render callback in the texture.
  119060. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  119061. */
  119062. set onAfterRender(callback: (faceIndex: number) => void);
  119063. /**
  119064. * An event triggered after the texture clear
  119065. */
  119066. onClearObservable: Observable<Engine>;
  119067. private _onClearObserver;
  119068. /**
  119069. * Set a clear callback in the texture.
  119070. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  119071. */
  119072. set onClear(callback: (Engine: Engine) => void);
  119073. /**
  119074. * An event triggered when the texture is resized.
  119075. */
  119076. onResizeObservable: Observable<RenderTargetTexture>;
  119077. /**
  119078. * Define the clear color of the Render Target if it should be different from the scene.
  119079. */
  119080. clearColor: Color4;
  119081. protected _size: number | {
  119082. width: number;
  119083. height: number;
  119084. layers?: number;
  119085. };
  119086. protected _initialSizeParameter: number | {
  119087. width: number;
  119088. height: number;
  119089. } | {
  119090. ratio: number;
  119091. };
  119092. protected _sizeRatio: Nullable<number>;
  119093. /** @hidden */
  119094. _generateMipMaps: boolean;
  119095. protected _renderingManager: RenderingManager;
  119096. /** @hidden */
  119097. _waitingRenderList?: string[];
  119098. protected _doNotChangeAspectRatio: boolean;
  119099. protected _currentRefreshId: number;
  119100. protected _refreshRate: number;
  119101. protected _textureMatrix: Matrix;
  119102. protected _samples: number;
  119103. protected _renderTargetOptions: RenderTargetCreationOptions;
  119104. /**
  119105. * Gets render target creation options that were used.
  119106. */
  119107. get renderTargetOptions(): RenderTargetCreationOptions;
  119108. protected _onRatioRescale(): void;
  119109. /**
  119110. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  119111. * It must define where the camera used to render the texture is set
  119112. */
  119113. boundingBoxPosition: Vector3;
  119114. private _boundingBoxSize;
  119115. /**
  119116. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  119117. * When defined, the cubemap will switch to local mode
  119118. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  119119. * @example https://www.babylonjs-playground.com/#RNASML
  119120. */
  119121. set boundingBoxSize(value: Vector3);
  119122. get boundingBoxSize(): Vector3;
  119123. /**
  119124. * In case the RTT has been created with a depth texture, get the associated
  119125. * depth texture.
  119126. * Otherwise, return null.
  119127. */
  119128. get depthStencilTexture(): Nullable<InternalTexture>;
  119129. /**
  119130. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  119131. * or used a shadow, depth texture...
  119132. * @param name The friendly name of the texture
  119133. * @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)
  119134. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  119135. * @param generateMipMaps True if mip maps need to be generated after render.
  119136. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  119137. * @param type The type of the buffer in the RTT (int, half float, float...)
  119138. * @param isCube True if a cube texture needs to be created
  119139. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  119140. * @param generateDepthBuffer True to generate a depth buffer
  119141. * @param generateStencilBuffer True to generate a stencil buffer
  119142. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  119143. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  119144. * @param delayAllocation if the texture allocation should be delayed (default: false)
  119145. */
  119146. constructor(name: string, size: number | {
  119147. width: number;
  119148. height: number;
  119149. layers?: number;
  119150. } | {
  119151. ratio: number;
  119152. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  119153. /**
  119154. * Creates a depth stencil texture.
  119155. * This is only available in WebGL 2 or with the depth texture extension available.
  119156. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  119157. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  119158. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  119159. */
  119160. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  119161. private _processSizeParameter;
  119162. /**
  119163. * Define the number of samples to use in case of MSAA.
  119164. * It defaults to one meaning no MSAA has been enabled.
  119165. */
  119166. get samples(): number;
  119167. set samples(value: number);
  119168. /**
  119169. * Resets the refresh counter of the texture and start bak from scratch.
  119170. * Could be useful to regenerate the texture if it is setup to render only once.
  119171. */
  119172. resetRefreshCounter(): void;
  119173. /**
  119174. * Define the refresh rate of the texture or the rendering frequency.
  119175. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  119176. */
  119177. get refreshRate(): number;
  119178. set refreshRate(value: number);
  119179. /**
  119180. * Adds a post process to the render target rendering passes.
  119181. * @param postProcess define the post process to add
  119182. */
  119183. addPostProcess(postProcess: PostProcess): void;
  119184. /**
  119185. * Clear all the post processes attached to the render target
  119186. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  119187. */
  119188. clearPostProcesses(dispose?: boolean): void;
  119189. /**
  119190. * Remove one of the post process from the list of attached post processes to the texture
  119191. * @param postProcess define the post process to remove from the list
  119192. */
  119193. removePostProcess(postProcess: PostProcess): void;
  119194. /** @hidden */
  119195. _shouldRender(): boolean;
  119196. /**
  119197. * Gets the actual render size of the texture.
  119198. * @returns the width of the render size
  119199. */
  119200. getRenderSize(): number;
  119201. /**
  119202. * Gets the actual render width of the texture.
  119203. * @returns the width of the render size
  119204. */
  119205. getRenderWidth(): number;
  119206. /**
  119207. * Gets the actual render height of the texture.
  119208. * @returns the height of the render size
  119209. */
  119210. getRenderHeight(): number;
  119211. /**
  119212. * Gets the actual number of layers of the texture.
  119213. * @returns the number of layers
  119214. */
  119215. getRenderLayers(): number;
  119216. /**
  119217. * Get if the texture can be rescaled or not.
  119218. */
  119219. get canRescale(): boolean;
  119220. /**
  119221. * Resize the texture using a ratio.
  119222. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  119223. */
  119224. scale(ratio: number): void;
  119225. /**
  119226. * Get the texture reflection matrix used to rotate/transform the reflection.
  119227. * @returns the reflection matrix
  119228. */
  119229. getReflectionTextureMatrix(): Matrix;
  119230. /**
  119231. * Resize the texture to a new desired size.
  119232. * Be carrefull as it will recreate all the data in the new texture.
  119233. * @param size Define the new size. It can be:
  119234. * - a number for squared texture,
  119235. * - an object containing { width: number, height: number }
  119236. * - or an object containing a ratio { ratio: number }
  119237. */
  119238. resize(size: number | {
  119239. width: number;
  119240. height: number;
  119241. } | {
  119242. ratio: number;
  119243. }): void;
  119244. private _defaultRenderListPrepared;
  119245. /**
  119246. * Renders all the objects from the render list into the texture.
  119247. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  119248. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  119249. */
  119250. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  119251. private _bestReflectionRenderTargetDimension;
  119252. private _prepareRenderingManager;
  119253. /**
  119254. * @hidden
  119255. * @param faceIndex face index to bind to if this is a cubetexture
  119256. * @param layer defines the index of the texture to bind in the array
  119257. */
  119258. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  119259. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  119260. private renderToTarget;
  119261. /**
  119262. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  119263. * This allowed control for front to back rendering or reversly depending of the special needs.
  119264. *
  119265. * @param renderingGroupId The rendering group id corresponding to its index
  119266. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  119267. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  119268. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  119269. */
  119270. 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;
  119271. /**
  119272. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  119273. *
  119274. * @param renderingGroupId The rendering group id corresponding to its index
  119275. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  119276. */
  119277. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  119278. /**
  119279. * Clones the texture.
  119280. * @returns the cloned texture
  119281. */
  119282. clone(): RenderTargetTexture;
  119283. /**
  119284. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  119285. * @returns The JSON representation of the texture
  119286. */
  119287. serialize(): any;
  119288. /**
  119289. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  119290. */
  119291. disposeFramebufferObjects(): void;
  119292. /**
  119293. * Dispose the texture and release its associated resources.
  119294. */
  119295. dispose(): void;
  119296. /** @hidden */
  119297. _rebuild(): void;
  119298. /**
  119299. * Clear the info related to rendering groups preventing retention point in material dispose.
  119300. */
  119301. freeRenderingGroups(): void;
  119302. /**
  119303. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  119304. * @returns the view count
  119305. */
  119306. getViewCount(): number;
  119307. }
  119308. }
  119309. declare module BABYLON {
  119310. /**
  119311. * Options to be used when creating an effect.
  119312. */
  119313. export interface IEffectCreationOptions {
  119314. /**
  119315. * Atrributes that will be used in the shader.
  119316. */
  119317. attributes: string[];
  119318. /**
  119319. * Uniform varible names that will be set in the shader.
  119320. */
  119321. uniformsNames: string[];
  119322. /**
  119323. * Uniform buffer variable names that will be set in the shader.
  119324. */
  119325. uniformBuffersNames: string[];
  119326. /**
  119327. * Sampler texture variable names that will be set in the shader.
  119328. */
  119329. samplers: string[];
  119330. /**
  119331. * Define statements that will be set in the shader.
  119332. */
  119333. defines: any;
  119334. /**
  119335. * Possible fallbacks for this effect to improve performance when needed.
  119336. */
  119337. fallbacks: Nullable<IEffectFallbacks>;
  119338. /**
  119339. * Callback that will be called when the shader is compiled.
  119340. */
  119341. onCompiled: Nullable<(effect: Effect) => void>;
  119342. /**
  119343. * Callback that will be called if an error occurs during shader compilation.
  119344. */
  119345. onError: Nullable<(effect: Effect, errors: string) => void>;
  119346. /**
  119347. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  119348. */
  119349. indexParameters?: any;
  119350. /**
  119351. * Max number of lights that can be used in the shader.
  119352. */
  119353. maxSimultaneousLights?: number;
  119354. /**
  119355. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  119356. */
  119357. transformFeedbackVaryings?: Nullable<string[]>;
  119358. /**
  119359. * 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
  119360. */
  119361. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  119362. /**
  119363. * Is this effect rendering to several color attachments ?
  119364. */
  119365. multiTarget?: boolean;
  119366. }
  119367. /**
  119368. * Effect containing vertex and fragment shader that can be executed on an object.
  119369. */
  119370. export class Effect implements IDisposable {
  119371. /**
  119372. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  119373. */
  119374. static ShadersRepository: string;
  119375. /**
  119376. * Enable logging of the shader code when a compilation error occurs
  119377. */
  119378. static LogShaderCodeOnCompilationError: boolean;
  119379. /**
  119380. * Name of the effect.
  119381. */
  119382. name: any;
  119383. /**
  119384. * String container all the define statements that should be set on the shader.
  119385. */
  119386. defines: string;
  119387. /**
  119388. * Callback that will be called when the shader is compiled.
  119389. */
  119390. onCompiled: Nullable<(effect: Effect) => void>;
  119391. /**
  119392. * Callback that will be called if an error occurs during shader compilation.
  119393. */
  119394. onError: Nullable<(effect: Effect, errors: string) => void>;
  119395. /**
  119396. * Callback that will be called when effect is bound.
  119397. */
  119398. onBind: Nullable<(effect: Effect) => void>;
  119399. /**
  119400. * Unique ID of the effect.
  119401. */
  119402. uniqueId: number;
  119403. /**
  119404. * Observable that will be called when the shader is compiled.
  119405. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  119406. */
  119407. onCompileObservable: Observable<Effect>;
  119408. /**
  119409. * Observable that will be called if an error occurs during shader compilation.
  119410. */
  119411. onErrorObservable: Observable<Effect>;
  119412. /** @hidden */
  119413. _onBindObservable: Nullable<Observable<Effect>>;
  119414. /**
  119415. * @hidden
  119416. * Specifies if the effect was previously ready
  119417. */
  119418. _wasPreviouslyReady: boolean;
  119419. /**
  119420. * Observable that will be called when effect is bound.
  119421. */
  119422. get onBindObservable(): Observable<Effect>;
  119423. /** @hidden */
  119424. _bonesComputationForcedToCPU: boolean;
  119425. /** @hidden */
  119426. _multiTarget: boolean;
  119427. private static _uniqueIdSeed;
  119428. private _engine;
  119429. private _uniformBuffersNames;
  119430. private _uniformBuffersNamesList;
  119431. private _uniformsNames;
  119432. private _samplerList;
  119433. private _samplers;
  119434. private _isReady;
  119435. private _compilationError;
  119436. private _allFallbacksProcessed;
  119437. private _attributesNames;
  119438. private _attributes;
  119439. private _attributeLocationByName;
  119440. private _uniforms;
  119441. /**
  119442. * Key for the effect.
  119443. * @hidden
  119444. */
  119445. _key: string;
  119446. private _indexParameters;
  119447. private _fallbacks;
  119448. private _vertexSourceCode;
  119449. private _fragmentSourceCode;
  119450. private _vertexSourceCodeOverride;
  119451. private _fragmentSourceCodeOverride;
  119452. private _transformFeedbackVaryings;
  119453. private _rawVertexSourceCode;
  119454. private _rawFragmentSourceCode;
  119455. /**
  119456. * Compiled shader to webGL program.
  119457. * @hidden
  119458. */
  119459. _pipelineContext: Nullable<IPipelineContext>;
  119460. private _valueCache;
  119461. private static _baseCache;
  119462. /**
  119463. * Instantiates an effect.
  119464. * An effect can be used to create/manage/execute vertex and fragment shaders.
  119465. * @param baseName Name of the effect.
  119466. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  119467. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  119468. * @param samplers List of sampler variables that will be passed to the shader.
  119469. * @param engine Engine to be used to render the effect
  119470. * @param defines Define statements to be added to the shader.
  119471. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  119472. * @param onCompiled Callback that will be called when the shader is compiled.
  119473. * @param onError Callback that will be called if an error occurs during shader compilation.
  119474. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  119475. */
  119476. 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);
  119477. private _useFinalCode;
  119478. /**
  119479. * Unique key for this effect
  119480. */
  119481. get key(): string;
  119482. /**
  119483. * If the effect has been compiled and prepared.
  119484. * @returns if the effect is compiled and prepared.
  119485. */
  119486. isReady(): boolean;
  119487. private _isReadyInternal;
  119488. /**
  119489. * The engine the effect was initialized with.
  119490. * @returns the engine.
  119491. */
  119492. getEngine(): Engine;
  119493. /**
  119494. * The pipeline context for this effect
  119495. * @returns the associated pipeline context
  119496. */
  119497. getPipelineContext(): Nullable<IPipelineContext>;
  119498. /**
  119499. * The set of names of attribute variables for the shader.
  119500. * @returns An array of attribute names.
  119501. */
  119502. getAttributesNames(): string[];
  119503. /**
  119504. * Returns the attribute at the given index.
  119505. * @param index The index of the attribute.
  119506. * @returns The location of the attribute.
  119507. */
  119508. getAttributeLocation(index: number): number;
  119509. /**
  119510. * Returns the attribute based on the name of the variable.
  119511. * @param name of the attribute to look up.
  119512. * @returns the attribute location.
  119513. */
  119514. getAttributeLocationByName(name: string): number;
  119515. /**
  119516. * The number of attributes.
  119517. * @returns the numnber of attributes.
  119518. */
  119519. getAttributesCount(): number;
  119520. /**
  119521. * Gets the index of a uniform variable.
  119522. * @param uniformName of the uniform to look up.
  119523. * @returns the index.
  119524. */
  119525. getUniformIndex(uniformName: string): number;
  119526. /**
  119527. * Returns the attribute based on the name of the variable.
  119528. * @param uniformName of the uniform to look up.
  119529. * @returns the location of the uniform.
  119530. */
  119531. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  119532. /**
  119533. * Returns an array of sampler variable names
  119534. * @returns The array of sampler variable names.
  119535. */
  119536. getSamplers(): string[];
  119537. /**
  119538. * Returns an array of uniform variable names
  119539. * @returns The array of uniform variable names.
  119540. */
  119541. getUniformNames(): string[];
  119542. /**
  119543. * Returns an array of uniform buffer variable names
  119544. * @returns The array of uniform buffer variable names.
  119545. */
  119546. getUniformBuffersNames(): string[];
  119547. /**
  119548. * Returns the index parameters used to create the effect
  119549. * @returns The index parameters object
  119550. */
  119551. getIndexParameters(): any;
  119552. /**
  119553. * The error from the last compilation.
  119554. * @returns the error string.
  119555. */
  119556. getCompilationError(): string;
  119557. /**
  119558. * Gets a boolean indicating that all fallbacks were used during compilation
  119559. * @returns true if all fallbacks were used
  119560. */
  119561. allFallbacksProcessed(): boolean;
  119562. /**
  119563. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  119564. * @param func The callback to be used.
  119565. */
  119566. executeWhenCompiled(func: (effect: Effect) => void): void;
  119567. private _checkIsReady;
  119568. private _loadShader;
  119569. /**
  119570. * Gets the vertex shader source code of this effect
  119571. */
  119572. get vertexSourceCode(): string;
  119573. /**
  119574. * Gets the fragment shader source code of this effect
  119575. */
  119576. get fragmentSourceCode(): string;
  119577. /**
  119578. * Gets the vertex shader source code before it has been processed by the preprocessor
  119579. */
  119580. get rawVertexSourceCode(): string;
  119581. /**
  119582. * Gets the fragment shader source code before it has been processed by the preprocessor
  119583. */
  119584. get rawFragmentSourceCode(): string;
  119585. /**
  119586. * Recompiles the webGL program
  119587. * @param vertexSourceCode The source code for the vertex shader.
  119588. * @param fragmentSourceCode The source code for the fragment shader.
  119589. * @param onCompiled Callback called when completed.
  119590. * @param onError Callback called on error.
  119591. * @hidden
  119592. */
  119593. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  119594. /**
  119595. * Prepares the effect
  119596. * @hidden
  119597. */
  119598. _prepareEffect(): void;
  119599. private _getShaderCodeAndErrorLine;
  119600. private _processCompilationErrors;
  119601. /**
  119602. * Checks if the effect is supported. (Must be called after compilation)
  119603. */
  119604. get isSupported(): boolean;
  119605. /**
  119606. * Binds a texture to the engine to be used as output of the shader.
  119607. * @param channel Name of the output variable.
  119608. * @param texture Texture to bind.
  119609. * @hidden
  119610. */
  119611. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  119612. /**
  119613. * Sets a texture on the engine to be used in the shader.
  119614. * @param channel Name of the sampler variable.
  119615. * @param texture Texture to set.
  119616. */
  119617. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  119618. /**
  119619. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  119620. * @param channel Name of the sampler variable.
  119621. * @param texture Texture to set.
  119622. */
  119623. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  119624. /**
  119625. * Sets an array of textures on the engine to be used in the shader.
  119626. * @param channel Name of the variable.
  119627. * @param textures Textures to set.
  119628. */
  119629. setTextureArray(channel: string, textures: ThinTexture[]): void;
  119630. /**
  119631. * 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)
  119632. * @param channel Name of the sampler variable.
  119633. * @param postProcess Post process to get the input texture from.
  119634. */
  119635. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  119636. /**
  119637. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  119638. * 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)
  119639. * @param channel Name of the sampler variable.
  119640. * @param postProcess Post process to get the output texture from.
  119641. */
  119642. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  119643. /** @hidden */
  119644. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  119645. /** @hidden */
  119646. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  119647. /** @hidden */
  119648. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  119649. /** @hidden */
  119650. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  119651. /**
  119652. * Binds a buffer to a uniform.
  119653. * @param buffer Buffer to bind.
  119654. * @param name Name of the uniform variable to bind to.
  119655. */
  119656. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  119657. /**
  119658. * Binds block to a uniform.
  119659. * @param blockName Name of the block to bind.
  119660. * @param index Index to bind.
  119661. */
  119662. bindUniformBlock(blockName: string, index: number): void;
  119663. /**
  119664. * Sets an interger value on a uniform variable.
  119665. * @param uniformName Name of the variable.
  119666. * @param value Value to be set.
  119667. * @returns this effect.
  119668. */
  119669. setInt(uniformName: string, value: number): Effect;
  119670. /**
  119671. * Sets an int array on a uniform variable.
  119672. * @param uniformName Name of the variable.
  119673. * @param array array to be set.
  119674. * @returns this effect.
  119675. */
  119676. setIntArray(uniformName: string, array: Int32Array): Effect;
  119677. /**
  119678. * 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)
  119679. * @param uniformName Name of the variable.
  119680. * @param array array to be set.
  119681. * @returns this effect.
  119682. */
  119683. setIntArray2(uniformName: string, array: Int32Array): Effect;
  119684. /**
  119685. * 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)
  119686. * @param uniformName Name of the variable.
  119687. * @param array array to be set.
  119688. * @returns this effect.
  119689. */
  119690. setIntArray3(uniformName: string, array: Int32Array): Effect;
  119691. /**
  119692. * 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)
  119693. * @param uniformName Name of the variable.
  119694. * @param array array to be set.
  119695. * @returns this effect.
  119696. */
  119697. setIntArray4(uniformName: string, array: Int32Array): Effect;
  119698. /**
  119699. * Sets an float array on a uniform variable.
  119700. * @param uniformName Name of the variable.
  119701. * @param array array to be set.
  119702. * @returns this effect.
  119703. */
  119704. setFloatArray(uniformName: string, array: Float32Array): Effect;
  119705. /**
  119706. * 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)
  119707. * @param uniformName Name of the variable.
  119708. * @param array array to be set.
  119709. * @returns this effect.
  119710. */
  119711. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  119712. /**
  119713. * 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)
  119714. * @param uniformName Name of the variable.
  119715. * @param array array to be set.
  119716. * @returns this effect.
  119717. */
  119718. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  119719. /**
  119720. * 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)
  119721. * @param uniformName Name of the variable.
  119722. * @param array array to be set.
  119723. * @returns this effect.
  119724. */
  119725. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  119726. /**
  119727. * Sets an array on a uniform variable.
  119728. * @param uniformName Name of the variable.
  119729. * @param array array to be set.
  119730. * @returns this effect.
  119731. */
  119732. setArray(uniformName: string, array: number[]): Effect;
  119733. /**
  119734. * 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)
  119735. * @param uniformName Name of the variable.
  119736. * @param array array to be set.
  119737. * @returns this effect.
  119738. */
  119739. setArray2(uniformName: string, array: number[]): Effect;
  119740. /**
  119741. * 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)
  119742. * @param uniformName Name of the variable.
  119743. * @param array array to be set.
  119744. * @returns this effect.
  119745. */
  119746. setArray3(uniformName: string, array: number[]): Effect;
  119747. /**
  119748. * 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)
  119749. * @param uniformName Name of the variable.
  119750. * @param array array to be set.
  119751. * @returns this effect.
  119752. */
  119753. setArray4(uniformName: string, array: number[]): Effect;
  119754. /**
  119755. * Sets matrices on a uniform variable.
  119756. * @param uniformName Name of the variable.
  119757. * @param matrices matrices to be set.
  119758. * @returns this effect.
  119759. */
  119760. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  119761. /**
  119762. * Sets matrix on a uniform variable.
  119763. * @param uniformName Name of the variable.
  119764. * @param matrix matrix to be set.
  119765. * @returns this effect.
  119766. */
  119767. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  119768. /**
  119769. * 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)
  119770. * @param uniformName Name of the variable.
  119771. * @param matrix matrix to be set.
  119772. * @returns this effect.
  119773. */
  119774. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  119775. /**
  119776. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  119777. * @param uniformName Name of the variable.
  119778. * @param matrix matrix to be set.
  119779. * @returns this effect.
  119780. */
  119781. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  119782. /**
  119783. * Sets a float on a uniform variable.
  119784. * @param uniformName Name of the variable.
  119785. * @param value value to be set.
  119786. * @returns this effect.
  119787. */
  119788. setFloat(uniformName: string, value: number): Effect;
  119789. /**
  119790. * Sets a boolean on a uniform variable.
  119791. * @param uniformName Name of the variable.
  119792. * @param bool value to be set.
  119793. * @returns this effect.
  119794. */
  119795. setBool(uniformName: string, bool: boolean): Effect;
  119796. /**
  119797. * Sets a Vector2 on a uniform variable.
  119798. * @param uniformName Name of the variable.
  119799. * @param vector2 vector2 to be set.
  119800. * @returns this effect.
  119801. */
  119802. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  119803. /**
  119804. * Sets a float2 on a uniform variable.
  119805. * @param uniformName Name of the variable.
  119806. * @param x First float in float2.
  119807. * @param y Second float in float2.
  119808. * @returns this effect.
  119809. */
  119810. setFloat2(uniformName: string, x: number, y: number): Effect;
  119811. /**
  119812. * Sets a Vector3 on a uniform variable.
  119813. * @param uniformName Name of the variable.
  119814. * @param vector3 Value to be set.
  119815. * @returns this effect.
  119816. */
  119817. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  119818. /**
  119819. * Sets a float3 on a uniform variable.
  119820. * @param uniformName Name of the variable.
  119821. * @param x First float in float3.
  119822. * @param y Second float in float3.
  119823. * @param z Third float in float3.
  119824. * @returns this effect.
  119825. */
  119826. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  119827. /**
  119828. * Sets a Vector4 on a uniform variable.
  119829. * @param uniformName Name of the variable.
  119830. * @param vector4 Value to be set.
  119831. * @returns this effect.
  119832. */
  119833. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  119834. /**
  119835. * Sets a float4 on a uniform variable.
  119836. * @param uniformName Name of the variable.
  119837. * @param x First float in float4.
  119838. * @param y Second float in float4.
  119839. * @param z Third float in float4.
  119840. * @param w Fourth float in float4.
  119841. * @returns this effect.
  119842. */
  119843. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  119844. /**
  119845. * Sets a Color3 on a uniform variable.
  119846. * @param uniformName Name of the variable.
  119847. * @param color3 Value to be set.
  119848. * @returns this effect.
  119849. */
  119850. setColor3(uniformName: string, color3: IColor3Like): Effect;
  119851. /**
  119852. * Sets a Color4 on a uniform variable.
  119853. * @param uniformName Name of the variable.
  119854. * @param color3 Value to be set.
  119855. * @param alpha Alpha value to be set.
  119856. * @returns this effect.
  119857. */
  119858. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  119859. /**
  119860. * Sets a Color4 on a uniform variable
  119861. * @param uniformName defines the name of the variable
  119862. * @param color4 defines the value to be set
  119863. * @returns this effect.
  119864. */
  119865. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  119866. /** Release all associated resources */
  119867. dispose(): void;
  119868. /**
  119869. * This function will add a new shader to the shader store
  119870. * @param name the name of the shader
  119871. * @param pixelShader optional pixel shader content
  119872. * @param vertexShader optional vertex shader content
  119873. */
  119874. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  119875. /**
  119876. * Store of each shader (The can be looked up using effect.key)
  119877. */
  119878. static ShadersStore: {
  119879. [key: string]: string;
  119880. };
  119881. /**
  119882. * Store of each included file for a shader (The can be looked up using effect.key)
  119883. */
  119884. static IncludesShadersStore: {
  119885. [key: string]: string;
  119886. };
  119887. /**
  119888. * Resets the cache of effects.
  119889. */
  119890. static ResetCache(): void;
  119891. }
  119892. }
  119893. declare module BABYLON {
  119894. /**
  119895. * Interface used to describe the capabilities of the engine relatively to the current browser
  119896. */
  119897. export interface EngineCapabilities {
  119898. /** Maximum textures units per fragment shader */
  119899. maxTexturesImageUnits: number;
  119900. /** Maximum texture units per vertex shader */
  119901. maxVertexTextureImageUnits: number;
  119902. /** Maximum textures units in the entire pipeline */
  119903. maxCombinedTexturesImageUnits: number;
  119904. /** Maximum texture size */
  119905. maxTextureSize: number;
  119906. /** Maximum texture samples */
  119907. maxSamples?: number;
  119908. /** Maximum cube texture size */
  119909. maxCubemapTextureSize: number;
  119910. /** Maximum render texture size */
  119911. maxRenderTextureSize: number;
  119912. /** Maximum number of vertex attributes */
  119913. maxVertexAttribs: number;
  119914. /** Maximum number of varyings */
  119915. maxVaryingVectors: number;
  119916. /** Maximum number of uniforms per vertex shader */
  119917. maxVertexUniformVectors: number;
  119918. /** Maximum number of uniforms per fragment shader */
  119919. maxFragmentUniformVectors: number;
  119920. /** Defines if standard derivates (dx/dy) are supported */
  119921. standardDerivatives: boolean;
  119922. /** Defines if s3tc texture compression is supported */
  119923. s3tc?: WEBGL_compressed_texture_s3tc;
  119924. /** Defines if pvrtc texture compression is supported */
  119925. pvrtc: any;
  119926. /** Defines if etc1 texture compression is supported */
  119927. etc1: any;
  119928. /** Defines if etc2 texture compression is supported */
  119929. etc2: any;
  119930. /** Defines if astc texture compression is supported */
  119931. astc: any;
  119932. /** Defines if bptc texture compression is supported */
  119933. bptc: any;
  119934. /** Defines if float textures are supported */
  119935. textureFloat: boolean;
  119936. /** Defines if vertex array objects are supported */
  119937. vertexArrayObject: boolean;
  119938. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  119939. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  119940. /** Gets the maximum level of anisotropy supported */
  119941. maxAnisotropy: number;
  119942. /** Defines if instancing is supported */
  119943. instancedArrays: boolean;
  119944. /** Defines if 32 bits indices are supported */
  119945. uintIndices: boolean;
  119946. /** Defines if high precision shaders are supported */
  119947. highPrecisionShaderSupported: boolean;
  119948. /** Defines if depth reading in the fragment shader is supported */
  119949. fragmentDepthSupported: boolean;
  119950. /** Defines if float texture linear filtering is supported*/
  119951. textureFloatLinearFiltering: boolean;
  119952. /** Defines if rendering to float textures is supported */
  119953. textureFloatRender: boolean;
  119954. /** Defines if half float textures are supported*/
  119955. textureHalfFloat: boolean;
  119956. /** Defines if half float texture linear filtering is supported*/
  119957. textureHalfFloatLinearFiltering: boolean;
  119958. /** Defines if rendering to half float textures is supported */
  119959. textureHalfFloatRender: boolean;
  119960. /** Defines if textureLOD shader command is supported */
  119961. textureLOD: boolean;
  119962. /** Defines if draw buffers extension is supported */
  119963. drawBuffersExtension: boolean;
  119964. /** Defines if depth textures are supported */
  119965. depthTextureExtension: boolean;
  119966. /** Defines if float color buffer are supported */
  119967. colorBufferFloat: boolean;
  119968. /** Gets disjoint timer query extension (null if not supported) */
  119969. timerQuery?: EXT_disjoint_timer_query;
  119970. /** Defines if timestamp can be used with timer query */
  119971. canUseTimestampForTimerQuery: boolean;
  119972. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  119973. multiview?: any;
  119974. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  119975. oculusMultiview?: any;
  119976. /** Function used to let the system compiles shaders in background */
  119977. parallelShaderCompile?: {
  119978. COMPLETION_STATUS_KHR: number;
  119979. };
  119980. /** Max number of texture samples for MSAA */
  119981. maxMSAASamples: number;
  119982. /** Defines if the blend min max extension is supported */
  119983. blendMinMax: boolean;
  119984. }
  119985. }
  119986. declare module BABYLON {
  119987. /**
  119988. * @hidden
  119989. **/
  119990. export class DepthCullingState {
  119991. private _isDepthTestDirty;
  119992. private _isDepthMaskDirty;
  119993. private _isDepthFuncDirty;
  119994. private _isCullFaceDirty;
  119995. private _isCullDirty;
  119996. private _isZOffsetDirty;
  119997. private _isFrontFaceDirty;
  119998. private _depthTest;
  119999. private _depthMask;
  120000. private _depthFunc;
  120001. private _cull;
  120002. private _cullFace;
  120003. private _zOffset;
  120004. private _frontFace;
  120005. /**
  120006. * Initializes the state.
  120007. */
  120008. constructor();
  120009. get isDirty(): boolean;
  120010. get zOffset(): number;
  120011. set zOffset(value: number);
  120012. get cullFace(): Nullable<number>;
  120013. set cullFace(value: Nullable<number>);
  120014. get cull(): Nullable<boolean>;
  120015. set cull(value: Nullable<boolean>);
  120016. get depthFunc(): Nullable<number>;
  120017. set depthFunc(value: Nullable<number>);
  120018. get depthMask(): boolean;
  120019. set depthMask(value: boolean);
  120020. get depthTest(): boolean;
  120021. set depthTest(value: boolean);
  120022. get frontFace(): Nullable<number>;
  120023. set frontFace(value: Nullable<number>);
  120024. reset(): void;
  120025. apply(gl: WebGLRenderingContext): void;
  120026. }
  120027. }
  120028. declare module BABYLON {
  120029. /**
  120030. * @hidden
  120031. **/
  120032. export class StencilState {
  120033. /** 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 */
  120034. static readonly ALWAYS: number;
  120035. /** Passed to stencilOperation to specify that stencil value must be kept */
  120036. static readonly KEEP: number;
  120037. /** Passed to stencilOperation to specify that stencil value must be replaced */
  120038. static readonly REPLACE: number;
  120039. private _isStencilTestDirty;
  120040. private _isStencilMaskDirty;
  120041. private _isStencilFuncDirty;
  120042. private _isStencilOpDirty;
  120043. private _stencilTest;
  120044. private _stencilMask;
  120045. private _stencilFunc;
  120046. private _stencilFuncRef;
  120047. private _stencilFuncMask;
  120048. private _stencilOpStencilFail;
  120049. private _stencilOpDepthFail;
  120050. private _stencilOpStencilDepthPass;
  120051. get isDirty(): boolean;
  120052. get stencilFunc(): number;
  120053. set stencilFunc(value: number);
  120054. get stencilFuncRef(): number;
  120055. set stencilFuncRef(value: number);
  120056. get stencilFuncMask(): number;
  120057. set stencilFuncMask(value: number);
  120058. get stencilOpStencilFail(): number;
  120059. set stencilOpStencilFail(value: number);
  120060. get stencilOpDepthFail(): number;
  120061. set stencilOpDepthFail(value: number);
  120062. get stencilOpStencilDepthPass(): number;
  120063. set stencilOpStencilDepthPass(value: number);
  120064. get stencilMask(): number;
  120065. set stencilMask(value: number);
  120066. get stencilTest(): boolean;
  120067. set stencilTest(value: boolean);
  120068. constructor();
  120069. reset(): void;
  120070. apply(gl: WebGLRenderingContext): void;
  120071. }
  120072. }
  120073. declare module BABYLON {
  120074. /**
  120075. * @hidden
  120076. **/
  120077. export class AlphaState {
  120078. private _isAlphaBlendDirty;
  120079. private _isBlendFunctionParametersDirty;
  120080. private _isBlendEquationParametersDirty;
  120081. private _isBlendConstantsDirty;
  120082. private _alphaBlend;
  120083. private _blendFunctionParameters;
  120084. private _blendEquationParameters;
  120085. private _blendConstants;
  120086. /**
  120087. * Initializes the state.
  120088. */
  120089. constructor();
  120090. get isDirty(): boolean;
  120091. get alphaBlend(): boolean;
  120092. set alphaBlend(value: boolean);
  120093. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  120094. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  120095. setAlphaEquationParameters(rgb: number, alpha: number): void;
  120096. reset(): void;
  120097. apply(gl: WebGLRenderingContext): void;
  120098. }
  120099. }
  120100. declare module BABYLON {
  120101. /** @hidden */
  120102. export class WebGLShaderProcessor implements IShaderProcessor {
  120103. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  120104. }
  120105. }
  120106. declare module BABYLON {
  120107. /** @hidden */
  120108. export class WebGL2ShaderProcessor implements IShaderProcessor {
  120109. attributeProcessor(attribute: string): string;
  120110. varyingProcessor(varying: string, isFragment: boolean): string;
  120111. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120112. }
  120113. }
  120114. declare module BABYLON {
  120115. /**
  120116. * Interface for attribute information associated with buffer instanciation
  120117. */
  120118. export interface InstancingAttributeInfo {
  120119. /**
  120120. * Name of the GLSL attribute
  120121. * if attribute index is not specified, this is used to retrieve the index from the effect
  120122. */
  120123. attributeName: string;
  120124. /**
  120125. * Index/offset of the attribute in the vertex shader
  120126. * if not specified, this will be computes from the name.
  120127. */
  120128. index?: number;
  120129. /**
  120130. * size of the attribute, 1, 2, 3 or 4
  120131. */
  120132. attributeSize: number;
  120133. /**
  120134. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  120135. */
  120136. offset: number;
  120137. /**
  120138. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  120139. * default to 1
  120140. */
  120141. divisor?: number;
  120142. /**
  120143. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  120144. * default is FLOAT
  120145. */
  120146. attributeType?: number;
  120147. /**
  120148. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  120149. */
  120150. normalized?: boolean;
  120151. }
  120152. }
  120153. declare module BABYLON {
  120154. interface ThinEngine {
  120155. /**
  120156. * Update a video texture
  120157. * @param texture defines the texture to update
  120158. * @param video defines the video element to use
  120159. * @param invertY defines if data must be stored with Y axis inverted
  120160. */
  120161. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  120162. }
  120163. }
  120164. declare module BABYLON {
  120165. interface ThinEngine {
  120166. /**
  120167. * Creates a dynamic texture
  120168. * @param width defines the width of the texture
  120169. * @param height defines the height of the texture
  120170. * @param generateMipMaps defines if the engine should generate the mip levels
  120171. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  120172. * @returns the dynamic texture inside an InternalTexture
  120173. */
  120174. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  120175. /**
  120176. * Update the content of a dynamic texture
  120177. * @param texture defines the texture to update
  120178. * @param canvas defines the canvas containing the source
  120179. * @param invertY defines if data must be stored with Y axis inverted
  120180. * @param premulAlpha defines if alpha is stored as premultiplied
  120181. * @param format defines the format of the data
  120182. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  120183. */
  120184. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  120185. }
  120186. }
  120187. declare module BABYLON {
  120188. /**
  120189. * Settings for finer control over video usage
  120190. */
  120191. export interface VideoTextureSettings {
  120192. /**
  120193. * Applies `autoplay` to video, if specified
  120194. */
  120195. autoPlay?: boolean;
  120196. /**
  120197. * Applies `muted` to video, if specified
  120198. */
  120199. muted?: boolean;
  120200. /**
  120201. * Applies `loop` to video, if specified
  120202. */
  120203. loop?: boolean;
  120204. /**
  120205. * Automatically updates internal texture from video at every frame in the render loop
  120206. */
  120207. autoUpdateTexture: boolean;
  120208. /**
  120209. * Image src displayed during the video loading or until the user interacts with the video.
  120210. */
  120211. poster?: string;
  120212. }
  120213. /**
  120214. * If you want to display a video in your scene, this is the special texture for that.
  120215. * This special texture works similar to other textures, with the exception of a few parameters.
  120216. * @see https://doc.babylonjs.com/how_to/video_texture
  120217. */
  120218. export class VideoTexture extends Texture {
  120219. /**
  120220. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  120221. */
  120222. readonly autoUpdateTexture: boolean;
  120223. /**
  120224. * The video instance used by the texture internally
  120225. */
  120226. readonly video: HTMLVideoElement;
  120227. private _onUserActionRequestedObservable;
  120228. /**
  120229. * Event triggerd when a dom action is required by the user to play the video.
  120230. * This happens due to recent changes in browser policies preventing video to auto start.
  120231. */
  120232. get onUserActionRequestedObservable(): Observable<Texture>;
  120233. private _generateMipMaps;
  120234. private _stillImageCaptured;
  120235. private _displayingPosterTexture;
  120236. private _settings;
  120237. private _createInternalTextureOnEvent;
  120238. private _frameId;
  120239. private _currentSrc;
  120240. /**
  120241. * Creates a video texture.
  120242. * If you want to display a video in your scene, this is the special texture for that.
  120243. * This special texture works similar to other textures, with the exception of a few parameters.
  120244. * @see https://doc.babylonjs.com/how_to/video_texture
  120245. * @param name optional name, will detect from video source, if not defined
  120246. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  120247. * @param scene is obviously the current scene.
  120248. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  120249. * @param invertY is false by default but can be used to invert video on Y axis
  120250. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  120251. * @param settings allows finer control over video usage
  120252. */
  120253. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  120254. private _getName;
  120255. private _getVideo;
  120256. private _createInternalTexture;
  120257. private reset;
  120258. /**
  120259. * @hidden Internal method to initiate `update`.
  120260. */
  120261. _rebuild(): void;
  120262. /**
  120263. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  120264. */
  120265. update(): void;
  120266. /**
  120267. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  120268. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  120269. */
  120270. updateTexture(isVisible: boolean): void;
  120271. protected _updateInternalTexture: () => void;
  120272. /**
  120273. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  120274. * @param url New url.
  120275. */
  120276. updateURL(url: string): void;
  120277. /**
  120278. * Clones the texture.
  120279. * @returns the cloned texture
  120280. */
  120281. clone(): VideoTexture;
  120282. /**
  120283. * Dispose the texture and release its associated resources.
  120284. */
  120285. dispose(): void;
  120286. /**
  120287. * Creates a video texture straight from a stream.
  120288. * @param scene Define the scene the texture should be created in
  120289. * @param stream Define the stream the texture should be created from
  120290. * @returns The created video texture as a promise
  120291. */
  120292. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  120293. /**
  120294. * Creates a video texture straight from your WebCam video feed.
  120295. * @param scene Define the scene the texture should be created in
  120296. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  120297. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  120298. * @returns The created video texture as a promise
  120299. */
  120300. static CreateFromWebCamAsync(scene: Scene, constraints: {
  120301. minWidth: number;
  120302. maxWidth: number;
  120303. minHeight: number;
  120304. maxHeight: number;
  120305. deviceId: string;
  120306. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  120307. /**
  120308. * Creates a video texture straight from your WebCam video feed.
  120309. * @param scene Define the scene the texture should be created in
  120310. * @param onReady Define a callback to triggered once the texture will be ready
  120311. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  120312. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  120313. */
  120314. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  120315. minWidth: number;
  120316. maxWidth: number;
  120317. minHeight: number;
  120318. maxHeight: number;
  120319. deviceId: string;
  120320. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  120321. }
  120322. }
  120323. declare module BABYLON {
  120324. /**
  120325. * Defines the interface used by objects working like Scene
  120326. * @hidden
  120327. */
  120328. export interface ISceneLike {
  120329. _addPendingData(data: any): void;
  120330. _removePendingData(data: any): void;
  120331. offlineProvider: IOfflineProvider;
  120332. }
  120333. /**
  120334. * Information about the current host
  120335. */
  120336. export interface HostInformation {
  120337. /**
  120338. * Defines if the current host is a mobile
  120339. */
  120340. isMobile: boolean;
  120341. }
  120342. /** Interface defining initialization parameters for Engine class */
  120343. export interface EngineOptions extends WebGLContextAttributes {
  120344. /**
  120345. * Defines if the engine should no exceed a specified device ratio
  120346. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  120347. */
  120348. limitDeviceRatio?: number;
  120349. /**
  120350. * Defines if webvr should be enabled automatically
  120351. * @see https://doc.babylonjs.com/how_to/webvr_camera
  120352. */
  120353. autoEnableWebVR?: boolean;
  120354. /**
  120355. * Defines if webgl2 should be turned off even if supported
  120356. * @see https://doc.babylonjs.com/features/webgl2
  120357. */
  120358. disableWebGL2Support?: boolean;
  120359. /**
  120360. * Defines if webaudio should be initialized as well
  120361. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120362. */
  120363. audioEngine?: boolean;
  120364. /**
  120365. * Defines if animations should run using a deterministic lock step
  120366. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120367. */
  120368. deterministicLockstep?: boolean;
  120369. /** Defines the maximum steps to use with deterministic lock step mode */
  120370. lockstepMaxSteps?: number;
  120371. /** Defines the seconds between each deterministic lock step */
  120372. timeStep?: number;
  120373. /**
  120374. * Defines that engine should ignore context lost events
  120375. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  120376. */
  120377. doNotHandleContextLost?: boolean;
  120378. /**
  120379. * Defines that engine should ignore modifying touch action attribute and style
  120380. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  120381. */
  120382. doNotHandleTouchAction?: boolean;
  120383. /**
  120384. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  120385. */
  120386. useHighPrecisionFloats?: boolean;
  120387. /**
  120388. * Make the canvas XR Compatible for XR sessions
  120389. */
  120390. xrCompatible?: boolean;
  120391. /**
  120392. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  120393. */
  120394. useHighPrecisionMatrix?: boolean;
  120395. /**
  120396. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  120397. */
  120398. failIfMajorPerformanceCaveat?: boolean;
  120399. }
  120400. /**
  120401. * The base engine class (root of all engines)
  120402. */
  120403. export class ThinEngine {
  120404. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  120405. static ExceptionList: ({
  120406. key: string;
  120407. capture: string;
  120408. captureConstraint: number;
  120409. targets: string[];
  120410. } | {
  120411. key: string;
  120412. capture: null;
  120413. captureConstraint: null;
  120414. targets: string[];
  120415. })[];
  120416. /** @hidden */
  120417. static _TextureLoaders: IInternalTextureLoader[];
  120418. /**
  120419. * Returns the current npm package of the sdk
  120420. */
  120421. static get NpmPackage(): string;
  120422. /**
  120423. * Returns the current version of the framework
  120424. */
  120425. static get Version(): string;
  120426. /**
  120427. * Returns a string describing the current engine
  120428. */
  120429. get description(): string;
  120430. /**
  120431. * Gets or sets the epsilon value used by collision engine
  120432. */
  120433. static CollisionsEpsilon: number;
  120434. /**
  120435. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  120436. */
  120437. static get ShadersRepository(): string;
  120438. static set ShadersRepository(value: string);
  120439. /** @hidden */
  120440. _shaderProcessor: IShaderProcessor;
  120441. /**
  120442. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  120443. */
  120444. forcePOTTextures: boolean;
  120445. /**
  120446. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  120447. */
  120448. isFullscreen: boolean;
  120449. /**
  120450. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  120451. */
  120452. cullBackFaces: boolean;
  120453. /**
  120454. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  120455. */
  120456. renderEvenInBackground: boolean;
  120457. /**
  120458. * Gets or sets a boolean indicating that cache can be kept between frames
  120459. */
  120460. preventCacheWipeBetweenFrames: boolean;
  120461. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  120462. validateShaderPrograms: boolean;
  120463. /**
  120464. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  120465. * This can provide greater z depth for distant objects.
  120466. */
  120467. useReverseDepthBuffer: boolean;
  120468. /**
  120469. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  120470. */
  120471. disableUniformBuffers: boolean;
  120472. /** @hidden */
  120473. _uniformBuffers: UniformBuffer[];
  120474. /**
  120475. * Gets a boolean indicating that the engine supports uniform buffers
  120476. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  120477. */
  120478. get supportsUniformBuffers(): boolean;
  120479. /** @hidden */
  120480. _gl: WebGLRenderingContext;
  120481. /** @hidden */
  120482. _webGLVersion: number;
  120483. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  120484. protected _windowIsBackground: boolean;
  120485. protected _creationOptions: EngineOptions;
  120486. protected _highPrecisionShadersAllowed: boolean;
  120487. /** @hidden */
  120488. get _shouldUseHighPrecisionShader(): boolean;
  120489. /**
  120490. * Gets a boolean indicating that only power of 2 textures are supported
  120491. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  120492. */
  120493. get needPOTTextures(): boolean;
  120494. /** @hidden */
  120495. _badOS: boolean;
  120496. /** @hidden */
  120497. _badDesktopOS: boolean;
  120498. private _hardwareScalingLevel;
  120499. /** @hidden */
  120500. _caps: EngineCapabilities;
  120501. private _isStencilEnable;
  120502. private _glVersion;
  120503. private _glRenderer;
  120504. private _glVendor;
  120505. /** @hidden */
  120506. _videoTextureSupported: boolean;
  120507. protected _renderingQueueLaunched: boolean;
  120508. protected _activeRenderLoops: (() => void)[];
  120509. /**
  120510. * Observable signaled when a context lost event is raised
  120511. */
  120512. onContextLostObservable: Observable<ThinEngine>;
  120513. /**
  120514. * Observable signaled when a context restored event is raised
  120515. */
  120516. onContextRestoredObservable: Observable<ThinEngine>;
  120517. private _onContextLost;
  120518. private _onContextRestored;
  120519. protected _contextWasLost: boolean;
  120520. /** @hidden */
  120521. _doNotHandleContextLost: boolean;
  120522. /**
  120523. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  120524. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  120525. */
  120526. get doNotHandleContextLost(): boolean;
  120527. set doNotHandleContextLost(value: boolean);
  120528. /**
  120529. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  120530. */
  120531. disableVertexArrayObjects: boolean;
  120532. /** @hidden */
  120533. protected _colorWrite: boolean;
  120534. /** @hidden */
  120535. protected _colorWriteChanged: boolean;
  120536. /** @hidden */
  120537. protected _depthCullingState: DepthCullingState;
  120538. /** @hidden */
  120539. protected _stencilState: StencilState;
  120540. /** @hidden */
  120541. _alphaState: AlphaState;
  120542. /** @hidden */
  120543. _alphaMode: number;
  120544. /** @hidden */
  120545. _alphaEquation: number;
  120546. /** @hidden */
  120547. _internalTexturesCache: InternalTexture[];
  120548. /** @hidden */
  120549. protected _activeChannel: number;
  120550. private _currentTextureChannel;
  120551. /** @hidden */
  120552. protected _boundTexturesCache: {
  120553. [key: string]: Nullable<InternalTexture>;
  120554. };
  120555. /** @hidden */
  120556. protected _currentEffect: Nullable<Effect>;
  120557. /** @hidden */
  120558. protected _currentProgram: Nullable<WebGLProgram>;
  120559. private _compiledEffects;
  120560. private _vertexAttribArraysEnabled;
  120561. /** @hidden */
  120562. protected _cachedViewport: Nullable<IViewportLike>;
  120563. private _cachedVertexArrayObject;
  120564. /** @hidden */
  120565. protected _cachedVertexBuffers: any;
  120566. /** @hidden */
  120567. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  120568. /** @hidden */
  120569. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  120570. /** @hidden */
  120571. _currentRenderTarget: Nullable<InternalTexture>;
  120572. private _uintIndicesCurrentlySet;
  120573. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  120574. /** @hidden */
  120575. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  120576. /** @hidden */
  120577. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  120578. private _currentBufferPointers;
  120579. private _currentInstanceLocations;
  120580. private _currentInstanceBuffers;
  120581. private _textureUnits;
  120582. /** @hidden */
  120583. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  120584. /** @hidden */
  120585. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  120586. /** @hidden */
  120587. _boundRenderFunction: any;
  120588. private _vaoRecordInProgress;
  120589. private _mustWipeVertexAttributes;
  120590. private _emptyTexture;
  120591. private _emptyCubeTexture;
  120592. private _emptyTexture3D;
  120593. private _emptyTexture2DArray;
  120594. /** @hidden */
  120595. _frameHandler: number;
  120596. private _nextFreeTextureSlots;
  120597. private _maxSimultaneousTextures;
  120598. private _activeRequests;
  120599. /** @hidden */
  120600. _transformTextureUrl: Nullable<(url: string) => string>;
  120601. /**
  120602. * Gets information about the current host
  120603. */
  120604. hostInformation: HostInformation;
  120605. protected get _supportsHardwareTextureRescaling(): boolean;
  120606. private _framebufferDimensionsObject;
  120607. /**
  120608. * sets the object from which width and height will be taken from when getting render width and height
  120609. * Will fallback to the gl object
  120610. * @param dimensions the framebuffer width and height that will be used.
  120611. */
  120612. set framebufferDimensionsObject(dimensions: Nullable<{
  120613. framebufferWidth: number;
  120614. framebufferHeight: number;
  120615. }>);
  120616. /**
  120617. * Gets the current viewport
  120618. */
  120619. get currentViewport(): Nullable<IViewportLike>;
  120620. /**
  120621. * Gets the default empty texture
  120622. */
  120623. get emptyTexture(): InternalTexture;
  120624. /**
  120625. * Gets the default empty 3D texture
  120626. */
  120627. get emptyTexture3D(): InternalTexture;
  120628. /**
  120629. * Gets the default empty 2D array texture
  120630. */
  120631. get emptyTexture2DArray(): InternalTexture;
  120632. /**
  120633. * Gets the default empty cube texture
  120634. */
  120635. get emptyCubeTexture(): InternalTexture;
  120636. /**
  120637. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  120638. */
  120639. readonly premultipliedAlpha: boolean;
  120640. /**
  120641. * Observable event triggered before each texture is initialized
  120642. */
  120643. onBeforeTextureInitObservable: Observable<Texture>;
  120644. /**
  120645. * Creates a new engine
  120646. * @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
  120647. * @param antialias defines enable antialiasing (default: false)
  120648. * @param options defines further options to be sent to the getContext() function
  120649. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  120650. */
  120651. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  120652. private _rebuildInternalTextures;
  120653. private _rebuildEffects;
  120654. /**
  120655. * Gets a boolean indicating if all created effects are ready
  120656. * @returns true if all effects are ready
  120657. */
  120658. areAllEffectsReady(): boolean;
  120659. protected _rebuildBuffers(): void;
  120660. protected _initGLContext(): void;
  120661. /**
  120662. * Gets version of the current webGL context
  120663. */
  120664. get webGLVersion(): number;
  120665. /**
  120666. * Gets a string identifying the name of the class
  120667. * @returns "Engine" string
  120668. */
  120669. getClassName(): string;
  120670. /**
  120671. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  120672. */
  120673. get isStencilEnable(): boolean;
  120674. /** @hidden */
  120675. _prepareWorkingCanvas(): void;
  120676. /**
  120677. * Reset the texture cache to empty state
  120678. */
  120679. resetTextureCache(): void;
  120680. /**
  120681. * Gets an object containing information about the current webGL context
  120682. * @returns an object containing the vender, the renderer and the version of the current webGL context
  120683. */
  120684. getGlInfo(): {
  120685. vendor: string;
  120686. renderer: string;
  120687. version: string;
  120688. };
  120689. /**
  120690. * Defines the hardware scaling level.
  120691. * By default the hardware scaling level is computed from the window device ratio.
  120692. * 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.
  120693. * @param level defines the level to use
  120694. */
  120695. setHardwareScalingLevel(level: number): void;
  120696. /**
  120697. * Gets the current hardware scaling level.
  120698. * By default the hardware scaling level is computed from the window device ratio.
  120699. * 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.
  120700. * @returns a number indicating the current hardware scaling level
  120701. */
  120702. getHardwareScalingLevel(): number;
  120703. /**
  120704. * Gets the list of loaded textures
  120705. * @returns an array containing all loaded textures
  120706. */
  120707. getLoadedTexturesCache(): InternalTexture[];
  120708. /**
  120709. * Gets the object containing all engine capabilities
  120710. * @returns the EngineCapabilities object
  120711. */
  120712. getCaps(): EngineCapabilities;
  120713. /**
  120714. * stop executing a render loop function and remove it from the execution array
  120715. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  120716. */
  120717. stopRenderLoop(renderFunction?: () => void): void;
  120718. /** @hidden */
  120719. _renderLoop(): void;
  120720. /**
  120721. * Gets the HTML canvas attached with the current webGL context
  120722. * @returns a HTML canvas
  120723. */
  120724. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  120725. /**
  120726. * Gets host window
  120727. * @returns the host window object
  120728. */
  120729. getHostWindow(): Nullable<Window>;
  120730. /**
  120731. * Gets the current render width
  120732. * @param useScreen defines if screen size must be used (or the current render target if any)
  120733. * @returns a number defining the current render width
  120734. */
  120735. getRenderWidth(useScreen?: boolean): number;
  120736. /**
  120737. * Gets the current render height
  120738. * @param useScreen defines if screen size must be used (or the current render target if any)
  120739. * @returns a number defining the current render height
  120740. */
  120741. getRenderHeight(useScreen?: boolean): number;
  120742. /**
  120743. * Can be used to override the current requestAnimationFrame requester.
  120744. * @hidden
  120745. */
  120746. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120747. /**
  120748. * Register and execute a render loop. The engine can have more than one render function
  120749. * @param renderFunction defines the function to continuously execute
  120750. */
  120751. runRenderLoop(renderFunction: () => void): void;
  120752. /**
  120753. * Clear the current render buffer or the current render target (if any is set up)
  120754. * @param color defines the color to use
  120755. * @param backBuffer defines if the back buffer must be cleared
  120756. * @param depth defines if the depth buffer must be cleared
  120757. * @param stencil defines if the stencil buffer must be cleared
  120758. */
  120759. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120760. private _viewportCached;
  120761. /** @hidden */
  120762. _viewport(x: number, y: number, width: number, height: number): void;
  120763. /**
  120764. * Set the WebGL's viewport
  120765. * @param viewport defines the viewport element to be used
  120766. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  120767. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  120768. */
  120769. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  120770. /**
  120771. * Begin a new frame
  120772. */
  120773. beginFrame(): void;
  120774. /**
  120775. * Enf the current frame
  120776. */
  120777. endFrame(): void;
  120778. /**
  120779. * Resize the view according to the canvas' size
  120780. */
  120781. resize(): void;
  120782. /**
  120783. * Force a specific size of the canvas
  120784. * @param width defines the new canvas' width
  120785. * @param height defines the new canvas' height
  120786. * @returns true if the size was changed
  120787. */
  120788. setSize(width: number, height: number): boolean;
  120789. /**
  120790. * Binds the frame buffer to the specified texture.
  120791. * @param texture The texture to render to or null for the default canvas
  120792. * @param faceIndex The face of the texture to render to in case of cube texture
  120793. * @param requiredWidth The width of the target to render to
  120794. * @param requiredHeight The height of the target to render to
  120795. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  120796. * @param lodLevel defines the lod level to bind to the frame buffer
  120797. * @param layer defines the 2d array index to bind to frame buffer to
  120798. */
  120799. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  120800. /** @hidden */
  120801. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120802. /**
  120803. * Unbind the current render target texture from the webGL context
  120804. * @param texture defines the render target texture to unbind
  120805. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120806. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120807. */
  120808. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120809. /**
  120810. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  120811. */
  120812. flushFramebuffer(): void;
  120813. /**
  120814. * Unbind the current render target and bind the default framebuffer
  120815. */
  120816. restoreDefaultFramebuffer(): void;
  120817. /** @hidden */
  120818. protected _resetVertexBufferBinding(): void;
  120819. /**
  120820. * Creates a vertex buffer
  120821. * @param data the data for the vertex buffer
  120822. * @returns the new WebGL static buffer
  120823. */
  120824. createVertexBuffer(data: DataArray): DataBuffer;
  120825. private _createVertexBuffer;
  120826. /**
  120827. * Creates a dynamic vertex buffer
  120828. * @param data the data for the dynamic vertex buffer
  120829. * @returns the new WebGL dynamic buffer
  120830. */
  120831. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  120832. protected _resetIndexBufferBinding(): void;
  120833. /**
  120834. * Creates a new index buffer
  120835. * @param indices defines the content of the index buffer
  120836. * @param updatable defines if the index buffer must be updatable
  120837. * @returns a new webGL buffer
  120838. */
  120839. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  120840. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  120841. /**
  120842. * Bind a webGL buffer to the webGL context
  120843. * @param buffer defines the buffer to bind
  120844. */
  120845. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  120846. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  120847. private bindBuffer;
  120848. /**
  120849. * update the bound buffer with the given data
  120850. * @param data defines the data to update
  120851. */
  120852. updateArrayBuffer(data: Float32Array): void;
  120853. private _vertexAttribPointer;
  120854. /** @hidden */
  120855. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  120856. private _bindVertexBuffersAttributes;
  120857. /**
  120858. * Records a vertex array object
  120859. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  120860. * @param vertexBuffers defines the list of vertex buffers to store
  120861. * @param indexBuffer defines the index buffer to store
  120862. * @param effect defines the effect to store
  120863. * @returns the new vertex array object
  120864. */
  120865. recordVertexArrayObject(vertexBuffers: {
  120866. [key: string]: VertexBuffer;
  120867. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120868. /**
  120869. * Bind a specific vertex array object
  120870. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  120871. * @param vertexArrayObject defines the vertex array object to bind
  120872. * @param indexBuffer defines the index buffer to bind
  120873. */
  120874. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  120875. /**
  120876. * Bind webGl buffers directly to the webGL context
  120877. * @param vertexBuffer defines the vertex buffer to bind
  120878. * @param indexBuffer defines the index buffer to bind
  120879. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  120880. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  120881. * @param effect defines the effect associated with the vertex buffer
  120882. */
  120883. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  120884. private _unbindVertexArrayObject;
  120885. /**
  120886. * Bind a list of vertex buffers to the webGL context
  120887. * @param vertexBuffers defines the list of vertex buffers to bind
  120888. * @param indexBuffer defines the index buffer to bind
  120889. * @param effect defines the effect associated with the vertex buffers
  120890. */
  120891. bindBuffers(vertexBuffers: {
  120892. [key: string]: Nullable<VertexBuffer>;
  120893. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  120894. /**
  120895. * Unbind all instance attributes
  120896. */
  120897. unbindInstanceAttributes(): void;
  120898. /**
  120899. * Release and free the memory of a vertex array object
  120900. * @param vao defines the vertex array object to delete
  120901. */
  120902. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  120903. /** @hidden */
  120904. _releaseBuffer(buffer: DataBuffer): boolean;
  120905. protected _deleteBuffer(buffer: DataBuffer): void;
  120906. /**
  120907. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  120908. * @param instancesBuffer defines the webGL buffer to update and bind
  120909. * @param data defines the data to store in the buffer
  120910. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  120911. */
  120912. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  120913. /**
  120914. * Bind the content of a webGL buffer used with instantiation
  120915. * @param instancesBuffer defines the webGL buffer to bind
  120916. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  120917. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  120918. */
  120919. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  120920. /**
  120921. * Disable the instance attribute corresponding to the name in parameter
  120922. * @param name defines the name of the attribute to disable
  120923. */
  120924. disableInstanceAttributeByName(name: string): void;
  120925. /**
  120926. * Disable the instance attribute corresponding to the location in parameter
  120927. * @param attributeLocation defines the attribute location of the attribute to disable
  120928. */
  120929. disableInstanceAttribute(attributeLocation: number): void;
  120930. /**
  120931. * Disable the attribute corresponding to the location in parameter
  120932. * @param attributeLocation defines the attribute location of the attribute to disable
  120933. */
  120934. disableAttributeByIndex(attributeLocation: number): void;
  120935. /**
  120936. * Send a draw order
  120937. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  120938. * @param indexStart defines the starting index
  120939. * @param indexCount defines the number of index to draw
  120940. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120941. */
  120942. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  120943. /**
  120944. * Draw a list of points
  120945. * @param verticesStart defines the index of first vertex to draw
  120946. * @param verticesCount defines the count of vertices to draw
  120947. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120948. */
  120949. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120950. /**
  120951. * Draw a list of unindexed primitives
  120952. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  120953. * @param verticesStart defines the index of first vertex to draw
  120954. * @param verticesCount defines the count of vertices to draw
  120955. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120956. */
  120957. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120958. /**
  120959. * Draw a list of indexed primitives
  120960. * @param fillMode defines the primitive to use
  120961. * @param indexStart defines the starting index
  120962. * @param indexCount defines the number of index to draw
  120963. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120964. */
  120965. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120966. /**
  120967. * Draw a list of unindexed primitives
  120968. * @param fillMode defines the primitive to use
  120969. * @param verticesStart defines the index of first vertex to draw
  120970. * @param verticesCount defines the count of vertices to draw
  120971. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120972. */
  120973. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120974. private _drawMode;
  120975. /** @hidden */
  120976. protected _reportDrawCall(): void;
  120977. /** @hidden */
  120978. _releaseEffect(effect: Effect): void;
  120979. /** @hidden */
  120980. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120981. /**
  120982. * Create a new effect (used to store vertex/fragment shaders)
  120983. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  120984. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  120985. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  120986. * @param samplers defines an array of string used to represent textures
  120987. * @param defines defines the string containing the defines to use to compile the shaders
  120988. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  120989. * @param onCompiled defines a function to call when the effect creation is successful
  120990. * @param onError defines a function to call when the effect creation has failed
  120991. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  120992. * @returns the new Effect
  120993. */
  120994. 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;
  120995. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  120996. private _compileShader;
  120997. private _compileRawShader;
  120998. /** @hidden */
  120999. _getShaderSource(shader: WebGLShader): Nullable<string>;
  121000. /**
  121001. * Directly creates a webGL program
  121002. * @param pipelineContext defines the pipeline context to attach to
  121003. * @param vertexCode defines the vertex shader code to use
  121004. * @param fragmentCode defines the fragment shader code to use
  121005. * @param context defines the webGL context to use (if not set, the current one will be used)
  121006. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  121007. * @returns the new webGL program
  121008. */
  121009. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121010. /**
  121011. * Creates a webGL program
  121012. * @param pipelineContext defines the pipeline context to attach to
  121013. * @param vertexCode defines the vertex shader code to use
  121014. * @param fragmentCode defines the fragment shader code to use
  121015. * @param defines defines the string containing the defines to use to compile the shaders
  121016. * @param context defines the webGL context to use (if not set, the current one will be used)
  121017. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  121018. * @returns the new webGL program
  121019. */
  121020. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121021. /**
  121022. * Creates a new pipeline context
  121023. * @returns the new pipeline
  121024. */
  121025. createPipelineContext(): IPipelineContext;
  121026. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121027. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  121028. /** @hidden */
  121029. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  121030. /** @hidden */
  121031. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  121032. /** @hidden */
  121033. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  121034. /**
  121035. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  121036. * @param pipelineContext defines the pipeline context to use
  121037. * @param uniformsNames defines the list of uniform names
  121038. * @returns an array of webGL uniform locations
  121039. */
  121040. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  121041. /**
  121042. * Gets the lsit of active attributes for a given webGL program
  121043. * @param pipelineContext defines the pipeline context to use
  121044. * @param attributesNames defines the list of attribute names to get
  121045. * @returns an array of indices indicating the offset of each attribute
  121046. */
  121047. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  121048. /**
  121049. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  121050. * @param effect defines the effect to activate
  121051. */
  121052. enableEffect(effect: Nullable<Effect>): void;
  121053. /**
  121054. * Set the value of an uniform to a number (int)
  121055. * @param uniform defines the webGL uniform location where to store the value
  121056. * @param value defines the int number to store
  121057. * @returns true if the value was set
  121058. */
  121059. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  121060. /**
  121061. * Set the value of an uniform to an array of int32
  121062. * @param uniform defines the webGL uniform location where to store the value
  121063. * @param array defines the array of int32 to store
  121064. * @returns true if the value was set
  121065. */
  121066. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  121067. /**
  121068. * Set the value of an uniform to an array of int32 (stored as vec2)
  121069. * @param uniform defines the webGL uniform location where to store the value
  121070. * @param array defines the array of int32 to store
  121071. * @returns true if the value was set
  121072. */
  121073. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  121074. /**
  121075. * Set the value of an uniform to an array of int32 (stored as vec3)
  121076. * @param uniform defines the webGL uniform location where to store the value
  121077. * @param array defines the array of int32 to store
  121078. * @returns true if the value was set
  121079. */
  121080. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  121081. /**
  121082. * Set the value of an uniform to an array of int32 (stored as vec4)
  121083. * @param uniform defines the webGL uniform location where to store the value
  121084. * @param array defines the array of int32 to store
  121085. * @returns true if the value was set
  121086. */
  121087. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  121088. /**
  121089. * Set the value of an uniform to an array of number
  121090. * @param uniform defines the webGL uniform location where to store the value
  121091. * @param array defines the array of number to store
  121092. * @returns true if the value was set
  121093. */
  121094. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  121095. /**
  121096. * Set the value of an uniform to an array of number (stored as vec2)
  121097. * @param uniform defines the webGL uniform location where to store the value
  121098. * @param array defines the array of number to store
  121099. * @returns true if the value was set
  121100. */
  121101. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  121102. /**
  121103. * Set the value of an uniform to an array of number (stored as vec3)
  121104. * @param uniform defines the webGL uniform location where to store the value
  121105. * @param array defines the array of number to store
  121106. * @returns true if the value was set
  121107. */
  121108. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  121109. /**
  121110. * Set the value of an uniform to an array of number (stored as vec4)
  121111. * @param uniform defines the webGL uniform location where to store the value
  121112. * @param array defines the array of number to store
  121113. * @returns true if the value was set
  121114. */
  121115. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  121116. /**
  121117. * Set the value of an uniform to an array of float32 (stored as matrices)
  121118. * @param uniform defines the webGL uniform location where to store the value
  121119. * @param matrices defines the array of float32 to store
  121120. * @returns true if the value was set
  121121. */
  121122. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  121123. /**
  121124. * Set the value of an uniform to a matrix (3x3)
  121125. * @param uniform defines the webGL uniform location where to store the value
  121126. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  121127. * @returns true if the value was set
  121128. */
  121129. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  121130. /**
  121131. * Set the value of an uniform to a matrix (2x2)
  121132. * @param uniform defines the webGL uniform location where to store the value
  121133. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  121134. * @returns true if the value was set
  121135. */
  121136. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  121137. /**
  121138. * Set the value of an uniform to a number (float)
  121139. * @param uniform defines the webGL uniform location where to store the value
  121140. * @param value defines the float number to store
  121141. * @returns true if the value was transfered
  121142. */
  121143. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  121144. /**
  121145. * Set the value of an uniform to a vec2
  121146. * @param uniform defines the webGL uniform location where to store the value
  121147. * @param x defines the 1st component of the value
  121148. * @param y defines the 2nd component of the value
  121149. * @returns true if the value was set
  121150. */
  121151. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  121152. /**
  121153. * Set the value of an uniform to a vec3
  121154. * @param uniform defines the webGL uniform location where to store the value
  121155. * @param x defines the 1st component of the value
  121156. * @param y defines the 2nd component of the value
  121157. * @param z defines the 3rd component of the value
  121158. * @returns true if the value was set
  121159. */
  121160. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  121161. /**
  121162. * Set the value of an uniform to a vec4
  121163. * @param uniform defines the webGL uniform location where to store the value
  121164. * @param x defines the 1st component of the value
  121165. * @param y defines the 2nd component of the value
  121166. * @param z defines the 3rd component of the value
  121167. * @param w defines the 4th component of the value
  121168. * @returns true if the value was set
  121169. */
  121170. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  121171. /**
  121172. * Apply all cached states (depth, culling, stencil and alpha)
  121173. */
  121174. applyStates(): void;
  121175. /**
  121176. * Enable or disable color writing
  121177. * @param enable defines the state to set
  121178. */
  121179. setColorWrite(enable: boolean): void;
  121180. /**
  121181. * Gets a boolean indicating if color writing is enabled
  121182. * @returns the current color writing state
  121183. */
  121184. getColorWrite(): boolean;
  121185. /**
  121186. * Gets the depth culling state manager
  121187. */
  121188. get depthCullingState(): DepthCullingState;
  121189. /**
  121190. * Gets the alpha state manager
  121191. */
  121192. get alphaState(): AlphaState;
  121193. /**
  121194. * Gets the stencil state manager
  121195. */
  121196. get stencilState(): StencilState;
  121197. /**
  121198. * Clears the list of texture accessible through engine.
  121199. * This can help preventing texture load conflict due to name collision.
  121200. */
  121201. clearInternalTexturesCache(): void;
  121202. /**
  121203. * Force the entire cache to be cleared
  121204. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  121205. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  121206. */
  121207. wipeCaches(bruteForce?: boolean): void;
  121208. /** @hidden */
  121209. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  121210. min: number;
  121211. mag: number;
  121212. };
  121213. /** @hidden */
  121214. _createTexture(): WebGLTexture;
  121215. /**
  121216. * Usually called from Texture.ts.
  121217. * Passed information to create a WebGLTexture
  121218. * @param url defines a value which contains one of the following:
  121219. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  121220. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  121221. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  121222. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  121223. * @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)
  121224. * @param scene needed for loading to the correct scene
  121225. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  121226. * @param onLoad optional callback to be called upon successful completion
  121227. * @param onError optional callback to be called upon failure
  121228. * @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
  121229. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121230. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121231. * @param forcedExtension defines the extension to use to pick the right loader
  121232. * @param mimeType defines an optional mime type
  121233. * @param loaderOptions options to be passed to the loader
  121234. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121235. */
  121236. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  121237. /**
  121238. * Loads an image as an HTMLImageElement.
  121239. * @param input url string, ArrayBuffer, or Blob to load
  121240. * @param onLoad callback called when the image successfully loads
  121241. * @param onError callback called when the image fails to load
  121242. * @param offlineProvider offline provider for caching
  121243. * @param mimeType optional mime type
  121244. * @returns the HTMLImageElement of the loaded image
  121245. * @hidden
  121246. */
  121247. 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>;
  121248. /**
  121249. * @hidden
  121250. */
  121251. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  121252. private _unpackFlipYCached;
  121253. /**
  121254. * In case you are sharing the context with other applications, it might
  121255. * be interested to not cache the unpack flip y state to ensure a consistent
  121256. * value would be set.
  121257. */
  121258. enableUnpackFlipYCached: boolean;
  121259. /** @hidden */
  121260. _unpackFlipY(value: boolean): void;
  121261. /** @hidden */
  121262. _getUnpackAlignement(): number;
  121263. private _getTextureTarget;
  121264. /**
  121265. * Update the sampling mode of a given texture
  121266. * @param samplingMode defines the required sampling mode
  121267. * @param texture defines the texture to update
  121268. * @param generateMipMaps defines whether to generate mipmaps for the texture
  121269. */
  121270. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  121271. /**
  121272. * Update the sampling mode of a given texture
  121273. * @param texture defines the texture to update
  121274. * @param wrapU defines the texture wrap mode of the u coordinates
  121275. * @param wrapV defines the texture wrap mode of the v coordinates
  121276. * @param wrapR defines the texture wrap mode of the r coordinates
  121277. */
  121278. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  121279. /** @hidden */
  121280. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  121281. width: number;
  121282. height: number;
  121283. layers?: number;
  121284. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  121285. /** @hidden */
  121286. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121287. /** @hidden */
  121288. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  121289. /**
  121290. * Update a portion of an internal texture
  121291. * @param texture defines the texture to update
  121292. * @param imageData defines the data to store into the texture
  121293. * @param xOffset defines the x coordinates of the update rectangle
  121294. * @param yOffset defines the y coordinates of the update rectangle
  121295. * @param width defines the width of the update rectangle
  121296. * @param height defines the height of the update rectangle
  121297. * @param faceIndex defines the face index if texture is a cube (0 by default)
  121298. * @param lod defines the lod level to update (0 by default)
  121299. */
  121300. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  121301. /** @hidden */
  121302. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121303. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  121304. private _prepareWebGLTexture;
  121305. /** @hidden */
  121306. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  121307. private _getDepthStencilBuffer;
  121308. /** @hidden */
  121309. _releaseFramebufferObjects(texture: InternalTexture): void;
  121310. /** @hidden */
  121311. _releaseTexture(texture: InternalTexture): void;
  121312. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  121313. protected _setProgram(program: WebGLProgram): void;
  121314. protected _boundUniforms: {
  121315. [key: number]: WebGLUniformLocation;
  121316. };
  121317. /**
  121318. * Binds an effect to the webGL context
  121319. * @param effect defines the effect to bind
  121320. */
  121321. bindSamplers(effect: Effect): void;
  121322. private _activateCurrentTexture;
  121323. /** @hidden */
  121324. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  121325. /** @hidden */
  121326. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  121327. /**
  121328. * Unbind all textures from the webGL context
  121329. */
  121330. unbindAllTextures(): void;
  121331. /**
  121332. * Sets a texture to the according uniform.
  121333. * @param channel The texture channel
  121334. * @param uniform The uniform to set
  121335. * @param texture The texture to apply
  121336. */
  121337. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>): void;
  121338. private _bindSamplerUniformToChannel;
  121339. private _getTextureWrapMode;
  121340. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  121341. /**
  121342. * Sets an array of texture to the webGL context
  121343. * @param channel defines the channel where the texture array must be set
  121344. * @param uniform defines the associated uniform location
  121345. * @param textures defines the array of textures to bind
  121346. */
  121347. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[]): void;
  121348. /** @hidden */
  121349. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  121350. private _setTextureParameterFloat;
  121351. private _setTextureParameterInteger;
  121352. /**
  121353. * Unbind all vertex attributes from the webGL context
  121354. */
  121355. unbindAllAttributes(): void;
  121356. /**
  121357. * 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
  121358. */
  121359. releaseEffects(): void;
  121360. /**
  121361. * Dispose and release all associated resources
  121362. */
  121363. dispose(): void;
  121364. /**
  121365. * Attach a new callback raised when context lost event is fired
  121366. * @param callback defines the callback to call
  121367. */
  121368. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  121369. /**
  121370. * Attach a new callback raised when context restored event is fired
  121371. * @param callback defines the callback to call
  121372. */
  121373. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  121374. /**
  121375. * Get the current error code of the webGL context
  121376. * @returns the error code
  121377. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  121378. */
  121379. getError(): number;
  121380. private _canRenderToFloatFramebuffer;
  121381. private _canRenderToHalfFloatFramebuffer;
  121382. private _canRenderToFramebuffer;
  121383. /** @hidden */
  121384. _getWebGLTextureType(type: number): number;
  121385. /** @hidden */
  121386. _getInternalFormat(format: number): number;
  121387. /** @hidden */
  121388. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  121389. /** @hidden */
  121390. _getRGBAMultiSampleBufferFormat(type: number): number;
  121391. /** @hidden */
  121392. _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;
  121393. /**
  121394. * Loads a file from a url
  121395. * @param url url to load
  121396. * @param onSuccess callback called when the file successfully loads
  121397. * @param onProgress callback called while file is loading (if the server supports this mode)
  121398. * @param offlineProvider defines the offline provider for caching
  121399. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  121400. * @param onError callback called when the file fails to load
  121401. * @returns a file request object
  121402. * @hidden
  121403. */
  121404. 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;
  121405. /**
  121406. * Reads pixels from the current frame buffer. Please note that this function can be slow
  121407. * @param x defines the x coordinate of the rectangle where pixels must be read
  121408. * @param y defines the y coordinate of the rectangle where pixels must be read
  121409. * @param width defines the width of the rectangle where pixels must be read
  121410. * @param height defines the height of the rectangle where pixels must be read
  121411. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  121412. * @returns a Uint8Array containing RGBA colors
  121413. */
  121414. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  121415. private static _IsSupported;
  121416. private static _HasMajorPerformanceCaveat;
  121417. /**
  121418. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  121419. */
  121420. static get IsSupported(): boolean;
  121421. /**
  121422. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  121423. * @returns true if the engine can be created
  121424. * @ignorenaming
  121425. */
  121426. static isSupported(): boolean;
  121427. /**
  121428. * 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)
  121429. */
  121430. static get HasMajorPerformanceCaveat(): boolean;
  121431. /**
  121432. * Find the next highest power of two.
  121433. * @param x Number to start search from.
  121434. * @return Next highest power of two.
  121435. */
  121436. static CeilingPOT(x: number): number;
  121437. /**
  121438. * Find the next lowest power of two.
  121439. * @param x Number to start search from.
  121440. * @return Next lowest power of two.
  121441. */
  121442. static FloorPOT(x: number): number;
  121443. /**
  121444. * Find the nearest power of two.
  121445. * @param x Number to start search from.
  121446. * @return Next nearest power of two.
  121447. */
  121448. static NearestPOT(x: number): number;
  121449. /**
  121450. * Get the closest exponent of two
  121451. * @param value defines the value to approximate
  121452. * @param max defines the maximum value to return
  121453. * @param mode defines how to define the closest value
  121454. * @returns closest exponent of two of the given value
  121455. */
  121456. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  121457. /**
  121458. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  121459. * @param func - the function to be called
  121460. * @param requester - the object that will request the next frame. Falls back to window.
  121461. * @returns frame number
  121462. */
  121463. static QueueNewFrame(func: () => void, requester?: any): number;
  121464. /**
  121465. * Gets host document
  121466. * @returns the host document object
  121467. */
  121468. getHostDocument(): Nullable<Document>;
  121469. }
  121470. }
  121471. declare module BABYLON {
  121472. /**
  121473. * Defines the source of the internal texture
  121474. */
  121475. export enum InternalTextureSource {
  121476. /**
  121477. * The source of the texture data is unknown
  121478. */
  121479. Unknown = 0,
  121480. /**
  121481. * Texture data comes from an URL
  121482. */
  121483. Url = 1,
  121484. /**
  121485. * Texture data is only used for temporary storage
  121486. */
  121487. Temp = 2,
  121488. /**
  121489. * Texture data comes from raw data (ArrayBuffer)
  121490. */
  121491. Raw = 3,
  121492. /**
  121493. * Texture content is dynamic (video or dynamic texture)
  121494. */
  121495. Dynamic = 4,
  121496. /**
  121497. * Texture content is generated by rendering to it
  121498. */
  121499. RenderTarget = 5,
  121500. /**
  121501. * Texture content is part of a multi render target process
  121502. */
  121503. MultiRenderTarget = 6,
  121504. /**
  121505. * Texture data comes from a cube data file
  121506. */
  121507. Cube = 7,
  121508. /**
  121509. * Texture data comes from a raw cube data
  121510. */
  121511. CubeRaw = 8,
  121512. /**
  121513. * Texture data come from a prefiltered cube data file
  121514. */
  121515. CubePrefiltered = 9,
  121516. /**
  121517. * Texture content is raw 3D data
  121518. */
  121519. Raw3D = 10,
  121520. /**
  121521. * Texture content is raw 2D array data
  121522. */
  121523. Raw2DArray = 11,
  121524. /**
  121525. * Texture content is a depth texture
  121526. */
  121527. Depth = 12,
  121528. /**
  121529. * Texture data comes from a raw cube data encoded with RGBD
  121530. */
  121531. CubeRawRGBD = 13
  121532. }
  121533. /**
  121534. * Class used to store data associated with WebGL texture data for the engine
  121535. * This class should not be used directly
  121536. */
  121537. export class InternalTexture {
  121538. /** @hidden */
  121539. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  121540. /**
  121541. * Defines if the texture is ready
  121542. */
  121543. isReady: boolean;
  121544. /**
  121545. * Defines if the texture is a cube texture
  121546. */
  121547. isCube: boolean;
  121548. /**
  121549. * Defines if the texture contains 3D data
  121550. */
  121551. is3D: boolean;
  121552. /**
  121553. * Defines if the texture contains 2D array data
  121554. */
  121555. is2DArray: boolean;
  121556. /**
  121557. * Defines if the texture contains multiview data
  121558. */
  121559. isMultiview: boolean;
  121560. /**
  121561. * Gets the URL used to load this texture
  121562. */
  121563. url: string;
  121564. /**
  121565. * Gets the sampling mode of the texture
  121566. */
  121567. samplingMode: number;
  121568. /**
  121569. * Gets a boolean indicating if the texture needs mipmaps generation
  121570. */
  121571. generateMipMaps: boolean;
  121572. /**
  121573. * Gets the number of samples used by the texture (WebGL2+ only)
  121574. */
  121575. samples: number;
  121576. /**
  121577. * Gets the type of the texture (int, float...)
  121578. */
  121579. type: number;
  121580. /**
  121581. * Gets the format of the texture (RGB, RGBA...)
  121582. */
  121583. format: number;
  121584. /**
  121585. * Observable called when the texture is loaded
  121586. */
  121587. onLoadedObservable: Observable<InternalTexture>;
  121588. /**
  121589. * Gets the width of the texture
  121590. */
  121591. width: number;
  121592. /**
  121593. * Gets the height of the texture
  121594. */
  121595. height: number;
  121596. /**
  121597. * Gets the depth of the texture
  121598. */
  121599. depth: number;
  121600. /**
  121601. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  121602. */
  121603. baseWidth: number;
  121604. /**
  121605. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  121606. */
  121607. baseHeight: number;
  121608. /**
  121609. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  121610. */
  121611. baseDepth: number;
  121612. /**
  121613. * Gets a boolean indicating if the texture is inverted on Y axis
  121614. */
  121615. invertY: boolean;
  121616. /** @hidden */
  121617. _invertVScale: boolean;
  121618. /** @hidden */
  121619. _associatedChannel: number;
  121620. /** @hidden */
  121621. _source: InternalTextureSource;
  121622. /** @hidden */
  121623. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  121624. /** @hidden */
  121625. _bufferView: Nullable<ArrayBufferView>;
  121626. /** @hidden */
  121627. _bufferViewArray: Nullable<ArrayBufferView[]>;
  121628. /** @hidden */
  121629. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  121630. /** @hidden */
  121631. _size: number;
  121632. /** @hidden */
  121633. _extension: string;
  121634. /** @hidden */
  121635. _files: Nullable<string[]>;
  121636. /** @hidden */
  121637. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  121638. /** @hidden */
  121639. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  121640. /** @hidden */
  121641. _framebuffer: Nullable<WebGLFramebuffer>;
  121642. /** @hidden */
  121643. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  121644. /** @hidden */
  121645. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  121646. /** @hidden */
  121647. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  121648. /** @hidden */
  121649. _attachments: Nullable<number[]>;
  121650. /** @hidden */
  121651. _textureArray: Nullable<InternalTexture[]>;
  121652. /** @hidden */
  121653. _cachedCoordinatesMode: Nullable<number>;
  121654. /** @hidden */
  121655. _cachedWrapU: Nullable<number>;
  121656. /** @hidden */
  121657. _cachedWrapV: Nullable<number>;
  121658. /** @hidden */
  121659. _cachedWrapR: Nullable<number>;
  121660. /** @hidden */
  121661. _cachedAnisotropicFilteringLevel: Nullable<number>;
  121662. /** @hidden */
  121663. _isDisabled: boolean;
  121664. /** @hidden */
  121665. _compression: Nullable<string>;
  121666. /** @hidden */
  121667. _generateStencilBuffer: boolean;
  121668. /** @hidden */
  121669. _generateDepthBuffer: boolean;
  121670. /** @hidden */
  121671. _comparisonFunction: number;
  121672. /** @hidden */
  121673. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  121674. /** @hidden */
  121675. _lodGenerationScale: number;
  121676. /** @hidden */
  121677. _lodGenerationOffset: number;
  121678. /** @hidden */
  121679. _depthStencilTexture: Nullable<InternalTexture>;
  121680. /** @hidden */
  121681. _colorTextureArray: Nullable<WebGLTexture>;
  121682. /** @hidden */
  121683. _depthStencilTextureArray: Nullable<WebGLTexture>;
  121684. /** @hidden */
  121685. _lodTextureHigh: Nullable<BaseTexture>;
  121686. /** @hidden */
  121687. _lodTextureMid: Nullable<BaseTexture>;
  121688. /** @hidden */
  121689. _lodTextureLow: Nullable<BaseTexture>;
  121690. /** @hidden */
  121691. _isRGBD: boolean;
  121692. /** @hidden */
  121693. _linearSpecularLOD: boolean;
  121694. /** @hidden */
  121695. _irradianceTexture: Nullable<BaseTexture>;
  121696. /** @hidden */
  121697. _webGLTexture: Nullable<WebGLTexture>;
  121698. /** @hidden */
  121699. _references: number;
  121700. /** @hidden */
  121701. _gammaSpace: Nullable<boolean>;
  121702. private _engine;
  121703. /**
  121704. * Gets the Engine the texture belongs to.
  121705. * @returns The babylon engine
  121706. */
  121707. getEngine(): ThinEngine;
  121708. /**
  121709. * Gets the data source type of the texture
  121710. */
  121711. get source(): InternalTextureSource;
  121712. /**
  121713. * Creates a new InternalTexture
  121714. * @param engine defines the engine to use
  121715. * @param source defines the type of data that will be used
  121716. * @param delayAllocation if the texture allocation should be delayed (default: false)
  121717. */
  121718. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  121719. /**
  121720. * Increments the number of references (ie. the number of Texture that point to it)
  121721. */
  121722. incrementReferences(): void;
  121723. /**
  121724. * Change the size of the texture (not the size of the content)
  121725. * @param width defines the new width
  121726. * @param height defines the new height
  121727. * @param depth defines the new depth (1 by default)
  121728. */
  121729. updateSize(width: int, height: int, depth?: int): void;
  121730. /** @hidden */
  121731. _rebuild(): void;
  121732. /** @hidden */
  121733. _swapAndDie(target: InternalTexture): void;
  121734. /**
  121735. * Dispose the current allocated resources
  121736. */
  121737. dispose(): void;
  121738. }
  121739. }
  121740. declare module BABYLON {
  121741. /**
  121742. * Interface used to present a loading screen while loading a scene
  121743. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121744. */
  121745. export interface ILoadingScreen {
  121746. /**
  121747. * Function called to display the loading screen
  121748. */
  121749. displayLoadingUI: () => void;
  121750. /**
  121751. * Function called to hide the loading screen
  121752. */
  121753. hideLoadingUI: () => void;
  121754. /**
  121755. * Gets or sets the color to use for the background
  121756. */
  121757. loadingUIBackgroundColor: string;
  121758. /**
  121759. * Gets or sets the text to display while loading
  121760. */
  121761. loadingUIText: string;
  121762. }
  121763. /**
  121764. * Class used for the default loading screen
  121765. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121766. */
  121767. export class DefaultLoadingScreen implements ILoadingScreen {
  121768. private _renderingCanvas;
  121769. private _loadingText;
  121770. private _loadingDivBackgroundColor;
  121771. private _loadingDiv;
  121772. private _loadingTextDiv;
  121773. /** Gets or sets the logo url to use for the default loading screen */
  121774. static DefaultLogoUrl: string;
  121775. /** Gets or sets the spinner url to use for the default loading screen */
  121776. static DefaultSpinnerUrl: string;
  121777. /**
  121778. * Creates a new default loading screen
  121779. * @param _renderingCanvas defines the canvas used to render the scene
  121780. * @param _loadingText defines the default text to display
  121781. * @param _loadingDivBackgroundColor defines the default background color
  121782. */
  121783. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  121784. /**
  121785. * Function called to display the loading screen
  121786. */
  121787. displayLoadingUI(): void;
  121788. /**
  121789. * Function called to hide the loading screen
  121790. */
  121791. hideLoadingUI(): void;
  121792. /**
  121793. * Gets or sets the text to display while loading
  121794. */
  121795. set loadingUIText(text: string);
  121796. get loadingUIText(): string;
  121797. /**
  121798. * Gets or sets the color to use for the background
  121799. */
  121800. get loadingUIBackgroundColor(): string;
  121801. set loadingUIBackgroundColor(color: string);
  121802. private _resizeLoadingUI;
  121803. }
  121804. }
  121805. declare module BABYLON {
  121806. /**
  121807. * Interface for any object that can request an animation frame
  121808. */
  121809. export interface ICustomAnimationFrameRequester {
  121810. /**
  121811. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  121812. */
  121813. renderFunction?: Function;
  121814. /**
  121815. * Called to request the next frame to render to
  121816. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  121817. */
  121818. requestAnimationFrame: Function;
  121819. /**
  121820. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  121821. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  121822. */
  121823. requestID?: number;
  121824. }
  121825. }
  121826. declare module BABYLON {
  121827. /**
  121828. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  121829. */
  121830. export class PerformanceMonitor {
  121831. private _enabled;
  121832. private _rollingFrameTime;
  121833. private _lastFrameTimeMs;
  121834. /**
  121835. * constructor
  121836. * @param frameSampleSize The number of samples required to saturate the sliding window
  121837. */
  121838. constructor(frameSampleSize?: number);
  121839. /**
  121840. * Samples current frame
  121841. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  121842. */
  121843. sampleFrame(timeMs?: number): void;
  121844. /**
  121845. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  121846. */
  121847. get averageFrameTime(): number;
  121848. /**
  121849. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  121850. */
  121851. get averageFrameTimeVariance(): number;
  121852. /**
  121853. * Returns the frame time of the most recent frame
  121854. */
  121855. get instantaneousFrameTime(): number;
  121856. /**
  121857. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  121858. */
  121859. get averageFPS(): number;
  121860. /**
  121861. * Returns the average framerate in frames per second using the most recent frame time
  121862. */
  121863. get instantaneousFPS(): number;
  121864. /**
  121865. * Returns true if enough samples have been taken to completely fill the sliding window
  121866. */
  121867. get isSaturated(): boolean;
  121868. /**
  121869. * Enables contributions to the sliding window sample set
  121870. */
  121871. enable(): void;
  121872. /**
  121873. * Disables contributions to the sliding window sample set
  121874. * Samples will not be interpolated over the disabled period
  121875. */
  121876. disable(): void;
  121877. /**
  121878. * Returns true if sampling is enabled
  121879. */
  121880. get isEnabled(): boolean;
  121881. /**
  121882. * Resets performance monitor
  121883. */
  121884. reset(): void;
  121885. }
  121886. /**
  121887. * RollingAverage
  121888. *
  121889. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  121890. */
  121891. export class RollingAverage {
  121892. /**
  121893. * Current average
  121894. */
  121895. average: number;
  121896. /**
  121897. * Current variance
  121898. */
  121899. variance: number;
  121900. protected _samples: Array<number>;
  121901. protected _sampleCount: number;
  121902. protected _pos: number;
  121903. protected _m2: number;
  121904. /**
  121905. * constructor
  121906. * @param length The number of samples required to saturate the sliding window
  121907. */
  121908. constructor(length: number);
  121909. /**
  121910. * Adds a sample to the sample set
  121911. * @param v The sample value
  121912. */
  121913. add(v: number): void;
  121914. /**
  121915. * Returns previously added values or null if outside of history or outside the sliding window domain
  121916. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  121917. * @return Value previously recorded with add() or null if outside of range
  121918. */
  121919. history(i: number): number;
  121920. /**
  121921. * Returns true if enough samples have been taken to completely fill the sliding window
  121922. * @return true if sample-set saturated
  121923. */
  121924. isSaturated(): boolean;
  121925. /**
  121926. * Resets the rolling average (equivalent to 0 samples taken so far)
  121927. */
  121928. reset(): void;
  121929. /**
  121930. * Wraps a value around the sample range boundaries
  121931. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  121932. * @return Wrapped position in sample range
  121933. */
  121934. protected _wrapPosition(i: number): number;
  121935. }
  121936. }
  121937. declare module BABYLON {
  121938. /**
  121939. * This class is used to track a performance counter which is number based.
  121940. * The user has access to many properties which give statistics of different nature.
  121941. *
  121942. * The implementer can track two kinds of Performance Counter: time and count.
  121943. * 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.
  121944. * 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.
  121945. */
  121946. export class PerfCounter {
  121947. /**
  121948. * Gets or sets a global boolean to turn on and off all the counters
  121949. */
  121950. static Enabled: boolean;
  121951. /**
  121952. * Returns the smallest value ever
  121953. */
  121954. get min(): number;
  121955. /**
  121956. * Returns the biggest value ever
  121957. */
  121958. get max(): number;
  121959. /**
  121960. * Returns the average value since the performance counter is running
  121961. */
  121962. get average(): number;
  121963. /**
  121964. * Returns the average value of the last second the counter was monitored
  121965. */
  121966. get lastSecAverage(): number;
  121967. /**
  121968. * Returns the current value
  121969. */
  121970. get current(): number;
  121971. /**
  121972. * Gets the accumulated total
  121973. */
  121974. get total(): number;
  121975. /**
  121976. * Gets the total value count
  121977. */
  121978. get count(): number;
  121979. /**
  121980. * Creates a new counter
  121981. */
  121982. constructor();
  121983. /**
  121984. * Call this method to start monitoring a new frame.
  121985. * 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.
  121986. */
  121987. fetchNewFrame(): void;
  121988. /**
  121989. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  121990. * @param newCount the count value to add to the monitored count
  121991. * @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.
  121992. */
  121993. addCount(newCount: number, fetchResult: boolean): void;
  121994. /**
  121995. * Start monitoring this performance counter
  121996. */
  121997. beginMonitoring(): void;
  121998. /**
  121999. * Compute the time lapsed since the previous beginMonitoring() call.
  122000. * @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
  122001. */
  122002. endMonitoring(newFrame?: boolean): void;
  122003. private _fetchResult;
  122004. private _startMonitoringTime;
  122005. private _min;
  122006. private _max;
  122007. private _average;
  122008. private _current;
  122009. private _totalValueCount;
  122010. private _totalAccumulated;
  122011. private _lastSecAverage;
  122012. private _lastSecAccumulated;
  122013. private _lastSecTime;
  122014. private _lastSecValueCount;
  122015. }
  122016. }
  122017. declare module BABYLON {
  122018. interface ThinEngine {
  122019. /** @hidden */
  122020. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  122021. }
  122022. }
  122023. declare module BABYLON {
  122024. /**
  122025. * Class used to work with sound analyzer using fast fourier transform (FFT)
  122026. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122027. */
  122028. export class Analyser {
  122029. /**
  122030. * Gets or sets the smoothing
  122031. * @ignorenaming
  122032. */
  122033. SMOOTHING: number;
  122034. /**
  122035. * Gets or sets the FFT table size
  122036. * @ignorenaming
  122037. */
  122038. FFT_SIZE: number;
  122039. /**
  122040. * Gets or sets the bar graph amplitude
  122041. * @ignorenaming
  122042. */
  122043. BARGRAPHAMPLITUDE: number;
  122044. /**
  122045. * Gets or sets the position of the debug canvas
  122046. * @ignorenaming
  122047. */
  122048. DEBUGCANVASPOS: {
  122049. x: number;
  122050. y: number;
  122051. };
  122052. /**
  122053. * Gets or sets the debug canvas size
  122054. * @ignorenaming
  122055. */
  122056. DEBUGCANVASSIZE: {
  122057. width: number;
  122058. height: number;
  122059. };
  122060. private _byteFreqs;
  122061. private _byteTime;
  122062. private _floatFreqs;
  122063. private _webAudioAnalyser;
  122064. private _debugCanvas;
  122065. private _debugCanvasContext;
  122066. private _scene;
  122067. private _registerFunc;
  122068. private _audioEngine;
  122069. /**
  122070. * Creates a new analyser
  122071. * @param scene defines hosting scene
  122072. */
  122073. constructor(scene: Scene);
  122074. /**
  122075. * Get the number of data values you will have to play with for the visualization
  122076. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  122077. * @returns a number
  122078. */
  122079. getFrequencyBinCount(): number;
  122080. /**
  122081. * Gets the current frequency data as a byte array
  122082. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  122083. * @returns a Uint8Array
  122084. */
  122085. getByteFrequencyData(): Uint8Array;
  122086. /**
  122087. * Gets the current waveform as a byte array
  122088. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  122089. * @returns a Uint8Array
  122090. */
  122091. getByteTimeDomainData(): Uint8Array;
  122092. /**
  122093. * Gets the current frequency data as a float array
  122094. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  122095. * @returns a Float32Array
  122096. */
  122097. getFloatFrequencyData(): Float32Array;
  122098. /**
  122099. * Renders the debug canvas
  122100. */
  122101. drawDebugCanvas(): void;
  122102. /**
  122103. * Stops rendering the debug canvas and removes it
  122104. */
  122105. stopDebugCanvas(): void;
  122106. /**
  122107. * Connects two audio nodes
  122108. * @param inputAudioNode defines first node to connect
  122109. * @param outputAudioNode defines second node to connect
  122110. */
  122111. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  122112. /**
  122113. * Releases all associated resources
  122114. */
  122115. dispose(): void;
  122116. }
  122117. }
  122118. declare module BABYLON {
  122119. /**
  122120. * This represents an audio engine and it is responsible
  122121. * to play, synchronize and analyse sounds throughout the application.
  122122. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122123. */
  122124. export interface IAudioEngine extends IDisposable {
  122125. /**
  122126. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  122127. */
  122128. readonly canUseWebAudio: boolean;
  122129. /**
  122130. * Gets the current AudioContext if available.
  122131. */
  122132. readonly audioContext: Nullable<AudioContext>;
  122133. /**
  122134. * The master gain node defines the global audio volume of your audio engine.
  122135. */
  122136. readonly masterGain: GainNode;
  122137. /**
  122138. * Gets whether or not mp3 are supported by your browser.
  122139. */
  122140. readonly isMP3supported: boolean;
  122141. /**
  122142. * Gets whether or not ogg are supported by your browser.
  122143. */
  122144. readonly isOGGsupported: boolean;
  122145. /**
  122146. * Defines if Babylon should emit a warning if WebAudio is not supported.
  122147. * @ignoreNaming
  122148. */
  122149. WarnedWebAudioUnsupported: boolean;
  122150. /**
  122151. * Defines if the audio engine relies on a custom unlocked button.
  122152. * In this case, the embedded button will not be displayed.
  122153. */
  122154. useCustomUnlockedButton: boolean;
  122155. /**
  122156. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  122157. */
  122158. readonly unlocked: boolean;
  122159. /**
  122160. * Event raised when audio has been unlocked on the browser.
  122161. */
  122162. onAudioUnlockedObservable: Observable<IAudioEngine>;
  122163. /**
  122164. * Event raised when audio has been locked on the browser.
  122165. */
  122166. onAudioLockedObservable: Observable<IAudioEngine>;
  122167. /**
  122168. * Flags the audio engine in Locked state.
  122169. * This happens due to new browser policies preventing audio to autoplay.
  122170. */
  122171. lock(): void;
  122172. /**
  122173. * Unlocks the audio engine once a user action has been done on the dom.
  122174. * This is helpful to resume play once browser policies have been satisfied.
  122175. */
  122176. unlock(): void;
  122177. /**
  122178. * Gets the global volume sets on the master gain.
  122179. * @returns the global volume if set or -1 otherwise
  122180. */
  122181. getGlobalVolume(): number;
  122182. /**
  122183. * Sets the global volume of your experience (sets on the master gain).
  122184. * @param newVolume Defines the new global volume of the application
  122185. */
  122186. setGlobalVolume(newVolume: number): void;
  122187. /**
  122188. * Connect the audio engine to an audio analyser allowing some amazing
  122189. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  122190. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  122191. * @param analyser The analyser to connect to the engine
  122192. */
  122193. connectToAnalyser(analyser: Analyser): void;
  122194. }
  122195. }
  122196. declare module BABYLON {
  122197. /**
  122198. * Defines the interface used by display changed events
  122199. */
  122200. export interface IDisplayChangedEventArgs {
  122201. /** Gets the vrDisplay object (if any) */
  122202. vrDisplay: Nullable<any>;
  122203. /** Gets a boolean indicating if webVR is supported */
  122204. vrSupported: boolean;
  122205. }
  122206. /**
  122207. * Defines the interface used by objects containing a viewport (like a camera)
  122208. */
  122209. interface IViewportOwnerLike {
  122210. /**
  122211. * Gets or sets the viewport
  122212. */
  122213. viewport: IViewportLike;
  122214. }
  122215. /**
  122216. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  122217. */
  122218. export class Engine extends ThinEngine {
  122219. /** Defines that alpha blending is disabled */
  122220. static readonly ALPHA_DISABLE: number;
  122221. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  122222. static readonly ALPHA_ADD: number;
  122223. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  122224. static readonly ALPHA_COMBINE: number;
  122225. /** Defines that alpha blending to DEST - SRC * DEST */
  122226. static readonly ALPHA_SUBTRACT: number;
  122227. /** Defines that alpha blending to SRC * DEST */
  122228. static readonly ALPHA_MULTIPLY: number;
  122229. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  122230. static readonly ALPHA_MAXIMIZED: number;
  122231. /** Defines that alpha blending to SRC + DEST */
  122232. static readonly ALPHA_ONEONE: number;
  122233. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  122234. static readonly ALPHA_PREMULTIPLIED: number;
  122235. /**
  122236. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  122237. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  122238. */
  122239. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  122240. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  122241. static readonly ALPHA_INTERPOLATE: number;
  122242. /**
  122243. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  122244. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  122245. */
  122246. static readonly ALPHA_SCREENMODE: number;
  122247. /** Defines that the ressource is not delayed*/
  122248. static readonly DELAYLOADSTATE_NONE: number;
  122249. /** Defines that the ressource was successfully delay loaded */
  122250. static readonly DELAYLOADSTATE_LOADED: number;
  122251. /** Defines that the ressource is currently delay loading */
  122252. static readonly DELAYLOADSTATE_LOADING: number;
  122253. /** Defines that the ressource is delayed and has not started loading */
  122254. static readonly DELAYLOADSTATE_NOTLOADED: number;
  122255. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  122256. static readonly NEVER: number;
  122257. /** 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 */
  122258. static readonly ALWAYS: number;
  122259. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  122260. static readonly LESS: number;
  122261. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  122262. static readonly EQUAL: number;
  122263. /** 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 */
  122264. static readonly LEQUAL: number;
  122265. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  122266. static readonly GREATER: number;
  122267. /** 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 */
  122268. static readonly GEQUAL: number;
  122269. /** 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 */
  122270. static readonly NOTEQUAL: number;
  122271. /** Passed to stencilOperation to specify that stencil value must be kept */
  122272. static readonly KEEP: number;
  122273. /** Passed to stencilOperation to specify that stencil value must be replaced */
  122274. static readonly REPLACE: number;
  122275. /** Passed to stencilOperation to specify that stencil value must be incremented */
  122276. static readonly INCR: number;
  122277. /** Passed to stencilOperation to specify that stencil value must be decremented */
  122278. static readonly DECR: number;
  122279. /** Passed to stencilOperation to specify that stencil value must be inverted */
  122280. static readonly INVERT: number;
  122281. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  122282. static readonly INCR_WRAP: number;
  122283. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  122284. static readonly DECR_WRAP: number;
  122285. /** Texture is not repeating outside of 0..1 UVs */
  122286. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  122287. /** Texture is repeating outside of 0..1 UVs */
  122288. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  122289. /** Texture is repeating and mirrored */
  122290. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  122291. /** ALPHA */
  122292. static readonly TEXTUREFORMAT_ALPHA: number;
  122293. /** LUMINANCE */
  122294. static readonly TEXTUREFORMAT_LUMINANCE: number;
  122295. /** LUMINANCE_ALPHA */
  122296. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  122297. /** RGB */
  122298. static readonly TEXTUREFORMAT_RGB: number;
  122299. /** RGBA */
  122300. static readonly TEXTUREFORMAT_RGBA: number;
  122301. /** RED */
  122302. static readonly TEXTUREFORMAT_RED: number;
  122303. /** RED (2nd reference) */
  122304. static readonly TEXTUREFORMAT_R: number;
  122305. /** RG */
  122306. static readonly TEXTUREFORMAT_RG: number;
  122307. /** RED_INTEGER */
  122308. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  122309. /** RED_INTEGER (2nd reference) */
  122310. static readonly TEXTUREFORMAT_R_INTEGER: number;
  122311. /** RG_INTEGER */
  122312. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  122313. /** RGB_INTEGER */
  122314. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  122315. /** RGBA_INTEGER */
  122316. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  122317. /** UNSIGNED_BYTE */
  122318. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  122319. /** UNSIGNED_BYTE (2nd reference) */
  122320. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  122321. /** FLOAT */
  122322. static readonly TEXTURETYPE_FLOAT: number;
  122323. /** HALF_FLOAT */
  122324. static readonly TEXTURETYPE_HALF_FLOAT: number;
  122325. /** BYTE */
  122326. static readonly TEXTURETYPE_BYTE: number;
  122327. /** SHORT */
  122328. static readonly TEXTURETYPE_SHORT: number;
  122329. /** UNSIGNED_SHORT */
  122330. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  122331. /** INT */
  122332. static readonly TEXTURETYPE_INT: number;
  122333. /** UNSIGNED_INT */
  122334. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  122335. /** UNSIGNED_SHORT_4_4_4_4 */
  122336. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  122337. /** UNSIGNED_SHORT_5_5_5_1 */
  122338. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  122339. /** UNSIGNED_SHORT_5_6_5 */
  122340. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  122341. /** UNSIGNED_INT_2_10_10_10_REV */
  122342. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  122343. /** UNSIGNED_INT_24_8 */
  122344. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  122345. /** UNSIGNED_INT_10F_11F_11F_REV */
  122346. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  122347. /** UNSIGNED_INT_5_9_9_9_REV */
  122348. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  122349. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  122350. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  122351. /** nearest is mag = nearest and min = nearest and mip = linear */
  122352. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  122353. /** Bilinear is mag = linear and min = linear and mip = nearest */
  122354. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  122355. /** Trilinear is mag = linear and min = linear and mip = linear */
  122356. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  122357. /** nearest is mag = nearest and min = nearest and mip = linear */
  122358. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  122359. /** Bilinear is mag = linear and min = linear and mip = nearest */
  122360. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  122361. /** Trilinear is mag = linear and min = linear and mip = linear */
  122362. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  122363. /** mag = nearest and min = nearest and mip = nearest */
  122364. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  122365. /** mag = nearest and min = linear and mip = nearest */
  122366. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  122367. /** mag = nearest and min = linear and mip = linear */
  122368. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  122369. /** mag = nearest and min = linear and mip = none */
  122370. static readonly TEXTURE_NEAREST_LINEAR: number;
  122371. /** mag = nearest and min = nearest and mip = none */
  122372. static readonly TEXTURE_NEAREST_NEAREST: number;
  122373. /** mag = linear and min = nearest and mip = nearest */
  122374. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  122375. /** mag = linear and min = nearest and mip = linear */
  122376. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  122377. /** mag = linear and min = linear and mip = none */
  122378. static readonly TEXTURE_LINEAR_LINEAR: number;
  122379. /** mag = linear and min = nearest and mip = none */
  122380. static readonly TEXTURE_LINEAR_NEAREST: number;
  122381. /** Explicit coordinates mode */
  122382. static readonly TEXTURE_EXPLICIT_MODE: number;
  122383. /** Spherical coordinates mode */
  122384. static readonly TEXTURE_SPHERICAL_MODE: number;
  122385. /** Planar coordinates mode */
  122386. static readonly TEXTURE_PLANAR_MODE: number;
  122387. /** Cubic coordinates mode */
  122388. static readonly TEXTURE_CUBIC_MODE: number;
  122389. /** Projection coordinates mode */
  122390. static readonly TEXTURE_PROJECTION_MODE: number;
  122391. /** Skybox coordinates mode */
  122392. static readonly TEXTURE_SKYBOX_MODE: number;
  122393. /** Inverse Cubic coordinates mode */
  122394. static readonly TEXTURE_INVCUBIC_MODE: number;
  122395. /** Equirectangular coordinates mode */
  122396. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  122397. /** Equirectangular Fixed coordinates mode */
  122398. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  122399. /** Equirectangular Fixed Mirrored coordinates mode */
  122400. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  122401. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  122402. static readonly SCALEMODE_FLOOR: number;
  122403. /** Defines that texture rescaling will look for the nearest power of 2 size */
  122404. static readonly SCALEMODE_NEAREST: number;
  122405. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  122406. static readonly SCALEMODE_CEILING: number;
  122407. /**
  122408. * Returns the current npm package of the sdk
  122409. */
  122410. static get NpmPackage(): string;
  122411. /**
  122412. * Returns the current version of the framework
  122413. */
  122414. static get Version(): string;
  122415. /** Gets the list of created engines */
  122416. static get Instances(): Engine[];
  122417. /**
  122418. * Gets the latest created engine
  122419. */
  122420. static get LastCreatedEngine(): Nullable<Engine>;
  122421. /**
  122422. * Gets the latest created scene
  122423. */
  122424. static get LastCreatedScene(): Nullable<Scene>;
  122425. /**
  122426. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  122427. * @param flag defines which part of the materials must be marked as dirty
  122428. * @param predicate defines a predicate used to filter which materials should be affected
  122429. */
  122430. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  122431. /**
  122432. * Method called to create the default loading screen.
  122433. * This can be overriden in your own app.
  122434. * @param canvas The rendering canvas element
  122435. * @returns The loading screen
  122436. */
  122437. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  122438. /**
  122439. * Method called to create the default rescale post process on each engine.
  122440. */
  122441. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  122442. /**
  122443. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  122444. **/
  122445. enableOfflineSupport: boolean;
  122446. /**
  122447. * 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)
  122448. **/
  122449. disableManifestCheck: boolean;
  122450. /**
  122451. * Gets the list of created scenes
  122452. */
  122453. scenes: Scene[];
  122454. /**
  122455. * Event raised when a new scene is created
  122456. */
  122457. onNewSceneAddedObservable: Observable<Scene>;
  122458. /**
  122459. * Gets the list of created postprocesses
  122460. */
  122461. postProcesses: PostProcess[];
  122462. /**
  122463. * Gets a boolean indicating if the pointer is currently locked
  122464. */
  122465. isPointerLock: boolean;
  122466. /**
  122467. * Observable event triggered each time the rendering canvas is resized
  122468. */
  122469. onResizeObservable: Observable<Engine>;
  122470. /**
  122471. * Observable event triggered each time the canvas loses focus
  122472. */
  122473. onCanvasBlurObservable: Observable<Engine>;
  122474. /**
  122475. * Observable event triggered each time the canvas gains focus
  122476. */
  122477. onCanvasFocusObservable: Observable<Engine>;
  122478. /**
  122479. * Observable event triggered each time the canvas receives pointerout event
  122480. */
  122481. onCanvasPointerOutObservable: Observable<PointerEvent>;
  122482. /**
  122483. * Observable raised when the engine begins a new frame
  122484. */
  122485. onBeginFrameObservable: Observable<Engine>;
  122486. /**
  122487. * If set, will be used to request the next animation frame for the render loop
  122488. */
  122489. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  122490. /**
  122491. * Observable raised when the engine ends the current frame
  122492. */
  122493. onEndFrameObservable: Observable<Engine>;
  122494. /**
  122495. * Observable raised when the engine is about to compile a shader
  122496. */
  122497. onBeforeShaderCompilationObservable: Observable<Engine>;
  122498. /**
  122499. * Observable raised when the engine has jsut compiled a shader
  122500. */
  122501. onAfterShaderCompilationObservable: Observable<Engine>;
  122502. /**
  122503. * Gets the audio engine
  122504. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122505. * @ignorenaming
  122506. */
  122507. static audioEngine: IAudioEngine;
  122508. /**
  122509. * Default AudioEngine factory responsible of creating the Audio Engine.
  122510. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  122511. */
  122512. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  122513. /**
  122514. * Default offline support factory responsible of creating a tool used to store data locally.
  122515. * By default, this will create a Database object if the workload has been embedded.
  122516. */
  122517. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  122518. private _loadingScreen;
  122519. private _pointerLockRequested;
  122520. private _rescalePostProcess;
  122521. private _deterministicLockstep;
  122522. private _lockstepMaxSteps;
  122523. private _timeStep;
  122524. protected get _supportsHardwareTextureRescaling(): boolean;
  122525. private _fps;
  122526. private _deltaTime;
  122527. /** @hidden */
  122528. _drawCalls: PerfCounter;
  122529. /** 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 */
  122530. canvasTabIndex: number;
  122531. /**
  122532. * Turn this value on if you want to pause FPS computation when in background
  122533. */
  122534. disablePerformanceMonitorInBackground: boolean;
  122535. private _performanceMonitor;
  122536. /**
  122537. * Gets the performance monitor attached to this engine
  122538. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  122539. */
  122540. get performanceMonitor(): PerformanceMonitor;
  122541. private _onFocus;
  122542. private _onBlur;
  122543. private _onCanvasPointerOut;
  122544. private _onCanvasBlur;
  122545. private _onCanvasFocus;
  122546. private _onFullscreenChange;
  122547. private _onPointerLockChange;
  122548. /**
  122549. * Gets the HTML element used to attach event listeners
  122550. * @returns a HTML element
  122551. */
  122552. getInputElement(): Nullable<HTMLElement>;
  122553. /**
  122554. * Creates a new engine
  122555. * @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
  122556. * @param antialias defines enable antialiasing (default: false)
  122557. * @param options defines further options to be sent to the getContext() function
  122558. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  122559. */
  122560. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  122561. /**
  122562. * Gets current aspect ratio
  122563. * @param viewportOwner defines the camera to use to get the aspect ratio
  122564. * @param useScreen defines if screen size must be used (or the current render target if any)
  122565. * @returns a number defining the aspect ratio
  122566. */
  122567. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  122568. /**
  122569. * Gets current screen aspect ratio
  122570. * @returns a number defining the aspect ratio
  122571. */
  122572. getScreenAspectRatio(): number;
  122573. /**
  122574. * Gets the client rect of the HTML canvas attached with the current webGL context
  122575. * @returns a client rectanglee
  122576. */
  122577. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  122578. /**
  122579. * Gets the client rect of the HTML element used for events
  122580. * @returns a client rectanglee
  122581. */
  122582. getInputElementClientRect(): Nullable<ClientRect>;
  122583. /**
  122584. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  122585. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122586. * @returns true if engine is in deterministic lock step mode
  122587. */
  122588. isDeterministicLockStep(): boolean;
  122589. /**
  122590. * Gets the max steps when engine is running in deterministic lock step
  122591. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122592. * @returns the max steps
  122593. */
  122594. getLockstepMaxSteps(): number;
  122595. /**
  122596. * Returns the time in ms between steps when using deterministic lock step.
  122597. * @returns time step in (ms)
  122598. */
  122599. getTimeStep(): number;
  122600. /**
  122601. * Force the mipmap generation for the given render target texture
  122602. * @param texture defines the render target texture to use
  122603. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  122604. */
  122605. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  122606. /** States */
  122607. /**
  122608. * Set various states to the webGL context
  122609. * @param culling defines backface culling state
  122610. * @param zOffset defines the value to apply to zOffset (0 by default)
  122611. * @param force defines if states must be applied even if cache is up to date
  122612. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  122613. */
  122614. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  122615. /**
  122616. * Set the z offset to apply to current rendering
  122617. * @param value defines the offset to apply
  122618. */
  122619. setZOffset(value: number): void;
  122620. /**
  122621. * Gets the current value of the zOffset
  122622. * @returns the current zOffset state
  122623. */
  122624. getZOffset(): number;
  122625. /**
  122626. * Enable or disable depth buffering
  122627. * @param enable defines the state to set
  122628. */
  122629. setDepthBuffer(enable: boolean): void;
  122630. /**
  122631. * Gets a boolean indicating if depth writing is enabled
  122632. * @returns the current depth writing state
  122633. */
  122634. getDepthWrite(): boolean;
  122635. /**
  122636. * Enable or disable depth writing
  122637. * @param enable defines the state to set
  122638. */
  122639. setDepthWrite(enable: boolean): void;
  122640. /**
  122641. * Gets a boolean indicating if stencil buffer is enabled
  122642. * @returns the current stencil buffer state
  122643. */
  122644. getStencilBuffer(): boolean;
  122645. /**
  122646. * Enable or disable the stencil buffer
  122647. * @param enable defines if the stencil buffer must be enabled or disabled
  122648. */
  122649. setStencilBuffer(enable: boolean): void;
  122650. /**
  122651. * Gets the current stencil mask
  122652. * @returns a number defining the new stencil mask to use
  122653. */
  122654. getStencilMask(): number;
  122655. /**
  122656. * Sets the current stencil mask
  122657. * @param mask defines the new stencil mask to use
  122658. */
  122659. setStencilMask(mask: number): void;
  122660. /**
  122661. * Gets the current stencil function
  122662. * @returns a number defining the stencil function to use
  122663. */
  122664. getStencilFunction(): number;
  122665. /**
  122666. * Gets the current stencil reference value
  122667. * @returns a number defining the stencil reference value to use
  122668. */
  122669. getStencilFunctionReference(): number;
  122670. /**
  122671. * Gets the current stencil mask
  122672. * @returns a number defining the stencil mask to use
  122673. */
  122674. getStencilFunctionMask(): number;
  122675. /**
  122676. * Sets the current stencil function
  122677. * @param stencilFunc defines the new stencil function to use
  122678. */
  122679. setStencilFunction(stencilFunc: number): void;
  122680. /**
  122681. * Sets the current stencil reference
  122682. * @param reference defines the new stencil reference to use
  122683. */
  122684. setStencilFunctionReference(reference: number): void;
  122685. /**
  122686. * Sets the current stencil mask
  122687. * @param mask defines the new stencil mask to use
  122688. */
  122689. setStencilFunctionMask(mask: number): void;
  122690. /**
  122691. * Gets the current stencil operation when stencil fails
  122692. * @returns a number defining stencil operation to use when stencil fails
  122693. */
  122694. getStencilOperationFail(): number;
  122695. /**
  122696. * Gets the current stencil operation when depth fails
  122697. * @returns a number defining stencil operation to use when depth fails
  122698. */
  122699. getStencilOperationDepthFail(): number;
  122700. /**
  122701. * Gets the current stencil operation when stencil passes
  122702. * @returns a number defining stencil operation to use when stencil passes
  122703. */
  122704. getStencilOperationPass(): number;
  122705. /**
  122706. * Sets the stencil operation to use when stencil fails
  122707. * @param operation defines the stencil operation to use when stencil fails
  122708. */
  122709. setStencilOperationFail(operation: number): void;
  122710. /**
  122711. * Sets the stencil operation to use when depth fails
  122712. * @param operation defines the stencil operation to use when depth fails
  122713. */
  122714. setStencilOperationDepthFail(operation: number): void;
  122715. /**
  122716. * Sets the stencil operation to use when stencil passes
  122717. * @param operation defines the stencil operation to use when stencil passes
  122718. */
  122719. setStencilOperationPass(operation: number): void;
  122720. /**
  122721. * Sets a boolean indicating if the dithering state is enabled or disabled
  122722. * @param value defines the dithering state
  122723. */
  122724. setDitheringState(value: boolean): void;
  122725. /**
  122726. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  122727. * @param value defines the rasterizer state
  122728. */
  122729. setRasterizerState(value: boolean): void;
  122730. /**
  122731. * Gets the current depth function
  122732. * @returns a number defining the depth function
  122733. */
  122734. getDepthFunction(): Nullable<number>;
  122735. /**
  122736. * Sets the current depth function
  122737. * @param depthFunc defines the function to use
  122738. */
  122739. setDepthFunction(depthFunc: number): void;
  122740. /**
  122741. * Sets the current depth function to GREATER
  122742. */
  122743. setDepthFunctionToGreater(): void;
  122744. /**
  122745. * Sets the current depth function to GEQUAL
  122746. */
  122747. setDepthFunctionToGreaterOrEqual(): void;
  122748. /**
  122749. * Sets the current depth function to LESS
  122750. */
  122751. setDepthFunctionToLess(): void;
  122752. /**
  122753. * Sets the current depth function to LEQUAL
  122754. */
  122755. setDepthFunctionToLessOrEqual(): void;
  122756. private _cachedStencilBuffer;
  122757. private _cachedStencilFunction;
  122758. private _cachedStencilMask;
  122759. private _cachedStencilOperationPass;
  122760. private _cachedStencilOperationFail;
  122761. private _cachedStencilOperationDepthFail;
  122762. private _cachedStencilReference;
  122763. /**
  122764. * Caches the the state of the stencil buffer
  122765. */
  122766. cacheStencilState(): void;
  122767. /**
  122768. * Restores the state of the stencil buffer
  122769. */
  122770. restoreStencilState(): void;
  122771. /**
  122772. * Directly set the WebGL Viewport
  122773. * @param x defines the x coordinate of the viewport (in screen space)
  122774. * @param y defines the y coordinate of the viewport (in screen space)
  122775. * @param width defines the width of the viewport (in screen space)
  122776. * @param height defines the height of the viewport (in screen space)
  122777. * @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
  122778. */
  122779. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  122780. /**
  122781. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  122782. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  122783. * @param y defines the y-coordinate of the corner of the clear rectangle
  122784. * @param width defines the width of the clear rectangle
  122785. * @param height defines the height of the clear rectangle
  122786. * @param clearColor defines the clear color
  122787. */
  122788. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  122789. /**
  122790. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  122791. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  122792. * @param y defines the y-coordinate of the corner of the clear rectangle
  122793. * @param width defines the width of the clear rectangle
  122794. * @param height defines the height of the clear rectangle
  122795. */
  122796. enableScissor(x: number, y: number, width: number, height: number): void;
  122797. /**
  122798. * Disable previously set scissor test rectangle
  122799. */
  122800. disableScissor(): void;
  122801. protected _reportDrawCall(): void;
  122802. /**
  122803. * Initializes a webVR display and starts listening to display change events
  122804. * The onVRDisplayChangedObservable will be notified upon these changes
  122805. * @returns The onVRDisplayChangedObservable
  122806. */
  122807. initWebVR(): Observable<IDisplayChangedEventArgs>;
  122808. /** @hidden */
  122809. _prepareVRComponent(): void;
  122810. /** @hidden */
  122811. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  122812. /** @hidden */
  122813. _submitVRFrame(): void;
  122814. /**
  122815. * Call this function to leave webVR mode
  122816. * Will do nothing if webVR is not supported or if there is no webVR device
  122817. * @see https://doc.babylonjs.com/how_to/webvr_camera
  122818. */
  122819. disableVR(): void;
  122820. /**
  122821. * Gets a boolean indicating that the system is in VR mode and is presenting
  122822. * @returns true if VR mode is engaged
  122823. */
  122824. isVRPresenting(): boolean;
  122825. /** @hidden */
  122826. _requestVRFrame(): void;
  122827. /** @hidden */
  122828. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  122829. /**
  122830. * Gets the source code of the vertex shader associated with a specific webGL program
  122831. * @param program defines the program to use
  122832. * @returns a string containing the source code of the vertex shader associated with the program
  122833. */
  122834. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  122835. /**
  122836. * Gets the source code of the fragment shader associated with a specific webGL program
  122837. * @param program defines the program to use
  122838. * @returns a string containing the source code of the fragment shader associated with the program
  122839. */
  122840. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  122841. /**
  122842. * Sets a depth stencil texture from a render target to the according uniform.
  122843. * @param channel The texture channel
  122844. * @param uniform The uniform to set
  122845. * @param texture The render target texture containing the depth stencil texture to apply
  122846. */
  122847. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  122848. /**
  122849. * Sets a texture to the webGL context from a postprocess
  122850. * @param channel defines the channel to use
  122851. * @param postProcess defines the source postprocess
  122852. */
  122853. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  122854. /**
  122855. * Binds the output of the passed in post process to the texture channel specified
  122856. * @param channel The channel the texture should be bound to
  122857. * @param postProcess The post process which's output should be bound
  122858. */
  122859. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  122860. protected _rebuildBuffers(): void;
  122861. /** @hidden */
  122862. _renderFrame(): void;
  122863. _renderLoop(): void;
  122864. /** @hidden */
  122865. _renderViews(): boolean;
  122866. /**
  122867. * Toggle full screen mode
  122868. * @param requestPointerLock defines if a pointer lock should be requested from the user
  122869. */
  122870. switchFullscreen(requestPointerLock: boolean): void;
  122871. /**
  122872. * Enters full screen mode
  122873. * @param requestPointerLock defines if a pointer lock should be requested from the user
  122874. */
  122875. enterFullscreen(requestPointerLock: boolean): void;
  122876. /**
  122877. * Exits full screen mode
  122878. */
  122879. exitFullscreen(): void;
  122880. /**
  122881. * Enters Pointerlock mode
  122882. */
  122883. enterPointerlock(): void;
  122884. /**
  122885. * Exits Pointerlock mode
  122886. */
  122887. exitPointerlock(): void;
  122888. /**
  122889. * Begin a new frame
  122890. */
  122891. beginFrame(): void;
  122892. /**
  122893. * Enf the current frame
  122894. */
  122895. endFrame(): void;
  122896. resize(): void;
  122897. /**
  122898. * Force a specific size of the canvas
  122899. * @param width defines the new canvas' width
  122900. * @param height defines the new canvas' height
  122901. * @returns true if the size was changed
  122902. */
  122903. setSize(width: number, height: number): boolean;
  122904. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  122905. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  122906. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  122907. _releaseTexture(texture: InternalTexture): void;
  122908. /**
  122909. * @hidden
  122910. * Rescales a texture
  122911. * @param source input texutre
  122912. * @param destination destination texture
  122913. * @param scene scene to use to render the resize
  122914. * @param internalFormat format to use when resizing
  122915. * @param onComplete callback to be called when resize has completed
  122916. */
  122917. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  122918. /**
  122919. * Gets the current framerate
  122920. * @returns a number representing the framerate
  122921. */
  122922. getFps(): number;
  122923. /**
  122924. * Gets the time spent between current and previous frame
  122925. * @returns a number representing the delta time in ms
  122926. */
  122927. getDeltaTime(): number;
  122928. private _measureFps;
  122929. /** @hidden */
  122930. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  122931. /**
  122932. * Updates the sample count of a render target texture
  122933. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  122934. * @param texture defines the texture to update
  122935. * @param samples defines the sample count to set
  122936. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  122937. */
  122938. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  122939. /**
  122940. * Updates a depth texture Comparison Mode and Function.
  122941. * If the comparison Function is equal to 0, the mode will be set to none.
  122942. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  122943. * @param texture The texture to set the comparison function for
  122944. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  122945. */
  122946. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  122947. /**
  122948. * Creates a webGL buffer to use with instanciation
  122949. * @param capacity defines the size of the buffer
  122950. * @returns the webGL buffer
  122951. */
  122952. createInstancesBuffer(capacity: number): DataBuffer;
  122953. /**
  122954. * Delete a webGL buffer used with instanciation
  122955. * @param buffer defines the webGL buffer to delete
  122956. */
  122957. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  122958. private _clientWaitAsync;
  122959. /** @hidden */
  122960. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  122961. dispose(): void;
  122962. private _disableTouchAction;
  122963. /**
  122964. * Display the loading screen
  122965. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122966. */
  122967. displayLoadingUI(): void;
  122968. /**
  122969. * Hide the loading screen
  122970. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122971. */
  122972. hideLoadingUI(): void;
  122973. /**
  122974. * Gets the current loading screen object
  122975. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122976. */
  122977. get loadingScreen(): ILoadingScreen;
  122978. /**
  122979. * Sets the current loading screen object
  122980. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122981. */
  122982. set loadingScreen(loadingScreen: ILoadingScreen);
  122983. /**
  122984. * Sets the current loading screen text
  122985. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122986. */
  122987. set loadingUIText(text: string);
  122988. /**
  122989. * Sets the current loading screen background color
  122990. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122991. */
  122992. set loadingUIBackgroundColor(color: string);
  122993. /** Pointerlock and fullscreen */
  122994. /**
  122995. * Ask the browser to promote the current element to pointerlock mode
  122996. * @param element defines the DOM element to promote
  122997. */
  122998. static _RequestPointerlock(element: HTMLElement): void;
  122999. /**
  123000. * Asks the browser to exit pointerlock mode
  123001. */
  123002. static _ExitPointerlock(): void;
  123003. /**
  123004. * Ask the browser to promote the current element to fullscreen rendering mode
  123005. * @param element defines the DOM element to promote
  123006. */
  123007. static _RequestFullscreen(element: HTMLElement): void;
  123008. /**
  123009. * Asks the browser to exit fullscreen mode
  123010. */
  123011. static _ExitFullscreen(): void;
  123012. }
  123013. }
  123014. declare module BABYLON {
  123015. /**
  123016. * The engine store class is responsible to hold all the instances of Engine and Scene created
  123017. * during the life time of the application.
  123018. */
  123019. export class EngineStore {
  123020. /** Gets the list of created engines */
  123021. static Instances: Engine[];
  123022. /** @hidden */
  123023. static _LastCreatedScene: Nullable<Scene>;
  123024. /**
  123025. * Gets the latest created engine
  123026. */
  123027. static get LastCreatedEngine(): Nullable<Engine>;
  123028. /**
  123029. * Gets the latest created scene
  123030. */
  123031. static get LastCreatedScene(): Nullable<Scene>;
  123032. /**
  123033. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  123034. * @ignorenaming
  123035. */
  123036. static UseFallbackTexture: boolean;
  123037. /**
  123038. * Texture content used if a texture cannot loaded
  123039. * @ignorenaming
  123040. */
  123041. static FallbackTexture: string;
  123042. }
  123043. }
  123044. declare module BABYLON {
  123045. /**
  123046. * Helper class that provides a small promise polyfill
  123047. */
  123048. export class PromisePolyfill {
  123049. /**
  123050. * Static function used to check if the polyfill is required
  123051. * If this is the case then the function will inject the polyfill to window.Promise
  123052. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  123053. */
  123054. static Apply(force?: boolean): void;
  123055. }
  123056. }
  123057. declare module BABYLON {
  123058. /**
  123059. * Interface for screenshot methods with describe argument called `size` as object with options
  123060. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  123061. */
  123062. export interface IScreenshotSize {
  123063. /**
  123064. * number in pixels for canvas height
  123065. */
  123066. height?: number;
  123067. /**
  123068. * multiplier allowing render at a higher or lower resolution
  123069. * If value is defined then height and width will be ignored and taken from camera
  123070. */
  123071. precision?: number;
  123072. /**
  123073. * number in pixels for canvas width
  123074. */
  123075. width?: number;
  123076. }
  123077. }
  123078. declare module BABYLON {
  123079. interface IColor4Like {
  123080. r: float;
  123081. g: float;
  123082. b: float;
  123083. a: float;
  123084. }
  123085. /**
  123086. * Class containing a set of static utilities functions
  123087. */
  123088. export class Tools {
  123089. /**
  123090. * Gets or sets the base URL to use to load assets
  123091. */
  123092. static get BaseUrl(): string;
  123093. static set BaseUrl(value: string);
  123094. /**
  123095. * Enable/Disable Custom HTTP Request Headers globally.
  123096. * default = false
  123097. * @see CustomRequestHeaders
  123098. */
  123099. static UseCustomRequestHeaders: boolean;
  123100. /**
  123101. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  123102. * i.e. when loading files, where the server/service expects an Authorization header
  123103. */
  123104. static CustomRequestHeaders: {
  123105. [key: string]: string;
  123106. };
  123107. /**
  123108. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  123109. */
  123110. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  123111. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  123112. /**
  123113. * Default behaviour for cors in the application.
  123114. * It can be a string if the expected behavior is identical in the entire app.
  123115. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  123116. */
  123117. static get CorsBehavior(): string | ((url: string | string[]) => string);
  123118. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  123119. /**
  123120. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  123121. * @ignorenaming
  123122. */
  123123. static get UseFallbackTexture(): boolean;
  123124. static set UseFallbackTexture(value: boolean);
  123125. /**
  123126. * Use this object to register external classes like custom textures or material
  123127. * to allow the laoders to instantiate them
  123128. */
  123129. static get RegisteredExternalClasses(): {
  123130. [key: string]: Object;
  123131. };
  123132. static set RegisteredExternalClasses(classes: {
  123133. [key: string]: Object;
  123134. });
  123135. /**
  123136. * Texture content used if a texture cannot loaded
  123137. * @ignorenaming
  123138. */
  123139. static get fallbackTexture(): string;
  123140. static set fallbackTexture(value: string);
  123141. /**
  123142. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  123143. * @param u defines the coordinate on X axis
  123144. * @param v defines the coordinate on Y axis
  123145. * @param width defines the width of the source data
  123146. * @param height defines the height of the source data
  123147. * @param pixels defines the source byte array
  123148. * @param color defines the output color
  123149. */
  123150. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  123151. /**
  123152. * Interpolates between a and b via alpha
  123153. * @param a The lower value (returned when alpha = 0)
  123154. * @param b The upper value (returned when alpha = 1)
  123155. * @param alpha The interpolation-factor
  123156. * @return The mixed value
  123157. */
  123158. static Mix(a: number, b: number, alpha: number): number;
  123159. /**
  123160. * Tries to instantiate a new object from a given class name
  123161. * @param className defines the class name to instantiate
  123162. * @returns the new object or null if the system was not able to do the instantiation
  123163. */
  123164. static Instantiate(className: string): any;
  123165. /**
  123166. * Provides a slice function that will work even on IE
  123167. * @param data defines the array to slice
  123168. * @param start defines the start of the data (optional)
  123169. * @param end defines the end of the data (optional)
  123170. * @returns the new sliced array
  123171. */
  123172. static Slice<T>(data: T, start?: number, end?: number): T;
  123173. /**
  123174. * Provides a slice function that will work even on IE
  123175. * The difference between this and Slice is that this will force-convert to array
  123176. * @param data defines the array to slice
  123177. * @param start defines the start of the data (optional)
  123178. * @param end defines the end of the data (optional)
  123179. * @returns the new sliced array
  123180. */
  123181. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  123182. /**
  123183. * Polyfill for setImmediate
  123184. * @param action defines the action to execute after the current execution block
  123185. */
  123186. static SetImmediate(action: () => void): void;
  123187. /**
  123188. * Function indicating if a number is an exponent of 2
  123189. * @param value defines the value to test
  123190. * @returns true if the value is an exponent of 2
  123191. */
  123192. static IsExponentOfTwo(value: number): boolean;
  123193. private static _tmpFloatArray;
  123194. /**
  123195. * Returns the nearest 32-bit single precision float representation of a Number
  123196. * @param value A Number. If the parameter is of a different type, it will get converted
  123197. * to a number or to NaN if it cannot be converted
  123198. * @returns number
  123199. */
  123200. static FloatRound(value: number): number;
  123201. /**
  123202. * Extracts the filename from a path
  123203. * @param path defines the path to use
  123204. * @returns the filename
  123205. */
  123206. static GetFilename(path: string): string;
  123207. /**
  123208. * Extracts the "folder" part of a path (everything before the filename).
  123209. * @param uri The URI to extract the info from
  123210. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  123211. * @returns The "folder" part of the path
  123212. */
  123213. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  123214. /**
  123215. * Extracts text content from a DOM element hierarchy
  123216. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  123217. */
  123218. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  123219. /**
  123220. * Convert an angle in radians to degrees
  123221. * @param angle defines the angle to convert
  123222. * @returns the angle in degrees
  123223. */
  123224. static ToDegrees(angle: number): number;
  123225. /**
  123226. * Convert an angle in degrees to radians
  123227. * @param angle defines the angle to convert
  123228. * @returns the angle in radians
  123229. */
  123230. static ToRadians(angle: number): number;
  123231. /**
  123232. * Returns an array if obj is not an array
  123233. * @param obj defines the object to evaluate as an array
  123234. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  123235. * @returns either obj directly if obj is an array or a new array containing obj
  123236. */
  123237. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  123238. /**
  123239. * Gets the pointer prefix to use
  123240. * @param engine defines the engine we are finding the prefix for
  123241. * @returns "pointer" if touch is enabled. Else returns "mouse"
  123242. */
  123243. static GetPointerPrefix(engine: Engine): string;
  123244. /**
  123245. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  123246. * @param url define the url we are trying
  123247. * @param element define the dom element where to configure the cors policy
  123248. */
  123249. static SetCorsBehavior(url: string | string[], element: {
  123250. crossOrigin: string | null;
  123251. }): void;
  123252. /**
  123253. * Removes unwanted characters from an url
  123254. * @param url defines the url to clean
  123255. * @returns the cleaned url
  123256. */
  123257. static CleanUrl(url: string): string;
  123258. /**
  123259. * Gets or sets a function used to pre-process url before using them to load assets
  123260. */
  123261. static get PreprocessUrl(): (url: string) => string;
  123262. static set PreprocessUrl(processor: (url: string) => string);
  123263. /**
  123264. * Loads an image as an HTMLImageElement.
  123265. * @param input url string, ArrayBuffer, or Blob to load
  123266. * @param onLoad callback called when the image successfully loads
  123267. * @param onError callback called when the image fails to load
  123268. * @param offlineProvider offline provider for caching
  123269. * @param mimeType optional mime type
  123270. * @returns the HTMLImageElement of the loaded image
  123271. */
  123272. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  123273. /**
  123274. * Loads a file from a url
  123275. * @param url url string, ArrayBuffer, or Blob to load
  123276. * @param onSuccess callback called when the file successfully loads
  123277. * @param onProgress callback called while file is loading (if the server supports this mode)
  123278. * @param offlineProvider defines the offline provider for caching
  123279. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  123280. * @param onError callback called when the file fails to load
  123281. * @returns a file request object
  123282. */
  123283. 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;
  123284. /**
  123285. * Loads a file from a url
  123286. * @param url the file url to load
  123287. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  123288. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  123289. */
  123290. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  123291. /**
  123292. * Load a script (identified by an url). When the url returns, the
  123293. * content of this file is added into a new script element, attached to the DOM (body element)
  123294. * @param scriptUrl defines the url of the script to laod
  123295. * @param onSuccess defines the callback called when the script is loaded
  123296. * @param onError defines the callback to call if an error occurs
  123297. * @param scriptId defines the id of the script element
  123298. */
  123299. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  123300. /**
  123301. * Load an asynchronous script (identified by an url). When the url returns, the
  123302. * content of this file is added into a new script element, attached to the DOM (body element)
  123303. * @param scriptUrl defines the url of the script to laod
  123304. * @param scriptId defines the id of the script element
  123305. * @returns a promise request object
  123306. */
  123307. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  123308. /**
  123309. * Loads a file from a blob
  123310. * @param fileToLoad defines the blob to use
  123311. * @param callback defines the callback to call when data is loaded
  123312. * @param progressCallback defines the callback to call during loading process
  123313. * @returns a file request object
  123314. */
  123315. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  123316. /**
  123317. * Reads a file from a File object
  123318. * @param file defines the file to load
  123319. * @param onSuccess defines the callback to call when data is loaded
  123320. * @param onProgress defines the callback to call during loading process
  123321. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  123322. * @param onError defines the callback to call when an error occurs
  123323. * @returns a file request object
  123324. */
  123325. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  123326. /**
  123327. * Creates a data url from a given string content
  123328. * @param content defines the content to convert
  123329. * @returns the new data url link
  123330. */
  123331. static FileAsURL(content: string): string;
  123332. /**
  123333. * Format the given number to a specific decimal format
  123334. * @param value defines the number to format
  123335. * @param decimals defines the number of decimals to use
  123336. * @returns the formatted string
  123337. */
  123338. static Format(value: number, decimals?: number): string;
  123339. /**
  123340. * Tries to copy an object by duplicating every property
  123341. * @param source defines the source object
  123342. * @param destination defines the target object
  123343. * @param doNotCopyList defines a list of properties to avoid
  123344. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  123345. */
  123346. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  123347. /**
  123348. * Gets a boolean indicating if the given object has no own property
  123349. * @param obj defines the object to test
  123350. * @returns true if object has no own property
  123351. */
  123352. static IsEmpty(obj: any): boolean;
  123353. /**
  123354. * Function used to register events at window level
  123355. * @param windowElement defines the Window object to use
  123356. * @param events defines the events to register
  123357. */
  123358. static RegisterTopRootEvents(windowElement: Window, events: {
  123359. name: string;
  123360. handler: Nullable<(e: FocusEvent) => any>;
  123361. }[]): void;
  123362. /**
  123363. * Function used to unregister events from window level
  123364. * @param windowElement defines the Window object to use
  123365. * @param events defines the events to unregister
  123366. */
  123367. static UnregisterTopRootEvents(windowElement: Window, events: {
  123368. name: string;
  123369. handler: Nullable<(e: FocusEvent) => any>;
  123370. }[]): void;
  123371. /**
  123372. * @ignore
  123373. */
  123374. static _ScreenshotCanvas: HTMLCanvasElement;
  123375. /**
  123376. * Dumps the current bound framebuffer
  123377. * @param width defines the rendering width
  123378. * @param height defines the rendering height
  123379. * @param engine defines the hosting engine
  123380. * @param successCallback defines the callback triggered once the data are available
  123381. * @param mimeType defines the mime type of the result
  123382. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  123383. */
  123384. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  123385. /**
  123386. * Converts the canvas data to blob.
  123387. * This acts as a polyfill for browsers not supporting the to blob function.
  123388. * @param canvas Defines the canvas to extract the data from
  123389. * @param successCallback Defines the callback triggered once the data are available
  123390. * @param mimeType Defines the mime type of the result
  123391. */
  123392. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  123393. /**
  123394. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  123395. * @param successCallback defines the callback triggered once the data are available
  123396. * @param mimeType defines the mime type of the result
  123397. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  123398. */
  123399. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  123400. /**
  123401. * Downloads a blob in the browser
  123402. * @param blob defines the blob to download
  123403. * @param fileName defines the name of the downloaded file
  123404. */
  123405. static Download(blob: Blob, fileName: string): void;
  123406. /**
  123407. * Will return the right value of the noPreventDefault variable
  123408. * Needed to keep backwards compatibility to the old API.
  123409. *
  123410. * @param args arguments passed to the attachControl function
  123411. * @returns the correct value for noPreventDefault
  123412. */
  123413. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  123414. /**
  123415. * Captures a screenshot of the current rendering
  123416. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123417. * @param engine defines the rendering engine
  123418. * @param camera defines the source camera
  123419. * @param size This parameter can be set to a single number or to an object with the
  123420. * following (optional) properties: precision, width, height. If a single number is passed,
  123421. * it will be used for both width and height. If an object is passed, the screenshot size
  123422. * will be derived from the parameters. The precision property is a multiplier allowing
  123423. * rendering at a higher or lower resolution
  123424. * @param successCallback defines the callback receives a single parameter which contains the
  123425. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  123426. * src parameter of an <img> to display it
  123427. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  123428. * Check your browser for supported MIME types
  123429. */
  123430. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  123431. /**
  123432. * Captures a screenshot of the current rendering
  123433. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123434. * @param engine defines the rendering engine
  123435. * @param camera defines the source camera
  123436. * @param size This parameter can be set to a single number or to an object with the
  123437. * following (optional) properties: precision, width, height. If a single number is passed,
  123438. * it will be used for both width and height. If an object is passed, the screenshot size
  123439. * will be derived from the parameters. The precision property is a multiplier allowing
  123440. * rendering at a higher or lower resolution
  123441. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  123442. * Check your browser for supported MIME types
  123443. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  123444. * to the src parameter of an <img> to display it
  123445. */
  123446. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  123447. /**
  123448. * Generates an image screenshot from the specified camera.
  123449. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123450. * @param engine The engine to use for rendering
  123451. * @param camera The camera to use for rendering
  123452. * @param size This parameter can be set to a single number or to an object with the
  123453. * following (optional) properties: precision, width, height. If a single number is passed,
  123454. * it will be used for both width and height. If an object is passed, the screenshot size
  123455. * will be derived from the parameters. The precision property is a multiplier allowing
  123456. * rendering at a higher or lower resolution
  123457. * @param successCallback The callback receives a single parameter which contains the
  123458. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  123459. * src parameter of an <img> to display it
  123460. * @param mimeType The MIME type of the screenshot image (default: image/png).
  123461. * Check your browser for supported MIME types
  123462. * @param samples Texture samples (default: 1)
  123463. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  123464. * @param fileName A name for for the downloaded file.
  123465. */
  123466. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  123467. /**
  123468. * Generates an image screenshot from the specified camera.
  123469. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123470. * @param engine The engine to use for rendering
  123471. * @param camera The camera to use for rendering
  123472. * @param size This parameter can be set to a single number or to an object with the
  123473. * following (optional) properties: precision, width, height. If a single number is passed,
  123474. * it will be used for both width and height. If an object is passed, the screenshot size
  123475. * will be derived from the parameters. The precision property is a multiplier allowing
  123476. * rendering at a higher or lower resolution
  123477. * @param mimeType The MIME type of the screenshot image (default: image/png).
  123478. * Check your browser for supported MIME types
  123479. * @param samples Texture samples (default: 1)
  123480. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  123481. * @param fileName A name for for the downloaded file.
  123482. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  123483. * to the src parameter of an <img> to display it
  123484. */
  123485. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  123486. /**
  123487. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  123488. * Be aware Math.random() could cause collisions, but:
  123489. * "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"
  123490. * @returns a pseudo random id
  123491. */
  123492. static RandomId(): string;
  123493. /**
  123494. * Test if the given uri is a base64 string
  123495. * @param uri The uri to test
  123496. * @return True if the uri is a base64 string or false otherwise
  123497. */
  123498. static IsBase64(uri: string): boolean;
  123499. /**
  123500. * Decode the given base64 uri.
  123501. * @param uri The uri to decode
  123502. * @return The decoded base64 data.
  123503. */
  123504. static DecodeBase64(uri: string): ArrayBuffer;
  123505. /**
  123506. * Gets the absolute url.
  123507. * @param url the input url
  123508. * @return the absolute url
  123509. */
  123510. static GetAbsoluteUrl(url: string): string;
  123511. /**
  123512. * No log
  123513. */
  123514. static readonly NoneLogLevel: number;
  123515. /**
  123516. * Only message logs
  123517. */
  123518. static readonly MessageLogLevel: number;
  123519. /**
  123520. * Only warning logs
  123521. */
  123522. static readonly WarningLogLevel: number;
  123523. /**
  123524. * Only error logs
  123525. */
  123526. static readonly ErrorLogLevel: number;
  123527. /**
  123528. * All logs
  123529. */
  123530. static readonly AllLogLevel: number;
  123531. /**
  123532. * Gets a value indicating the number of loading errors
  123533. * @ignorenaming
  123534. */
  123535. static get errorsCount(): number;
  123536. /**
  123537. * Callback called when a new log is added
  123538. */
  123539. static OnNewCacheEntry: (entry: string) => void;
  123540. /**
  123541. * Log a message to the console
  123542. * @param message defines the message to log
  123543. */
  123544. static Log(message: string): void;
  123545. /**
  123546. * Write a warning message to the console
  123547. * @param message defines the message to log
  123548. */
  123549. static Warn(message: string): void;
  123550. /**
  123551. * Write an error message to the console
  123552. * @param message defines the message to log
  123553. */
  123554. static Error(message: string): void;
  123555. /**
  123556. * Gets current log cache (list of logs)
  123557. */
  123558. static get LogCache(): string;
  123559. /**
  123560. * Clears the log cache
  123561. */
  123562. static ClearLogCache(): void;
  123563. /**
  123564. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  123565. */
  123566. static set LogLevels(level: number);
  123567. /**
  123568. * Checks if the window object exists
  123569. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  123570. */
  123571. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  123572. /**
  123573. * No performance log
  123574. */
  123575. static readonly PerformanceNoneLogLevel: number;
  123576. /**
  123577. * Use user marks to log performance
  123578. */
  123579. static readonly PerformanceUserMarkLogLevel: number;
  123580. /**
  123581. * Log performance to the console
  123582. */
  123583. static readonly PerformanceConsoleLogLevel: number;
  123584. private static _performance;
  123585. /**
  123586. * Sets the current performance log level
  123587. */
  123588. static set PerformanceLogLevel(level: number);
  123589. private static _StartPerformanceCounterDisabled;
  123590. private static _EndPerformanceCounterDisabled;
  123591. private static _StartUserMark;
  123592. private static _EndUserMark;
  123593. private static _StartPerformanceConsole;
  123594. private static _EndPerformanceConsole;
  123595. /**
  123596. * Starts a performance counter
  123597. */
  123598. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  123599. /**
  123600. * Ends a specific performance coutner
  123601. */
  123602. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  123603. /**
  123604. * Gets either window.performance.now() if supported or Date.now() else
  123605. */
  123606. static get Now(): number;
  123607. /**
  123608. * This method will return the name of the class used to create the instance of the given object.
  123609. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  123610. * @param object the object to get the class name from
  123611. * @param isType defines if the object is actually a type
  123612. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  123613. */
  123614. static GetClassName(object: any, isType?: boolean): string;
  123615. /**
  123616. * Gets the first element of an array satisfying a given predicate
  123617. * @param array defines the array to browse
  123618. * @param predicate defines the predicate to use
  123619. * @returns null if not found or the element
  123620. */
  123621. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  123622. /**
  123623. * This method will return the name of the full name of the class, including its owning module (if any).
  123624. * 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).
  123625. * @param object the object to get the class name from
  123626. * @param isType defines if the object is actually a type
  123627. * @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.
  123628. * @ignorenaming
  123629. */
  123630. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  123631. /**
  123632. * Returns a promise that resolves after the given amount of time.
  123633. * @param delay Number of milliseconds to delay
  123634. * @returns Promise that resolves after the given amount of time
  123635. */
  123636. static DelayAsync(delay: number): Promise<void>;
  123637. /**
  123638. * Utility function to detect if the current user agent is Safari
  123639. * @returns whether or not the current user agent is safari
  123640. */
  123641. static IsSafari(): boolean;
  123642. }
  123643. /**
  123644. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  123645. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  123646. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  123647. * @param name The name of the class, case should be preserved
  123648. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  123649. */
  123650. export function className(name: string, module?: string): (target: Object) => void;
  123651. /**
  123652. * An implementation of a loop for asynchronous functions.
  123653. */
  123654. export class AsyncLoop {
  123655. /**
  123656. * Defines the number of iterations for the loop
  123657. */
  123658. iterations: number;
  123659. /**
  123660. * Defines the current index of the loop.
  123661. */
  123662. index: number;
  123663. private _done;
  123664. private _fn;
  123665. private _successCallback;
  123666. /**
  123667. * Constructor.
  123668. * @param iterations the number of iterations.
  123669. * @param func the function to run each iteration
  123670. * @param successCallback the callback that will be called upon succesful execution
  123671. * @param offset starting offset.
  123672. */
  123673. constructor(
  123674. /**
  123675. * Defines the number of iterations for the loop
  123676. */
  123677. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  123678. /**
  123679. * Execute the next iteration. Must be called after the last iteration was finished.
  123680. */
  123681. executeNext(): void;
  123682. /**
  123683. * Break the loop and run the success callback.
  123684. */
  123685. breakLoop(): void;
  123686. /**
  123687. * Create and run an async loop.
  123688. * @param iterations the number of iterations.
  123689. * @param fn the function to run each iteration
  123690. * @param successCallback the callback that will be called upon succesful execution
  123691. * @param offset starting offset.
  123692. * @returns the created async loop object
  123693. */
  123694. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  123695. /**
  123696. * A for-loop that will run a given number of iterations synchronous and the rest async.
  123697. * @param iterations total number of iterations
  123698. * @param syncedIterations number of synchronous iterations in each async iteration.
  123699. * @param fn the function to call each iteration.
  123700. * @param callback a success call back that will be called when iterating stops.
  123701. * @param breakFunction a break condition (optional)
  123702. * @param timeout timeout settings for the setTimeout function. default - 0.
  123703. * @returns the created async loop object
  123704. */
  123705. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  123706. }
  123707. }
  123708. declare module BABYLON {
  123709. /**
  123710. * This class implement a typical dictionary using a string as key and the generic type T as value.
  123711. * The underlying implementation relies on an associative array to ensure the best performances.
  123712. * The value can be anything including 'null' but except 'undefined'
  123713. */
  123714. export class StringDictionary<T> {
  123715. /**
  123716. * This will clear this dictionary and copy the content from the 'source' one.
  123717. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  123718. * @param source the dictionary to take the content from and copy to this dictionary
  123719. */
  123720. copyFrom(source: StringDictionary<T>): void;
  123721. /**
  123722. * Get a value based from its key
  123723. * @param key the given key to get the matching value from
  123724. * @return the value if found, otherwise undefined is returned
  123725. */
  123726. get(key: string): T | undefined;
  123727. /**
  123728. * Get a value from its key or add it if it doesn't exist.
  123729. * This method will ensure you that a given key/data will be present in the dictionary.
  123730. * @param key the given key to get the matching value from
  123731. * @param factory the factory that will create the value if the key is not present in the dictionary.
  123732. * The factory will only be invoked if there's no data for the given key.
  123733. * @return the value corresponding to the key.
  123734. */
  123735. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  123736. /**
  123737. * Get a value from its key if present in the dictionary otherwise add it
  123738. * @param key the key to get the value from
  123739. * @param val if there's no such key/value pair in the dictionary add it with this value
  123740. * @return the value corresponding to the key
  123741. */
  123742. getOrAdd(key: string, val: T): T;
  123743. /**
  123744. * Check if there's a given key in the dictionary
  123745. * @param key the key to check for
  123746. * @return true if the key is present, false otherwise
  123747. */
  123748. contains(key: string): boolean;
  123749. /**
  123750. * Add a new key and its corresponding value
  123751. * @param key the key to add
  123752. * @param value the value corresponding to the key
  123753. * @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
  123754. */
  123755. add(key: string, value: T): boolean;
  123756. /**
  123757. * Update a specific value associated to a key
  123758. * @param key defines the key to use
  123759. * @param value defines the value to store
  123760. * @returns true if the value was updated (or false if the key was not found)
  123761. */
  123762. set(key: string, value: T): boolean;
  123763. /**
  123764. * Get the element of the given key and remove it from the dictionary
  123765. * @param key defines the key to search
  123766. * @returns the value associated with the key or null if not found
  123767. */
  123768. getAndRemove(key: string): Nullable<T>;
  123769. /**
  123770. * Remove a key/value from the dictionary.
  123771. * @param key the key to remove
  123772. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  123773. */
  123774. remove(key: string): boolean;
  123775. /**
  123776. * Clear the whole content of the dictionary
  123777. */
  123778. clear(): void;
  123779. /**
  123780. * Gets the current count
  123781. */
  123782. get count(): number;
  123783. /**
  123784. * Execute a callback on each key/val of the dictionary.
  123785. * Note that you can remove any element in this dictionary in the callback implementation
  123786. * @param callback the callback to execute on a given key/value pair
  123787. */
  123788. forEach(callback: (key: string, val: T) => void): void;
  123789. /**
  123790. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  123791. * If the callback returns null or undefined the method will iterate to the next key/value pair
  123792. * Note that you can remove any element in this dictionary in the callback implementation
  123793. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  123794. * @returns the first item
  123795. */
  123796. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  123797. private _count;
  123798. private _data;
  123799. }
  123800. }
  123801. declare module BABYLON {
  123802. /** @hidden */
  123803. export interface ICollisionCoordinator {
  123804. createCollider(): Collider;
  123805. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  123806. init(scene: Scene): void;
  123807. }
  123808. /** @hidden */
  123809. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  123810. private _scene;
  123811. private _scaledPosition;
  123812. private _scaledVelocity;
  123813. private _finalPosition;
  123814. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  123815. createCollider(): Collider;
  123816. init(scene: Scene): void;
  123817. private _collideWithWorld;
  123818. }
  123819. }
  123820. declare module BABYLON {
  123821. /**
  123822. * Class used to manage all inputs for the scene.
  123823. */
  123824. export class InputManager {
  123825. /** The distance in pixel that you have to move to prevent some events */
  123826. static DragMovementThreshold: number;
  123827. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  123828. static LongPressDelay: number;
  123829. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  123830. static DoubleClickDelay: number;
  123831. /** If you need to check double click without raising a single click at first click, enable this flag */
  123832. static ExclusiveDoubleClickMode: boolean;
  123833. /** 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. */
  123834. private _alreadyAttached;
  123835. private _alreadyAttachedTo;
  123836. private _wheelEventName;
  123837. private _onPointerMove;
  123838. private _onPointerDown;
  123839. private _onPointerUp;
  123840. private _initClickEvent;
  123841. private _initActionManager;
  123842. private _delayedSimpleClick;
  123843. private _delayedSimpleClickTimeout;
  123844. private _previousDelayedSimpleClickTimeout;
  123845. private _meshPickProceed;
  123846. private _previousButtonPressed;
  123847. private _currentPickResult;
  123848. private _previousPickResult;
  123849. private _totalPointersPressed;
  123850. private _doubleClickOccured;
  123851. private _pointerOverMesh;
  123852. private _pickedDownMesh;
  123853. private _pickedUpMesh;
  123854. private _pointerX;
  123855. private _pointerY;
  123856. private _unTranslatedPointerX;
  123857. private _unTranslatedPointerY;
  123858. private _startingPointerPosition;
  123859. private _previousStartingPointerPosition;
  123860. private _startingPointerTime;
  123861. private _previousStartingPointerTime;
  123862. private _pointerCaptures;
  123863. private _meshUnderPointerId;
  123864. private _onKeyDown;
  123865. private _onKeyUp;
  123866. private _keyboardIsAttached;
  123867. private _onCanvasFocusObserver;
  123868. private _onCanvasBlurObserver;
  123869. private _scene;
  123870. /**
  123871. * Creates a new InputManager
  123872. * @param scene defines the hosting scene
  123873. */
  123874. constructor(scene: Scene);
  123875. /**
  123876. * Gets the mesh that is currently under the pointer
  123877. */
  123878. get meshUnderPointer(): Nullable<AbstractMesh>;
  123879. /**
  123880. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  123881. * @param pointerId the pointer id to use
  123882. * @returns The mesh under this pointer id or null if not found
  123883. */
  123884. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  123885. /**
  123886. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  123887. */
  123888. get unTranslatedPointer(): Vector2;
  123889. /**
  123890. * Gets or sets the current on-screen X position of the pointer
  123891. */
  123892. get pointerX(): number;
  123893. set pointerX(value: number);
  123894. /**
  123895. * Gets or sets the current on-screen Y position of the pointer
  123896. */
  123897. get pointerY(): number;
  123898. set pointerY(value: number);
  123899. private _updatePointerPosition;
  123900. private _processPointerMove;
  123901. private _setRayOnPointerInfo;
  123902. private _checkPrePointerObservable;
  123903. /**
  123904. * Use this method to simulate a pointer move on a mesh
  123905. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123906. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123907. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123908. */
  123909. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  123910. /**
  123911. * Use this method to simulate a pointer down on a mesh
  123912. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123913. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123914. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123915. */
  123916. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  123917. private _processPointerDown;
  123918. /** @hidden */
  123919. _isPointerSwiping(): boolean;
  123920. /**
  123921. * Use this method to simulate a pointer up on a mesh
  123922. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123923. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123924. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123925. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  123926. */
  123927. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  123928. private _processPointerUp;
  123929. /**
  123930. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  123931. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  123932. * @returns true if the pointer was captured
  123933. */
  123934. isPointerCaptured(pointerId?: number): boolean;
  123935. /**
  123936. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  123937. * @param attachUp defines if you want to attach events to pointerup
  123938. * @param attachDown defines if you want to attach events to pointerdown
  123939. * @param attachMove defines if you want to attach events to pointermove
  123940. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  123941. */
  123942. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  123943. /**
  123944. * Detaches all event handlers
  123945. */
  123946. detachControl(): void;
  123947. /**
  123948. * Force the value of meshUnderPointer
  123949. * @param mesh defines the mesh to use
  123950. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  123951. */
  123952. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  123953. /**
  123954. * Gets the mesh under the pointer
  123955. * @returns a Mesh or null if no mesh is under the pointer
  123956. */
  123957. getPointerOverMesh(): Nullable<AbstractMesh>;
  123958. }
  123959. }
  123960. declare module BABYLON {
  123961. /**
  123962. * This class defines the direct association between an animation and a target
  123963. */
  123964. export class TargetedAnimation {
  123965. /**
  123966. * Animation to perform
  123967. */
  123968. animation: Animation;
  123969. /**
  123970. * Target to animate
  123971. */
  123972. target: any;
  123973. /**
  123974. * Returns the string "TargetedAnimation"
  123975. * @returns "TargetedAnimation"
  123976. */
  123977. getClassName(): string;
  123978. /**
  123979. * Serialize the object
  123980. * @returns the JSON object representing the current entity
  123981. */
  123982. serialize(): any;
  123983. }
  123984. /**
  123985. * Use this class to create coordinated animations on multiple targets
  123986. */
  123987. export class AnimationGroup implements IDisposable {
  123988. /** The name of the animation group */
  123989. name: string;
  123990. private _scene;
  123991. private _targetedAnimations;
  123992. private _animatables;
  123993. private _from;
  123994. private _to;
  123995. private _isStarted;
  123996. private _isPaused;
  123997. private _speedRatio;
  123998. private _loopAnimation;
  123999. private _isAdditive;
  124000. /**
  124001. * Gets or sets the unique id of the node
  124002. */
  124003. uniqueId: number;
  124004. /**
  124005. * This observable will notify when one animation have ended
  124006. */
  124007. onAnimationEndObservable: Observable<TargetedAnimation>;
  124008. /**
  124009. * Observer raised when one animation loops
  124010. */
  124011. onAnimationLoopObservable: Observable<TargetedAnimation>;
  124012. /**
  124013. * Observer raised when all animations have looped
  124014. */
  124015. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  124016. /**
  124017. * This observable will notify when all animations have ended.
  124018. */
  124019. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  124020. /**
  124021. * This observable will notify when all animations have paused.
  124022. */
  124023. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  124024. /**
  124025. * This observable will notify when all animations are playing.
  124026. */
  124027. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  124028. /**
  124029. * Gets the first frame
  124030. */
  124031. get from(): number;
  124032. /**
  124033. * Gets the last frame
  124034. */
  124035. get to(): number;
  124036. /**
  124037. * Define if the animations are started
  124038. */
  124039. get isStarted(): boolean;
  124040. /**
  124041. * Gets a value indicating that the current group is playing
  124042. */
  124043. get isPlaying(): boolean;
  124044. /**
  124045. * Gets or sets the speed ratio to use for all animations
  124046. */
  124047. get speedRatio(): number;
  124048. /**
  124049. * Gets or sets the speed ratio to use for all animations
  124050. */
  124051. set speedRatio(value: number);
  124052. /**
  124053. * Gets or sets if all animations should loop or not
  124054. */
  124055. get loopAnimation(): boolean;
  124056. set loopAnimation(value: boolean);
  124057. /**
  124058. * Gets or sets if all animations should be evaluated additively
  124059. */
  124060. get isAdditive(): boolean;
  124061. set isAdditive(value: boolean);
  124062. /**
  124063. * Gets the targeted animations for this animation group
  124064. */
  124065. get targetedAnimations(): Array<TargetedAnimation>;
  124066. /**
  124067. * returning the list of animatables controlled by this animation group.
  124068. */
  124069. get animatables(): Array<Animatable>;
  124070. /**
  124071. * Gets the list of target animations
  124072. */
  124073. get children(): TargetedAnimation[];
  124074. /**
  124075. * Instantiates a new Animation Group.
  124076. * This helps managing several animations at once.
  124077. * @see https://doc.babylonjs.com/how_to/group
  124078. * @param name Defines the name of the group
  124079. * @param scene Defines the scene the group belongs to
  124080. */
  124081. constructor(
  124082. /** The name of the animation group */
  124083. name: string, scene?: Nullable<Scene>);
  124084. /**
  124085. * Add an animation (with its target) in the group
  124086. * @param animation defines the animation we want to add
  124087. * @param target defines the target of the animation
  124088. * @returns the TargetedAnimation object
  124089. */
  124090. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  124091. /**
  124092. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  124093. * It can add constant keys at begin or end
  124094. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  124095. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  124096. * @returns the animation group
  124097. */
  124098. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  124099. private _animationLoopCount;
  124100. private _animationLoopFlags;
  124101. private _processLoop;
  124102. /**
  124103. * Start all animations on given targets
  124104. * @param loop defines if animations must loop
  124105. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  124106. * @param from defines the from key (optional)
  124107. * @param to defines the to key (optional)
  124108. * @param isAdditive defines the additive state for the resulting animatables (optional)
  124109. * @returns the current animation group
  124110. */
  124111. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  124112. /**
  124113. * Pause all animations
  124114. * @returns the animation group
  124115. */
  124116. pause(): AnimationGroup;
  124117. /**
  124118. * Play all animations to initial state
  124119. * This function will start() the animations if they were not started or will restart() them if they were paused
  124120. * @param loop defines if animations must loop
  124121. * @returns the animation group
  124122. */
  124123. play(loop?: boolean): AnimationGroup;
  124124. /**
  124125. * Reset all animations to initial state
  124126. * @returns the animation group
  124127. */
  124128. reset(): AnimationGroup;
  124129. /**
  124130. * Restart animations from key 0
  124131. * @returns the animation group
  124132. */
  124133. restart(): AnimationGroup;
  124134. /**
  124135. * Stop all animations
  124136. * @returns the animation group
  124137. */
  124138. stop(): AnimationGroup;
  124139. /**
  124140. * Set animation weight for all animatables
  124141. * @param weight defines the weight to use
  124142. * @return the animationGroup
  124143. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  124144. */
  124145. setWeightForAllAnimatables(weight: number): AnimationGroup;
  124146. /**
  124147. * Synchronize and normalize all animatables with a source animatable
  124148. * @param root defines the root animatable to synchronize with
  124149. * @return the animationGroup
  124150. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  124151. */
  124152. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  124153. /**
  124154. * Goes to a specific frame in this animation group
  124155. * @param frame the frame number to go to
  124156. * @return the animationGroup
  124157. */
  124158. goToFrame(frame: number): AnimationGroup;
  124159. /**
  124160. * Dispose all associated resources
  124161. */
  124162. dispose(): void;
  124163. private _checkAnimationGroupEnded;
  124164. /**
  124165. * Clone the current animation group and returns a copy
  124166. * @param newName defines the name of the new group
  124167. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  124168. * @returns the new aniamtion group
  124169. */
  124170. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  124171. /**
  124172. * Serializes the animationGroup to an object
  124173. * @returns Serialized object
  124174. */
  124175. serialize(): any;
  124176. /**
  124177. * Returns a new AnimationGroup object parsed from the source provided.
  124178. * @param parsedAnimationGroup defines the source
  124179. * @param scene defines the scene that will receive the animationGroup
  124180. * @returns a new AnimationGroup
  124181. */
  124182. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  124183. /**
  124184. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  124185. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  124186. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  124187. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  124188. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  124189. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  124190. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  124191. */
  124192. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  124193. /**
  124194. * Returns the string "AnimationGroup"
  124195. * @returns "AnimationGroup"
  124196. */
  124197. getClassName(): string;
  124198. /**
  124199. * Creates a detailled string about the object
  124200. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  124201. * @returns a string representing the object
  124202. */
  124203. toString(fullDetails?: boolean): string;
  124204. }
  124205. }
  124206. declare module BABYLON {
  124207. /**
  124208. * Define an interface for all classes that will hold resources
  124209. */
  124210. export interface IDisposable {
  124211. /**
  124212. * Releases all held resources
  124213. */
  124214. dispose(): void;
  124215. }
  124216. /** Interface defining initialization parameters for Scene class */
  124217. export interface SceneOptions {
  124218. /**
  124219. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  124220. * It will improve performance when the number of geometries becomes important.
  124221. */
  124222. useGeometryUniqueIdsMap?: boolean;
  124223. /**
  124224. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  124225. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  124226. */
  124227. useMaterialMeshMap?: boolean;
  124228. /**
  124229. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  124230. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  124231. */
  124232. useClonedMeshMap?: boolean;
  124233. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  124234. virtual?: boolean;
  124235. }
  124236. /**
  124237. * Represents a scene to be rendered by the engine.
  124238. * @see https://doc.babylonjs.com/features/scene
  124239. */
  124240. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  124241. /** The fog is deactivated */
  124242. static readonly FOGMODE_NONE: number;
  124243. /** The fog density is following an exponential function */
  124244. static readonly FOGMODE_EXP: number;
  124245. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  124246. static readonly FOGMODE_EXP2: number;
  124247. /** The fog density is following a linear function. */
  124248. static readonly FOGMODE_LINEAR: number;
  124249. /**
  124250. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  124251. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124252. */
  124253. static MinDeltaTime: number;
  124254. /**
  124255. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  124256. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124257. */
  124258. static MaxDeltaTime: number;
  124259. /**
  124260. * Factory used to create the default material.
  124261. * @param name The name of the material to create
  124262. * @param scene The scene to create the material for
  124263. * @returns The default material
  124264. */
  124265. static DefaultMaterialFactory(scene: Scene): Material;
  124266. /**
  124267. * Factory used to create the a collision coordinator.
  124268. * @returns The collision coordinator
  124269. */
  124270. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  124271. /** @hidden */
  124272. _inputManager: InputManager;
  124273. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  124274. cameraToUseForPointers: Nullable<Camera>;
  124275. /** @hidden */
  124276. readonly _isScene: boolean;
  124277. /** @hidden */
  124278. _blockEntityCollection: boolean;
  124279. /**
  124280. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  124281. */
  124282. autoClear: boolean;
  124283. /**
  124284. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  124285. */
  124286. autoClearDepthAndStencil: boolean;
  124287. /**
  124288. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  124289. */
  124290. clearColor: Color4;
  124291. /**
  124292. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  124293. */
  124294. ambientColor: Color3;
  124295. /**
  124296. * This is use to store the default BRDF lookup for PBR materials in your scene.
  124297. * It should only be one of the following (if not the default embedded one):
  124298. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  124299. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  124300. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  124301. * The material properties need to be setup according to the type of texture in use.
  124302. */
  124303. environmentBRDFTexture: BaseTexture;
  124304. /**
  124305. * Texture used in all pbr material as the reflection texture.
  124306. * As in the majority of the scene they are the same (exception for multi room and so on),
  124307. * this is easier to reference from here than from all the materials.
  124308. */
  124309. get environmentTexture(): Nullable<BaseTexture>;
  124310. /**
  124311. * Texture used in all pbr material as the reflection texture.
  124312. * As in the majority of the scene they are the same (exception for multi room and so on),
  124313. * this is easier to set here than in all the materials.
  124314. */
  124315. set environmentTexture(value: Nullable<BaseTexture>);
  124316. /** @hidden */
  124317. protected _environmentIntensity: number;
  124318. /**
  124319. * Intensity of the environment in all pbr material.
  124320. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  124321. * As in the majority of the scene they are the same (exception for multi room and so on),
  124322. * this is easier to reference from here than from all the materials.
  124323. */
  124324. get environmentIntensity(): number;
  124325. /**
  124326. * Intensity of the environment in all pbr material.
  124327. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  124328. * As in the majority of the scene they are the same (exception for multi room and so on),
  124329. * this is easier to set here than in all the materials.
  124330. */
  124331. set environmentIntensity(value: number);
  124332. /** @hidden */
  124333. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124334. /**
  124335. * Default image processing configuration used either in the rendering
  124336. * Forward main pass or through the imageProcessingPostProcess if present.
  124337. * As in the majority of the scene they are the same (exception for multi camera),
  124338. * this is easier to reference from here than from all the materials and post process.
  124339. *
  124340. * No setter as we it is a shared configuration, you can set the values instead.
  124341. */
  124342. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  124343. private _forceWireframe;
  124344. /**
  124345. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  124346. */
  124347. set forceWireframe(value: boolean);
  124348. get forceWireframe(): boolean;
  124349. private _skipFrustumClipping;
  124350. /**
  124351. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  124352. */
  124353. set skipFrustumClipping(value: boolean);
  124354. get skipFrustumClipping(): boolean;
  124355. private _forcePointsCloud;
  124356. /**
  124357. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  124358. */
  124359. set forcePointsCloud(value: boolean);
  124360. get forcePointsCloud(): boolean;
  124361. /**
  124362. * Gets or sets the active clipplane 1
  124363. */
  124364. clipPlane: Nullable<Plane>;
  124365. /**
  124366. * Gets or sets the active clipplane 2
  124367. */
  124368. clipPlane2: Nullable<Plane>;
  124369. /**
  124370. * Gets or sets the active clipplane 3
  124371. */
  124372. clipPlane3: Nullable<Plane>;
  124373. /**
  124374. * Gets or sets the active clipplane 4
  124375. */
  124376. clipPlane4: Nullable<Plane>;
  124377. /**
  124378. * Gets or sets the active clipplane 5
  124379. */
  124380. clipPlane5: Nullable<Plane>;
  124381. /**
  124382. * Gets or sets the active clipplane 6
  124383. */
  124384. clipPlane6: Nullable<Plane>;
  124385. /**
  124386. * Gets or sets a boolean indicating if animations are enabled
  124387. */
  124388. animationsEnabled: boolean;
  124389. private _animationPropertiesOverride;
  124390. /**
  124391. * Gets or sets the animation properties override
  124392. */
  124393. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  124394. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  124395. /**
  124396. * Gets or sets a boolean indicating if a constant deltatime has to be used
  124397. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  124398. */
  124399. useConstantAnimationDeltaTime: boolean;
  124400. /**
  124401. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  124402. * Please note that it requires to run a ray cast through the scene on every frame
  124403. */
  124404. constantlyUpdateMeshUnderPointer: boolean;
  124405. /**
  124406. * Defines the HTML cursor to use when hovering over interactive elements
  124407. */
  124408. hoverCursor: string;
  124409. /**
  124410. * Defines the HTML default cursor to use (empty by default)
  124411. */
  124412. defaultCursor: string;
  124413. /**
  124414. * Defines whether cursors are handled by the scene.
  124415. */
  124416. doNotHandleCursors: boolean;
  124417. /**
  124418. * This is used to call preventDefault() on pointer down
  124419. * in order to block unwanted artifacts like system double clicks
  124420. */
  124421. preventDefaultOnPointerDown: boolean;
  124422. /**
  124423. * This is used to call preventDefault() on pointer up
  124424. * in order to block unwanted artifacts like system double clicks
  124425. */
  124426. preventDefaultOnPointerUp: boolean;
  124427. /**
  124428. * Gets or sets user defined metadata
  124429. */
  124430. metadata: any;
  124431. /**
  124432. * For internal use only. Please do not use.
  124433. */
  124434. reservedDataStore: any;
  124435. /**
  124436. * Gets the name of the plugin used to load this scene (null by default)
  124437. */
  124438. loadingPluginName: string;
  124439. /**
  124440. * Use this array to add regular expressions used to disable offline support for specific urls
  124441. */
  124442. disableOfflineSupportExceptionRules: RegExp[];
  124443. /**
  124444. * An event triggered when the scene is disposed.
  124445. */
  124446. onDisposeObservable: Observable<Scene>;
  124447. private _onDisposeObserver;
  124448. /** Sets a function to be executed when this scene is disposed. */
  124449. set onDispose(callback: () => void);
  124450. /**
  124451. * An event triggered before rendering the scene (right after animations and physics)
  124452. */
  124453. onBeforeRenderObservable: Observable<Scene>;
  124454. private _onBeforeRenderObserver;
  124455. /** Sets a function to be executed before rendering this scene */
  124456. set beforeRender(callback: Nullable<() => void>);
  124457. /**
  124458. * An event triggered after rendering the scene
  124459. */
  124460. onAfterRenderObservable: Observable<Scene>;
  124461. /**
  124462. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  124463. */
  124464. onAfterRenderCameraObservable: Observable<Camera>;
  124465. private _onAfterRenderObserver;
  124466. /** Sets a function to be executed after rendering this scene */
  124467. set afterRender(callback: Nullable<() => void>);
  124468. /**
  124469. * An event triggered before animating the scene
  124470. */
  124471. onBeforeAnimationsObservable: Observable<Scene>;
  124472. /**
  124473. * An event triggered after animations processing
  124474. */
  124475. onAfterAnimationsObservable: Observable<Scene>;
  124476. /**
  124477. * An event triggered before draw calls are ready to be sent
  124478. */
  124479. onBeforeDrawPhaseObservable: Observable<Scene>;
  124480. /**
  124481. * An event triggered after draw calls have been sent
  124482. */
  124483. onAfterDrawPhaseObservable: Observable<Scene>;
  124484. /**
  124485. * An event triggered when the scene is ready
  124486. */
  124487. onReadyObservable: Observable<Scene>;
  124488. /**
  124489. * An event triggered before rendering a camera
  124490. */
  124491. onBeforeCameraRenderObservable: Observable<Camera>;
  124492. private _onBeforeCameraRenderObserver;
  124493. /** Sets a function to be executed before rendering a camera*/
  124494. set beforeCameraRender(callback: () => void);
  124495. /**
  124496. * An event triggered after rendering a camera
  124497. */
  124498. onAfterCameraRenderObservable: Observable<Camera>;
  124499. private _onAfterCameraRenderObserver;
  124500. /** Sets a function to be executed after rendering a camera*/
  124501. set afterCameraRender(callback: () => void);
  124502. /**
  124503. * An event triggered when active meshes evaluation is about to start
  124504. */
  124505. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  124506. /**
  124507. * An event triggered when active meshes evaluation is done
  124508. */
  124509. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  124510. /**
  124511. * An event triggered when particles rendering is about to start
  124512. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  124513. */
  124514. onBeforeParticlesRenderingObservable: Observable<Scene>;
  124515. /**
  124516. * An event triggered when particles rendering is done
  124517. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  124518. */
  124519. onAfterParticlesRenderingObservable: Observable<Scene>;
  124520. /**
  124521. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  124522. */
  124523. onDataLoadedObservable: Observable<Scene>;
  124524. /**
  124525. * An event triggered when a camera is created
  124526. */
  124527. onNewCameraAddedObservable: Observable<Camera>;
  124528. /**
  124529. * An event triggered when a camera is removed
  124530. */
  124531. onCameraRemovedObservable: Observable<Camera>;
  124532. /**
  124533. * An event triggered when a light is created
  124534. */
  124535. onNewLightAddedObservable: Observable<Light>;
  124536. /**
  124537. * An event triggered when a light is removed
  124538. */
  124539. onLightRemovedObservable: Observable<Light>;
  124540. /**
  124541. * An event triggered when a geometry is created
  124542. */
  124543. onNewGeometryAddedObservable: Observable<Geometry>;
  124544. /**
  124545. * An event triggered when a geometry is removed
  124546. */
  124547. onGeometryRemovedObservable: Observable<Geometry>;
  124548. /**
  124549. * An event triggered when a transform node is created
  124550. */
  124551. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  124552. /**
  124553. * An event triggered when a transform node is removed
  124554. */
  124555. onTransformNodeRemovedObservable: Observable<TransformNode>;
  124556. /**
  124557. * An event triggered when a mesh is created
  124558. */
  124559. onNewMeshAddedObservable: Observable<AbstractMesh>;
  124560. /**
  124561. * An event triggered when a mesh is removed
  124562. */
  124563. onMeshRemovedObservable: Observable<AbstractMesh>;
  124564. /**
  124565. * An event triggered when a skeleton is created
  124566. */
  124567. onNewSkeletonAddedObservable: Observable<Skeleton>;
  124568. /**
  124569. * An event triggered when a skeleton is removed
  124570. */
  124571. onSkeletonRemovedObservable: Observable<Skeleton>;
  124572. /**
  124573. * An event triggered when a material is created
  124574. */
  124575. onNewMaterialAddedObservable: Observable<Material>;
  124576. /**
  124577. * An event triggered when a multi material is created
  124578. */
  124579. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  124580. /**
  124581. * An event triggered when a material is removed
  124582. */
  124583. onMaterialRemovedObservable: Observable<Material>;
  124584. /**
  124585. * An event triggered when a multi material is removed
  124586. */
  124587. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  124588. /**
  124589. * An event triggered when a texture is created
  124590. */
  124591. onNewTextureAddedObservable: Observable<BaseTexture>;
  124592. /**
  124593. * An event triggered when a texture is removed
  124594. */
  124595. onTextureRemovedObservable: Observable<BaseTexture>;
  124596. /**
  124597. * An event triggered when render targets are about to be rendered
  124598. * Can happen multiple times per frame.
  124599. */
  124600. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  124601. /**
  124602. * An event triggered when render targets were rendered.
  124603. * Can happen multiple times per frame.
  124604. */
  124605. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  124606. /**
  124607. * An event triggered before calculating deterministic simulation step
  124608. */
  124609. onBeforeStepObservable: Observable<Scene>;
  124610. /**
  124611. * An event triggered after calculating deterministic simulation step
  124612. */
  124613. onAfterStepObservable: Observable<Scene>;
  124614. /**
  124615. * An event triggered when the activeCamera property is updated
  124616. */
  124617. onActiveCameraChanged: Observable<Scene>;
  124618. /**
  124619. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  124620. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  124621. * 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)
  124622. */
  124623. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  124624. /**
  124625. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  124626. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  124627. * 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)
  124628. */
  124629. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  124630. /**
  124631. * This Observable will when a mesh has been imported into the scene.
  124632. */
  124633. onMeshImportedObservable: Observable<AbstractMesh>;
  124634. /**
  124635. * This Observable will when an animation file has been imported into the scene.
  124636. */
  124637. onAnimationFileImportedObservable: Observable<Scene>;
  124638. /**
  124639. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  124640. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  124641. */
  124642. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  124643. /** @hidden */
  124644. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  124645. /**
  124646. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  124647. */
  124648. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  124649. /**
  124650. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  124651. */
  124652. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  124653. /**
  124654. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  124655. */
  124656. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  124657. /** Callback called when a pointer move is detected */
  124658. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  124659. /** Callback called when a pointer down is detected */
  124660. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  124661. /** Callback called when a pointer up is detected */
  124662. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  124663. /** Callback called when a pointer pick is detected */
  124664. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  124665. /**
  124666. * 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).
  124667. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  124668. */
  124669. onPrePointerObservable: Observable<PointerInfoPre>;
  124670. /**
  124671. * Observable event triggered each time an input event is received from the rendering canvas
  124672. */
  124673. onPointerObservable: Observable<PointerInfo>;
  124674. /**
  124675. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  124676. */
  124677. get unTranslatedPointer(): Vector2;
  124678. /**
  124679. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  124680. */
  124681. static get DragMovementThreshold(): number;
  124682. static set DragMovementThreshold(value: number);
  124683. /**
  124684. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  124685. */
  124686. static get LongPressDelay(): number;
  124687. static set LongPressDelay(value: number);
  124688. /**
  124689. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  124690. */
  124691. static get DoubleClickDelay(): number;
  124692. static set DoubleClickDelay(value: number);
  124693. /** If you need to check double click without raising a single click at first click, enable this flag */
  124694. static get ExclusiveDoubleClickMode(): boolean;
  124695. static set ExclusiveDoubleClickMode(value: boolean);
  124696. /** @hidden */
  124697. _mirroredCameraPosition: Nullable<Vector3>;
  124698. /**
  124699. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  124700. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  124701. */
  124702. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  124703. /**
  124704. * Observable event triggered each time an keyboard event is received from the hosting window
  124705. */
  124706. onKeyboardObservable: Observable<KeyboardInfo>;
  124707. private _useRightHandedSystem;
  124708. /**
  124709. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  124710. */
  124711. set useRightHandedSystem(value: boolean);
  124712. get useRightHandedSystem(): boolean;
  124713. private _timeAccumulator;
  124714. private _currentStepId;
  124715. private _currentInternalStep;
  124716. /**
  124717. * Sets the step Id used by deterministic lock step
  124718. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124719. * @param newStepId defines the step Id
  124720. */
  124721. setStepId(newStepId: number): void;
  124722. /**
  124723. * Gets the step Id used by deterministic lock step
  124724. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124725. * @returns the step Id
  124726. */
  124727. getStepId(): number;
  124728. /**
  124729. * Gets the internal step used by deterministic lock step
  124730. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124731. * @returns the internal step
  124732. */
  124733. getInternalStep(): number;
  124734. private _fogEnabled;
  124735. /**
  124736. * Gets or sets a boolean indicating if fog is enabled on this scene
  124737. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124738. * (Default is true)
  124739. */
  124740. set fogEnabled(value: boolean);
  124741. get fogEnabled(): boolean;
  124742. private _fogMode;
  124743. /**
  124744. * Gets or sets the fog mode to use
  124745. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124746. * | mode | value |
  124747. * | --- | --- |
  124748. * | FOGMODE_NONE | 0 |
  124749. * | FOGMODE_EXP | 1 |
  124750. * | FOGMODE_EXP2 | 2 |
  124751. * | FOGMODE_LINEAR | 3 |
  124752. */
  124753. set fogMode(value: number);
  124754. get fogMode(): number;
  124755. /**
  124756. * Gets or sets the fog color to use
  124757. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124758. * (Default is Color3(0.2, 0.2, 0.3))
  124759. */
  124760. fogColor: Color3;
  124761. /**
  124762. * Gets or sets the fog density to use
  124763. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124764. * (Default is 0.1)
  124765. */
  124766. fogDensity: number;
  124767. /**
  124768. * Gets or sets the fog start distance to use
  124769. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124770. * (Default is 0)
  124771. */
  124772. fogStart: number;
  124773. /**
  124774. * Gets or sets the fog end distance to use
  124775. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124776. * (Default is 1000)
  124777. */
  124778. fogEnd: number;
  124779. /**
  124780. * Flag indicating that the frame buffer binding is handled by another component
  124781. */
  124782. prePass: boolean;
  124783. private _shadowsEnabled;
  124784. /**
  124785. * Gets or sets a boolean indicating if shadows are enabled on this scene
  124786. */
  124787. set shadowsEnabled(value: boolean);
  124788. get shadowsEnabled(): boolean;
  124789. private _lightsEnabled;
  124790. /**
  124791. * Gets or sets a boolean indicating if lights are enabled on this scene
  124792. */
  124793. set lightsEnabled(value: boolean);
  124794. get lightsEnabled(): boolean;
  124795. /** All of the active cameras added to this scene. */
  124796. activeCameras: Camera[];
  124797. /** @hidden */
  124798. _activeCamera: Nullable<Camera>;
  124799. /** Gets or sets the current active camera */
  124800. get activeCamera(): Nullable<Camera>;
  124801. set activeCamera(value: Nullable<Camera>);
  124802. private _defaultMaterial;
  124803. /** The default material used on meshes when no material is affected */
  124804. get defaultMaterial(): Material;
  124805. /** The default material used on meshes when no material is affected */
  124806. set defaultMaterial(value: Material);
  124807. private _texturesEnabled;
  124808. /**
  124809. * Gets or sets a boolean indicating if textures are enabled on this scene
  124810. */
  124811. set texturesEnabled(value: boolean);
  124812. get texturesEnabled(): boolean;
  124813. /**
  124814. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  124815. */
  124816. physicsEnabled: boolean;
  124817. /**
  124818. * Gets or sets a boolean indicating if particles are enabled on this scene
  124819. */
  124820. particlesEnabled: boolean;
  124821. /**
  124822. * Gets or sets a boolean indicating if sprites are enabled on this scene
  124823. */
  124824. spritesEnabled: boolean;
  124825. private _skeletonsEnabled;
  124826. /**
  124827. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  124828. */
  124829. set skeletonsEnabled(value: boolean);
  124830. get skeletonsEnabled(): boolean;
  124831. /**
  124832. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  124833. */
  124834. lensFlaresEnabled: boolean;
  124835. /**
  124836. * Gets or sets a boolean indicating if collisions are enabled on this scene
  124837. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  124838. */
  124839. collisionsEnabled: boolean;
  124840. private _collisionCoordinator;
  124841. /** @hidden */
  124842. get collisionCoordinator(): ICollisionCoordinator;
  124843. /**
  124844. * Defines the gravity applied to this scene (used only for collisions)
  124845. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  124846. */
  124847. gravity: Vector3;
  124848. /**
  124849. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  124850. */
  124851. postProcessesEnabled: boolean;
  124852. /**
  124853. * Gets the current postprocess manager
  124854. */
  124855. postProcessManager: PostProcessManager;
  124856. /**
  124857. * Gets or sets a boolean indicating if render targets are enabled on this scene
  124858. */
  124859. renderTargetsEnabled: boolean;
  124860. /**
  124861. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  124862. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  124863. */
  124864. dumpNextRenderTargets: boolean;
  124865. /**
  124866. * The list of user defined render targets added to the scene
  124867. */
  124868. customRenderTargets: RenderTargetTexture[];
  124869. /**
  124870. * Defines if texture loading must be delayed
  124871. * If true, textures will only be loaded when they need to be rendered
  124872. */
  124873. useDelayedTextureLoading: boolean;
  124874. /**
  124875. * Gets the list of meshes imported to the scene through SceneLoader
  124876. */
  124877. importedMeshesFiles: String[];
  124878. /**
  124879. * Gets or sets a boolean indicating if probes are enabled on this scene
  124880. */
  124881. probesEnabled: boolean;
  124882. /**
  124883. * Gets or sets the current offline provider to use to store scene data
  124884. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  124885. */
  124886. offlineProvider: IOfflineProvider;
  124887. /**
  124888. * Gets or sets the action manager associated with the scene
  124889. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  124890. */
  124891. actionManager: AbstractActionManager;
  124892. private _meshesForIntersections;
  124893. /**
  124894. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  124895. */
  124896. proceduralTexturesEnabled: boolean;
  124897. private _engine;
  124898. private _totalVertices;
  124899. /** @hidden */
  124900. _activeIndices: PerfCounter;
  124901. /** @hidden */
  124902. _activeParticles: PerfCounter;
  124903. /** @hidden */
  124904. _activeBones: PerfCounter;
  124905. private _animationRatio;
  124906. /** @hidden */
  124907. _animationTimeLast: number;
  124908. /** @hidden */
  124909. _animationTime: number;
  124910. /**
  124911. * Gets or sets a general scale for animation speed
  124912. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  124913. */
  124914. animationTimeScale: number;
  124915. /** @hidden */
  124916. _cachedMaterial: Nullable<Material>;
  124917. /** @hidden */
  124918. _cachedEffect: Nullable<Effect>;
  124919. /** @hidden */
  124920. _cachedVisibility: Nullable<number>;
  124921. private _renderId;
  124922. private _frameId;
  124923. private _executeWhenReadyTimeoutId;
  124924. private _intermediateRendering;
  124925. private _viewUpdateFlag;
  124926. private _projectionUpdateFlag;
  124927. /** @hidden */
  124928. _toBeDisposed: Nullable<IDisposable>[];
  124929. private _activeRequests;
  124930. /** @hidden */
  124931. _pendingData: any[];
  124932. private _isDisposed;
  124933. /**
  124934. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  124935. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  124936. */
  124937. dispatchAllSubMeshesOfActiveMeshes: boolean;
  124938. private _activeMeshes;
  124939. private _processedMaterials;
  124940. private _renderTargets;
  124941. /** @hidden */
  124942. _activeParticleSystems: SmartArray<IParticleSystem>;
  124943. private _activeSkeletons;
  124944. private _softwareSkinnedMeshes;
  124945. private _renderingManager;
  124946. /** @hidden */
  124947. _activeAnimatables: Animatable[];
  124948. private _transformMatrix;
  124949. private _sceneUbo;
  124950. /** @hidden */
  124951. _viewMatrix: Matrix;
  124952. private _projectionMatrix;
  124953. /** @hidden */
  124954. _forcedViewPosition: Nullable<Vector3>;
  124955. /** @hidden */
  124956. _frustumPlanes: Plane[];
  124957. /**
  124958. * Gets the list of frustum planes (built from the active camera)
  124959. */
  124960. get frustumPlanes(): Plane[];
  124961. /**
  124962. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  124963. * This is useful if there are more lights that the maximum simulteanous authorized
  124964. */
  124965. requireLightSorting: boolean;
  124966. /** @hidden */
  124967. readonly useMaterialMeshMap: boolean;
  124968. /** @hidden */
  124969. readonly useClonedMeshMap: boolean;
  124970. private _externalData;
  124971. private _uid;
  124972. /**
  124973. * @hidden
  124974. * Backing store of defined scene components.
  124975. */
  124976. _components: ISceneComponent[];
  124977. /**
  124978. * @hidden
  124979. * Backing store of defined scene components.
  124980. */
  124981. _serializableComponents: ISceneSerializableComponent[];
  124982. /**
  124983. * List of components to register on the next registration step.
  124984. */
  124985. private _transientComponents;
  124986. /**
  124987. * Registers the transient components if needed.
  124988. */
  124989. private _registerTransientComponents;
  124990. /**
  124991. * @hidden
  124992. * Add a component to the scene.
  124993. * Note that the ccomponent could be registered on th next frame if this is called after
  124994. * the register component stage.
  124995. * @param component Defines the component to add to the scene
  124996. */
  124997. _addComponent(component: ISceneComponent): void;
  124998. /**
  124999. * @hidden
  125000. * Gets a component from the scene.
  125001. * @param name defines the name of the component to retrieve
  125002. * @returns the component or null if not present
  125003. */
  125004. _getComponent(name: string): Nullable<ISceneComponent>;
  125005. /**
  125006. * @hidden
  125007. * Defines the actions happening before camera updates.
  125008. */
  125009. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  125010. /**
  125011. * @hidden
  125012. * Defines the actions happening before clear the canvas.
  125013. */
  125014. _beforeClearStage: Stage<SimpleStageAction>;
  125015. /**
  125016. * @hidden
  125017. * Defines the actions when collecting render targets for the frame.
  125018. */
  125019. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  125020. /**
  125021. * @hidden
  125022. * Defines the actions happening for one camera in the frame.
  125023. */
  125024. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  125025. /**
  125026. * @hidden
  125027. * Defines the actions happening during the per mesh ready checks.
  125028. */
  125029. _isReadyForMeshStage: Stage<MeshStageAction>;
  125030. /**
  125031. * @hidden
  125032. * Defines the actions happening before evaluate active mesh checks.
  125033. */
  125034. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  125035. /**
  125036. * @hidden
  125037. * Defines the actions happening during the evaluate sub mesh checks.
  125038. */
  125039. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  125040. /**
  125041. * @hidden
  125042. * Defines the actions happening during the active mesh stage.
  125043. */
  125044. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  125045. /**
  125046. * @hidden
  125047. * Defines the actions happening during the per camera render target step.
  125048. */
  125049. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  125050. /**
  125051. * @hidden
  125052. * Defines the actions happening just before the active camera is drawing.
  125053. */
  125054. _beforeCameraDrawStage: Stage<CameraStageAction>;
  125055. /**
  125056. * @hidden
  125057. * Defines the actions happening just before a render target is drawing.
  125058. */
  125059. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  125060. /**
  125061. * @hidden
  125062. * Defines the actions happening just before a rendering group is drawing.
  125063. */
  125064. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  125065. /**
  125066. * @hidden
  125067. * Defines the actions happening just before a mesh is drawing.
  125068. */
  125069. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  125070. /**
  125071. * @hidden
  125072. * Defines the actions happening just after a mesh has been drawn.
  125073. */
  125074. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  125075. /**
  125076. * @hidden
  125077. * Defines the actions happening just after a rendering group has been drawn.
  125078. */
  125079. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  125080. /**
  125081. * @hidden
  125082. * Defines the actions happening just after the active camera has been drawn.
  125083. */
  125084. _afterCameraDrawStage: Stage<CameraStageAction>;
  125085. /**
  125086. * @hidden
  125087. * Defines the actions happening just after a render target has been drawn.
  125088. */
  125089. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  125090. /**
  125091. * @hidden
  125092. * Defines the actions happening just after rendering all cameras and computing intersections.
  125093. */
  125094. _afterRenderStage: Stage<SimpleStageAction>;
  125095. /**
  125096. * @hidden
  125097. * Defines the actions happening when a pointer move event happens.
  125098. */
  125099. _pointerMoveStage: Stage<PointerMoveStageAction>;
  125100. /**
  125101. * @hidden
  125102. * Defines the actions happening when a pointer down event happens.
  125103. */
  125104. _pointerDownStage: Stage<PointerUpDownStageAction>;
  125105. /**
  125106. * @hidden
  125107. * Defines the actions happening when a pointer up event happens.
  125108. */
  125109. _pointerUpStage: Stage<PointerUpDownStageAction>;
  125110. /**
  125111. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  125112. */
  125113. private geometriesByUniqueId;
  125114. /**
  125115. * Creates a new Scene
  125116. * @param engine defines the engine to use to render this scene
  125117. * @param options defines the scene options
  125118. */
  125119. constructor(engine: Engine, options?: SceneOptions);
  125120. /**
  125121. * Gets a string identifying the name of the class
  125122. * @returns "Scene" string
  125123. */
  125124. getClassName(): string;
  125125. private _defaultMeshCandidates;
  125126. /**
  125127. * @hidden
  125128. */
  125129. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  125130. private _defaultSubMeshCandidates;
  125131. /**
  125132. * @hidden
  125133. */
  125134. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  125135. /**
  125136. * Sets the default candidate providers for the scene.
  125137. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  125138. * and getCollidingSubMeshCandidates to their default function
  125139. */
  125140. setDefaultCandidateProviders(): void;
  125141. /**
  125142. * Gets the mesh that is currently under the pointer
  125143. */
  125144. get meshUnderPointer(): Nullable<AbstractMesh>;
  125145. /**
  125146. * Gets or sets the current on-screen X position of the pointer
  125147. */
  125148. get pointerX(): number;
  125149. set pointerX(value: number);
  125150. /**
  125151. * Gets or sets the current on-screen Y position of the pointer
  125152. */
  125153. get pointerY(): number;
  125154. set pointerY(value: number);
  125155. /**
  125156. * Gets the cached material (ie. the latest rendered one)
  125157. * @returns the cached material
  125158. */
  125159. getCachedMaterial(): Nullable<Material>;
  125160. /**
  125161. * Gets the cached effect (ie. the latest rendered one)
  125162. * @returns the cached effect
  125163. */
  125164. getCachedEffect(): Nullable<Effect>;
  125165. /**
  125166. * Gets the cached visibility state (ie. the latest rendered one)
  125167. * @returns the cached visibility state
  125168. */
  125169. getCachedVisibility(): Nullable<number>;
  125170. /**
  125171. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  125172. * @param material defines the current material
  125173. * @param effect defines the current effect
  125174. * @param visibility defines the current visibility state
  125175. * @returns true if one parameter is not cached
  125176. */
  125177. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  125178. /**
  125179. * Gets the engine associated with the scene
  125180. * @returns an Engine
  125181. */
  125182. getEngine(): Engine;
  125183. /**
  125184. * Gets the total number of vertices rendered per frame
  125185. * @returns the total number of vertices rendered per frame
  125186. */
  125187. getTotalVertices(): number;
  125188. /**
  125189. * Gets the performance counter for total vertices
  125190. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  125191. */
  125192. get totalVerticesPerfCounter(): PerfCounter;
  125193. /**
  125194. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  125195. * @returns the total number of active indices rendered per frame
  125196. */
  125197. getActiveIndices(): number;
  125198. /**
  125199. * Gets the performance counter for active indices
  125200. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  125201. */
  125202. get totalActiveIndicesPerfCounter(): PerfCounter;
  125203. /**
  125204. * Gets the total number of active particles rendered per frame
  125205. * @returns the total number of active particles rendered per frame
  125206. */
  125207. getActiveParticles(): number;
  125208. /**
  125209. * Gets the performance counter for active particles
  125210. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  125211. */
  125212. get activeParticlesPerfCounter(): PerfCounter;
  125213. /**
  125214. * Gets the total number of active bones rendered per frame
  125215. * @returns the total number of active bones rendered per frame
  125216. */
  125217. getActiveBones(): number;
  125218. /**
  125219. * Gets the performance counter for active bones
  125220. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  125221. */
  125222. get activeBonesPerfCounter(): PerfCounter;
  125223. /**
  125224. * Gets the array of active meshes
  125225. * @returns an array of AbstractMesh
  125226. */
  125227. getActiveMeshes(): SmartArray<AbstractMesh>;
  125228. /**
  125229. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  125230. * @returns a number
  125231. */
  125232. getAnimationRatio(): number;
  125233. /**
  125234. * Gets an unique Id for the current render phase
  125235. * @returns a number
  125236. */
  125237. getRenderId(): number;
  125238. /**
  125239. * Gets an unique Id for the current frame
  125240. * @returns a number
  125241. */
  125242. getFrameId(): number;
  125243. /** Call this function if you want to manually increment the render Id*/
  125244. incrementRenderId(): void;
  125245. private _createUbo;
  125246. /**
  125247. * Use this method to simulate a pointer move on a mesh
  125248. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  125249. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  125250. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  125251. * @returns the current scene
  125252. */
  125253. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  125254. /**
  125255. * Use this method to simulate a pointer down on a mesh
  125256. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  125257. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  125258. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  125259. * @returns the current scene
  125260. */
  125261. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  125262. /**
  125263. * Use this method to simulate a pointer up on a mesh
  125264. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  125265. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  125266. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  125267. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  125268. * @returns the current scene
  125269. */
  125270. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  125271. /**
  125272. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  125273. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  125274. * @returns true if the pointer was captured
  125275. */
  125276. isPointerCaptured(pointerId?: number): boolean;
  125277. /**
  125278. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  125279. * @param attachUp defines if you want to attach events to pointerup
  125280. * @param attachDown defines if you want to attach events to pointerdown
  125281. * @param attachMove defines if you want to attach events to pointermove
  125282. */
  125283. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  125284. /** Detaches all event handlers*/
  125285. detachControl(): void;
  125286. /**
  125287. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  125288. * Delay loaded resources are not taking in account
  125289. * @return true if all required resources are ready
  125290. */
  125291. isReady(): boolean;
  125292. /** Resets all cached information relative to material (including effect and visibility) */
  125293. resetCachedMaterial(): void;
  125294. /**
  125295. * Registers a function to be called before every frame render
  125296. * @param func defines the function to register
  125297. */
  125298. registerBeforeRender(func: () => void): void;
  125299. /**
  125300. * Unregisters a function called before every frame render
  125301. * @param func defines the function to unregister
  125302. */
  125303. unregisterBeforeRender(func: () => void): void;
  125304. /**
  125305. * Registers a function to be called after every frame render
  125306. * @param func defines the function to register
  125307. */
  125308. registerAfterRender(func: () => void): void;
  125309. /**
  125310. * Unregisters a function called after every frame render
  125311. * @param func defines the function to unregister
  125312. */
  125313. unregisterAfterRender(func: () => void): void;
  125314. private _executeOnceBeforeRender;
  125315. /**
  125316. * The provided function will run before render once and will be disposed afterwards.
  125317. * A timeout delay can be provided so that the function will be executed in N ms.
  125318. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  125319. * @param func The function to be executed.
  125320. * @param timeout optional delay in ms
  125321. */
  125322. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  125323. /** @hidden */
  125324. _addPendingData(data: any): void;
  125325. /** @hidden */
  125326. _removePendingData(data: any): void;
  125327. /**
  125328. * Returns the number of items waiting to be loaded
  125329. * @returns the number of items waiting to be loaded
  125330. */
  125331. getWaitingItemsCount(): number;
  125332. /**
  125333. * Returns a boolean indicating if the scene is still loading data
  125334. */
  125335. get isLoading(): boolean;
  125336. /**
  125337. * Registers a function to be executed when the scene is ready
  125338. * @param {Function} func - the function to be executed
  125339. */
  125340. executeWhenReady(func: () => void): void;
  125341. /**
  125342. * Returns a promise that resolves when the scene is ready
  125343. * @returns A promise that resolves when the scene is ready
  125344. */
  125345. whenReadyAsync(): Promise<void>;
  125346. /** @hidden */
  125347. _checkIsReady(): void;
  125348. /**
  125349. * Gets all animatable attached to the scene
  125350. */
  125351. get animatables(): Animatable[];
  125352. /**
  125353. * Resets the last animation time frame.
  125354. * Useful to override when animations start running when loading a scene for the first time.
  125355. */
  125356. resetLastAnimationTimeFrame(): void;
  125357. /**
  125358. * Gets the current view matrix
  125359. * @returns a Matrix
  125360. */
  125361. getViewMatrix(): Matrix;
  125362. /**
  125363. * Gets the current projection matrix
  125364. * @returns a Matrix
  125365. */
  125366. getProjectionMatrix(): Matrix;
  125367. /**
  125368. * Gets the current transform matrix
  125369. * @returns a Matrix made of View * Projection
  125370. */
  125371. getTransformMatrix(): Matrix;
  125372. /**
  125373. * Sets the current transform matrix
  125374. * @param viewL defines the View matrix to use
  125375. * @param projectionL defines the Projection matrix to use
  125376. * @param viewR defines the right View matrix to use (if provided)
  125377. * @param projectionR defines the right Projection matrix to use (if provided)
  125378. */
  125379. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  125380. /**
  125381. * Gets the uniform buffer used to store scene data
  125382. * @returns a UniformBuffer
  125383. */
  125384. getSceneUniformBuffer(): UniformBuffer;
  125385. /**
  125386. * Gets an unique (relatively to the current scene) Id
  125387. * @returns an unique number for the scene
  125388. */
  125389. getUniqueId(): number;
  125390. /**
  125391. * Add a mesh to the list of scene's meshes
  125392. * @param newMesh defines the mesh to add
  125393. * @param recursive if all child meshes should also be added to the scene
  125394. */
  125395. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  125396. /**
  125397. * Remove a mesh for the list of scene's meshes
  125398. * @param toRemove defines the mesh to remove
  125399. * @param recursive if all child meshes should also be removed from the scene
  125400. * @returns the index where the mesh was in the mesh list
  125401. */
  125402. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  125403. /**
  125404. * Add a transform node to the list of scene's transform nodes
  125405. * @param newTransformNode defines the transform node to add
  125406. */
  125407. addTransformNode(newTransformNode: TransformNode): void;
  125408. /**
  125409. * Remove a transform node for the list of scene's transform nodes
  125410. * @param toRemove defines the transform node to remove
  125411. * @returns the index where the transform node was in the transform node list
  125412. */
  125413. removeTransformNode(toRemove: TransformNode): number;
  125414. /**
  125415. * Remove a skeleton for the list of scene's skeletons
  125416. * @param toRemove defines the skeleton to remove
  125417. * @returns the index where the skeleton was in the skeleton list
  125418. */
  125419. removeSkeleton(toRemove: Skeleton): number;
  125420. /**
  125421. * Remove a morph target for the list of scene's morph targets
  125422. * @param toRemove defines the morph target to remove
  125423. * @returns the index where the morph target was in the morph target list
  125424. */
  125425. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  125426. /**
  125427. * Remove a light for the list of scene's lights
  125428. * @param toRemove defines the light to remove
  125429. * @returns the index where the light was in the light list
  125430. */
  125431. removeLight(toRemove: Light): number;
  125432. /**
  125433. * Remove a camera for the list of scene's cameras
  125434. * @param toRemove defines the camera to remove
  125435. * @returns the index where the camera was in the camera list
  125436. */
  125437. removeCamera(toRemove: Camera): number;
  125438. /**
  125439. * Remove a particle system for the list of scene's particle systems
  125440. * @param toRemove defines the particle system to remove
  125441. * @returns the index where the particle system was in the particle system list
  125442. */
  125443. removeParticleSystem(toRemove: IParticleSystem): number;
  125444. /**
  125445. * Remove a animation for the list of scene's animations
  125446. * @param toRemove defines the animation to remove
  125447. * @returns the index where the animation was in the animation list
  125448. */
  125449. removeAnimation(toRemove: Animation): number;
  125450. /**
  125451. * Will stop the animation of the given target
  125452. * @param target - the target
  125453. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  125454. * @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)
  125455. */
  125456. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  125457. /**
  125458. * Removes the given animation group from this scene.
  125459. * @param toRemove The animation group to remove
  125460. * @returns The index of the removed animation group
  125461. */
  125462. removeAnimationGroup(toRemove: AnimationGroup): number;
  125463. /**
  125464. * Removes the given multi-material from this scene.
  125465. * @param toRemove The multi-material to remove
  125466. * @returns The index of the removed multi-material
  125467. */
  125468. removeMultiMaterial(toRemove: MultiMaterial): number;
  125469. /**
  125470. * Removes the given material from this scene.
  125471. * @param toRemove The material to remove
  125472. * @returns The index of the removed material
  125473. */
  125474. removeMaterial(toRemove: Material): number;
  125475. /**
  125476. * Removes the given action manager from this scene.
  125477. * @param toRemove The action manager to remove
  125478. * @returns The index of the removed action manager
  125479. */
  125480. removeActionManager(toRemove: AbstractActionManager): number;
  125481. /**
  125482. * Removes the given texture from this scene.
  125483. * @param toRemove The texture to remove
  125484. * @returns The index of the removed texture
  125485. */
  125486. removeTexture(toRemove: BaseTexture): number;
  125487. /**
  125488. * Adds the given light to this scene
  125489. * @param newLight The light to add
  125490. */
  125491. addLight(newLight: Light): void;
  125492. /**
  125493. * Sorts the list list based on light priorities
  125494. */
  125495. sortLightsByPriority(): void;
  125496. /**
  125497. * Adds the given camera to this scene
  125498. * @param newCamera The camera to add
  125499. */
  125500. addCamera(newCamera: Camera): void;
  125501. /**
  125502. * Adds the given skeleton to this scene
  125503. * @param newSkeleton The skeleton to add
  125504. */
  125505. addSkeleton(newSkeleton: Skeleton): void;
  125506. /**
  125507. * Adds the given particle system to this scene
  125508. * @param newParticleSystem The particle system to add
  125509. */
  125510. addParticleSystem(newParticleSystem: IParticleSystem): void;
  125511. /**
  125512. * Adds the given animation to this scene
  125513. * @param newAnimation The animation to add
  125514. */
  125515. addAnimation(newAnimation: Animation): void;
  125516. /**
  125517. * Adds the given animation group to this scene.
  125518. * @param newAnimationGroup The animation group to add
  125519. */
  125520. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  125521. /**
  125522. * Adds the given multi-material to this scene
  125523. * @param newMultiMaterial The multi-material to add
  125524. */
  125525. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  125526. /**
  125527. * Adds the given material to this scene
  125528. * @param newMaterial The material to add
  125529. */
  125530. addMaterial(newMaterial: Material): void;
  125531. /**
  125532. * Adds the given morph target to this scene
  125533. * @param newMorphTargetManager The morph target to add
  125534. */
  125535. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  125536. /**
  125537. * Adds the given geometry to this scene
  125538. * @param newGeometry The geometry to add
  125539. */
  125540. addGeometry(newGeometry: Geometry): void;
  125541. /**
  125542. * Adds the given action manager to this scene
  125543. * @param newActionManager The action manager to add
  125544. */
  125545. addActionManager(newActionManager: AbstractActionManager): void;
  125546. /**
  125547. * Adds the given texture to this scene.
  125548. * @param newTexture The texture to add
  125549. */
  125550. addTexture(newTexture: BaseTexture): void;
  125551. /**
  125552. * Switch active camera
  125553. * @param newCamera defines the new active camera
  125554. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  125555. */
  125556. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  125557. /**
  125558. * sets the active camera of the scene using its ID
  125559. * @param id defines the camera's ID
  125560. * @return the new active camera or null if none found.
  125561. */
  125562. setActiveCameraByID(id: string): Nullable<Camera>;
  125563. /**
  125564. * sets the active camera of the scene using its name
  125565. * @param name defines the camera's name
  125566. * @returns the new active camera or null if none found.
  125567. */
  125568. setActiveCameraByName(name: string): Nullable<Camera>;
  125569. /**
  125570. * get an animation group using its name
  125571. * @param name defines the material's name
  125572. * @return the animation group or null if none found.
  125573. */
  125574. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  125575. /**
  125576. * Get a material using its unique id
  125577. * @param uniqueId defines the material's unique id
  125578. * @return the material or null if none found.
  125579. */
  125580. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  125581. /**
  125582. * get a material using its id
  125583. * @param id defines the material's ID
  125584. * @return the material or null if none found.
  125585. */
  125586. getMaterialByID(id: string): Nullable<Material>;
  125587. /**
  125588. * Gets a the last added material using a given id
  125589. * @param id defines the material's ID
  125590. * @return the last material with the given id or null if none found.
  125591. */
  125592. getLastMaterialByID(id: string): Nullable<Material>;
  125593. /**
  125594. * Gets a material using its name
  125595. * @param name defines the material's name
  125596. * @return the material or null if none found.
  125597. */
  125598. getMaterialByName(name: string): Nullable<Material>;
  125599. /**
  125600. * Get a texture using its unique id
  125601. * @param uniqueId defines the texture's unique id
  125602. * @return the texture or null if none found.
  125603. */
  125604. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  125605. /**
  125606. * Gets a camera using its id
  125607. * @param id defines the id to look for
  125608. * @returns the camera or null if not found
  125609. */
  125610. getCameraByID(id: string): Nullable<Camera>;
  125611. /**
  125612. * Gets a camera using its unique id
  125613. * @param uniqueId defines the unique id to look for
  125614. * @returns the camera or null if not found
  125615. */
  125616. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  125617. /**
  125618. * Gets a camera using its name
  125619. * @param name defines the camera's name
  125620. * @return the camera or null if none found.
  125621. */
  125622. getCameraByName(name: string): Nullable<Camera>;
  125623. /**
  125624. * Gets a bone using its id
  125625. * @param id defines the bone's id
  125626. * @return the bone or null if not found
  125627. */
  125628. getBoneByID(id: string): Nullable<Bone>;
  125629. /**
  125630. * Gets a bone using its id
  125631. * @param name defines the bone's name
  125632. * @return the bone or null if not found
  125633. */
  125634. getBoneByName(name: string): Nullable<Bone>;
  125635. /**
  125636. * Gets a light node using its name
  125637. * @param name defines the the light's name
  125638. * @return the light or null if none found.
  125639. */
  125640. getLightByName(name: string): Nullable<Light>;
  125641. /**
  125642. * Gets a light node using its id
  125643. * @param id defines the light's id
  125644. * @return the light or null if none found.
  125645. */
  125646. getLightByID(id: string): Nullable<Light>;
  125647. /**
  125648. * Gets a light node using its scene-generated unique ID
  125649. * @param uniqueId defines the light's unique id
  125650. * @return the light or null if none found.
  125651. */
  125652. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  125653. /**
  125654. * Gets a particle system by id
  125655. * @param id defines the particle system id
  125656. * @return the corresponding system or null if none found
  125657. */
  125658. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  125659. /**
  125660. * Gets a geometry using its ID
  125661. * @param id defines the geometry's id
  125662. * @return the geometry or null if none found.
  125663. */
  125664. getGeometryByID(id: string): Nullable<Geometry>;
  125665. private _getGeometryByUniqueID;
  125666. /**
  125667. * Add a new geometry to this scene
  125668. * @param geometry defines the geometry to be added to the scene.
  125669. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  125670. * @return a boolean defining if the geometry was added or not
  125671. */
  125672. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  125673. /**
  125674. * Removes an existing geometry
  125675. * @param geometry defines the geometry to be removed from the scene
  125676. * @return a boolean defining if the geometry was removed or not
  125677. */
  125678. removeGeometry(geometry: Geometry): boolean;
  125679. /**
  125680. * Gets the list of geometries attached to the scene
  125681. * @returns an array of Geometry
  125682. */
  125683. getGeometries(): Geometry[];
  125684. /**
  125685. * Gets the first added mesh found of a given ID
  125686. * @param id defines the id to search for
  125687. * @return the mesh found or null if not found at all
  125688. */
  125689. getMeshByID(id: string): Nullable<AbstractMesh>;
  125690. /**
  125691. * Gets a list of meshes using their id
  125692. * @param id defines the id to search for
  125693. * @returns a list of meshes
  125694. */
  125695. getMeshesByID(id: string): Array<AbstractMesh>;
  125696. /**
  125697. * Gets the first added transform node found of a given ID
  125698. * @param id defines the id to search for
  125699. * @return the found transform node or null if not found at all.
  125700. */
  125701. getTransformNodeByID(id: string): Nullable<TransformNode>;
  125702. /**
  125703. * Gets a transform node with its auto-generated unique id
  125704. * @param uniqueId efines the unique id to search for
  125705. * @return the found transform node or null if not found at all.
  125706. */
  125707. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  125708. /**
  125709. * Gets a list of transform nodes using their id
  125710. * @param id defines the id to search for
  125711. * @returns a list of transform nodes
  125712. */
  125713. getTransformNodesByID(id: string): Array<TransformNode>;
  125714. /**
  125715. * Gets a mesh with its auto-generated unique id
  125716. * @param uniqueId defines the unique id to search for
  125717. * @return the found mesh or null if not found at all.
  125718. */
  125719. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  125720. /**
  125721. * Gets a the last added mesh using a given id
  125722. * @param id defines the id to search for
  125723. * @return the found mesh or null if not found at all.
  125724. */
  125725. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  125726. /**
  125727. * Gets a the last added node (Mesh, Camera, Light) using a given id
  125728. * @param id defines the id to search for
  125729. * @return the found node or null if not found at all
  125730. */
  125731. getLastEntryByID(id: string): Nullable<Node>;
  125732. /**
  125733. * Gets a node (Mesh, Camera, Light) using a given id
  125734. * @param id defines the id to search for
  125735. * @return the found node or null if not found at all
  125736. */
  125737. getNodeByID(id: string): Nullable<Node>;
  125738. /**
  125739. * Gets a node (Mesh, Camera, Light) using a given name
  125740. * @param name defines the name to search for
  125741. * @return the found node or null if not found at all.
  125742. */
  125743. getNodeByName(name: string): Nullable<Node>;
  125744. /**
  125745. * Gets a mesh using a given name
  125746. * @param name defines the name to search for
  125747. * @return the found mesh or null if not found at all.
  125748. */
  125749. getMeshByName(name: string): Nullable<AbstractMesh>;
  125750. /**
  125751. * Gets a transform node using a given name
  125752. * @param name defines the name to search for
  125753. * @return the found transform node or null if not found at all.
  125754. */
  125755. getTransformNodeByName(name: string): Nullable<TransformNode>;
  125756. /**
  125757. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  125758. * @param id defines the id to search for
  125759. * @return the found skeleton or null if not found at all.
  125760. */
  125761. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  125762. /**
  125763. * Gets a skeleton using a given auto generated unique id
  125764. * @param uniqueId defines the unique id to search for
  125765. * @return the found skeleton or null if not found at all.
  125766. */
  125767. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  125768. /**
  125769. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  125770. * @param id defines the id to search for
  125771. * @return the found skeleton or null if not found at all.
  125772. */
  125773. getSkeletonById(id: string): Nullable<Skeleton>;
  125774. /**
  125775. * Gets a skeleton using a given name
  125776. * @param name defines the name to search for
  125777. * @return the found skeleton or null if not found at all.
  125778. */
  125779. getSkeletonByName(name: string): Nullable<Skeleton>;
  125780. /**
  125781. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  125782. * @param id defines the id to search for
  125783. * @return the found morph target manager or null if not found at all.
  125784. */
  125785. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  125786. /**
  125787. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  125788. * @param id defines the id to search for
  125789. * @return the found morph target or null if not found at all.
  125790. */
  125791. getMorphTargetById(id: string): Nullable<MorphTarget>;
  125792. /**
  125793. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  125794. * @param name defines the name to search for
  125795. * @return the found morph target or null if not found at all.
  125796. */
  125797. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  125798. /**
  125799. * Gets a post process using a given name (if many are found, this function will pick the first one)
  125800. * @param name defines the name to search for
  125801. * @return the found post process or null if not found at all.
  125802. */
  125803. getPostProcessByName(name: string): Nullable<PostProcess>;
  125804. /**
  125805. * Gets a boolean indicating if the given mesh is active
  125806. * @param mesh defines the mesh to look for
  125807. * @returns true if the mesh is in the active list
  125808. */
  125809. isActiveMesh(mesh: AbstractMesh): boolean;
  125810. /**
  125811. * Return a unique id as a string which can serve as an identifier for the scene
  125812. */
  125813. get uid(): string;
  125814. /**
  125815. * Add an externaly attached data from its key.
  125816. * This method call will fail and return false, if such key already exists.
  125817. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  125818. * @param key the unique key that identifies the data
  125819. * @param data the data object to associate to the key for this Engine instance
  125820. * @return true if no such key were already present and the data was added successfully, false otherwise
  125821. */
  125822. addExternalData<T>(key: string, data: T): boolean;
  125823. /**
  125824. * Get an externaly attached data from its key
  125825. * @param key the unique key that identifies the data
  125826. * @return the associated data, if present (can be null), or undefined if not present
  125827. */
  125828. getExternalData<T>(key: string): Nullable<T>;
  125829. /**
  125830. * Get an externaly attached data from its key, create it using a factory if it's not already present
  125831. * @param key the unique key that identifies the data
  125832. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  125833. * @return the associated data, can be null if the factory returned null.
  125834. */
  125835. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  125836. /**
  125837. * Remove an externaly attached data from the Engine instance
  125838. * @param key the unique key that identifies the data
  125839. * @return true if the data was successfully removed, false if it doesn't exist
  125840. */
  125841. removeExternalData(key: string): boolean;
  125842. private _evaluateSubMesh;
  125843. /**
  125844. * Clear the processed materials smart array preventing retention point in material dispose.
  125845. */
  125846. freeProcessedMaterials(): void;
  125847. private _preventFreeActiveMeshesAndRenderingGroups;
  125848. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  125849. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  125850. * when disposing several meshes in a row or a hierarchy of meshes.
  125851. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  125852. */
  125853. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  125854. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  125855. /**
  125856. * Clear the active meshes smart array preventing retention point in mesh dispose.
  125857. */
  125858. freeActiveMeshes(): void;
  125859. /**
  125860. * Clear the info related to rendering groups preventing retention points during dispose.
  125861. */
  125862. freeRenderingGroups(): void;
  125863. /** @hidden */
  125864. _isInIntermediateRendering(): boolean;
  125865. /**
  125866. * Lambda returning the list of potentially active meshes.
  125867. */
  125868. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  125869. /**
  125870. * Lambda returning the list of potentially active sub meshes.
  125871. */
  125872. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  125873. /**
  125874. * Lambda returning the list of potentially intersecting sub meshes.
  125875. */
  125876. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  125877. /**
  125878. * Lambda returning the list of potentially colliding sub meshes.
  125879. */
  125880. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  125881. private _activeMeshesFrozen;
  125882. private _skipEvaluateActiveMeshesCompletely;
  125883. /**
  125884. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  125885. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  125886. * @param onSuccess optional success callback
  125887. * @param onError optional error callback
  125888. * @returns the current scene
  125889. */
  125890. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  125891. /**
  125892. * Use this function to restart evaluating active meshes on every frame
  125893. * @returns the current scene
  125894. */
  125895. unfreezeActiveMeshes(): Scene;
  125896. private _evaluateActiveMeshes;
  125897. private _activeMesh;
  125898. /**
  125899. * Update the transform matrix to update from the current active camera
  125900. * @param force defines a boolean used to force the update even if cache is up to date
  125901. */
  125902. updateTransformMatrix(force?: boolean): void;
  125903. private _bindFrameBuffer;
  125904. /** @hidden */
  125905. _allowPostProcessClearColor: boolean;
  125906. /** @hidden */
  125907. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  125908. private _processSubCameras;
  125909. private _checkIntersections;
  125910. /** @hidden */
  125911. _advancePhysicsEngineStep(step: number): void;
  125912. /**
  125913. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  125914. */
  125915. getDeterministicFrameTime: () => number;
  125916. /** @hidden */
  125917. _animate(): void;
  125918. /** Execute all animations (for a frame) */
  125919. animate(): void;
  125920. /**
  125921. * Render the scene
  125922. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  125923. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  125924. */
  125925. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  125926. /**
  125927. * Freeze all materials
  125928. * A frozen material will not be updatable but should be faster to render
  125929. */
  125930. freezeMaterials(): void;
  125931. /**
  125932. * Unfreeze all materials
  125933. * A frozen material will not be updatable but should be faster to render
  125934. */
  125935. unfreezeMaterials(): void;
  125936. /**
  125937. * Releases all held ressources
  125938. */
  125939. dispose(): void;
  125940. /**
  125941. * Gets if the scene is already disposed
  125942. */
  125943. get isDisposed(): boolean;
  125944. /**
  125945. * Call this function to reduce memory footprint of the scene.
  125946. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  125947. */
  125948. clearCachedVertexData(): void;
  125949. /**
  125950. * This function will remove the local cached buffer data from texture.
  125951. * It will save memory but will prevent the texture from being rebuilt
  125952. */
  125953. cleanCachedTextureBuffer(): void;
  125954. /**
  125955. * Get the world extend vectors with an optional filter
  125956. *
  125957. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  125958. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  125959. */
  125960. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  125961. min: Vector3;
  125962. max: Vector3;
  125963. };
  125964. /**
  125965. * Creates a ray that can be used to pick in the scene
  125966. * @param x defines the x coordinate of the origin (on-screen)
  125967. * @param y defines the y coordinate of the origin (on-screen)
  125968. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  125969. * @param camera defines the camera to use for the picking
  125970. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  125971. * @returns a Ray
  125972. */
  125973. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  125974. /**
  125975. * Creates a ray that can be used to pick in the scene
  125976. * @param x defines the x coordinate of the origin (on-screen)
  125977. * @param y defines the y coordinate of the origin (on-screen)
  125978. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  125979. * @param result defines the ray where to store the picking ray
  125980. * @param camera defines the camera to use for the picking
  125981. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  125982. * @returns the current scene
  125983. */
  125984. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  125985. /**
  125986. * Creates a ray that can be used to pick in the scene
  125987. * @param x defines the x coordinate of the origin (on-screen)
  125988. * @param y defines the y coordinate of the origin (on-screen)
  125989. * @param camera defines the camera to use for the picking
  125990. * @returns a Ray
  125991. */
  125992. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  125993. /**
  125994. * Creates a ray that can be used to pick in the scene
  125995. * @param x defines the x coordinate of the origin (on-screen)
  125996. * @param y defines the y coordinate of the origin (on-screen)
  125997. * @param result defines the ray where to store the picking ray
  125998. * @param camera defines the camera to use for the picking
  125999. * @returns the current scene
  126000. */
  126001. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  126002. /** Launch a ray to try to pick a mesh in the scene
  126003. * @param x position on screen
  126004. * @param y position on screen
  126005. * @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
  126006. * @param fastCheck defines if the first intersection will be used (and not the closest)
  126007. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  126008. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  126009. * @returns a PickingInfo
  126010. */
  126011. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  126012. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  126013. * @param x position on screen
  126014. * @param y position on screen
  126015. * @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
  126016. * @param fastCheck defines if the first intersection will be used (and not the closest)
  126017. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  126018. * @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)
  126019. */
  126020. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  126021. /** Use the given ray to pick a mesh in the scene
  126022. * @param ray The ray to use to pick meshes
  126023. * @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
  126024. * @param fastCheck defines if the first intersection will be used (and not the closest)
  126025. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  126026. * @returns a PickingInfo
  126027. */
  126028. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  126029. /**
  126030. * Launch a ray to try to pick a mesh in the scene
  126031. * @param x X position on screen
  126032. * @param y Y position on screen
  126033. * @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
  126034. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  126035. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  126036. * @returns an array of PickingInfo
  126037. */
  126038. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  126039. /**
  126040. * Launch a ray to try to pick a mesh in the scene
  126041. * @param ray Ray to use
  126042. * @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
  126043. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  126044. * @returns an array of PickingInfo
  126045. */
  126046. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  126047. /**
  126048. * Force the value of meshUnderPointer
  126049. * @param mesh defines the mesh to use
  126050. * @param pointerId optional pointer id when using more than one pointer
  126051. */
  126052. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  126053. /**
  126054. * Gets the mesh under the pointer
  126055. * @returns a Mesh or null if no mesh is under the pointer
  126056. */
  126057. getPointerOverMesh(): Nullable<AbstractMesh>;
  126058. /** @hidden */
  126059. _rebuildGeometries(): void;
  126060. /** @hidden */
  126061. _rebuildTextures(): void;
  126062. private _getByTags;
  126063. /**
  126064. * Get a list of meshes by tags
  126065. * @param tagsQuery defines the tags query to use
  126066. * @param forEach defines a predicate used to filter results
  126067. * @returns an array of Mesh
  126068. */
  126069. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  126070. /**
  126071. * Get a list of cameras by tags
  126072. * @param tagsQuery defines the tags query to use
  126073. * @param forEach defines a predicate used to filter results
  126074. * @returns an array of Camera
  126075. */
  126076. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  126077. /**
  126078. * Get a list of lights by tags
  126079. * @param tagsQuery defines the tags query to use
  126080. * @param forEach defines a predicate used to filter results
  126081. * @returns an array of Light
  126082. */
  126083. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  126084. /**
  126085. * Get a list of materials by tags
  126086. * @param tagsQuery defines the tags query to use
  126087. * @param forEach defines a predicate used to filter results
  126088. * @returns an array of Material
  126089. */
  126090. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  126091. /**
  126092. * Get a list of transform nodes by tags
  126093. * @param tagsQuery defines the tags query to use
  126094. * @param forEach defines a predicate used to filter results
  126095. * @returns an array of TransformNode
  126096. */
  126097. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  126098. /**
  126099. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  126100. * This allowed control for front to back rendering or reversly depending of the special needs.
  126101. *
  126102. * @param renderingGroupId The rendering group id corresponding to its index
  126103. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  126104. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  126105. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  126106. */
  126107. 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;
  126108. /**
  126109. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  126110. *
  126111. * @param renderingGroupId The rendering group id corresponding to its index
  126112. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  126113. * @param depth Automatically clears depth between groups if true and autoClear is true.
  126114. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  126115. */
  126116. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  126117. /**
  126118. * Gets the current auto clear configuration for one rendering group of the rendering
  126119. * manager.
  126120. * @param index the rendering group index to get the information for
  126121. * @returns The auto clear setup for the requested rendering group
  126122. */
  126123. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  126124. private _blockMaterialDirtyMechanism;
  126125. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  126126. get blockMaterialDirtyMechanism(): boolean;
  126127. set blockMaterialDirtyMechanism(value: boolean);
  126128. /**
  126129. * Will flag all materials as dirty to trigger new shader compilation
  126130. * @param flag defines the flag used to specify which material part must be marked as dirty
  126131. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  126132. */
  126133. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  126134. /** @hidden */
  126135. _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;
  126136. /** @hidden */
  126137. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  126138. /** @hidden */
  126139. _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;
  126140. /** @hidden */
  126141. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  126142. /** @hidden */
  126143. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  126144. /** @hidden */
  126145. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  126146. }
  126147. }
  126148. declare module BABYLON {
  126149. /**
  126150. * Set of assets to keep when moving a scene into an asset container.
  126151. */
  126152. export class KeepAssets extends AbstractScene {
  126153. }
  126154. /**
  126155. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  126156. */
  126157. export class InstantiatedEntries {
  126158. /**
  126159. * List of new root nodes (eg. nodes with no parent)
  126160. */
  126161. rootNodes: TransformNode[];
  126162. /**
  126163. * List of new skeletons
  126164. */
  126165. skeletons: Skeleton[];
  126166. /**
  126167. * List of new animation groups
  126168. */
  126169. animationGroups: AnimationGroup[];
  126170. }
  126171. /**
  126172. * Container with a set of assets that can be added or removed from a scene.
  126173. */
  126174. export class AssetContainer extends AbstractScene {
  126175. private _wasAddedToScene;
  126176. /**
  126177. * The scene the AssetContainer belongs to.
  126178. */
  126179. scene: Scene;
  126180. /**
  126181. * Instantiates an AssetContainer.
  126182. * @param scene The scene the AssetContainer belongs to.
  126183. */
  126184. constructor(scene: Scene);
  126185. /**
  126186. * Instantiate or clone all meshes and add the new ones to the scene.
  126187. * Skeletons and animation groups will all be cloned
  126188. * @param nameFunction defines an optional function used to get new names for clones
  126189. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  126190. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  126191. */
  126192. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  126193. /**
  126194. * Adds all the assets from the container to the scene.
  126195. */
  126196. addAllToScene(): void;
  126197. /**
  126198. * Removes all the assets in the container from the scene
  126199. */
  126200. removeAllFromScene(): void;
  126201. /**
  126202. * Disposes all the assets in the container
  126203. */
  126204. dispose(): void;
  126205. private _moveAssets;
  126206. /**
  126207. * Removes all the assets contained in the scene and adds them to the container.
  126208. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  126209. */
  126210. moveAllFromScene(keepAssets?: KeepAssets): void;
  126211. /**
  126212. * 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.
  126213. * @returns the root mesh
  126214. */
  126215. createRootMesh(): Mesh;
  126216. /**
  126217. * Merge animations (direct and animation groups) from this asset container into a scene
  126218. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126219. * @param animatables set of animatables to retarget to a node from the scene
  126220. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  126221. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  126222. */
  126223. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  126224. }
  126225. }
  126226. declare module BABYLON {
  126227. /**
  126228. * Defines how the parser contract is defined.
  126229. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  126230. */
  126231. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  126232. /**
  126233. * Defines how the individual parser contract is defined.
  126234. * These parser can parse an individual asset
  126235. */
  126236. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  126237. /**
  126238. * Base class of the scene acting as a container for the different elements composing a scene.
  126239. * This class is dynamically extended by the different components of the scene increasing
  126240. * flexibility and reducing coupling
  126241. */
  126242. export abstract class AbstractScene {
  126243. /**
  126244. * Stores the list of available parsers in the application.
  126245. */
  126246. private static _BabylonFileParsers;
  126247. /**
  126248. * Stores the list of available individual parsers in the application.
  126249. */
  126250. private static _IndividualBabylonFileParsers;
  126251. /**
  126252. * Adds a parser in the list of available ones
  126253. * @param name Defines the name of the parser
  126254. * @param parser Defines the parser to add
  126255. */
  126256. static AddParser(name: string, parser: BabylonFileParser): void;
  126257. /**
  126258. * Gets a general parser from the list of avaialble ones
  126259. * @param name Defines the name of the parser
  126260. * @returns the requested parser or null
  126261. */
  126262. static GetParser(name: string): Nullable<BabylonFileParser>;
  126263. /**
  126264. * Adds n individual parser in the list of available ones
  126265. * @param name Defines the name of the parser
  126266. * @param parser Defines the parser to add
  126267. */
  126268. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  126269. /**
  126270. * Gets an individual parser from the list of avaialble ones
  126271. * @param name Defines the name of the parser
  126272. * @returns the requested parser or null
  126273. */
  126274. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  126275. /**
  126276. * Parser json data and populate both a scene and its associated container object
  126277. * @param jsonData Defines the data to parse
  126278. * @param scene Defines the scene to parse the data for
  126279. * @param container Defines the container attached to the parsing sequence
  126280. * @param rootUrl Defines the root url of the data
  126281. */
  126282. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  126283. /**
  126284. * Gets the list of root nodes (ie. nodes with no parent)
  126285. */
  126286. rootNodes: Node[];
  126287. /** All of the cameras added to this scene
  126288. * @see https://doc.babylonjs.com/babylon101/cameras
  126289. */
  126290. cameras: Camera[];
  126291. /**
  126292. * All of the lights added to this scene
  126293. * @see https://doc.babylonjs.com/babylon101/lights
  126294. */
  126295. lights: Light[];
  126296. /**
  126297. * All of the (abstract) meshes added to this scene
  126298. */
  126299. meshes: AbstractMesh[];
  126300. /**
  126301. * The list of skeletons added to the scene
  126302. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  126303. */
  126304. skeletons: Skeleton[];
  126305. /**
  126306. * All of the particle systems added to this scene
  126307. * @see https://doc.babylonjs.com/babylon101/particles
  126308. */
  126309. particleSystems: IParticleSystem[];
  126310. /**
  126311. * Gets a list of Animations associated with the scene
  126312. */
  126313. animations: Animation[];
  126314. /**
  126315. * All of the animation groups added to this scene
  126316. * @see https://doc.babylonjs.com/how_to/group
  126317. */
  126318. animationGroups: AnimationGroup[];
  126319. /**
  126320. * All of the multi-materials added to this scene
  126321. * @see https://doc.babylonjs.com/how_to/multi_materials
  126322. */
  126323. multiMaterials: MultiMaterial[];
  126324. /**
  126325. * All of the materials added to this scene
  126326. * In the context of a Scene, it is not supposed to be modified manually.
  126327. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  126328. * Note also that the order of the Material within the array is not significant and might change.
  126329. * @see https://doc.babylonjs.com/babylon101/materials
  126330. */
  126331. materials: Material[];
  126332. /**
  126333. * The list of morph target managers added to the scene
  126334. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  126335. */
  126336. morphTargetManagers: MorphTargetManager[];
  126337. /**
  126338. * The list of geometries used in the scene.
  126339. */
  126340. geometries: Geometry[];
  126341. /**
  126342. * All of the tranform nodes added to this scene
  126343. * In the context of a Scene, it is not supposed to be modified manually.
  126344. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  126345. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  126346. * @see https://doc.babylonjs.com/how_to/transformnode
  126347. */
  126348. transformNodes: TransformNode[];
  126349. /**
  126350. * ActionManagers available on the scene.
  126351. */
  126352. actionManagers: AbstractActionManager[];
  126353. /**
  126354. * Textures to keep.
  126355. */
  126356. textures: BaseTexture[];
  126357. /** @hidden */
  126358. protected _environmentTexture: Nullable<BaseTexture>;
  126359. /**
  126360. * Texture used in all pbr material as the reflection texture.
  126361. * As in the majority of the scene they are the same (exception for multi room and so on),
  126362. * this is easier to reference from here than from all the materials.
  126363. */
  126364. get environmentTexture(): Nullable<BaseTexture>;
  126365. set environmentTexture(value: Nullable<BaseTexture>);
  126366. /**
  126367. * The list of postprocesses added to the scene
  126368. */
  126369. postProcesses: PostProcess[];
  126370. /**
  126371. * @returns all meshes, lights, cameras, transformNodes and bones
  126372. */
  126373. getNodes(): Array<Node>;
  126374. }
  126375. }
  126376. declare module BABYLON {
  126377. /**
  126378. * Interface used to define options for Sound class
  126379. */
  126380. export interface ISoundOptions {
  126381. /**
  126382. * Does the sound autoplay once loaded.
  126383. */
  126384. autoplay?: boolean;
  126385. /**
  126386. * Does the sound loop after it finishes playing once.
  126387. */
  126388. loop?: boolean;
  126389. /**
  126390. * Sound's volume
  126391. */
  126392. volume?: number;
  126393. /**
  126394. * Is it a spatial sound?
  126395. */
  126396. spatialSound?: boolean;
  126397. /**
  126398. * Maximum distance to hear that sound
  126399. */
  126400. maxDistance?: number;
  126401. /**
  126402. * Uses user defined attenuation function
  126403. */
  126404. useCustomAttenuation?: boolean;
  126405. /**
  126406. * Define the roll off factor of spatial sounds.
  126407. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126408. */
  126409. rolloffFactor?: number;
  126410. /**
  126411. * Define the reference distance the sound should be heard perfectly.
  126412. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126413. */
  126414. refDistance?: number;
  126415. /**
  126416. * Define the distance attenuation model the sound will follow.
  126417. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126418. */
  126419. distanceModel?: string;
  126420. /**
  126421. * Defines the playback speed (1 by default)
  126422. */
  126423. playbackRate?: number;
  126424. /**
  126425. * Defines if the sound is from a streaming source
  126426. */
  126427. streaming?: boolean;
  126428. /**
  126429. * Defines an optional length (in seconds) inside the sound file
  126430. */
  126431. length?: number;
  126432. /**
  126433. * Defines an optional offset (in seconds) inside the sound file
  126434. */
  126435. offset?: number;
  126436. /**
  126437. * If true, URLs will not be required to state the audio file codec to use.
  126438. */
  126439. skipCodecCheck?: boolean;
  126440. }
  126441. }
  126442. declare module BABYLON {
  126443. /**
  126444. * Defines a sound that can be played in the application.
  126445. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  126446. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126447. */
  126448. export class Sound {
  126449. /**
  126450. * The name of the sound in the scene.
  126451. */
  126452. name: string;
  126453. /**
  126454. * Does the sound autoplay once loaded.
  126455. */
  126456. autoplay: boolean;
  126457. /**
  126458. * Does the sound loop after it finishes playing once.
  126459. */
  126460. loop: boolean;
  126461. /**
  126462. * Does the sound use a custom attenuation curve to simulate the falloff
  126463. * happening when the source gets further away from the camera.
  126464. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  126465. */
  126466. useCustomAttenuation: boolean;
  126467. /**
  126468. * The sound track id this sound belongs to.
  126469. */
  126470. soundTrackId: number;
  126471. /**
  126472. * Is this sound currently played.
  126473. */
  126474. isPlaying: boolean;
  126475. /**
  126476. * Is this sound currently paused.
  126477. */
  126478. isPaused: boolean;
  126479. /**
  126480. * Does this sound enables spatial sound.
  126481. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126482. */
  126483. spatialSound: boolean;
  126484. /**
  126485. * Define the reference distance the sound should be heard perfectly.
  126486. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126487. */
  126488. refDistance: number;
  126489. /**
  126490. * Define the roll off factor of spatial sounds.
  126491. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126492. */
  126493. rolloffFactor: number;
  126494. /**
  126495. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  126496. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126497. */
  126498. maxDistance: number;
  126499. /**
  126500. * Define the distance attenuation model the sound will follow.
  126501. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126502. */
  126503. distanceModel: string;
  126504. /**
  126505. * @hidden
  126506. * Back Compat
  126507. **/
  126508. onended: () => any;
  126509. /**
  126510. * Gets or sets an object used to store user defined information for the sound.
  126511. */
  126512. metadata: any;
  126513. /**
  126514. * Observable event when the current playing sound finishes.
  126515. */
  126516. onEndedObservable: Observable<Sound>;
  126517. /**
  126518. * Gets the current time for the sound.
  126519. */
  126520. get currentTime(): number;
  126521. private _panningModel;
  126522. private _playbackRate;
  126523. private _streaming;
  126524. private _startTime;
  126525. private _startOffset;
  126526. private _position;
  126527. /** @hidden */
  126528. _positionInEmitterSpace: boolean;
  126529. private _localDirection;
  126530. private _volume;
  126531. private _isReadyToPlay;
  126532. private _isDirectional;
  126533. private _readyToPlayCallback;
  126534. private _audioBuffer;
  126535. private _soundSource;
  126536. private _streamingSource;
  126537. private _soundPanner;
  126538. private _soundGain;
  126539. private _inputAudioNode;
  126540. private _outputAudioNode;
  126541. private _coneInnerAngle;
  126542. private _coneOuterAngle;
  126543. private _coneOuterGain;
  126544. private _scene;
  126545. private _connectedTransformNode;
  126546. private _customAttenuationFunction;
  126547. private _registerFunc;
  126548. private _isOutputConnected;
  126549. private _htmlAudioElement;
  126550. private _urlType;
  126551. private _length?;
  126552. private _offset?;
  126553. /** @hidden */
  126554. static _SceneComponentInitialization: (scene: Scene) => void;
  126555. /**
  126556. * Create a sound and attach it to a scene
  126557. * @param name Name of your sound
  126558. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  126559. * @param scene defines the scene the sound belongs to
  126560. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  126561. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  126562. */
  126563. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  126564. /**
  126565. * Release the sound and its associated resources
  126566. */
  126567. dispose(): void;
  126568. /**
  126569. * Gets if the sounds is ready to be played or not.
  126570. * @returns true if ready, otherwise false
  126571. */
  126572. isReady(): boolean;
  126573. private _soundLoaded;
  126574. /**
  126575. * Sets the data of the sound from an audiobuffer
  126576. * @param audioBuffer The audioBuffer containing the data
  126577. */
  126578. setAudioBuffer(audioBuffer: AudioBuffer): void;
  126579. /**
  126580. * Updates the current sounds options such as maxdistance, loop...
  126581. * @param options A JSON object containing values named as the object properties
  126582. */
  126583. updateOptions(options: ISoundOptions): void;
  126584. private _createSpatialParameters;
  126585. private _updateSpatialParameters;
  126586. /**
  126587. * Switch the panning model to HRTF:
  126588. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  126589. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126590. */
  126591. switchPanningModelToHRTF(): void;
  126592. /**
  126593. * Switch the panning model to Equal Power:
  126594. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  126595. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126596. */
  126597. switchPanningModelToEqualPower(): void;
  126598. private _switchPanningModel;
  126599. /**
  126600. * Connect this sound to a sound track audio node like gain...
  126601. * @param soundTrackAudioNode the sound track audio node to connect to
  126602. */
  126603. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  126604. /**
  126605. * Transform this sound into a directional source
  126606. * @param coneInnerAngle Size of the inner cone in degree
  126607. * @param coneOuterAngle Size of the outer cone in degree
  126608. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  126609. */
  126610. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  126611. /**
  126612. * Gets or sets the inner angle for the directional cone.
  126613. */
  126614. get directionalConeInnerAngle(): number;
  126615. /**
  126616. * Gets or sets the inner angle for the directional cone.
  126617. */
  126618. set directionalConeInnerAngle(value: number);
  126619. /**
  126620. * Gets or sets the outer angle for the directional cone.
  126621. */
  126622. get directionalConeOuterAngle(): number;
  126623. /**
  126624. * Gets or sets the outer angle for the directional cone.
  126625. */
  126626. set directionalConeOuterAngle(value: number);
  126627. /**
  126628. * Sets the position of the emitter if spatial sound is enabled
  126629. * @param newPosition Defines the new posisiton
  126630. */
  126631. setPosition(newPosition: Vector3): void;
  126632. /**
  126633. * Sets the local direction of the emitter if spatial sound is enabled
  126634. * @param newLocalDirection Defines the new local direction
  126635. */
  126636. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  126637. private _updateDirection;
  126638. /** @hidden */
  126639. updateDistanceFromListener(): void;
  126640. /**
  126641. * Sets a new custom attenuation function for the sound.
  126642. * @param callback Defines the function used for the attenuation
  126643. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  126644. */
  126645. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  126646. /**
  126647. * Play the sound
  126648. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  126649. * @param offset (optional) Start the sound at a specific time in seconds
  126650. * @param length (optional) Sound duration (in seconds)
  126651. */
  126652. play(time?: number, offset?: number, length?: number): void;
  126653. private _onended;
  126654. /**
  126655. * Stop the sound
  126656. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  126657. */
  126658. stop(time?: number): void;
  126659. /**
  126660. * Put the sound in pause
  126661. */
  126662. pause(): void;
  126663. /**
  126664. * Sets a dedicated volume for this sounds
  126665. * @param newVolume Define the new volume of the sound
  126666. * @param time Define time for gradual change to new volume
  126667. */
  126668. setVolume(newVolume: number, time?: number): void;
  126669. /**
  126670. * Set the sound play back rate
  126671. * @param newPlaybackRate Define the playback rate the sound should be played at
  126672. */
  126673. setPlaybackRate(newPlaybackRate: number): void;
  126674. /**
  126675. * Gets the volume of the sound.
  126676. * @returns the volume of the sound
  126677. */
  126678. getVolume(): number;
  126679. /**
  126680. * Attach the sound to a dedicated mesh
  126681. * @param transformNode The transform node to connect the sound with
  126682. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  126683. */
  126684. attachToMesh(transformNode: TransformNode): void;
  126685. /**
  126686. * Detach the sound from the previously attached mesh
  126687. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  126688. */
  126689. detachFromMesh(): void;
  126690. private _onRegisterAfterWorldMatrixUpdate;
  126691. /**
  126692. * Clone the current sound in the scene.
  126693. * @returns the new sound clone
  126694. */
  126695. clone(): Nullable<Sound>;
  126696. /**
  126697. * Gets the current underlying audio buffer containing the data
  126698. * @returns the audio buffer
  126699. */
  126700. getAudioBuffer(): Nullable<AudioBuffer>;
  126701. /**
  126702. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  126703. * @returns the source node
  126704. */
  126705. getSoundSource(): Nullable<AudioBufferSourceNode>;
  126706. /**
  126707. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  126708. * @returns the gain node
  126709. */
  126710. getSoundGain(): Nullable<GainNode>;
  126711. /**
  126712. * Serializes the Sound in a JSON representation
  126713. * @returns the JSON representation of the sound
  126714. */
  126715. serialize(): any;
  126716. /**
  126717. * Parse a JSON representation of a sound to innstantiate in a given scene
  126718. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  126719. * @param scene Define the scene the new parsed sound should be created in
  126720. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  126721. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  126722. * @returns the newly parsed sound
  126723. */
  126724. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  126725. }
  126726. }
  126727. declare module BABYLON {
  126728. /**
  126729. * This defines an action helpful to play a defined sound on a triggered action.
  126730. */
  126731. export class PlaySoundAction extends Action {
  126732. private _sound;
  126733. /**
  126734. * Instantiate the action
  126735. * @param triggerOptions defines the trigger options
  126736. * @param sound defines the sound to play
  126737. * @param condition defines the trigger related conditions
  126738. */
  126739. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  126740. /** @hidden */
  126741. _prepare(): void;
  126742. /**
  126743. * Execute the action and play the sound.
  126744. */
  126745. execute(): void;
  126746. /**
  126747. * Serializes the actions and its related information.
  126748. * @param parent defines the object to serialize in
  126749. * @returns the serialized object
  126750. */
  126751. serialize(parent: any): any;
  126752. }
  126753. /**
  126754. * This defines an action helpful to stop a defined sound on a triggered action.
  126755. */
  126756. export class StopSoundAction extends Action {
  126757. private _sound;
  126758. /**
  126759. * Instantiate the action
  126760. * @param triggerOptions defines the trigger options
  126761. * @param sound defines the sound to stop
  126762. * @param condition defines the trigger related conditions
  126763. */
  126764. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  126765. /** @hidden */
  126766. _prepare(): void;
  126767. /**
  126768. * Execute the action and stop the sound.
  126769. */
  126770. execute(): void;
  126771. /**
  126772. * Serializes the actions and its related information.
  126773. * @param parent defines the object to serialize in
  126774. * @returns the serialized object
  126775. */
  126776. serialize(parent: any): any;
  126777. }
  126778. }
  126779. declare module BABYLON {
  126780. /**
  126781. * This defines an action responsible to change the value of a property
  126782. * by interpolating between its current value and the newly set one once triggered.
  126783. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  126784. */
  126785. export class InterpolateValueAction extends Action {
  126786. /**
  126787. * Defines the path of the property where the value should be interpolated
  126788. */
  126789. propertyPath: string;
  126790. /**
  126791. * Defines the target value at the end of the interpolation.
  126792. */
  126793. value: any;
  126794. /**
  126795. * Defines the time it will take for the property to interpolate to the value.
  126796. */
  126797. duration: number;
  126798. /**
  126799. * Defines if the other scene animations should be stopped when the action has been triggered
  126800. */
  126801. stopOtherAnimations?: boolean;
  126802. /**
  126803. * Defines a callback raised once the interpolation animation has been done.
  126804. */
  126805. onInterpolationDone?: () => void;
  126806. /**
  126807. * Observable triggered once the interpolation animation has been done.
  126808. */
  126809. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  126810. private _target;
  126811. private _effectiveTarget;
  126812. private _property;
  126813. /**
  126814. * Instantiate the action
  126815. * @param triggerOptions defines the trigger options
  126816. * @param target defines the object containing the value to interpolate
  126817. * @param propertyPath defines the path to the property in the target object
  126818. * @param value defines the target value at the end of the interpolation
  126819. * @param duration deines the time it will take for the property to interpolate to the value.
  126820. * @param condition defines the trigger related conditions
  126821. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  126822. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  126823. */
  126824. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  126825. /** @hidden */
  126826. _prepare(): void;
  126827. /**
  126828. * Execute the action starts the value interpolation.
  126829. */
  126830. execute(): void;
  126831. /**
  126832. * Serializes the actions and its related information.
  126833. * @param parent defines the object to serialize in
  126834. * @returns the serialized object
  126835. */
  126836. serialize(parent: any): any;
  126837. }
  126838. }
  126839. declare module BABYLON {
  126840. /**
  126841. * This represents the default audio engine used in babylon.
  126842. * It is responsible to play, synchronize and analyse sounds throughout the application.
  126843. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126844. */
  126845. export class AudioEngine implements IAudioEngine {
  126846. private _audioContext;
  126847. private _audioContextInitialized;
  126848. private _muteButton;
  126849. private _hostElement;
  126850. /**
  126851. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  126852. */
  126853. canUseWebAudio: boolean;
  126854. /**
  126855. * The master gain node defines the global audio volume of your audio engine.
  126856. */
  126857. masterGain: GainNode;
  126858. /**
  126859. * Defines if Babylon should emit a warning if WebAudio is not supported.
  126860. * @ignoreNaming
  126861. */
  126862. WarnedWebAudioUnsupported: boolean;
  126863. /**
  126864. * Gets whether or not mp3 are supported by your browser.
  126865. */
  126866. isMP3supported: boolean;
  126867. /**
  126868. * Gets whether or not ogg are supported by your browser.
  126869. */
  126870. isOGGsupported: boolean;
  126871. /**
  126872. * Gets whether audio has been unlocked on the device.
  126873. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  126874. * a user interaction has happened.
  126875. */
  126876. unlocked: boolean;
  126877. /**
  126878. * Defines if the audio engine relies on a custom unlocked button.
  126879. * In this case, the embedded button will not be displayed.
  126880. */
  126881. useCustomUnlockedButton: boolean;
  126882. /**
  126883. * Event raised when audio has been unlocked on the browser.
  126884. */
  126885. onAudioUnlockedObservable: Observable<IAudioEngine>;
  126886. /**
  126887. * Event raised when audio has been locked on the browser.
  126888. */
  126889. onAudioLockedObservable: Observable<IAudioEngine>;
  126890. /**
  126891. * Gets the current AudioContext if available.
  126892. */
  126893. get audioContext(): Nullable<AudioContext>;
  126894. private _connectedAnalyser;
  126895. /**
  126896. * Instantiates a new audio engine.
  126897. *
  126898. * There should be only one per page as some browsers restrict the number
  126899. * of audio contexts you can create.
  126900. * @param hostElement defines the host element where to display the mute icon if necessary
  126901. */
  126902. constructor(hostElement?: Nullable<HTMLElement>);
  126903. /**
  126904. * Flags the audio engine in Locked state.
  126905. * This happens due to new browser policies preventing audio to autoplay.
  126906. */
  126907. lock(): void;
  126908. /**
  126909. * Unlocks the audio engine once a user action has been done on the dom.
  126910. * This is helpful to resume play once browser policies have been satisfied.
  126911. */
  126912. unlock(): void;
  126913. private _resumeAudioContext;
  126914. private _initializeAudioContext;
  126915. private _tryToRun;
  126916. private _triggerRunningState;
  126917. private _triggerSuspendedState;
  126918. private _displayMuteButton;
  126919. private _moveButtonToTopLeft;
  126920. private _onResize;
  126921. private _hideMuteButton;
  126922. /**
  126923. * Destroy and release the resources associated with the audio ccontext.
  126924. */
  126925. dispose(): void;
  126926. /**
  126927. * Gets the global volume sets on the master gain.
  126928. * @returns the global volume if set or -1 otherwise
  126929. */
  126930. getGlobalVolume(): number;
  126931. /**
  126932. * Sets the global volume of your experience (sets on the master gain).
  126933. * @param newVolume Defines the new global volume of the application
  126934. */
  126935. setGlobalVolume(newVolume: number): void;
  126936. /**
  126937. * Connect the audio engine to an audio analyser allowing some amazing
  126938. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  126939. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  126940. * @param analyser The analyser to connect to the engine
  126941. */
  126942. connectToAnalyser(analyser: Analyser): void;
  126943. }
  126944. }
  126945. declare module BABYLON {
  126946. /**
  126947. * Options allowed during the creation of a sound track.
  126948. */
  126949. export interface ISoundTrackOptions {
  126950. /**
  126951. * The volume the sound track should take during creation
  126952. */
  126953. volume?: number;
  126954. /**
  126955. * Define if the sound track is the main sound track of the scene
  126956. */
  126957. mainTrack?: boolean;
  126958. }
  126959. /**
  126960. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  126961. * It will be also used in a future release to apply effects on a specific track.
  126962. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  126963. */
  126964. export class SoundTrack {
  126965. /**
  126966. * The unique identifier of the sound track in the scene.
  126967. */
  126968. id: number;
  126969. /**
  126970. * The list of sounds included in the sound track.
  126971. */
  126972. soundCollection: Array<Sound>;
  126973. private _outputAudioNode;
  126974. private _scene;
  126975. private _connectedAnalyser;
  126976. private _options;
  126977. private _isInitialized;
  126978. /**
  126979. * Creates a new sound track.
  126980. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  126981. * @param scene Define the scene the sound track belongs to
  126982. * @param options
  126983. */
  126984. constructor(scene: Scene, options?: ISoundTrackOptions);
  126985. private _initializeSoundTrackAudioGraph;
  126986. /**
  126987. * Release the sound track and its associated resources
  126988. */
  126989. dispose(): void;
  126990. /**
  126991. * Adds a sound to this sound track
  126992. * @param sound define the cound to add
  126993. * @ignoreNaming
  126994. */
  126995. addSound(sound: Sound): void;
  126996. /**
  126997. * Removes a sound to this sound track
  126998. * @param sound define the cound to remove
  126999. * @ignoreNaming
  127000. */
  127001. removeSound(sound: Sound): void;
  127002. /**
  127003. * Set a global volume for the full sound track.
  127004. * @param newVolume Define the new volume of the sound track
  127005. */
  127006. setVolume(newVolume: number): void;
  127007. /**
  127008. * Switch the panning model to HRTF:
  127009. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  127010. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  127011. */
  127012. switchPanningModelToHRTF(): void;
  127013. /**
  127014. * Switch the panning model to Equal Power:
  127015. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  127016. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  127017. */
  127018. switchPanningModelToEqualPower(): void;
  127019. /**
  127020. * Connect the sound track to an audio analyser allowing some amazing
  127021. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  127022. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  127023. * @param analyser The analyser to connect to the engine
  127024. */
  127025. connectToAnalyser(analyser: Analyser): void;
  127026. }
  127027. }
  127028. declare module BABYLON {
  127029. interface AbstractScene {
  127030. /**
  127031. * The list of sounds used in the scene.
  127032. */
  127033. sounds: Nullable<Array<Sound>>;
  127034. }
  127035. interface Scene {
  127036. /**
  127037. * @hidden
  127038. * Backing field
  127039. */
  127040. _mainSoundTrack: SoundTrack;
  127041. /**
  127042. * The main sound track played by the scene.
  127043. * It cotains your primary collection of sounds.
  127044. */
  127045. mainSoundTrack: SoundTrack;
  127046. /**
  127047. * The list of sound tracks added to the scene
  127048. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127049. */
  127050. soundTracks: Nullable<Array<SoundTrack>>;
  127051. /**
  127052. * Gets a sound using a given name
  127053. * @param name defines the name to search for
  127054. * @return the found sound or null if not found at all.
  127055. */
  127056. getSoundByName(name: string): Nullable<Sound>;
  127057. /**
  127058. * Gets or sets if audio support is enabled
  127059. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127060. */
  127061. audioEnabled: boolean;
  127062. /**
  127063. * Gets or sets if audio will be output to headphones
  127064. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127065. */
  127066. headphone: boolean;
  127067. /**
  127068. * Gets or sets custom audio listener position provider
  127069. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127070. */
  127071. audioListenerPositionProvider: Nullable<() => Vector3>;
  127072. /**
  127073. * Gets or sets a refresh rate when using 3D audio positioning
  127074. */
  127075. audioPositioningRefreshRate: number;
  127076. }
  127077. /**
  127078. * Defines the sound scene component responsible to manage any sounds
  127079. * in a given scene.
  127080. */
  127081. export class AudioSceneComponent implements ISceneSerializableComponent {
  127082. private static _CameraDirectionLH;
  127083. private static _CameraDirectionRH;
  127084. /**
  127085. * The component name helpfull to identify the component in the list of scene components.
  127086. */
  127087. readonly name: string;
  127088. /**
  127089. * The scene the component belongs to.
  127090. */
  127091. scene: Scene;
  127092. private _audioEnabled;
  127093. /**
  127094. * Gets whether audio is enabled or not.
  127095. * Please use related enable/disable method to switch state.
  127096. */
  127097. get audioEnabled(): boolean;
  127098. private _headphone;
  127099. /**
  127100. * Gets whether audio is outputing to headphone or not.
  127101. * Please use the according Switch methods to change output.
  127102. */
  127103. get headphone(): boolean;
  127104. /**
  127105. * Gets or sets a refresh rate when using 3D audio positioning
  127106. */
  127107. audioPositioningRefreshRate: number;
  127108. private _audioListenerPositionProvider;
  127109. /**
  127110. * Gets the current audio listener position provider
  127111. */
  127112. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  127113. /**
  127114. * Sets a custom listener position for all sounds in the scene
  127115. * By default, this is the position of the first active camera
  127116. */
  127117. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  127118. /**
  127119. * Creates a new instance of the component for the given scene
  127120. * @param scene Defines the scene to register the component in
  127121. */
  127122. constructor(scene: Scene);
  127123. /**
  127124. * Registers the component in a given scene
  127125. */
  127126. register(): void;
  127127. /**
  127128. * Rebuilds the elements related to this component in case of
  127129. * context lost for instance.
  127130. */
  127131. rebuild(): void;
  127132. /**
  127133. * Serializes the component data to the specified json object
  127134. * @param serializationObject The object to serialize to
  127135. */
  127136. serialize(serializationObject: any): void;
  127137. /**
  127138. * Adds all the elements from the container to the scene
  127139. * @param container the container holding the elements
  127140. */
  127141. addFromContainer(container: AbstractScene): void;
  127142. /**
  127143. * Removes all the elements in the container from the scene
  127144. * @param container contains the elements to remove
  127145. * @param dispose if the removed element should be disposed (default: false)
  127146. */
  127147. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127148. /**
  127149. * Disposes the component and the associated ressources.
  127150. */
  127151. dispose(): void;
  127152. /**
  127153. * Disables audio in the associated scene.
  127154. */
  127155. disableAudio(): void;
  127156. /**
  127157. * Enables audio in the associated scene.
  127158. */
  127159. enableAudio(): void;
  127160. /**
  127161. * Switch audio to headphone output.
  127162. */
  127163. switchAudioModeForHeadphones(): void;
  127164. /**
  127165. * Switch audio to normal speakers.
  127166. */
  127167. switchAudioModeForNormalSpeakers(): void;
  127168. private _cachedCameraDirection;
  127169. private _cachedCameraPosition;
  127170. private _lastCheck;
  127171. private _afterRender;
  127172. }
  127173. }
  127174. declare module BABYLON {
  127175. /**
  127176. * Wraps one or more Sound objects and selects one with random weight for playback.
  127177. */
  127178. export class WeightedSound {
  127179. /** When true a Sound will be selected and played when the current playing Sound completes. */
  127180. loop: boolean;
  127181. private _coneInnerAngle;
  127182. private _coneOuterAngle;
  127183. private _volume;
  127184. /** A Sound is currently playing. */
  127185. isPlaying: boolean;
  127186. /** A Sound is currently paused. */
  127187. isPaused: boolean;
  127188. private _sounds;
  127189. private _weights;
  127190. private _currentIndex?;
  127191. /**
  127192. * Creates a new WeightedSound from the list of sounds given.
  127193. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  127194. * @param sounds Array of Sounds that will be selected from.
  127195. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  127196. */
  127197. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  127198. /**
  127199. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  127200. */
  127201. get directionalConeInnerAngle(): number;
  127202. /**
  127203. * The size of cone in degress for a directional sound in which there will be no attenuation.
  127204. */
  127205. set directionalConeInnerAngle(value: number);
  127206. /**
  127207. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  127208. * Listener angles between innerAngle and outerAngle will falloff linearly.
  127209. */
  127210. get directionalConeOuterAngle(): number;
  127211. /**
  127212. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  127213. * Listener angles between innerAngle and outerAngle will falloff linearly.
  127214. */
  127215. set directionalConeOuterAngle(value: number);
  127216. /**
  127217. * Playback volume.
  127218. */
  127219. get volume(): number;
  127220. /**
  127221. * Playback volume.
  127222. */
  127223. set volume(value: number);
  127224. private _onended;
  127225. /**
  127226. * Suspend playback
  127227. */
  127228. pause(): void;
  127229. /**
  127230. * Stop playback
  127231. */
  127232. stop(): void;
  127233. /**
  127234. * Start playback.
  127235. * @param startOffset Position the clip head at a specific time in seconds.
  127236. */
  127237. play(startOffset?: number): void;
  127238. }
  127239. }
  127240. declare module BABYLON {
  127241. /**
  127242. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  127243. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  127244. */
  127245. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  127246. /**
  127247. * Gets the name of the behavior.
  127248. */
  127249. get name(): string;
  127250. /**
  127251. * The easing function used by animations
  127252. */
  127253. static EasingFunction: BackEase;
  127254. /**
  127255. * The easing mode used by animations
  127256. */
  127257. static EasingMode: number;
  127258. /**
  127259. * The duration of the animation, in milliseconds
  127260. */
  127261. transitionDuration: number;
  127262. /**
  127263. * Length of the distance animated by the transition when lower radius is reached
  127264. */
  127265. lowerRadiusTransitionRange: number;
  127266. /**
  127267. * Length of the distance animated by the transition when upper radius is reached
  127268. */
  127269. upperRadiusTransitionRange: number;
  127270. private _autoTransitionRange;
  127271. /**
  127272. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  127273. */
  127274. get autoTransitionRange(): boolean;
  127275. /**
  127276. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  127277. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  127278. */
  127279. set autoTransitionRange(value: boolean);
  127280. private _attachedCamera;
  127281. private _onAfterCheckInputsObserver;
  127282. private _onMeshTargetChangedObserver;
  127283. /**
  127284. * Initializes the behavior.
  127285. */
  127286. init(): void;
  127287. /**
  127288. * Attaches the behavior to its arc rotate camera.
  127289. * @param camera Defines the camera to attach the behavior to
  127290. */
  127291. attach(camera: ArcRotateCamera): void;
  127292. /**
  127293. * Detaches the behavior from its current arc rotate camera.
  127294. */
  127295. detach(): void;
  127296. private _radiusIsAnimating;
  127297. private _radiusBounceTransition;
  127298. private _animatables;
  127299. private _cachedWheelPrecision;
  127300. /**
  127301. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  127302. * @param radiusLimit The limit to check against.
  127303. * @return Bool to indicate if at limit.
  127304. */
  127305. private _isRadiusAtLimit;
  127306. /**
  127307. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  127308. * @param radiusDelta The delta by which to animate to. Can be negative.
  127309. */
  127310. private _applyBoundRadiusAnimation;
  127311. /**
  127312. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  127313. */
  127314. protected _clearAnimationLocks(): void;
  127315. /**
  127316. * Stops and removes all animations that have been applied to the camera
  127317. */
  127318. stopAllAnimations(): void;
  127319. }
  127320. }
  127321. declare module BABYLON {
  127322. /**
  127323. * 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.
  127324. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  127325. */
  127326. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  127327. /**
  127328. * Gets the name of the behavior.
  127329. */
  127330. get name(): string;
  127331. private _mode;
  127332. private _radiusScale;
  127333. private _positionScale;
  127334. private _defaultElevation;
  127335. private _elevationReturnTime;
  127336. private _elevationReturnWaitTime;
  127337. private _zoomStopsAnimation;
  127338. private _framingTime;
  127339. /**
  127340. * The easing function used by animations
  127341. */
  127342. static EasingFunction: ExponentialEase;
  127343. /**
  127344. * The easing mode used by animations
  127345. */
  127346. static EasingMode: number;
  127347. /**
  127348. * Sets the current mode used by the behavior
  127349. */
  127350. set mode(mode: number);
  127351. /**
  127352. * Gets current mode used by the behavior.
  127353. */
  127354. get mode(): number;
  127355. /**
  127356. * Sets the scale applied to the radius (1 by default)
  127357. */
  127358. set radiusScale(radius: number);
  127359. /**
  127360. * Gets the scale applied to the radius
  127361. */
  127362. get radiusScale(): number;
  127363. /**
  127364. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  127365. */
  127366. set positionScale(scale: number);
  127367. /**
  127368. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  127369. */
  127370. get positionScale(): number;
  127371. /**
  127372. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  127373. * behaviour is triggered, in radians.
  127374. */
  127375. set defaultElevation(elevation: number);
  127376. /**
  127377. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  127378. * behaviour is triggered, in radians.
  127379. */
  127380. get defaultElevation(): number;
  127381. /**
  127382. * Sets the time (in milliseconds) taken to return to the default beta position.
  127383. * Negative value indicates camera should not return to default.
  127384. */
  127385. set elevationReturnTime(speed: number);
  127386. /**
  127387. * Gets the time (in milliseconds) taken to return to the default beta position.
  127388. * Negative value indicates camera should not return to default.
  127389. */
  127390. get elevationReturnTime(): number;
  127391. /**
  127392. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  127393. */
  127394. set elevationReturnWaitTime(time: number);
  127395. /**
  127396. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  127397. */
  127398. get elevationReturnWaitTime(): number;
  127399. /**
  127400. * Sets the flag that indicates if user zooming should stop animation.
  127401. */
  127402. set zoomStopsAnimation(flag: boolean);
  127403. /**
  127404. * Gets the flag that indicates if user zooming should stop animation.
  127405. */
  127406. get zoomStopsAnimation(): boolean;
  127407. /**
  127408. * Sets the transition time when framing the mesh, in milliseconds
  127409. */
  127410. set framingTime(time: number);
  127411. /**
  127412. * Gets the transition time when framing the mesh, in milliseconds
  127413. */
  127414. get framingTime(): number;
  127415. /**
  127416. * Define if the behavior should automatically change the configured
  127417. * camera limits and sensibilities.
  127418. */
  127419. autoCorrectCameraLimitsAndSensibility: boolean;
  127420. private _onPrePointerObservableObserver;
  127421. private _onAfterCheckInputsObserver;
  127422. private _onMeshTargetChangedObserver;
  127423. private _attachedCamera;
  127424. private _isPointerDown;
  127425. private _lastInteractionTime;
  127426. /**
  127427. * Initializes the behavior.
  127428. */
  127429. init(): void;
  127430. /**
  127431. * Attaches the behavior to its arc rotate camera.
  127432. * @param camera Defines the camera to attach the behavior to
  127433. */
  127434. attach(camera: ArcRotateCamera): void;
  127435. /**
  127436. * Detaches the behavior from its current arc rotate camera.
  127437. */
  127438. detach(): void;
  127439. private _animatables;
  127440. private _betaIsAnimating;
  127441. private _betaTransition;
  127442. private _radiusTransition;
  127443. private _vectorTransition;
  127444. /**
  127445. * Targets the given mesh and updates zoom level accordingly.
  127446. * @param mesh The mesh to target.
  127447. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127448. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127449. */
  127450. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127451. /**
  127452. * Targets the given mesh with its children and updates zoom level accordingly.
  127453. * @param mesh The mesh to target.
  127454. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127455. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127456. */
  127457. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127458. /**
  127459. * Targets the given meshes with their children and updates zoom level accordingly.
  127460. * @param meshes The mesh to target.
  127461. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127462. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127463. */
  127464. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127465. /**
  127466. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  127467. * @param minimumWorld Determines the smaller position of the bounding box extend
  127468. * @param maximumWorld Determines the bigger position of the bounding box extend
  127469. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127470. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127471. */
  127472. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127473. /**
  127474. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  127475. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  127476. * frustum width.
  127477. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  127478. * to fully enclose the mesh in the viewing frustum.
  127479. */
  127480. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  127481. /**
  127482. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  127483. * is automatically returned to its default position (expected to be above ground plane).
  127484. */
  127485. private _maintainCameraAboveGround;
  127486. /**
  127487. * Returns the frustum slope based on the canvas ratio and camera FOV
  127488. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  127489. */
  127490. private _getFrustumSlope;
  127491. /**
  127492. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  127493. */
  127494. private _clearAnimationLocks;
  127495. /**
  127496. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  127497. */
  127498. private _applyUserInteraction;
  127499. /**
  127500. * Stops and removes all animations that have been applied to the camera
  127501. */
  127502. stopAllAnimations(): void;
  127503. /**
  127504. * Gets a value indicating if the user is moving the camera
  127505. */
  127506. get isUserIsMoving(): boolean;
  127507. /**
  127508. * The camera can move all the way towards the mesh.
  127509. */
  127510. static IgnoreBoundsSizeMode: number;
  127511. /**
  127512. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  127513. */
  127514. static FitFrustumSidesMode: number;
  127515. }
  127516. }
  127517. declare module BABYLON {
  127518. /**
  127519. * Base class for Camera Pointer Inputs.
  127520. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  127521. * for example usage.
  127522. */
  127523. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  127524. /**
  127525. * Defines the camera the input is attached to.
  127526. */
  127527. abstract camera: Camera;
  127528. /**
  127529. * Whether keyboard modifier keys are pressed at time of last mouse event.
  127530. */
  127531. protected _altKey: boolean;
  127532. protected _ctrlKey: boolean;
  127533. protected _metaKey: boolean;
  127534. protected _shiftKey: boolean;
  127535. /**
  127536. * Which mouse buttons were pressed at time of last mouse event.
  127537. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  127538. */
  127539. protected _buttonsPressed: number;
  127540. /**
  127541. * Defines the buttons associated with the input to handle camera move.
  127542. */
  127543. buttons: number[];
  127544. /**
  127545. * Attach the input controls to a specific dom element to get the input from.
  127546. * @param element Defines the element the controls should be listened from
  127547. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127548. */
  127549. attachControl(noPreventDefault?: boolean): void;
  127550. /**
  127551. * Detach the current controls from the specified dom element.
  127552. */
  127553. detachControl(): void;
  127554. /**
  127555. * Gets the class name of the current input.
  127556. * @returns the class name
  127557. */
  127558. getClassName(): string;
  127559. /**
  127560. * Get the friendly name associated with the input class.
  127561. * @returns the input friendly name
  127562. */
  127563. getSimpleName(): string;
  127564. /**
  127565. * Called on pointer POINTERDOUBLETAP event.
  127566. * Override this method to provide functionality on POINTERDOUBLETAP event.
  127567. */
  127568. protected onDoubleTap(type: string): void;
  127569. /**
  127570. * Called on pointer POINTERMOVE event if only a single touch is active.
  127571. * Override this method to provide functionality.
  127572. */
  127573. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  127574. /**
  127575. * Called on pointer POINTERMOVE event if multiple touches are active.
  127576. * Override this method to provide functionality.
  127577. */
  127578. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  127579. /**
  127580. * Called on JS contextmenu event.
  127581. * Override this method to provide functionality.
  127582. */
  127583. protected onContextMenu(evt: PointerEvent): void;
  127584. /**
  127585. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  127586. * press.
  127587. * Override this method to provide functionality.
  127588. */
  127589. protected onButtonDown(evt: PointerEvent): void;
  127590. /**
  127591. * Called each time a new POINTERUP event occurs. Ie, for each button
  127592. * release.
  127593. * Override this method to provide functionality.
  127594. */
  127595. protected onButtonUp(evt: PointerEvent): void;
  127596. /**
  127597. * Called when window becomes inactive.
  127598. * Override this method to provide functionality.
  127599. */
  127600. protected onLostFocus(): void;
  127601. private _pointerInput;
  127602. private _observer;
  127603. private _onLostFocus;
  127604. private pointA;
  127605. private pointB;
  127606. }
  127607. }
  127608. declare module BABYLON {
  127609. /**
  127610. * Manage the pointers inputs to control an arc rotate camera.
  127611. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127612. */
  127613. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  127614. /**
  127615. * Defines the camera the input is attached to.
  127616. */
  127617. camera: ArcRotateCamera;
  127618. /**
  127619. * Gets the class name of the current input.
  127620. * @returns the class name
  127621. */
  127622. getClassName(): string;
  127623. /**
  127624. * Defines the buttons associated with the input to handle camera move.
  127625. */
  127626. buttons: number[];
  127627. /**
  127628. * Defines the pointer angular sensibility along the X axis or how fast is
  127629. * the camera rotating.
  127630. */
  127631. angularSensibilityX: number;
  127632. /**
  127633. * Defines the pointer angular sensibility along the Y axis or how fast is
  127634. * the camera rotating.
  127635. */
  127636. angularSensibilityY: number;
  127637. /**
  127638. * Defines the pointer pinch precision or how fast is the camera zooming.
  127639. */
  127640. pinchPrecision: number;
  127641. /**
  127642. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  127643. * from 0.
  127644. * It defines the percentage of current camera.radius to use as delta when
  127645. * pinch zoom is used.
  127646. */
  127647. pinchDeltaPercentage: number;
  127648. /**
  127649. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  127650. * that any object in the plane at the camera's target point will scale
  127651. * perfectly with finger motion.
  127652. * Overrides pinchDeltaPercentage and pinchPrecision.
  127653. */
  127654. useNaturalPinchZoom: boolean;
  127655. /**
  127656. * Defines the pointer panning sensibility or how fast is the camera moving.
  127657. */
  127658. panningSensibility: number;
  127659. /**
  127660. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  127661. */
  127662. multiTouchPanning: boolean;
  127663. /**
  127664. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  127665. * zoom (pinch) through multitouch.
  127666. */
  127667. multiTouchPanAndZoom: boolean;
  127668. /**
  127669. * Revers pinch action direction.
  127670. */
  127671. pinchInwards: boolean;
  127672. private _isPanClick;
  127673. private _twoFingerActivityCount;
  127674. private _isPinching;
  127675. /**
  127676. * Called on pointer POINTERMOVE event if only a single touch is active.
  127677. */
  127678. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  127679. /**
  127680. * Called on pointer POINTERDOUBLETAP event.
  127681. */
  127682. protected onDoubleTap(type: string): void;
  127683. /**
  127684. * Called on pointer POINTERMOVE event if multiple touches are active.
  127685. */
  127686. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  127687. /**
  127688. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  127689. * press.
  127690. */
  127691. protected onButtonDown(evt: PointerEvent): void;
  127692. /**
  127693. * Called each time a new POINTERUP event occurs. Ie, for each button
  127694. * release.
  127695. */
  127696. protected onButtonUp(evt: PointerEvent): void;
  127697. /**
  127698. * Called when window becomes inactive.
  127699. */
  127700. protected onLostFocus(): void;
  127701. }
  127702. }
  127703. declare module BABYLON {
  127704. /**
  127705. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  127706. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127707. */
  127708. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  127709. /**
  127710. * Defines the camera the input is attached to.
  127711. */
  127712. camera: ArcRotateCamera;
  127713. /**
  127714. * Defines the list of key codes associated with the up action (increase alpha)
  127715. */
  127716. keysUp: number[];
  127717. /**
  127718. * Defines the list of key codes associated with the down action (decrease alpha)
  127719. */
  127720. keysDown: number[];
  127721. /**
  127722. * Defines the list of key codes associated with the left action (increase beta)
  127723. */
  127724. keysLeft: number[];
  127725. /**
  127726. * Defines the list of key codes associated with the right action (decrease beta)
  127727. */
  127728. keysRight: number[];
  127729. /**
  127730. * Defines the list of key codes associated with the reset action.
  127731. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  127732. */
  127733. keysReset: number[];
  127734. /**
  127735. * Defines the panning sensibility of the inputs.
  127736. * (How fast is the camera panning)
  127737. */
  127738. panningSensibility: number;
  127739. /**
  127740. * Defines the zooming sensibility of the inputs.
  127741. * (How fast is the camera zooming)
  127742. */
  127743. zoomingSensibility: number;
  127744. /**
  127745. * Defines whether maintaining the alt key down switch the movement mode from
  127746. * orientation to zoom.
  127747. */
  127748. useAltToZoom: boolean;
  127749. /**
  127750. * Rotation speed of the camera
  127751. */
  127752. angularSpeed: number;
  127753. private _keys;
  127754. private _ctrlPressed;
  127755. private _altPressed;
  127756. private _onCanvasBlurObserver;
  127757. private _onKeyboardObserver;
  127758. private _engine;
  127759. private _scene;
  127760. /**
  127761. * Attach the input controls to a specific dom element to get the input from.
  127762. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127763. */
  127764. attachControl(noPreventDefault?: boolean): void;
  127765. /**
  127766. * Detach the current controls from the specified dom element.
  127767. */
  127768. detachControl(): void;
  127769. /**
  127770. * Update the current camera state depending on the inputs that have been used this frame.
  127771. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127772. */
  127773. checkInputs(): void;
  127774. /**
  127775. * Gets the class name of the current intput.
  127776. * @returns the class name
  127777. */
  127778. getClassName(): string;
  127779. /**
  127780. * Get the friendly name associated with the input class.
  127781. * @returns the input friendly name
  127782. */
  127783. getSimpleName(): string;
  127784. }
  127785. }
  127786. declare module BABYLON {
  127787. /**
  127788. * Manage the mouse wheel inputs to control an arc rotate camera.
  127789. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127790. */
  127791. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  127792. /**
  127793. * Defines the camera the input is attached to.
  127794. */
  127795. camera: ArcRotateCamera;
  127796. /**
  127797. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  127798. */
  127799. wheelPrecision: number;
  127800. /**
  127801. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  127802. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  127803. */
  127804. wheelDeltaPercentage: number;
  127805. private _wheel;
  127806. private _observer;
  127807. private computeDeltaFromMouseWheelLegacyEvent;
  127808. /**
  127809. * Attach the input controls to a specific dom element to get the input from.
  127810. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127811. */
  127812. attachControl(noPreventDefault?: boolean): void;
  127813. /**
  127814. * Detach the current controls from the specified dom element.
  127815. */
  127816. detachControl(): void;
  127817. /**
  127818. * Gets the class name of the current intput.
  127819. * @returns the class name
  127820. */
  127821. getClassName(): string;
  127822. /**
  127823. * Get the friendly name associated with the input class.
  127824. * @returns the input friendly name
  127825. */
  127826. getSimpleName(): string;
  127827. }
  127828. }
  127829. declare module BABYLON {
  127830. /**
  127831. * Default Inputs manager for the ArcRotateCamera.
  127832. * It groups all the default supported inputs for ease of use.
  127833. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127834. */
  127835. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  127836. /**
  127837. * Instantiates a new ArcRotateCameraInputsManager.
  127838. * @param camera Defines the camera the inputs belong to
  127839. */
  127840. constructor(camera: ArcRotateCamera);
  127841. /**
  127842. * Add mouse wheel input support to the input manager.
  127843. * @returns the current input manager
  127844. */
  127845. addMouseWheel(): ArcRotateCameraInputsManager;
  127846. /**
  127847. * Add pointers input support to the input manager.
  127848. * @returns the current input manager
  127849. */
  127850. addPointers(): ArcRotateCameraInputsManager;
  127851. /**
  127852. * Add keyboard input support to the input manager.
  127853. * @returns the current input manager
  127854. */
  127855. addKeyboard(): ArcRotateCameraInputsManager;
  127856. }
  127857. }
  127858. declare module BABYLON {
  127859. /**
  127860. * This represents an orbital type of camera.
  127861. *
  127862. * 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.
  127863. * 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.
  127864. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  127865. */
  127866. export class ArcRotateCamera extends TargetCamera {
  127867. /**
  127868. * Defines the rotation angle of the camera along the longitudinal axis.
  127869. */
  127870. alpha: number;
  127871. /**
  127872. * Defines the rotation angle of the camera along the latitudinal axis.
  127873. */
  127874. beta: number;
  127875. /**
  127876. * Defines the radius of the camera from it s target point.
  127877. */
  127878. radius: number;
  127879. protected _target: Vector3;
  127880. protected _targetHost: Nullable<AbstractMesh>;
  127881. /**
  127882. * Defines the target point of the camera.
  127883. * The camera looks towards it form the radius distance.
  127884. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  127885. */
  127886. get target(): Vector3;
  127887. set target(value: Vector3);
  127888. /**
  127889. * Define the current local position of the camera in the scene
  127890. */
  127891. get position(): Vector3;
  127892. set position(newPosition: Vector3);
  127893. protected _upToYMatrix: Matrix;
  127894. protected _YToUpMatrix: Matrix;
  127895. /**
  127896. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  127897. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  127898. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  127899. */
  127900. set upVector(vec: Vector3);
  127901. get upVector(): Vector3;
  127902. /**
  127903. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  127904. */
  127905. setMatUp(): void;
  127906. /**
  127907. * Current inertia value on the longitudinal axis.
  127908. * The bigger this number the longer it will take for the camera to stop.
  127909. */
  127910. inertialAlphaOffset: number;
  127911. /**
  127912. * Current inertia value on the latitudinal axis.
  127913. * The bigger this number the longer it will take for the camera to stop.
  127914. */
  127915. inertialBetaOffset: number;
  127916. /**
  127917. * Current inertia value on the radius axis.
  127918. * The bigger this number the longer it will take for the camera to stop.
  127919. */
  127920. inertialRadiusOffset: number;
  127921. /**
  127922. * Minimum allowed angle on the longitudinal axis.
  127923. * This can help limiting how the Camera is able to move in the scene.
  127924. */
  127925. lowerAlphaLimit: Nullable<number>;
  127926. /**
  127927. * Maximum allowed angle on the longitudinal axis.
  127928. * This can help limiting how the Camera is able to move in the scene.
  127929. */
  127930. upperAlphaLimit: Nullable<number>;
  127931. /**
  127932. * Minimum allowed angle on the latitudinal axis.
  127933. * This can help limiting how the Camera is able to move in the scene.
  127934. */
  127935. lowerBetaLimit: number;
  127936. /**
  127937. * Maximum allowed angle on the latitudinal axis.
  127938. * This can help limiting how the Camera is able to move in the scene.
  127939. */
  127940. upperBetaLimit: number;
  127941. /**
  127942. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  127943. * This can help limiting how the Camera is able to move in the scene.
  127944. */
  127945. lowerRadiusLimit: Nullable<number>;
  127946. /**
  127947. * Maximum allowed distance of the camera to the target (The camera can not get further).
  127948. * This can help limiting how the Camera is able to move in the scene.
  127949. */
  127950. upperRadiusLimit: Nullable<number>;
  127951. /**
  127952. * Defines the current inertia value used during panning of the camera along the X axis.
  127953. */
  127954. inertialPanningX: number;
  127955. /**
  127956. * Defines the current inertia value used during panning of the camera along the Y axis.
  127957. */
  127958. inertialPanningY: number;
  127959. /**
  127960. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  127961. * Basically if your fingers moves away from more than this distance you will be considered
  127962. * in pinch mode.
  127963. */
  127964. pinchToPanMaxDistance: number;
  127965. /**
  127966. * Defines the maximum distance the camera can pan.
  127967. * This could help keeping the cammera always in your scene.
  127968. */
  127969. panningDistanceLimit: Nullable<number>;
  127970. /**
  127971. * Defines the target of the camera before paning.
  127972. */
  127973. panningOriginTarget: Vector3;
  127974. /**
  127975. * Defines the value of the inertia used during panning.
  127976. * 0 would mean stop inertia and one would mean no decelleration at all.
  127977. */
  127978. panningInertia: number;
  127979. /**
  127980. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  127981. */
  127982. get angularSensibilityX(): number;
  127983. set angularSensibilityX(value: number);
  127984. /**
  127985. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  127986. */
  127987. get angularSensibilityY(): number;
  127988. set angularSensibilityY(value: number);
  127989. /**
  127990. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  127991. */
  127992. get pinchPrecision(): number;
  127993. set pinchPrecision(value: number);
  127994. /**
  127995. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  127996. * It will be used instead of pinchDeltaPrecision if different from 0.
  127997. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  127998. */
  127999. get pinchDeltaPercentage(): number;
  128000. set pinchDeltaPercentage(value: number);
  128001. /**
  128002. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  128003. * and pinch delta percentage.
  128004. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  128005. * that any object in the plane at the camera's target point will scale
  128006. * perfectly with finger motion.
  128007. */
  128008. get useNaturalPinchZoom(): boolean;
  128009. set useNaturalPinchZoom(value: boolean);
  128010. /**
  128011. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  128012. */
  128013. get panningSensibility(): number;
  128014. set panningSensibility(value: number);
  128015. /**
  128016. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  128017. */
  128018. get keysUp(): number[];
  128019. set keysUp(value: number[]);
  128020. /**
  128021. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  128022. */
  128023. get keysDown(): number[];
  128024. set keysDown(value: number[]);
  128025. /**
  128026. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  128027. */
  128028. get keysLeft(): number[];
  128029. set keysLeft(value: number[]);
  128030. /**
  128031. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  128032. */
  128033. get keysRight(): number[];
  128034. set keysRight(value: number[]);
  128035. /**
  128036. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  128037. */
  128038. get wheelPrecision(): number;
  128039. set wheelPrecision(value: number);
  128040. /**
  128041. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  128042. * It will be used instead of pinchDeltaPrecision if different from 0.
  128043. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  128044. */
  128045. get wheelDeltaPercentage(): number;
  128046. set wheelDeltaPercentage(value: number);
  128047. /**
  128048. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  128049. */
  128050. zoomOnFactor: number;
  128051. /**
  128052. * Defines a screen offset for the camera position.
  128053. */
  128054. targetScreenOffset: Vector2;
  128055. /**
  128056. * Allows the camera to be completely reversed.
  128057. * If false the camera can not arrive upside down.
  128058. */
  128059. allowUpsideDown: boolean;
  128060. /**
  128061. * Define if double tap/click is used to restore the previously saved state of the camera.
  128062. */
  128063. useInputToRestoreState: boolean;
  128064. /** @hidden */
  128065. _viewMatrix: Matrix;
  128066. /** @hidden */
  128067. _useCtrlForPanning: boolean;
  128068. /** @hidden */
  128069. _panningMouseButton: number;
  128070. /**
  128071. * Defines the input associated to the camera.
  128072. */
  128073. inputs: ArcRotateCameraInputsManager;
  128074. /** @hidden */
  128075. _reset: () => void;
  128076. /**
  128077. * Defines the allowed panning axis.
  128078. */
  128079. panningAxis: Vector3;
  128080. protected _localDirection: Vector3;
  128081. protected _transformedDirection: Vector3;
  128082. private _bouncingBehavior;
  128083. /**
  128084. * Gets the bouncing behavior of the camera if it has been enabled.
  128085. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  128086. */
  128087. get bouncingBehavior(): Nullable<BouncingBehavior>;
  128088. /**
  128089. * Defines if the bouncing behavior of the camera is enabled on the camera.
  128090. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  128091. */
  128092. get useBouncingBehavior(): boolean;
  128093. set useBouncingBehavior(value: boolean);
  128094. private _framingBehavior;
  128095. /**
  128096. * Gets the framing behavior of the camera if it has been enabled.
  128097. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  128098. */
  128099. get framingBehavior(): Nullable<FramingBehavior>;
  128100. /**
  128101. * Defines if the framing behavior of the camera is enabled on the camera.
  128102. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  128103. */
  128104. get useFramingBehavior(): boolean;
  128105. set useFramingBehavior(value: boolean);
  128106. private _autoRotationBehavior;
  128107. /**
  128108. * Gets the auto rotation behavior of the camera if it has been enabled.
  128109. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  128110. */
  128111. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  128112. /**
  128113. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  128114. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  128115. */
  128116. get useAutoRotationBehavior(): boolean;
  128117. set useAutoRotationBehavior(value: boolean);
  128118. /**
  128119. * Observable triggered when the mesh target has been changed on the camera.
  128120. */
  128121. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  128122. /**
  128123. * Event raised when the camera is colliding with a mesh.
  128124. */
  128125. onCollide: (collidedMesh: AbstractMesh) => void;
  128126. /**
  128127. * Defines whether the camera should check collision with the objects oh the scene.
  128128. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  128129. */
  128130. checkCollisions: boolean;
  128131. /**
  128132. * Defines the collision radius of the camera.
  128133. * This simulates a sphere around the camera.
  128134. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  128135. */
  128136. collisionRadius: Vector3;
  128137. protected _collider: Collider;
  128138. protected _previousPosition: Vector3;
  128139. protected _collisionVelocity: Vector3;
  128140. protected _newPosition: Vector3;
  128141. protected _previousAlpha: number;
  128142. protected _previousBeta: number;
  128143. protected _previousRadius: number;
  128144. protected _collisionTriggered: boolean;
  128145. protected _targetBoundingCenter: Nullable<Vector3>;
  128146. private _computationVector;
  128147. /**
  128148. * Instantiates a new ArcRotateCamera in a given scene
  128149. * @param name Defines the name of the camera
  128150. * @param alpha Defines the camera rotation along the logitudinal axis
  128151. * @param beta Defines the camera rotation along the latitudinal axis
  128152. * @param radius Defines the camera distance from its target
  128153. * @param target Defines the camera target
  128154. * @param scene Defines the scene the camera belongs to
  128155. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  128156. */
  128157. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  128158. /** @hidden */
  128159. _initCache(): void;
  128160. /** @hidden */
  128161. _updateCache(ignoreParentClass?: boolean): void;
  128162. protected _getTargetPosition(): Vector3;
  128163. private _storedAlpha;
  128164. private _storedBeta;
  128165. private _storedRadius;
  128166. private _storedTarget;
  128167. private _storedTargetScreenOffset;
  128168. /**
  128169. * Stores the current state of the camera (alpha, beta, radius and target)
  128170. * @returns the camera itself
  128171. */
  128172. storeState(): Camera;
  128173. /**
  128174. * @hidden
  128175. * Restored camera state. You must call storeState() first
  128176. */
  128177. _restoreStateValues(): boolean;
  128178. /** @hidden */
  128179. _isSynchronizedViewMatrix(): boolean;
  128180. /**
  128181. * Attach the input controls to a specific dom element to get the input from.
  128182. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128183. */
  128184. attachControl(noPreventDefault?: boolean): void;
  128185. /**
  128186. * Attach the input controls to a specific dom element to get the input from.
  128187. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  128188. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128189. */
  128190. attachControl(ignored: any, noPreventDefault?: boolean): void;
  128191. /**
  128192. * Attached controls to the current camera.
  128193. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128194. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  128195. */
  128196. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  128197. /**
  128198. * Attached controls to the current camera.
  128199. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  128200. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128201. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  128202. */
  128203. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  128204. /**
  128205. * Attached controls to the current camera.
  128206. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128207. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  128208. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  128209. */
  128210. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  128211. /**
  128212. * Detach the current controls from the specified dom element.
  128213. */
  128214. detachControl(): void;
  128215. /**
  128216. * Detach the current controls from the specified dom element.
  128217. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  128218. */
  128219. detachControl(ignored: any): void;
  128220. /** @hidden */
  128221. _checkInputs(): void;
  128222. protected _checkLimits(): void;
  128223. /**
  128224. * Rebuilds angles (alpha, beta) and radius from the give position and target
  128225. */
  128226. rebuildAnglesAndRadius(): void;
  128227. /**
  128228. * Use a position to define the current camera related information like alpha, beta and radius
  128229. * @param position Defines the position to set the camera at
  128230. */
  128231. setPosition(position: Vector3): void;
  128232. /**
  128233. * Defines the target the camera should look at.
  128234. * This will automatically adapt alpha beta and radius to fit within the new target.
  128235. * @param target Defines the new target as a Vector or a mesh
  128236. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  128237. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  128238. */
  128239. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  128240. /** @hidden */
  128241. _getViewMatrix(): Matrix;
  128242. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  128243. /**
  128244. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  128245. * @param meshes Defines the mesh to zoom on
  128246. * @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)
  128247. */
  128248. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  128249. /**
  128250. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  128251. * The target will be changed but the radius
  128252. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  128253. * @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)
  128254. */
  128255. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  128256. min: Vector3;
  128257. max: Vector3;
  128258. distance: number;
  128259. }, doNotUpdateMaxZ?: boolean): void;
  128260. /**
  128261. * @override
  128262. * Override Camera.createRigCamera
  128263. */
  128264. createRigCamera(name: string, cameraIndex: number): Camera;
  128265. /**
  128266. * @hidden
  128267. * @override
  128268. * Override Camera._updateRigCameras
  128269. */
  128270. _updateRigCameras(): void;
  128271. /**
  128272. * Destroy the camera and release the current resources hold by it.
  128273. */
  128274. dispose(): void;
  128275. /**
  128276. * Gets the current object class name.
  128277. * @return the class name
  128278. */
  128279. getClassName(): string;
  128280. }
  128281. }
  128282. declare module BABYLON {
  128283. /**
  128284. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  128285. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  128286. */
  128287. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  128288. /**
  128289. * Gets the name of the behavior.
  128290. */
  128291. get name(): string;
  128292. private _zoomStopsAnimation;
  128293. private _idleRotationSpeed;
  128294. private _idleRotationWaitTime;
  128295. private _idleRotationSpinupTime;
  128296. /**
  128297. * Sets the flag that indicates if user zooming should stop animation.
  128298. */
  128299. set zoomStopsAnimation(flag: boolean);
  128300. /**
  128301. * Gets the flag that indicates if user zooming should stop animation.
  128302. */
  128303. get zoomStopsAnimation(): boolean;
  128304. /**
  128305. * Sets the default speed at which the camera rotates around the model.
  128306. */
  128307. set idleRotationSpeed(speed: number);
  128308. /**
  128309. * Gets the default speed at which the camera rotates around the model.
  128310. */
  128311. get idleRotationSpeed(): number;
  128312. /**
  128313. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  128314. */
  128315. set idleRotationWaitTime(time: number);
  128316. /**
  128317. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  128318. */
  128319. get idleRotationWaitTime(): number;
  128320. /**
  128321. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  128322. */
  128323. set idleRotationSpinupTime(time: number);
  128324. /**
  128325. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  128326. */
  128327. get idleRotationSpinupTime(): number;
  128328. /**
  128329. * Gets a value indicating if the camera is currently rotating because of this behavior
  128330. */
  128331. get rotationInProgress(): boolean;
  128332. private _onPrePointerObservableObserver;
  128333. private _onAfterCheckInputsObserver;
  128334. private _attachedCamera;
  128335. private _isPointerDown;
  128336. private _lastFrameTime;
  128337. private _lastInteractionTime;
  128338. private _cameraRotationSpeed;
  128339. /**
  128340. * Initializes the behavior.
  128341. */
  128342. init(): void;
  128343. /**
  128344. * Attaches the behavior to its arc rotate camera.
  128345. * @param camera Defines the camera to attach the behavior to
  128346. */
  128347. attach(camera: ArcRotateCamera): void;
  128348. /**
  128349. * Detaches the behavior from its current arc rotate camera.
  128350. */
  128351. detach(): void;
  128352. /**
  128353. * Returns true if user is scrolling.
  128354. * @return true if user is scrolling.
  128355. */
  128356. private _userIsZooming;
  128357. private _lastFrameRadius;
  128358. private _shouldAnimationStopForInteraction;
  128359. /**
  128360. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  128361. */
  128362. private _applyUserInteraction;
  128363. private _userIsMoving;
  128364. }
  128365. }
  128366. declare module BABYLON {
  128367. /**
  128368. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  128369. */
  128370. export class AttachToBoxBehavior implements Behavior<Mesh> {
  128371. private ui;
  128372. /**
  128373. * The name of the behavior
  128374. */
  128375. name: string;
  128376. /**
  128377. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  128378. */
  128379. distanceAwayFromFace: number;
  128380. /**
  128381. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  128382. */
  128383. distanceAwayFromBottomOfFace: number;
  128384. private _faceVectors;
  128385. private _target;
  128386. private _scene;
  128387. private _onRenderObserver;
  128388. private _tmpMatrix;
  128389. private _tmpVector;
  128390. /**
  128391. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  128392. * @param ui The transform node that should be attched to the mesh
  128393. */
  128394. constructor(ui: TransformNode);
  128395. /**
  128396. * Initializes the behavior
  128397. */
  128398. init(): void;
  128399. private _closestFace;
  128400. private _zeroVector;
  128401. private _lookAtTmpMatrix;
  128402. private _lookAtToRef;
  128403. /**
  128404. * Attaches the AttachToBoxBehavior to the passed in mesh
  128405. * @param target The mesh that the specified node will be attached to
  128406. */
  128407. attach(target: Mesh): void;
  128408. /**
  128409. * Detaches the behavior from the mesh
  128410. */
  128411. detach(): void;
  128412. }
  128413. }
  128414. declare module BABYLON {
  128415. /**
  128416. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  128417. */
  128418. export class FadeInOutBehavior implements Behavior<Mesh> {
  128419. /**
  128420. * Time in milliseconds to delay before fading in (Default: 0)
  128421. */
  128422. delay: number;
  128423. /**
  128424. * Time in milliseconds for the mesh to fade in (Default: 300)
  128425. */
  128426. fadeInTime: number;
  128427. private _millisecondsPerFrame;
  128428. private _hovered;
  128429. private _hoverValue;
  128430. private _ownerNode;
  128431. /**
  128432. * Instatiates the FadeInOutBehavior
  128433. */
  128434. constructor();
  128435. /**
  128436. * The name of the behavior
  128437. */
  128438. get name(): string;
  128439. /**
  128440. * Initializes the behavior
  128441. */
  128442. init(): void;
  128443. /**
  128444. * Attaches the fade behavior on the passed in mesh
  128445. * @param ownerNode The mesh that will be faded in/out once attached
  128446. */
  128447. attach(ownerNode: Mesh): void;
  128448. /**
  128449. * Detaches the behavior from the mesh
  128450. */
  128451. detach(): void;
  128452. /**
  128453. * Triggers the mesh to begin fading in or out
  128454. * @param value if the object should fade in or out (true to fade in)
  128455. */
  128456. fadeIn(value: boolean): void;
  128457. private _update;
  128458. private _setAllVisibility;
  128459. }
  128460. }
  128461. declare module BABYLON {
  128462. /**
  128463. * Class containing a set of static utilities functions for managing Pivots
  128464. * @hidden
  128465. */
  128466. export class PivotTools {
  128467. private static _PivotCached;
  128468. private static _OldPivotPoint;
  128469. private static _PivotTranslation;
  128470. private static _PivotTmpVector;
  128471. private static _PivotPostMultiplyPivotMatrix;
  128472. /** @hidden */
  128473. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  128474. /** @hidden */
  128475. static _RestorePivotPoint(mesh: AbstractMesh): void;
  128476. }
  128477. }
  128478. declare module BABYLON {
  128479. /**
  128480. * Class containing static functions to help procedurally build meshes
  128481. */
  128482. export class PlaneBuilder {
  128483. /**
  128484. * Creates a plane mesh
  128485. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  128486. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  128487. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  128488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128489. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128491. * @param name defines the name of the mesh
  128492. * @param options defines the options used to create the mesh
  128493. * @param scene defines the hosting scene
  128494. * @returns the plane mesh
  128495. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  128496. */
  128497. static CreatePlane(name: string, options: {
  128498. size?: number;
  128499. width?: number;
  128500. height?: number;
  128501. sideOrientation?: number;
  128502. frontUVs?: Vector4;
  128503. backUVs?: Vector4;
  128504. updatable?: boolean;
  128505. sourcePlane?: Plane;
  128506. }, scene?: Nullable<Scene>): Mesh;
  128507. }
  128508. }
  128509. declare module BABYLON {
  128510. /**
  128511. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  128512. */
  128513. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  128514. private static _AnyMouseID;
  128515. /**
  128516. * Abstract mesh the behavior is set on
  128517. */
  128518. attachedNode: AbstractMesh;
  128519. private _dragPlane;
  128520. private _scene;
  128521. private _pointerObserver;
  128522. private _beforeRenderObserver;
  128523. private static _planeScene;
  128524. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  128525. /**
  128526. * 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)
  128527. */
  128528. maxDragAngle: number;
  128529. /**
  128530. * @hidden
  128531. */
  128532. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  128533. /**
  128534. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  128535. */
  128536. currentDraggingPointerID: number;
  128537. /**
  128538. * The last position where the pointer hit the drag plane in world space
  128539. */
  128540. lastDragPosition: Vector3;
  128541. /**
  128542. * If the behavior is currently in a dragging state
  128543. */
  128544. dragging: boolean;
  128545. /**
  128546. * 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)
  128547. */
  128548. dragDeltaRatio: number;
  128549. /**
  128550. * If the drag plane orientation should be updated during the dragging (Default: true)
  128551. */
  128552. updateDragPlane: boolean;
  128553. private _debugMode;
  128554. private _moving;
  128555. /**
  128556. * Fires each time the attached mesh is dragged with the pointer
  128557. * * delta between last drag position and current drag position in world space
  128558. * * dragDistance along the drag axis
  128559. * * dragPlaneNormal normal of the current drag plane used during the drag
  128560. * * dragPlanePoint in world space where the drag intersects the drag plane
  128561. */
  128562. onDragObservable: Observable<{
  128563. delta: Vector3;
  128564. dragPlanePoint: Vector3;
  128565. dragPlaneNormal: Vector3;
  128566. dragDistance: number;
  128567. pointerId: number;
  128568. }>;
  128569. /**
  128570. * Fires each time a drag begins (eg. mouse down on mesh)
  128571. */
  128572. onDragStartObservable: Observable<{
  128573. dragPlanePoint: Vector3;
  128574. pointerId: number;
  128575. }>;
  128576. /**
  128577. * Fires each time a drag ends (eg. mouse release after drag)
  128578. */
  128579. onDragEndObservable: Observable<{
  128580. dragPlanePoint: Vector3;
  128581. pointerId: number;
  128582. }>;
  128583. /**
  128584. * If the attached mesh should be moved when dragged
  128585. */
  128586. moveAttached: boolean;
  128587. /**
  128588. * If the drag behavior will react to drag events (Default: true)
  128589. */
  128590. enabled: boolean;
  128591. /**
  128592. * If pointer events should start and release the drag (Default: true)
  128593. */
  128594. startAndReleaseDragOnPointerEvents: boolean;
  128595. /**
  128596. * If camera controls should be detached during the drag
  128597. */
  128598. detachCameraControls: boolean;
  128599. /**
  128600. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  128601. */
  128602. useObjectOrientationForDragging: boolean;
  128603. private _options;
  128604. /**
  128605. * Gets the options used by the behavior
  128606. */
  128607. get options(): {
  128608. dragAxis?: Vector3;
  128609. dragPlaneNormal?: Vector3;
  128610. };
  128611. /**
  128612. * Sets the options used by the behavior
  128613. */
  128614. set options(options: {
  128615. dragAxis?: Vector3;
  128616. dragPlaneNormal?: Vector3;
  128617. });
  128618. /**
  128619. * Creates a pointer drag behavior that can be attached to a mesh
  128620. * @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)
  128621. */
  128622. constructor(options?: {
  128623. dragAxis?: Vector3;
  128624. dragPlaneNormal?: Vector3;
  128625. });
  128626. /**
  128627. * Predicate to determine if it is valid to move the object to a new position when it is moved
  128628. */
  128629. validateDrag: (targetPosition: Vector3) => boolean;
  128630. /**
  128631. * The name of the behavior
  128632. */
  128633. get name(): string;
  128634. /**
  128635. * Initializes the behavior
  128636. */
  128637. init(): void;
  128638. private _tmpVector;
  128639. private _alternatePickedPoint;
  128640. private _worldDragAxis;
  128641. private _targetPosition;
  128642. private _attachedToElement;
  128643. /**
  128644. * Attaches the drag behavior the passed in mesh
  128645. * @param ownerNode The mesh that will be dragged around once attached
  128646. * @param predicate Predicate to use for pick filtering
  128647. */
  128648. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  128649. /**
  128650. * Force relase the drag action by code.
  128651. */
  128652. releaseDrag(): void;
  128653. private _startDragRay;
  128654. private _lastPointerRay;
  128655. /**
  128656. * Simulates the start of a pointer drag event on the behavior
  128657. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  128658. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  128659. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  128660. */
  128661. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  128662. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  128663. private _dragDelta;
  128664. protected _moveDrag(ray: Ray): void;
  128665. private _pickWithRayOnDragPlane;
  128666. private _pointA;
  128667. private _pointC;
  128668. private _localAxis;
  128669. private _lookAt;
  128670. private _updateDragPlanePosition;
  128671. /**
  128672. * Detaches the behavior from the mesh
  128673. */
  128674. detach(): void;
  128675. }
  128676. }
  128677. declare module BABYLON {
  128678. /**
  128679. * A behavior that when attached to a mesh will allow the mesh to be scaled
  128680. */
  128681. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  128682. private _dragBehaviorA;
  128683. private _dragBehaviorB;
  128684. private _startDistance;
  128685. private _initialScale;
  128686. private _targetScale;
  128687. private _ownerNode;
  128688. private _sceneRenderObserver;
  128689. /**
  128690. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  128691. */
  128692. constructor();
  128693. /**
  128694. * The name of the behavior
  128695. */
  128696. get name(): string;
  128697. /**
  128698. * Initializes the behavior
  128699. */
  128700. init(): void;
  128701. private _getCurrentDistance;
  128702. /**
  128703. * Attaches the scale behavior the passed in mesh
  128704. * @param ownerNode The mesh that will be scaled around once attached
  128705. */
  128706. attach(ownerNode: Mesh): void;
  128707. /**
  128708. * Detaches the behavior from the mesh
  128709. */
  128710. detach(): void;
  128711. }
  128712. }
  128713. declare module BABYLON {
  128714. /**
  128715. * 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
  128716. */
  128717. export class SixDofDragBehavior implements Behavior<Mesh> {
  128718. private static _virtualScene;
  128719. private _ownerNode;
  128720. private _sceneRenderObserver;
  128721. private _scene;
  128722. private _targetPosition;
  128723. private _virtualOriginMesh;
  128724. private _virtualDragMesh;
  128725. private _pointerObserver;
  128726. private _moving;
  128727. private _startingOrientation;
  128728. private _attachedToElement;
  128729. /**
  128730. * 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)
  128731. */
  128732. private zDragFactor;
  128733. /**
  128734. * If the object should rotate to face the drag origin
  128735. */
  128736. rotateDraggedObject: boolean;
  128737. /**
  128738. * If the behavior is currently in a dragging state
  128739. */
  128740. dragging: boolean;
  128741. /**
  128742. * 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)
  128743. */
  128744. dragDeltaRatio: number;
  128745. /**
  128746. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  128747. */
  128748. currentDraggingPointerID: number;
  128749. /**
  128750. * If camera controls should be detached during the drag
  128751. */
  128752. detachCameraControls: boolean;
  128753. /**
  128754. * Fires each time a drag starts
  128755. */
  128756. onDragStartObservable: Observable<{}>;
  128757. /**
  128758. * Fires each time a drag ends (eg. mouse release after drag)
  128759. */
  128760. onDragEndObservable: Observable<{}>;
  128761. /**
  128762. * 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
  128763. */
  128764. constructor();
  128765. /**
  128766. * The name of the behavior
  128767. */
  128768. get name(): string;
  128769. /**
  128770. * Initializes the behavior
  128771. */
  128772. init(): void;
  128773. /**
  128774. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  128775. */
  128776. private get _pointerCamera();
  128777. /**
  128778. * Attaches the scale behavior the passed in mesh
  128779. * @param ownerNode The mesh that will be scaled around once attached
  128780. */
  128781. attach(ownerNode: Mesh): void;
  128782. /**
  128783. * Detaches the behavior from the mesh
  128784. */
  128785. detach(): void;
  128786. }
  128787. }
  128788. declare module BABYLON {
  128789. /**
  128790. * Class used to apply inverse kinematics to bones
  128791. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  128792. */
  128793. export class BoneIKController {
  128794. private static _tmpVecs;
  128795. private static _tmpQuat;
  128796. private static _tmpMats;
  128797. /**
  128798. * Gets or sets the target mesh
  128799. */
  128800. targetMesh: AbstractMesh;
  128801. /** Gets or sets the mesh used as pole */
  128802. poleTargetMesh: AbstractMesh;
  128803. /**
  128804. * Gets or sets the bone used as pole
  128805. */
  128806. poleTargetBone: Nullable<Bone>;
  128807. /**
  128808. * Gets or sets the target position
  128809. */
  128810. targetPosition: Vector3;
  128811. /**
  128812. * Gets or sets the pole target position
  128813. */
  128814. poleTargetPosition: Vector3;
  128815. /**
  128816. * Gets or sets the pole target local offset
  128817. */
  128818. poleTargetLocalOffset: Vector3;
  128819. /**
  128820. * Gets or sets the pole angle
  128821. */
  128822. poleAngle: number;
  128823. /**
  128824. * Gets or sets the mesh associated with the controller
  128825. */
  128826. mesh: AbstractMesh;
  128827. /**
  128828. * 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)
  128829. */
  128830. slerpAmount: number;
  128831. private _bone1Quat;
  128832. private _bone1Mat;
  128833. private _bone2Ang;
  128834. private _bone1;
  128835. private _bone2;
  128836. private _bone1Length;
  128837. private _bone2Length;
  128838. private _maxAngle;
  128839. private _maxReach;
  128840. private _rightHandedSystem;
  128841. private _bendAxis;
  128842. private _slerping;
  128843. private _adjustRoll;
  128844. /**
  128845. * Gets or sets maximum allowed angle
  128846. */
  128847. get maxAngle(): number;
  128848. set maxAngle(value: number);
  128849. /**
  128850. * Creates a new BoneIKController
  128851. * @param mesh defines the mesh to control
  128852. * @param bone defines the bone to control
  128853. * @param options defines options to set up the controller
  128854. */
  128855. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  128856. targetMesh?: AbstractMesh;
  128857. poleTargetMesh?: AbstractMesh;
  128858. poleTargetBone?: Bone;
  128859. poleTargetLocalOffset?: Vector3;
  128860. poleAngle?: number;
  128861. bendAxis?: Vector3;
  128862. maxAngle?: number;
  128863. slerpAmount?: number;
  128864. });
  128865. private _setMaxAngle;
  128866. /**
  128867. * Force the controller to update the bones
  128868. */
  128869. update(): void;
  128870. }
  128871. }
  128872. declare module BABYLON {
  128873. /**
  128874. * Class used to make a bone look toward a point in space
  128875. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  128876. */
  128877. export class BoneLookController {
  128878. private static _tmpVecs;
  128879. private static _tmpQuat;
  128880. private static _tmpMats;
  128881. /**
  128882. * The target Vector3 that the bone will look at
  128883. */
  128884. target: Vector3;
  128885. /**
  128886. * The mesh that the bone is attached to
  128887. */
  128888. mesh: AbstractMesh;
  128889. /**
  128890. * The bone that will be looking to the target
  128891. */
  128892. bone: Bone;
  128893. /**
  128894. * The up axis of the coordinate system that is used when the bone is rotated
  128895. */
  128896. upAxis: Vector3;
  128897. /**
  128898. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  128899. */
  128900. upAxisSpace: Space;
  128901. /**
  128902. * Used to make an adjustment to the yaw of the bone
  128903. */
  128904. adjustYaw: number;
  128905. /**
  128906. * Used to make an adjustment to the pitch of the bone
  128907. */
  128908. adjustPitch: number;
  128909. /**
  128910. * Used to make an adjustment to the roll of the bone
  128911. */
  128912. adjustRoll: number;
  128913. /**
  128914. * 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)
  128915. */
  128916. slerpAmount: number;
  128917. private _minYaw;
  128918. private _maxYaw;
  128919. private _minPitch;
  128920. private _maxPitch;
  128921. private _minYawSin;
  128922. private _minYawCos;
  128923. private _maxYawSin;
  128924. private _maxYawCos;
  128925. private _midYawConstraint;
  128926. private _minPitchTan;
  128927. private _maxPitchTan;
  128928. private _boneQuat;
  128929. private _slerping;
  128930. private _transformYawPitch;
  128931. private _transformYawPitchInv;
  128932. private _firstFrameSkipped;
  128933. private _yawRange;
  128934. private _fowardAxis;
  128935. /**
  128936. * Gets or sets the minimum yaw angle that the bone can look to
  128937. */
  128938. get minYaw(): number;
  128939. set minYaw(value: number);
  128940. /**
  128941. * Gets or sets the maximum yaw angle that the bone can look to
  128942. */
  128943. get maxYaw(): number;
  128944. set maxYaw(value: number);
  128945. /**
  128946. * Gets or sets the minimum pitch angle that the bone can look to
  128947. */
  128948. get minPitch(): number;
  128949. set minPitch(value: number);
  128950. /**
  128951. * Gets or sets the maximum pitch angle that the bone can look to
  128952. */
  128953. get maxPitch(): number;
  128954. set maxPitch(value: number);
  128955. /**
  128956. * Create a BoneLookController
  128957. * @param mesh the mesh that the bone belongs to
  128958. * @param bone the bone that will be looking to the target
  128959. * @param target the target Vector3 to look at
  128960. * @param options optional settings:
  128961. * * maxYaw: the maximum angle the bone will yaw to
  128962. * * minYaw: the minimum angle the bone will yaw to
  128963. * * maxPitch: the maximum angle the bone will pitch to
  128964. * * minPitch: the minimum angle the bone will yaw to
  128965. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  128966. * * upAxis: the up axis of the coordinate system
  128967. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  128968. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  128969. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  128970. * * adjustYaw: used to make an adjustment to the yaw of the bone
  128971. * * adjustPitch: used to make an adjustment to the pitch of the bone
  128972. * * adjustRoll: used to make an adjustment to the roll of the bone
  128973. **/
  128974. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  128975. maxYaw?: number;
  128976. minYaw?: number;
  128977. maxPitch?: number;
  128978. minPitch?: number;
  128979. slerpAmount?: number;
  128980. upAxis?: Vector3;
  128981. upAxisSpace?: Space;
  128982. yawAxis?: Vector3;
  128983. pitchAxis?: Vector3;
  128984. adjustYaw?: number;
  128985. adjustPitch?: number;
  128986. adjustRoll?: number;
  128987. });
  128988. /**
  128989. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  128990. */
  128991. update(): void;
  128992. private _getAngleDiff;
  128993. private _getAngleBetween;
  128994. private _isAngleBetween;
  128995. }
  128996. }
  128997. declare module BABYLON {
  128998. /**
  128999. * Manage the gamepad inputs to control an arc rotate camera.
  129000. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129001. */
  129002. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  129003. /**
  129004. * Defines the camera the input is attached to.
  129005. */
  129006. camera: ArcRotateCamera;
  129007. /**
  129008. * Defines the gamepad the input is gathering event from.
  129009. */
  129010. gamepad: Nullable<Gamepad>;
  129011. /**
  129012. * Defines the gamepad rotation sensiblity.
  129013. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  129014. */
  129015. gamepadRotationSensibility: number;
  129016. /**
  129017. * Defines the gamepad move sensiblity.
  129018. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  129019. */
  129020. gamepadMoveSensibility: number;
  129021. private _yAxisScale;
  129022. /**
  129023. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  129024. */
  129025. get invertYAxis(): boolean;
  129026. set invertYAxis(value: boolean);
  129027. private _onGamepadConnectedObserver;
  129028. private _onGamepadDisconnectedObserver;
  129029. /**
  129030. * Attach the input controls to a specific dom element to get the input from.
  129031. */
  129032. attachControl(): void;
  129033. /**
  129034. * Detach the current controls from the specified dom element.
  129035. */
  129036. detachControl(): void;
  129037. /**
  129038. * Update the current camera state depending on the inputs that have been used this frame.
  129039. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129040. */
  129041. checkInputs(): void;
  129042. /**
  129043. * Gets the class name of the current intput.
  129044. * @returns the class name
  129045. */
  129046. getClassName(): string;
  129047. /**
  129048. * Get the friendly name associated with the input class.
  129049. * @returns the input friendly name
  129050. */
  129051. getSimpleName(): string;
  129052. }
  129053. }
  129054. declare module BABYLON {
  129055. interface ArcRotateCameraInputsManager {
  129056. /**
  129057. * Add orientation input support to the input manager.
  129058. * @returns the current input manager
  129059. */
  129060. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  129061. }
  129062. /**
  129063. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  129064. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129065. */
  129066. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  129067. /**
  129068. * Defines the camera the input is attached to.
  129069. */
  129070. camera: ArcRotateCamera;
  129071. /**
  129072. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  129073. */
  129074. alphaCorrection: number;
  129075. /**
  129076. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  129077. */
  129078. gammaCorrection: number;
  129079. private _alpha;
  129080. private _gamma;
  129081. private _dirty;
  129082. private _deviceOrientationHandler;
  129083. /**
  129084. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  129085. */
  129086. constructor();
  129087. /**
  129088. * Attach the input controls to a specific dom element to get the input from.
  129089. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129090. */
  129091. attachControl(noPreventDefault?: boolean): void;
  129092. /** @hidden */
  129093. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  129094. /**
  129095. * Update the current camera state depending on the inputs that have been used this frame.
  129096. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129097. */
  129098. checkInputs(): void;
  129099. /**
  129100. * Detach the current controls from the specified dom element.
  129101. */
  129102. detachControl(): void;
  129103. /**
  129104. * Gets the class name of the current intput.
  129105. * @returns the class name
  129106. */
  129107. getClassName(): string;
  129108. /**
  129109. * Get the friendly name associated with the input class.
  129110. * @returns the input friendly name
  129111. */
  129112. getSimpleName(): string;
  129113. }
  129114. }
  129115. declare module BABYLON {
  129116. /**
  129117. * Listen to mouse events to control the camera.
  129118. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129119. */
  129120. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  129121. /**
  129122. * Defines the camera the input is attached to.
  129123. */
  129124. camera: FlyCamera;
  129125. /**
  129126. * Defines if touch is enabled. (Default is true.)
  129127. */
  129128. touchEnabled: boolean;
  129129. /**
  129130. * Defines the buttons associated with the input to handle camera rotation.
  129131. */
  129132. buttons: number[];
  129133. /**
  129134. * Assign buttons for Yaw control.
  129135. */
  129136. buttonsYaw: number[];
  129137. /**
  129138. * Assign buttons for Pitch control.
  129139. */
  129140. buttonsPitch: number[];
  129141. /**
  129142. * Assign buttons for Roll control.
  129143. */
  129144. buttonsRoll: number[];
  129145. /**
  129146. * Detect if any button is being pressed while mouse is moved.
  129147. * -1 = Mouse locked.
  129148. * 0 = Left button.
  129149. * 1 = Middle Button.
  129150. * 2 = Right Button.
  129151. */
  129152. activeButton: number;
  129153. /**
  129154. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  129155. * Higher values reduce its sensitivity.
  129156. */
  129157. angularSensibility: number;
  129158. private _observer;
  129159. private _rollObserver;
  129160. private previousPosition;
  129161. private noPreventDefault;
  129162. private element;
  129163. /**
  129164. * Listen to mouse events to control the camera.
  129165. * @param touchEnabled Define if touch is enabled. (Default is true.)
  129166. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129167. */
  129168. constructor(touchEnabled?: boolean);
  129169. /**
  129170. * Attach the mouse control to the HTML DOM element.
  129171. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  129172. */
  129173. attachControl(noPreventDefault?: boolean): void;
  129174. /**
  129175. * Detach the current controls from the specified dom element.
  129176. */
  129177. detachControl(): void;
  129178. /**
  129179. * Gets the class name of the current input.
  129180. * @returns the class name.
  129181. */
  129182. getClassName(): string;
  129183. /**
  129184. * Get the friendly name associated with the input class.
  129185. * @returns the input's friendly name.
  129186. */
  129187. getSimpleName(): string;
  129188. private _pointerInput;
  129189. private _onMouseMove;
  129190. /**
  129191. * Rotate camera by mouse offset.
  129192. */
  129193. private rotateCamera;
  129194. }
  129195. }
  129196. declare module BABYLON {
  129197. /**
  129198. * Default Inputs manager for the FlyCamera.
  129199. * It groups all the default supported inputs for ease of use.
  129200. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129201. */
  129202. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  129203. /**
  129204. * Instantiates a new FlyCameraInputsManager.
  129205. * @param camera Defines the camera the inputs belong to.
  129206. */
  129207. constructor(camera: FlyCamera);
  129208. /**
  129209. * Add keyboard input support to the input manager.
  129210. * @returns the new FlyCameraKeyboardMoveInput().
  129211. */
  129212. addKeyboard(): FlyCameraInputsManager;
  129213. /**
  129214. * Add mouse input support to the input manager.
  129215. * @param touchEnabled Enable touch screen support.
  129216. * @returns the new FlyCameraMouseInput().
  129217. */
  129218. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  129219. }
  129220. }
  129221. declare module BABYLON {
  129222. /**
  129223. * This is a flying camera, designed for 3D movement and rotation in all directions,
  129224. * such as in a 3D Space Shooter or a Flight Simulator.
  129225. */
  129226. export class FlyCamera extends TargetCamera {
  129227. /**
  129228. * Define the collision ellipsoid of the camera.
  129229. * This is helpful for simulating a camera body, like a player's body.
  129230. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  129231. */
  129232. ellipsoid: Vector3;
  129233. /**
  129234. * Define an offset for the position of the ellipsoid around the camera.
  129235. * This can be helpful if the camera is attached away from the player's body center,
  129236. * such as at its head.
  129237. */
  129238. ellipsoidOffset: Vector3;
  129239. /**
  129240. * Enable or disable collisions of the camera with the rest of the scene objects.
  129241. */
  129242. checkCollisions: boolean;
  129243. /**
  129244. * Enable or disable gravity on the camera.
  129245. */
  129246. applyGravity: boolean;
  129247. /**
  129248. * Define the current direction the camera is moving to.
  129249. */
  129250. cameraDirection: Vector3;
  129251. /**
  129252. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  129253. * This overrides and empties cameraRotation.
  129254. */
  129255. rotationQuaternion: Quaternion;
  129256. /**
  129257. * Track Roll to maintain the wanted Rolling when looking around.
  129258. */
  129259. _trackRoll: number;
  129260. /**
  129261. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  129262. */
  129263. rollCorrect: number;
  129264. /**
  129265. * Mimic a banked turn, Rolling the camera when Yawing.
  129266. * It's recommended to use rollCorrect = 10 for faster banking correction.
  129267. */
  129268. bankedTurn: boolean;
  129269. /**
  129270. * Limit in radians for how much Roll banking will add. (Default: 90°)
  129271. */
  129272. bankedTurnLimit: number;
  129273. /**
  129274. * Value of 0 disables the banked Roll.
  129275. * Value of 1 is equal to the Yaw angle in radians.
  129276. */
  129277. bankedTurnMultiplier: number;
  129278. /**
  129279. * The inputs manager loads all the input sources, such as keyboard and mouse.
  129280. */
  129281. inputs: FlyCameraInputsManager;
  129282. /**
  129283. * Gets the input sensibility for mouse input.
  129284. * Higher values reduce sensitivity.
  129285. */
  129286. get angularSensibility(): number;
  129287. /**
  129288. * Sets the input sensibility for a mouse input.
  129289. * Higher values reduce sensitivity.
  129290. */
  129291. set angularSensibility(value: number);
  129292. /**
  129293. * Get the keys for camera movement forward.
  129294. */
  129295. get keysForward(): number[];
  129296. /**
  129297. * Set the keys for camera movement forward.
  129298. */
  129299. set keysForward(value: number[]);
  129300. /**
  129301. * Get the keys for camera movement backward.
  129302. */
  129303. get keysBackward(): number[];
  129304. set keysBackward(value: number[]);
  129305. /**
  129306. * Get the keys for camera movement up.
  129307. */
  129308. get keysUp(): number[];
  129309. /**
  129310. * Set the keys for camera movement up.
  129311. */
  129312. set keysUp(value: number[]);
  129313. /**
  129314. * Get the keys for camera movement down.
  129315. */
  129316. get keysDown(): number[];
  129317. /**
  129318. * Set the keys for camera movement down.
  129319. */
  129320. set keysDown(value: number[]);
  129321. /**
  129322. * Get the keys for camera movement left.
  129323. */
  129324. get keysLeft(): number[];
  129325. /**
  129326. * Set the keys for camera movement left.
  129327. */
  129328. set keysLeft(value: number[]);
  129329. /**
  129330. * Set the keys for camera movement right.
  129331. */
  129332. get keysRight(): number[];
  129333. /**
  129334. * Set the keys for camera movement right.
  129335. */
  129336. set keysRight(value: number[]);
  129337. /**
  129338. * Event raised when the camera collides with a mesh in the scene.
  129339. */
  129340. onCollide: (collidedMesh: AbstractMesh) => void;
  129341. private _collider;
  129342. private _needMoveForGravity;
  129343. private _oldPosition;
  129344. private _diffPosition;
  129345. private _newPosition;
  129346. /** @hidden */
  129347. _localDirection: Vector3;
  129348. /** @hidden */
  129349. _transformedDirection: Vector3;
  129350. /**
  129351. * Instantiates a FlyCamera.
  129352. * This is a flying camera, designed for 3D movement and rotation in all directions,
  129353. * such as in a 3D Space Shooter or a Flight Simulator.
  129354. * @param name Define the name of the camera in the scene.
  129355. * @param position Define the starting position of the camera in the scene.
  129356. * @param scene Define the scene the camera belongs to.
  129357. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  129358. */
  129359. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  129360. /**
  129361. * Attach the input controls to a specific dom element to get the input from.
  129362. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129363. */
  129364. attachControl(noPreventDefault?: boolean): void;
  129365. /**
  129366. * Detach a control from the HTML DOM element.
  129367. * The camera will stop reacting to that input.
  129368. */
  129369. detachControl(): void;
  129370. private _collisionMask;
  129371. /**
  129372. * Get the mask that the camera ignores in collision events.
  129373. */
  129374. get collisionMask(): number;
  129375. /**
  129376. * Set the mask that the camera ignores in collision events.
  129377. */
  129378. set collisionMask(mask: number);
  129379. /** @hidden */
  129380. _collideWithWorld(displacement: Vector3): void;
  129381. /** @hidden */
  129382. private _onCollisionPositionChange;
  129383. /** @hidden */
  129384. _checkInputs(): void;
  129385. /** @hidden */
  129386. _decideIfNeedsToMove(): boolean;
  129387. /** @hidden */
  129388. _updatePosition(): void;
  129389. /**
  129390. * Restore the Roll to its target value at the rate specified.
  129391. * @param rate - Higher means slower restoring.
  129392. * @hidden
  129393. */
  129394. restoreRoll(rate: number): void;
  129395. /**
  129396. * Destroy the camera and release the current resources held by it.
  129397. */
  129398. dispose(): void;
  129399. /**
  129400. * Get the current object class name.
  129401. * @returns the class name.
  129402. */
  129403. getClassName(): string;
  129404. }
  129405. }
  129406. declare module BABYLON {
  129407. /**
  129408. * Listen to keyboard events to control the camera.
  129409. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129410. */
  129411. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  129412. /**
  129413. * Defines the camera the input is attached to.
  129414. */
  129415. camera: FlyCamera;
  129416. /**
  129417. * The list of keyboard keys used to control the forward move of the camera.
  129418. */
  129419. keysForward: number[];
  129420. /**
  129421. * The list of keyboard keys used to control the backward move of the camera.
  129422. */
  129423. keysBackward: number[];
  129424. /**
  129425. * The list of keyboard keys used to control the forward move of the camera.
  129426. */
  129427. keysUp: number[];
  129428. /**
  129429. * The list of keyboard keys used to control the backward move of the camera.
  129430. */
  129431. keysDown: number[];
  129432. /**
  129433. * The list of keyboard keys used to control the right strafe move of the camera.
  129434. */
  129435. keysRight: number[];
  129436. /**
  129437. * The list of keyboard keys used to control the left strafe move of the camera.
  129438. */
  129439. keysLeft: number[];
  129440. private _keys;
  129441. private _onCanvasBlurObserver;
  129442. private _onKeyboardObserver;
  129443. private _engine;
  129444. private _scene;
  129445. /**
  129446. * Attach the input controls to a specific dom element to get the input from.
  129447. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129448. */
  129449. attachControl(noPreventDefault?: boolean): void;
  129450. /**
  129451. * Detach the current controls from the specified dom element.
  129452. */
  129453. detachControl(): void;
  129454. /**
  129455. * Gets the class name of the current intput.
  129456. * @returns the class name
  129457. */
  129458. getClassName(): string;
  129459. /** @hidden */
  129460. _onLostFocus(e: FocusEvent): void;
  129461. /**
  129462. * Get the friendly name associated with the input class.
  129463. * @returns the input friendly name
  129464. */
  129465. getSimpleName(): string;
  129466. /**
  129467. * Update the current camera state depending on the inputs that have been used this frame.
  129468. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129469. */
  129470. checkInputs(): void;
  129471. }
  129472. }
  129473. declare module BABYLON {
  129474. /**
  129475. * Manage the mouse wheel inputs to control a follow camera.
  129476. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129477. */
  129478. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  129479. /**
  129480. * Defines the camera the input is attached to.
  129481. */
  129482. camera: FollowCamera;
  129483. /**
  129484. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  129485. */
  129486. axisControlRadius: boolean;
  129487. /**
  129488. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  129489. */
  129490. axisControlHeight: boolean;
  129491. /**
  129492. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  129493. */
  129494. axisControlRotation: boolean;
  129495. /**
  129496. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  129497. * relation to mouseWheel events.
  129498. */
  129499. wheelPrecision: number;
  129500. /**
  129501. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  129502. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  129503. */
  129504. wheelDeltaPercentage: number;
  129505. private _wheel;
  129506. private _observer;
  129507. /**
  129508. * Attach the input controls to a specific dom element to get the input from.
  129509. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129510. */
  129511. attachControl(noPreventDefault?: boolean): void;
  129512. /**
  129513. * Detach the current controls from the specified dom element.
  129514. */
  129515. detachControl(): void;
  129516. /**
  129517. * Gets the class name of the current intput.
  129518. * @returns the class name
  129519. */
  129520. getClassName(): string;
  129521. /**
  129522. * Get the friendly name associated with the input class.
  129523. * @returns the input friendly name
  129524. */
  129525. getSimpleName(): string;
  129526. }
  129527. }
  129528. declare module BABYLON {
  129529. /**
  129530. * Manage the pointers inputs to control an follow camera.
  129531. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129532. */
  129533. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  129534. /**
  129535. * Defines the camera the input is attached to.
  129536. */
  129537. camera: FollowCamera;
  129538. /**
  129539. * Gets the class name of the current input.
  129540. * @returns the class name
  129541. */
  129542. getClassName(): string;
  129543. /**
  129544. * Defines the pointer angular sensibility along the X axis or how fast is
  129545. * the camera rotating.
  129546. * A negative number will reverse the axis direction.
  129547. */
  129548. angularSensibilityX: number;
  129549. /**
  129550. * Defines the pointer angular sensibility along the Y axis or how fast is
  129551. * the camera rotating.
  129552. * A negative number will reverse the axis direction.
  129553. */
  129554. angularSensibilityY: number;
  129555. /**
  129556. * Defines the pointer pinch precision or how fast is the camera zooming.
  129557. * A negative number will reverse the axis direction.
  129558. */
  129559. pinchPrecision: number;
  129560. /**
  129561. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  129562. * from 0.
  129563. * It defines the percentage of current camera.radius to use as delta when
  129564. * pinch zoom is used.
  129565. */
  129566. pinchDeltaPercentage: number;
  129567. /**
  129568. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  129569. */
  129570. axisXControlRadius: boolean;
  129571. /**
  129572. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  129573. */
  129574. axisXControlHeight: boolean;
  129575. /**
  129576. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  129577. */
  129578. axisXControlRotation: boolean;
  129579. /**
  129580. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  129581. */
  129582. axisYControlRadius: boolean;
  129583. /**
  129584. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  129585. */
  129586. axisYControlHeight: boolean;
  129587. /**
  129588. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  129589. */
  129590. axisYControlRotation: boolean;
  129591. /**
  129592. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  129593. */
  129594. axisPinchControlRadius: boolean;
  129595. /**
  129596. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  129597. */
  129598. axisPinchControlHeight: boolean;
  129599. /**
  129600. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  129601. */
  129602. axisPinchControlRotation: boolean;
  129603. /**
  129604. * Log error messages if basic misconfiguration has occurred.
  129605. */
  129606. warningEnable: boolean;
  129607. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  129608. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  129609. private _warningCounter;
  129610. private _warning;
  129611. }
  129612. }
  129613. declare module BABYLON {
  129614. /**
  129615. * Default Inputs manager for the FollowCamera.
  129616. * It groups all the default supported inputs for ease of use.
  129617. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129618. */
  129619. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  129620. /**
  129621. * Instantiates a new FollowCameraInputsManager.
  129622. * @param camera Defines the camera the inputs belong to
  129623. */
  129624. constructor(camera: FollowCamera);
  129625. /**
  129626. * Add keyboard input support to the input manager.
  129627. * @returns the current input manager
  129628. */
  129629. addKeyboard(): FollowCameraInputsManager;
  129630. /**
  129631. * Add mouse wheel input support to the input manager.
  129632. * @returns the current input manager
  129633. */
  129634. addMouseWheel(): FollowCameraInputsManager;
  129635. /**
  129636. * Add pointers input support to the input manager.
  129637. * @returns the current input manager
  129638. */
  129639. addPointers(): FollowCameraInputsManager;
  129640. /**
  129641. * Add orientation input support to the input manager.
  129642. * @returns the current input manager
  129643. */
  129644. addVRDeviceOrientation(): FollowCameraInputsManager;
  129645. }
  129646. }
  129647. declare module BABYLON {
  129648. /**
  129649. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  129650. * an arc rotate version arcFollowCamera are available.
  129651. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129652. */
  129653. export class FollowCamera extends TargetCamera {
  129654. /**
  129655. * Distance the follow camera should follow an object at
  129656. */
  129657. radius: number;
  129658. /**
  129659. * Minimum allowed distance of the camera to the axis of rotation
  129660. * (The camera can not get closer).
  129661. * This can help limiting how the Camera is able to move in the scene.
  129662. */
  129663. lowerRadiusLimit: Nullable<number>;
  129664. /**
  129665. * Maximum allowed distance of the camera to the axis of rotation
  129666. * (The camera can not get further).
  129667. * This can help limiting how the Camera is able to move in the scene.
  129668. */
  129669. upperRadiusLimit: Nullable<number>;
  129670. /**
  129671. * Define a rotation offset between the camera and the object it follows
  129672. */
  129673. rotationOffset: number;
  129674. /**
  129675. * Minimum allowed angle to camera position relative to target object.
  129676. * This can help limiting how the Camera is able to move in the scene.
  129677. */
  129678. lowerRotationOffsetLimit: Nullable<number>;
  129679. /**
  129680. * Maximum allowed angle to camera position relative to target object.
  129681. * This can help limiting how the Camera is able to move in the scene.
  129682. */
  129683. upperRotationOffsetLimit: Nullable<number>;
  129684. /**
  129685. * Define a height offset between the camera and the object it follows.
  129686. * It can help following an object from the top (like a car chaing a plane)
  129687. */
  129688. heightOffset: number;
  129689. /**
  129690. * Minimum allowed height of camera position relative to target object.
  129691. * This can help limiting how the Camera is able to move in the scene.
  129692. */
  129693. lowerHeightOffsetLimit: Nullable<number>;
  129694. /**
  129695. * Maximum allowed height of camera position relative to target object.
  129696. * This can help limiting how the Camera is able to move in the scene.
  129697. */
  129698. upperHeightOffsetLimit: Nullable<number>;
  129699. /**
  129700. * Define how fast the camera can accelerate to follow it s target.
  129701. */
  129702. cameraAcceleration: number;
  129703. /**
  129704. * Define the speed limit of the camera following an object.
  129705. */
  129706. maxCameraSpeed: number;
  129707. /**
  129708. * Define the target of the camera.
  129709. */
  129710. lockedTarget: Nullable<AbstractMesh>;
  129711. /**
  129712. * Defines the input associated with the camera.
  129713. */
  129714. inputs: FollowCameraInputsManager;
  129715. /**
  129716. * Instantiates the follow camera.
  129717. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129718. * @param name Define the name of the camera in the scene
  129719. * @param position Define the position of the camera
  129720. * @param scene Define the scene the camera belong to
  129721. * @param lockedTarget Define the target of the camera
  129722. */
  129723. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  129724. private _follow;
  129725. /**
  129726. * Attach the input controls to a specific dom element to get the input from.
  129727. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129728. */
  129729. attachControl(noPreventDefault?: boolean): void;
  129730. /**
  129731. * Detach the current controls from the specified dom element.
  129732. */
  129733. detachControl(): void;
  129734. /** @hidden */
  129735. _checkInputs(): void;
  129736. private _checkLimits;
  129737. /**
  129738. * Gets the camera class name.
  129739. * @returns the class name
  129740. */
  129741. getClassName(): string;
  129742. }
  129743. /**
  129744. * Arc Rotate version of the follow camera.
  129745. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  129746. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129747. */
  129748. export class ArcFollowCamera extends TargetCamera {
  129749. /** The longitudinal angle of the camera */
  129750. alpha: number;
  129751. /** The latitudinal angle of the camera */
  129752. beta: number;
  129753. /** The radius of the camera from its target */
  129754. radius: number;
  129755. private _cartesianCoordinates;
  129756. /** Define the camera target (the mesh it should follow) */
  129757. private _meshTarget;
  129758. /**
  129759. * Instantiates a new ArcFollowCamera
  129760. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129761. * @param name Define the name of the camera
  129762. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  129763. * @param beta Define the rotation angle of the camera around the elevation axis
  129764. * @param radius Define the radius of the camera from its target point
  129765. * @param target Define the target of the camera
  129766. * @param scene Define the scene the camera belongs to
  129767. */
  129768. constructor(name: string,
  129769. /** The longitudinal angle of the camera */
  129770. alpha: number,
  129771. /** The latitudinal angle of the camera */
  129772. beta: number,
  129773. /** The radius of the camera from its target */
  129774. radius: number,
  129775. /** Define the camera target (the mesh it should follow) */
  129776. target: Nullable<AbstractMesh>, scene: Scene);
  129777. private _follow;
  129778. /** @hidden */
  129779. _checkInputs(): void;
  129780. /**
  129781. * Returns the class name of the object.
  129782. * It is mostly used internally for serialization purposes.
  129783. */
  129784. getClassName(): string;
  129785. }
  129786. }
  129787. declare module BABYLON {
  129788. /**
  129789. * Manage the keyboard inputs to control the movement of a follow camera.
  129790. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129791. */
  129792. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  129793. /**
  129794. * Defines the camera the input is attached to.
  129795. */
  129796. camera: FollowCamera;
  129797. /**
  129798. * Defines the list of key codes associated with the up action (increase heightOffset)
  129799. */
  129800. keysHeightOffsetIncr: number[];
  129801. /**
  129802. * Defines the list of key codes associated with the down action (decrease heightOffset)
  129803. */
  129804. keysHeightOffsetDecr: number[];
  129805. /**
  129806. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  129807. */
  129808. keysHeightOffsetModifierAlt: boolean;
  129809. /**
  129810. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  129811. */
  129812. keysHeightOffsetModifierCtrl: boolean;
  129813. /**
  129814. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  129815. */
  129816. keysHeightOffsetModifierShift: boolean;
  129817. /**
  129818. * Defines the list of key codes associated with the left action (increase rotationOffset)
  129819. */
  129820. keysRotationOffsetIncr: number[];
  129821. /**
  129822. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  129823. */
  129824. keysRotationOffsetDecr: number[];
  129825. /**
  129826. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  129827. */
  129828. keysRotationOffsetModifierAlt: boolean;
  129829. /**
  129830. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  129831. */
  129832. keysRotationOffsetModifierCtrl: boolean;
  129833. /**
  129834. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  129835. */
  129836. keysRotationOffsetModifierShift: boolean;
  129837. /**
  129838. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  129839. */
  129840. keysRadiusIncr: number[];
  129841. /**
  129842. * Defines the list of key codes associated with the zoom-out action (increase radius)
  129843. */
  129844. keysRadiusDecr: number[];
  129845. /**
  129846. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  129847. */
  129848. keysRadiusModifierAlt: boolean;
  129849. /**
  129850. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  129851. */
  129852. keysRadiusModifierCtrl: boolean;
  129853. /**
  129854. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  129855. */
  129856. keysRadiusModifierShift: boolean;
  129857. /**
  129858. * Defines the rate of change of heightOffset.
  129859. */
  129860. heightSensibility: number;
  129861. /**
  129862. * Defines the rate of change of rotationOffset.
  129863. */
  129864. rotationSensibility: number;
  129865. /**
  129866. * Defines the rate of change of radius.
  129867. */
  129868. radiusSensibility: number;
  129869. private _keys;
  129870. private _ctrlPressed;
  129871. private _altPressed;
  129872. private _shiftPressed;
  129873. private _onCanvasBlurObserver;
  129874. private _onKeyboardObserver;
  129875. private _engine;
  129876. private _scene;
  129877. /**
  129878. * Attach the input controls to a specific dom element to get the input from.
  129879. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129880. */
  129881. attachControl(noPreventDefault?: boolean): void;
  129882. /**
  129883. * Detach the current controls from the specified dom element.
  129884. */
  129885. detachControl(): void;
  129886. /**
  129887. * Update the current camera state depending on the inputs that have been used this frame.
  129888. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129889. */
  129890. checkInputs(): void;
  129891. /**
  129892. * Gets the class name of the current input.
  129893. * @returns the class name
  129894. */
  129895. getClassName(): string;
  129896. /**
  129897. * Get the friendly name associated with the input class.
  129898. * @returns the input friendly name
  129899. */
  129900. getSimpleName(): string;
  129901. /**
  129902. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  129903. * allow modification of the heightOffset value.
  129904. */
  129905. private _modifierHeightOffset;
  129906. /**
  129907. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  129908. * allow modification of the rotationOffset value.
  129909. */
  129910. private _modifierRotationOffset;
  129911. /**
  129912. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  129913. * allow modification of the radius value.
  129914. */
  129915. private _modifierRadius;
  129916. }
  129917. }
  129918. declare module BABYLON {
  129919. interface FreeCameraInputsManager {
  129920. /**
  129921. * @hidden
  129922. */
  129923. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  129924. /**
  129925. * Add orientation input support to the input manager.
  129926. * @returns the current input manager
  129927. */
  129928. addDeviceOrientation(): FreeCameraInputsManager;
  129929. }
  129930. /**
  129931. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  129932. * Screen rotation is taken into account.
  129933. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129934. */
  129935. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  129936. private _camera;
  129937. private _screenOrientationAngle;
  129938. private _constantTranform;
  129939. private _screenQuaternion;
  129940. private _alpha;
  129941. private _beta;
  129942. private _gamma;
  129943. /**
  129944. * Can be used to detect if a device orientation sensor is available on a device
  129945. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  129946. * @returns a promise that will resolve on orientation change
  129947. */
  129948. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  129949. /**
  129950. * @hidden
  129951. */
  129952. _onDeviceOrientationChangedObservable: Observable<void>;
  129953. /**
  129954. * Instantiates a new input
  129955. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129956. */
  129957. constructor();
  129958. /**
  129959. * Define the camera controlled by the input.
  129960. */
  129961. get camera(): FreeCamera;
  129962. set camera(camera: FreeCamera);
  129963. /**
  129964. * Attach the input controls to a specific dom element to get the input from.
  129965. */
  129966. attachControl(): void;
  129967. private _orientationChanged;
  129968. private _deviceOrientation;
  129969. /**
  129970. * Detach the current controls from the specified dom element.
  129971. */
  129972. detachControl(): void;
  129973. /**
  129974. * Update the current camera state depending on the inputs that have been used this frame.
  129975. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129976. */
  129977. checkInputs(): void;
  129978. /**
  129979. * Gets the class name of the current intput.
  129980. * @returns the class name
  129981. */
  129982. getClassName(): string;
  129983. /**
  129984. * Get the friendly name associated with the input class.
  129985. * @returns the input friendly name
  129986. */
  129987. getSimpleName(): string;
  129988. }
  129989. }
  129990. declare module BABYLON {
  129991. /**
  129992. * Manage the gamepad inputs to control a free camera.
  129993. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129994. */
  129995. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  129996. /**
  129997. * Define the camera the input is attached to.
  129998. */
  129999. camera: FreeCamera;
  130000. /**
  130001. * Define the Gamepad controlling the input
  130002. */
  130003. gamepad: Nullable<Gamepad>;
  130004. /**
  130005. * Defines the gamepad rotation sensiblity.
  130006. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  130007. */
  130008. gamepadAngularSensibility: number;
  130009. /**
  130010. * Defines the gamepad move sensiblity.
  130011. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  130012. */
  130013. gamepadMoveSensibility: number;
  130014. private _yAxisScale;
  130015. /**
  130016. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  130017. */
  130018. get invertYAxis(): boolean;
  130019. set invertYAxis(value: boolean);
  130020. private _onGamepadConnectedObserver;
  130021. private _onGamepadDisconnectedObserver;
  130022. private _cameraTransform;
  130023. private _deltaTransform;
  130024. private _vector3;
  130025. private _vector2;
  130026. /**
  130027. * Attach the input controls to a specific dom element to get the input from.
  130028. */
  130029. attachControl(): void;
  130030. /**
  130031. * Detach the current controls from the specified dom element.
  130032. */
  130033. detachControl(): void;
  130034. /**
  130035. * Update the current camera state depending on the inputs that have been used this frame.
  130036. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  130037. */
  130038. checkInputs(): void;
  130039. /**
  130040. * Gets the class name of the current intput.
  130041. * @returns the class name
  130042. */
  130043. getClassName(): string;
  130044. /**
  130045. * Get the friendly name associated with the input class.
  130046. * @returns the input friendly name
  130047. */
  130048. getSimpleName(): string;
  130049. }
  130050. }
  130051. declare module BABYLON {
  130052. /**
  130053. * Defines the potential axis of a Joystick
  130054. */
  130055. export enum JoystickAxis {
  130056. /** X axis */
  130057. X = 0,
  130058. /** Y axis */
  130059. Y = 1,
  130060. /** Z axis */
  130061. Z = 2
  130062. }
  130063. /**
  130064. * Represents the different customization options available
  130065. * for VirtualJoystick
  130066. */
  130067. interface VirtualJoystickCustomizations {
  130068. /**
  130069. * Size of the joystick's puck
  130070. */
  130071. puckSize: number;
  130072. /**
  130073. * Size of the joystick's container
  130074. */
  130075. containerSize: number;
  130076. /**
  130077. * Color of the joystick && puck
  130078. */
  130079. color: string;
  130080. /**
  130081. * Image URL for the joystick's puck
  130082. */
  130083. puckImage?: string;
  130084. /**
  130085. * Image URL for the joystick's container
  130086. */
  130087. containerImage?: string;
  130088. /**
  130089. * Defines the unmoving position of the joystick container
  130090. */
  130091. position?: {
  130092. x: number;
  130093. y: number;
  130094. };
  130095. /**
  130096. * Defines whether or not the joystick container is always visible
  130097. */
  130098. alwaysVisible: boolean;
  130099. /**
  130100. * Defines whether or not to limit the movement of the puck to the joystick's container
  130101. */
  130102. limitToContainer: boolean;
  130103. }
  130104. /**
  130105. * Class used to define virtual joystick (used in touch mode)
  130106. */
  130107. export class VirtualJoystick {
  130108. /**
  130109. * Gets or sets a boolean indicating that left and right values must be inverted
  130110. */
  130111. reverseLeftRight: boolean;
  130112. /**
  130113. * Gets or sets a boolean indicating that up and down values must be inverted
  130114. */
  130115. reverseUpDown: boolean;
  130116. /**
  130117. * Gets the offset value for the position (ie. the change of the position value)
  130118. */
  130119. deltaPosition: Vector3;
  130120. /**
  130121. * Gets a boolean indicating if the virtual joystick was pressed
  130122. */
  130123. pressed: boolean;
  130124. /**
  130125. * Canvas the virtual joystick will render onto, default z-index of this is 5
  130126. */
  130127. static Canvas: Nullable<HTMLCanvasElement>;
  130128. /**
  130129. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  130130. */
  130131. limitToContainer: boolean;
  130132. private static _globalJoystickIndex;
  130133. private static _alwaysVisibleSticks;
  130134. private static vjCanvasContext;
  130135. private static vjCanvasWidth;
  130136. private static vjCanvasHeight;
  130137. private static halfWidth;
  130138. private static _GetDefaultOptions;
  130139. private _action;
  130140. private _axisTargetedByLeftAndRight;
  130141. private _axisTargetedByUpAndDown;
  130142. private _joystickSensibility;
  130143. private _inversedSensibility;
  130144. private _joystickPointerID;
  130145. private _joystickColor;
  130146. private _joystickPointerPos;
  130147. private _joystickPreviousPointerPos;
  130148. private _joystickPointerStartPos;
  130149. private _deltaJoystickVector;
  130150. private _leftJoystick;
  130151. private _touches;
  130152. private _joystickPosition;
  130153. private _alwaysVisible;
  130154. private _puckImage;
  130155. private _containerImage;
  130156. private _joystickPuckSize;
  130157. private _joystickContainerSize;
  130158. private _clearPuckSize;
  130159. private _clearContainerSize;
  130160. private _clearPuckSizeOffset;
  130161. private _clearContainerSizeOffset;
  130162. private _onPointerDownHandlerRef;
  130163. private _onPointerMoveHandlerRef;
  130164. private _onPointerUpHandlerRef;
  130165. private _onResize;
  130166. /**
  130167. * Creates a new virtual joystick
  130168. * @param leftJoystick defines that the joystick is for left hand (false by default)
  130169. * @param customizations Defines the options we want to customize the VirtualJoystick
  130170. */
  130171. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  130172. /**
  130173. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  130174. * @param newJoystickSensibility defines the new sensibility
  130175. */
  130176. setJoystickSensibility(newJoystickSensibility: number): void;
  130177. private _onPointerDown;
  130178. private _onPointerMove;
  130179. private _onPointerUp;
  130180. /**
  130181. * Change the color of the virtual joystick
  130182. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  130183. */
  130184. setJoystickColor(newColor: string): void;
  130185. /**
  130186. * Size of the joystick's container
  130187. */
  130188. set containerSize(newSize: number);
  130189. get containerSize(): number;
  130190. /**
  130191. * Size of the joystick's puck
  130192. */
  130193. set puckSize(newSize: number);
  130194. get puckSize(): number;
  130195. /**
  130196. * Clears the set position of the joystick
  130197. */
  130198. clearPosition(): void;
  130199. /**
  130200. * Defines whether or not the joystick container is always visible
  130201. */
  130202. set alwaysVisible(value: boolean);
  130203. get alwaysVisible(): boolean;
  130204. /**
  130205. * Sets the constant position of the Joystick container
  130206. * @param x X axis coordinate
  130207. * @param y Y axis coordinate
  130208. */
  130209. setPosition(x: number, y: number): void;
  130210. /**
  130211. * Defines a callback to call when the joystick is touched
  130212. * @param action defines the callback
  130213. */
  130214. setActionOnTouch(action: () => any): void;
  130215. /**
  130216. * Defines which axis you'd like to control for left & right
  130217. * @param axis defines the axis to use
  130218. */
  130219. setAxisForLeftRight(axis: JoystickAxis): void;
  130220. /**
  130221. * Defines which axis you'd like to control for up & down
  130222. * @param axis defines the axis to use
  130223. */
  130224. setAxisForUpDown(axis: JoystickAxis): void;
  130225. /**
  130226. * Clears the canvas from the previous puck / container draw
  130227. */
  130228. private _clearPreviousDraw;
  130229. /**
  130230. * Loads `urlPath` to be used for the container's image
  130231. * @param urlPath defines the urlPath of an image to use
  130232. */
  130233. setContainerImage(urlPath: string): void;
  130234. /**
  130235. * Loads `urlPath` to be used for the puck's image
  130236. * @param urlPath defines the urlPath of an image to use
  130237. */
  130238. setPuckImage(urlPath: string): void;
  130239. /**
  130240. * Draws the Virtual Joystick's container
  130241. */
  130242. private _drawContainer;
  130243. /**
  130244. * Draws the Virtual Joystick's puck
  130245. */
  130246. private _drawPuck;
  130247. private _drawVirtualJoystick;
  130248. /**
  130249. * Release internal HTML canvas
  130250. */
  130251. releaseCanvas(): void;
  130252. }
  130253. }
  130254. declare module BABYLON {
  130255. interface FreeCameraInputsManager {
  130256. /**
  130257. * Add virtual joystick input support to the input manager.
  130258. * @returns the current input manager
  130259. */
  130260. addVirtualJoystick(): FreeCameraInputsManager;
  130261. }
  130262. /**
  130263. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  130264. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  130265. */
  130266. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  130267. /**
  130268. * Defines the camera the input is attached to.
  130269. */
  130270. camera: FreeCamera;
  130271. private _leftjoystick;
  130272. private _rightjoystick;
  130273. /**
  130274. * Gets the left stick of the virtual joystick.
  130275. * @returns The virtual Joystick
  130276. */
  130277. getLeftJoystick(): VirtualJoystick;
  130278. /**
  130279. * Gets the right stick of the virtual joystick.
  130280. * @returns The virtual Joystick
  130281. */
  130282. getRightJoystick(): VirtualJoystick;
  130283. /**
  130284. * Update the current camera state depending on the inputs that have been used this frame.
  130285. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  130286. */
  130287. checkInputs(): void;
  130288. /**
  130289. * Attach the input controls to a specific dom element to get the input from.
  130290. */
  130291. attachControl(): void;
  130292. /**
  130293. * Detach the current controls from the specified dom element.
  130294. */
  130295. detachControl(): void;
  130296. /**
  130297. * Gets the class name of the current intput.
  130298. * @returns the class name
  130299. */
  130300. getClassName(): string;
  130301. /**
  130302. * Get the friendly name associated with the input class.
  130303. * @returns the input friendly name
  130304. */
  130305. getSimpleName(): string;
  130306. }
  130307. }
  130308. declare module BABYLON {
  130309. /**
  130310. * This represents a FPS type of camera controlled by touch.
  130311. * This is like a universal camera minus the Gamepad controls.
  130312. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130313. */
  130314. export class TouchCamera extends FreeCamera {
  130315. /**
  130316. * Defines the touch sensibility for rotation.
  130317. * The higher the faster.
  130318. */
  130319. get touchAngularSensibility(): number;
  130320. set touchAngularSensibility(value: number);
  130321. /**
  130322. * Defines the touch sensibility for move.
  130323. * The higher the faster.
  130324. */
  130325. get touchMoveSensibility(): number;
  130326. set touchMoveSensibility(value: number);
  130327. /**
  130328. * Instantiates a new touch camera.
  130329. * This represents a FPS type of camera controlled by touch.
  130330. * This is like a universal camera minus the Gamepad controls.
  130331. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130332. * @param name Define the name of the camera in the scene
  130333. * @param position Define the start position of the camera in the scene
  130334. * @param scene Define the scene the camera belongs to
  130335. */
  130336. constructor(name: string, position: Vector3, scene: Scene);
  130337. /**
  130338. * Gets the current object class name.
  130339. * @return the class name
  130340. */
  130341. getClassName(): string;
  130342. /** @hidden */
  130343. _setupInputs(): void;
  130344. }
  130345. }
  130346. declare module BABYLON {
  130347. /**
  130348. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  130349. * being tilted forward or back and left or right.
  130350. */
  130351. export class DeviceOrientationCamera extends FreeCamera {
  130352. private _initialQuaternion;
  130353. private _quaternionCache;
  130354. private _tmpDragQuaternion;
  130355. private _disablePointerInputWhenUsingDeviceOrientation;
  130356. /**
  130357. * Creates a new device orientation camera
  130358. * @param name The name of the camera
  130359. * @param position The start position camera
  130360. * @param scene The scene the camera belongs to
  130361. */
  130362. constructor(name: string, position: Vector3, scene: Scene);
  130363. /**
  130364. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  130365. */
  130366. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  130367. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  130368. private _dragFactor;
  130369. /**
  130370. * Enabled turning on the y axis when the orientation sensor is active
  130371. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  130372. */
  130373. enableHorizontalDragging(dragFactor?: number): void;
  130374. /**
  130375. * Gets the current instance class name ("DeviceOrientationCamera").
  130376. * This helps avoiding instanceof at run time.
  130377. * @returns the class name
  130378. */
  130379. getClassName(): string;
  130380. /**
  130381. * @hidden
  130382. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  130383. */
  130384. _checkInputs(): void;
  130385. /**
  130386. * Reset the camera to its default orientation on the specified axis only.
  130387. * @param axis The axis to reset
  130388. */
  130389. resetToCurrentRotation(axis?: Axis): void;
  130390. }
  130391. }
  130392. declare module BABYLON {
  130393. /**
  130394. * Defines supported buttons for XBox360 compatible gamepads
  130395. */
  130396. export enum Xbox360Button {
  130397. /** A */
  130398. A = 0,
  130399. /** B */
  130400. B = 1,
  130401. /** X */
  130402. X = 2,
  130403. /** Y */
  130404. Y = 3,
  130405. /** Left button */
  130406. LB = 4,
  130407. /** Right button */
  130408. RB = 5,
  130409. /** Back */
  130410. Back = 8,
  130411. /** Start */
  130412. Start = 9,
  130413. /** Left stick */
  130414. LeftStick = 10,
  130415. /** Right stick */
  130416. RightStick = 11
  130417. }
  130418. /** Defines values for XBox360 DPad */
  130419. export enum Xbox360Dpad {
  130420. /** Up */
  130421. Up = 12,
  130422. /** Down */
  130423. Down = 13,
  130424. /** Left */
  130425. Left = 14,
  130426. /** Right */
  130427. Right = 15
  130428. }
  130429. /**
  130430. * Defines a XBox360 gamepad
  130431. */
  130432. export class Xbox360Pad extends Gamepad {
  130433. private _leftTrigger;
  130434. private _rightTrigger;
  130435. private _onlefttriggerchanged;
  130436. private _onrighttriggerchanged;
  130437. private _onbuttondown;
  130438. private _onbuttonup;
  130439. private _ondpaddown;
  130440. private _ondpadup;
  130441. /** Observable raised when a button is pressed */
  130442. onButtonDownObservable: Observable<Xbox360Button>;
  130443. /** Observable raised when a button is released */
  130444. onButtonUpObservable: Observable<Xbox360Button>;
  130445. /** Observable raised when a pad is pressed */
  130446. onPadDownObservable: Observable<Xbox360Dpad>;
  130447. /** Observable raised when a pad is released */
  130448. onPadUpObservable: Observable<Xbox360Dpad>;
  130449. private _buttonA;
  130450. private _buttonB;
  130451. private _buttonX;
  130452. private _buttonY;
  130453. private _buttonBack;
  130454. private _buttonStart;
  130455. private _buttonLB;
  130456. private _buttonRB;
  130457. private _buttonLeftStick;
  130458. private _buttonRightStick;
  130459. private _dPadUp;
  130460. private _dPadDown;
  130461. private _dPadLeft;
  130462. private _dPadRight;
  130463. private _isXboxOnePad;
  130464. /**
  130465. * Creates a new XBox360 gamepad object
  130466. * @param id defines the id of this gamepad
  130467. * @param index defines its index
  130468. * @param gamepad defines the internal HTML gamepad object
  130469. * @param xboxOne defines if it is a XBox One gamepad
  130470. */
  130471. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  130472. /**
  130473. * Defines the callback to call when left trigger is pressed
  130474. * @param callback defines the callback to use
  130475. */
  130476. onlefttriggerchanged(callback: (value: number) => void): void;
  130477. /**
  130478. * Defines the callback to call when right trigger is pressed
  130479. * @param callback defines the callback to use
  130480. */
  130481. onrighttriggerchanged(callback: (value: number) => void): void;
  130482. /**
  130483. * Gets the left trigger value
  130484. */
  130485. get leftTrigger(): number;
  130486. /**
  130487. * Sets the left trigger value
  130488. */
  130489. set leftTrigger(newValue: number);
  130490. /**
  130491. * Gets the right trigger value
  130492. */
  130493. get rightTrigger(): number;
  130494. /**
  130495. * Sets the right trigger value
  130496. */
  130497. set rightTrigger(newValue: number);
  130498. /**
  130499. * Defines the callback to call when a button is pressed
  130500. * @param callback defines the callback to use
  130501. */
  130502. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  130503. /**
  130504. * Defines the callback to call when a button is released
  130505. * @param callback defines the callback to use
  130506. */
  130507. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  130508. /**
  130509. * Defines the callback to call when a pad is pressed
  130510. * @param callback defines the callback to use
  130511. */
  130512. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  130513. /**
  130514. * Defines the callback to call when a pad is released
  130515. * @param callback defines the callback to use
  130516. */
  130517. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  130518. private _setButtonValue;
  130519. private _setDPadValue;
  130520. /**
  130521. * Gets the value of the `A` button
  130522. */
  130523. get buttonA(): number;
  130524. /**
  130525. * Sets the value of the `A` button
  130526. */
  130527. set buttonA(value: number);
  130528. /**
  130529. * Gets the value of the `B` button
  130530. */
  130531. get buttonB(): number;
  130532. /**
  130533. * Sets the value of the `B` button
  130534. */
  130535. set buttonB(value: number);
  130536. /**
  130537. * Gets the value of the `X` button
  130538. */
  130539. get buttonX(): number;
  130540. /**
  130541. * Sets the value of the `X` button
  130542. */
  130543. set buttonX(value: number);
  130544. /**
  130545. * Gets the value of the `Y` button
  130546. */
  130547. get buttonY(): number;
  130548. /**
  130549. * Sets the value of the `Y` button
  130550. */
  130551. set buttonY(value: number);
  130552. /**
  130553. * Gets the value of the `Start` button
  130554. */
  130555. get buttonStart(): number;
  130556. /**
  130557. * Sets the value of the `Start` button
  130558. */
  130559. set buttonStart(value: number);
  130560. /**
  130561. * Gets the value of the `Back` button
  130562. */
  130563. get buttonBack(): number;
  130564. /**
  130565. * Sets the value of the `Back` button
  130566. */
  130567. set buttonBack(value: number);
  130568. /**
  130569. * Gets the value of the `Left` button
  130570. */
  130571. get buttonLB(): number;
  130572. /**
  130573. * Sets the value of the `Left` button
  130574. */
  130575. set buttonLB(value: number);
  130576. /**
  130577. * Gets the value of the `Right` button
  130578. */
  130579. get buttonRB(): number;
  130580. /**
  130581. * Sets the value of the `Right` button
  130582. */
  130583. set buttonRB(value: number);
  130584. /**
  130585. * Gets the value of the Left joystick
  130586. */
  130587. get buttonLeftStick(): number;
  130588. /**
  130589. * Sets the value of the Left joystick
  130590. */
  130591. set buttonLeftStick(value: number);
  130592. /**
  130593. * Gets the value of the Right joystick
  130594. */
  130595. get buttonRightStick(): number;
  130596. /**
  130597. * Sets the value of the Right joystick
  130598. */
  130599. set buttonRightStick(value: number);
  130600. /**
  130601. * Gets the value of D-pad up
  130602. */
  130603. get dPadUp(): number;
  130604. /**
  130605. * Sets the value of D-pad up
  130606. */
  130607. set dPadUp(value: number);
  130608. /**
  130609. * Gets the value of D-pad down
  130610. */
  130611. get dPadDown(): number;
  130612. /**
  130613. * Sets the value of D-pad down
  130614. */
  130615. set dPadDown(value: number);
  130616. /**
  130617. * Gets the value of D-pad left
  130618. */
  130619. get dPadLeft(): number;
  130620. /**
  130621. * Sets the value of D-pad left
  130622. */
  130623. set dPadLeft(value: number);
  130624. /**
  130625. * Gets the value of D-pad right
  130626. */
  130627. get dPadRight(): number;
  130628. /**
  130629. * Sets the value of D-pad right
  130630. */
  130631. set dPadRight(value: number);
  130632. /**
  130633. * Force the gamepad to synchronize with device values
  130634. */
  130635. update(): void;
  130636. /**
  130637. * Disposes the gamepad
  130638. */
  130639. dispose(): void;
  130640. }
  130641. }
  130642. declare module BABYLON {
  130643. /**
  130644. * Defines supported buttons for DualShock compatible gamepads
  130645. */
  130646. export enum DualShockButton {
  130647. /** Cross */
  130648. Cross = 0,
  130649. /** Circle */
  130650. Circle = 1,
  130651. /** Square */
  130652. Square = 2,
  130653. /** Triangle */
  130654. Triangle = 3,
  130655. /** L1 */
  130656. L1 = 4,
  130657. /** R1 */
  130658. R1 = 5,
  130659. /** Share */
  130660. Share = 8,
  130661. /** Options */
  130662. Options = 9,
  130663. /** Left stick */
  130664. LeftStick = 10,
  130665. /** Right stick */
  130666. RightStick = 11
  130667. }
  130668. /** Defines values for DualShock DPad */
  130669. export enum DualShockDpad {
  130670. /** Up */
  130671. Up = 12,
  130672. /** Down */
  130673. Down = 13,
  130674. /** Left */
  130675. Left = 14,
  130676. /** Right */
  130677. Right = 15
  130678. }
  130679. /**
  130680. * Defines a DualShock gamepad
  130681. */
  130682. export class DualShockPad extends Gamepad {
  130683. private _leftTrigger;
  130684. private _rightTrigger;
  130685. private _onlefttriggerchanged;
  130686. private _onrighttriggerchanged;
  130687. private _onbuttondown;
  130688. private _onbuttonup;
  130689. private _ondpaddown;
  130690. private _ondpadup;
  130691. /** Observable raised when a button is pressed */
  130692. onButtonDownObservable: Observable<DualShockButton>;
  130693. /** Observable raised when a button is released */
  130694. onButtonUpObservable: Observable<DualShockButton>;
  130695. /** Observable raised when a pad is pressed */
  130696. onPadDownObservable: Observable<DualShockDpad>;
  130697. /** Observable raised when a pad is released */
  130698. onPadUpObservable: Observable<DualShockDpad>;
  130699. private _buttonCross;
  130700. private _buttonCircle;
  130701. private _buttonSquare;
  130702. private _buttonTriangle;
  130703. private _buttonShare;
  130704. private _buttonOptions;
  130705. private _buttonL1;
  130706. private _buttonR1;
  130707. private _buttonLeftStick;
  130708. private _buttonRightStick;
  130709. private _dPadUp;
  130710. private _dPadDown;
  130711. private _dPadLeft;
  130712. private _dPadRight;
  130713. /**
  130714. * Creates a new DualShock gamepad object
  130715. * @param id defines the id of this gamepad
  130716. * @param index defines its index
  130717. * @param gamepad defines the internal HTML gamepad object
  130718. */
  130719. constructor(id: string, index: number, gamepad: any);
  130720. /**
  130721. * Defines the callback to call when left trigger is pressed
  130722. * @param callback defines the callback to use
  130723. */
  130724. onlefttriggerchanged(callback: (value: number) => void): void;
  130725. /**
  130726. * Defines the callback to call when right trigger is pressed
  130727. * @param callback defines the callback to use
  130728. */
  130729. onrighttriggerchanged(callback: (value: number) => void): void;
  130730. /**
  130731. * Gets the left trigger value
  130732. */
  130733. get leftTrigger(): number;
  130734. /**
  130735. * Sets the left trigger value
  130736. */
  130737. set leftTrigger(newValue: number);
  130738. /**
  130739. * Gets the right trigger value
  130740. */
  130741. get rightTrigger(): number;
  130742. /**
  130743. * Sets the right trigger value
  130744. */
  130745. set rightTrigger(newValue: number);
  130746. /**
  130747. * Defines the callback to call when a button is pressed
  130748. * @param callback defines the callback to use
  130749. */
  130750. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  130751. /**
  130752. * Defines the callback to call when a button is released
  130753. * @param callback defines the callback to use
  130754. */
  130755. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  130756. /**
  130757. * Defines the callback to call when a pad is pressed
  130758. * @param callback defines the callback to use
  130759. */
  130760. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  130761. /**
  130762. * Defines the callback to call when a pad is released
  130763. * @param callback defines the callback to use
  130764. */
  130765. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  130766. private _setButtonValue;
  130767. private _setDPadValue;
  130768. /**
  130769. * Gets the value of the `Cross` button
  130770. */
  130771. get buttonCross(): number;
  130772. /**
  130773. * Sets the value of the `Cross` button
  130774. */
  130775. set buttonCross(value: number);
  130776. /**
  130777. * Gets the value of the `Circle` button
  130778. */
  130779. get buttonCircle(): number;
  130780. /**
  130781. * Sets the value of the `Circle` button
  130782. */
  130783. set buttonCircle(value: number);
  130784. /**
  130785. * Gets the value of the `Square` button
  130786. */
  130787. get buttonSquare(): number;
  130788. /**
  130789. * Sets the value of the `Square` button
  130790. */
  130791. set buttonSquare(value: number);
  130792. /**
  130793. * Gets the value of the `Triangle` button
  130794. */
  130795. get buttonTriangle(): number;
  130796. /**
  130797. * Sets the value of the `Triangle` button
  130798. */
  130799. set buttonTriangle(value: number);
  130800. /**
  130801. * Gets the value of the `Options` button
  130802. */
  130803. get buttonOptions(): number;
  130804. /**
  130805. * Sets the value of the `Options` button
  130806. */
  130807. set buttonOptions(value: number);
  130808. /**
  130809. * Gets the value of the `Share` button
  130810. */
  130811. get buttonShare(): number;
  130812. /**
  130813. * Sets the value of the `Share` button
  130814. */
  130815. set buttonShare(value: number);
  130816. /**
  130817. * Gets the value of the `L1` button
  130818. */
  130819. get buttonL1(): number;
  130820. /**
  130821. * Sets the value of the `L1` button
  130822. */
  130823. set buttonL1(value: number);
  130824. /**
  130825. * Gets the value of the `R1` button
  130826. */
  130827. get buttonR1(): number;
  130828. /**
  130829. * Sets the value of the `R1` button
  130830. */
  130831. set buttonR1(value: number);
  130832. /**
  130833. * Gets the value of the Left joystick
  130834. */
  130835. get buttonLeftStick(): number;
  130836. /**
  130837. * Sets the value of the Left joystick
  130838. */
  130839. set buttonLeftStick(value: number);
  130840. /**
  130841. * Gets the value of the Right joystick
  130842. */
  130843. get buttonRightStick(): number;
  130844. /**
  130845. * Sets the value of the Right joystick
  130846. */
  130847. set buttonRightStick(value: number);
  130848. /**
  130849. * Gets the value of D-pad up
  130850. */
  130851. get dPadUp(): number;
  130852. /**
  130853. * Sets the value of D-pad up
  130854. */
  130855. set dPadUp(value: number);
  130856. /**
  130857. * Gets the value of D-pad down
  130858. */
  130859. get dPadDown(): number;
  130860. /**
  130861. * Sets the value of D-pad down
  130862. */
  130863. set dPadDown(value: number);
  130864. /**
  130865. * Gets the value of D-pad left
  130866. */
  130867. get dPadLeft(): number;
  130868. /**
  130869. * Sets the value of D-pad left
  130870. */
  130871. set dPadLeft(value: number);
  130872. /**
  130873. * Gets the value of D-pad right
  130874. */
  130875. get dPadRight(): number;
  130876. /**
  130877. * Sets the value of D-pad right
  130878. */
  130879. set dPadRight(value: number);
  130880. /**
  130881. * Force the gamepad to synchronize with device values
  130882. */
  130883. update(): void;
  130884. /**
  130885. * Disposes the gamepad
  130886. */
  130887. dispose(): void;
  130888. }
  130889. }
  130890. declare module BABYLON {
  130891. /**
  130892. * Manager for handling gamepads
  130893. */
  130894. export class GamepadManager {
  130895. private _scene?;
  130896. private _babylonGamepads;
  130897. private _oneGamepadConnected;
  130898. /** @hidden */
  130899. _isMonitoring: boolean;
  130900. private _gamepadEventSupported;
  130901. private _gamepadSupport?;
  130902. /**
  130903. * observable to be triggered when the gamepad controller has been connected
  130904. */
  130905. onGamepadConnectedObservable: Observable<Gamepad>;
  130906. /**
  130907. * observable to be triggered when the gamepad controller has been disconnected
  130908. */
  130909. onGamepadDisconnectedObservable: Observable<Gamepad>;
  130910. private _onGamepadConnectedEvent;
  130911. private _onGamepadDisconnectedEvent;
  130912. /**
  130913. * Initializes the gamepad manager
  130914. * @param _scene BabylonJS scene
  130915. */
  130916. constructor(_scene?: Scene | undefined);
  130917. /**
  130918. * The gamepads in the game pad manager
  130919. */
  130920. get gamepads(): Gamepad[];
  130921. /**
  130922. * Get the gamepad controllers based on type
  130923. * @param type The type of gamepad controller
  130924. * @returns Nullable gamepad
  130925. */
  130926. getGamepadByType(type?: number): Nullable<Gamepad>;
  130927. /**
  130928. * Disposes the gamepad manager
  130929. */
  130930. dispose(): void;
  130931. private _addNewGamepad;
  130932. private _startMonitoringGamepads;
  130933. private _stopMonitoringGamepads;
  130934. /** @hidden */
  130935. _checkGamepadsStatus(): void;
  130936. private _updateGamepadObjects;
  130937. }
  130938. }
  130939. declare module BABYLON {
  130940. interface Scene {
  130941. /** @hidden */
  130942. _gamepadManager: Nullable<GamepadManager>;
  130943. /**
  130944. * Gets the gamepad manager associated with the scene
  130945. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  130946. */
  130947. gamepadManager: GamepadManager;
  130948. }
  130949. /**
  130950. * Interface representing a free camera inputs manager
  130951. */
  130952. interface FreeCameraInputsManager {
  130953. /**
  130954. * Adds gamepad input support to the FreeCameraInputsManager.
  130955. * @returns the FreeCameraInputsManager
  130956. */
  130957. addGamepad(): FreeCameraInputsManager;
  130958. }
  130959. /**
  130960. * Interface representing an arc rotate camera inputs manager
  130961. */
  130962. interface ArcRotateCameraInputsManager {
  130963. /**
  130964. * Adds gamepad input support to the ArcRotateCamera InputManager.
  130965. * @returns the camera inputs manager
  130966. */
  130967. addGamepad(): ArcRotateCameraInputsManager;
  130968. }
  130969. /**
  130970. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  130971. */
  130972. export class GamepadSystemSceneComponent implements ISceneComponent {
  130973. /**
  130974. * The component name helpfull to identify the component in the list of scene components.
  130975. */
  130976. readonly name: string;
  130977. /**
  130978. * The scene the component belongs to.
  130979. */
  130980. scene: Scene;
  130981. /**
  130982. * Creates a new instance of the component for the given scene
  130983. * @param scene Defines the scene to register the component in
  130984. */
  130985. constructor(scene: Scene);
  130986. /**
  130987. * Registers the component in a given scene
  130988. */
  130989. register(): void;
  130990. /**
  130991. * Rebuilds the elements related to this component in case of
  130992. * context lost for instance.
  130993. */
  130994. rebuild(): void;
  130995. /**
  130996. * Disposes the component and the associated ressources
  130997. */
  130998. dispose(): void;
  130999. private _beforeCameraUpdate;
  131000. }
  131001. }
  131002. declare module BABYLON {
  131003. /**
  131004. * 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,
  131005. * which still works and will still be found in many Playgrounds.
  131006. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  131007. */
  131008. export class UniversalCamera extends TouchCamera {
  131009. /**
  131010. * Defines the gamepad rotation sensiblity.
  131011. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  131012. */
  131013. get gamepadAngularSensibility(): number;
  131014. set gamepadAngularSensibility(value: number);
  131015. /**
  131016. * Defines the gamepad move sensiblity.
  131017. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  131018. */
  131019. get gamepadMoveSensibility(): number;
  131020. set gamepadMoveSensibility(value: number);
  131021. /**
  131022. * 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,
  131023. * which still works and will still be found in many Playgrounds.
  131024. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  131025. * @param name Define the name of the camera in the scene
  131026. * @param position Define the start position of the camera in the scene
  131027. * @param scene Define the scene the camera belongs to
  131028. */
  131029. constructor(name: string, position: Vector3, scene: Scene);
  131030. /**
  131031. * Gets the current object class name.
  131032. * @return the class name
  131033. */
  131034. getClassName(): string;
  131035. }
  131036. }
  131037. declare module BABYLON {
  131038. /**
  131039. * This represents a FPS type of camera. This is only here for back compat purpose.
  131040. * Please use the UniversalCamera instead as both are identical.
  131041. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  131042. */
  131043. export class GamepadCamera extends UniversalCamera {
  131044. /**
  131045. * Instantiates a new Gamepad Camera
  131046. * This represents a FPS type of camera. This is only here for back compat purpose.
  131047. * Please use the UniversalCamera instead as both are identical.
  131048. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  131049. * @param name Define the name of the camera in the scene
  131050. * @param position Define the start position of the camera in the scene
  131051. * @param scene Define the scene the camera belongs to
  131052. */
  131053. constructor(name: string, position: Vector3, scene: Scene);
  131054. /**
  131055. * Gets the current object class name.
  131056. * @return the class name
  131057. */
  131058. getClassName(): string;
  131059. }
  131060. }
  131061. declare module BABYLON {
  131062. /** @hidden */
  131063. export var passPixelShader: {
  131064. name: string;
  131065. shader: string;
  131066. };
  131067. }
  131068. declare module BABYLON {
  131069. /** @hidden */
  131070. export var passCubePixelShader: {
  131071. name: string;
  131072. shader: string;
  131073. };
  131074. }
  131075. declare module BABYLON {
  131076. /**
  131077. * PassPostProcess which produces an output the same as it's input
  131078. */
  131079. export class PassPostProcess extends PostProcess {
  131080. /**
  131081. * Gets a string identifying the name of the class
  131082. * @returns "PassPostProcess" string
  131083. */
  131084. getClassName(): string;
  131085. /**
  131086. * Creates the PassPostProcess
  131087. * @param name The name of the effect.
  131088. * @param options The required width/height ratio to downsize to before computing the render pass.
  131089. * @param camera The camera to apply the render pass to.
  131090. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131091. * @param engine The engine which the post process will be applied. (default: current engine)
  131092. * @param reusable If the post process can be reused on the same frame. (default: false)
  131093. * @param textureType The type of texture to be used when performing the post processing.
  131094. * @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)
  131095. */
  131096. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  131097. /** @hidden */
  131098. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  131099. }
  131100. /**
  131101. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  131102. */
  131103. export class PassCubePostProcess extends PostProcess {
  131104. private _face;
  131105. /**
  131106. * Gets or sets the cube face to display.
  131107. * * 0 is +X
  131108. * * 1 is -X
  131109. * * 2 is +Y
  131110. * * 3 is -Y
  131111. * * 4 is +Z
  131112. * * 5 is -Z
  131113. */
  131114. get face(): number;
  131115. set face(value: number);
  131116. /**
  131117. * Gets a string identifying the name of the class
  131118. * @returns "PassCubePostProcess" string
  131119. */
  131120. getClassName(): string;
  131121. /**
  131122. * Creates the PassCubePostProcess
  131123. * @param name The name of the effect.
  131124. * @param options The required width/height ratio to downsize to before computing the render pass.
  131125. * @param camera The camera to apply the render pass to.
  131126. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131127. * @param engine The engine which the post process will be applied. (default: current engine)
  131128. * @param reusable If the post process can be reused on the same frame. (default: false)
  131129. * @param textureType The type of texture to be used when performing the post processing.
  131130. * @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)
  131131. */
  131132. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  131133. /** @hidden */
  131134. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  131135. }
  131136. }
  131137. declare module BABYLON {
  131138. /** @hidden */
  131139. export var anaglyphPixelShader: {
  131140. name: string;
  131141. shader: string;
  131142. };
  131143. }
  131144. declare module BABYLON {
  131145. /**
  131146. * Postprocess used to generate anaglyphic rendering
  131147. */
  131148. export class AnaglyphPostProcess extends PostProcess {
  131149. private _passedProcess;
  131150. /**
  131151. * Gets a string identifying the name of the class
  131152. * @returns "AnaglyphPostProcess" string
  131153. */
  131154. getClassName(): string;
  131155. /**
  131156. * Creates a new AnaglyphPostProcess
  131157. * @param name defines postprocess name
  131158. * @param options defines creation options or target ratio scale
  131159. * @param rigCameras defines cameras using this postprocess
  131160. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  131161. * @param engine defines hosting engine
  131162. * @param reusable defines if the postprocess will be reused multiple times per frame
  131163. */
  131164. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  131165. }
  131166. }
  131167. declare module BABYLON {
  131168. /**
  131169. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  131170. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  131171. */
  131172. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  131173. /**
  131174. * Creates a new AnaglyphArcRotateCamera
  131175. * @param name defines camera name
  131176. * @param alpha defines alpha angle (in radians)
  131177. * @param beta defines beta angle (in radians)
  131178. * @param radius defines radius
  131179. * @param target defines camera target
  131180. * @param interaxialDistance defines distance between each color axis
  131181. * @param scene defines the hosting scene
  131182. */
  131183. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  131184. /**
  131185. * Gets camera class name
  131186. * @returns AnaglyphArcRotateCamera
  131187. */
  131188. getClassName(): string;
  131189. }
  131190. }
  131191. declare module BABYLON {
  131192. /**
  131193. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  131194. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  131195. */
  131196. export class AnaglyphFreeCamera extends FreeCamera {
  131197. /**
  131198. * Creates a new AnaglyphFreeCamera
  131199. * @param name defines camera name
  131200. * @param position defines initial position
  131201. * @param interaxialDistance defines distance between each color axis
  131202. * @param scene defines the hosting scene
  131203. */
  131204. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  131205. /**
  131206. * Gets camera class name
  131207. * @returns AnaglyphFreeCamera
  131208. */
  131209. getClassName(): string;
  131210. }
  131211. }
  131212. declare module BABYLON {
  131213. /**
  131214. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  131215. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  131216. */
  131217. export class AnaglyphGamepadCamera extends GamepadCamera {
  131218. /**
  131219. * Creates a new AnaglyphGamepadCamera
  131220. * @param name defines camera name
  131221. * @param position defines initial position
  131222. * @param interaxialDistance defines distance between each color axis
  131223. * @param scene defines the hosting scene
  131224. */
  131225. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  131226. /**
  131227. * Gets camera class name
  131228. * @returns AnaglyphGamepadCamera
  131229. */
  131230. getClassName(): string;
  131231. }
  131232. }
  131233. declare module BABYLON {
  131234. /**
  131235. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  131236. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  131237. */
  131238. export class AnaglyphUniversalCamera extends UniversalCamera {
  131239. /**
  131240. * Creates a new AnaglyphUniversalCamera
  131241. * @param name defines camera name
  131242. * @param position defines initial position
  131243. * @param interaxialDistance defines distance between each color axis
  131244. * @param scene defines the hosting scene
  131245. */
  131246. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  131247. /**
  131248. * Gets camera class name
  131249. * @returns AnaglyphUniversalCamera
  131250. */
  131251. getClassName(): string;
  131252. }
  131253. }
  131254. declare module BABYLON {
  131255. /**
  131256. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  131257. * @see https://doc.babylonjs.com/features/cameras
  131258. */
  131259. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  131260. /**
  131261. * Creates a new StereoscopicArcRotateCamera
  131262. * @param name defines camera name
  131263. * @param alpha defines alpha angle (in radians)
  131264. * @param beta defines beta angle (in radians)
  131265. * @param radius defines radius
  131266. * @param target defines camera target
  131267. * @param interaxialDistance defines distance between each color axis
  131268. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  131269. * @param scene defines the hosting scene
  131270. */
  131271. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  131272. /**
  131273. * Gets camera class name
  131274. * @returns StereoscopicArcRotateCamera
  131275. */
  131276. getClassName(): string;
  131277. }
  131278. }
  131279. declare module BABYLON {
  131280. /**
  131281. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  131282. * @see https://doc.babylonjs.com/features/cameras
  131283. */
  131284. export class StereoscopicFreeCamera extends FreeCamera {
  131285. /**
  131286. * Creates a new StereoscopicFreeCamera
  131287. * @param name defines camera name
  131288. * @param position defines initial position
  131289. * @param interaxialDistance defines distance between each color axis
  131290. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  131291. * @param scene defines the hosting scene
  131292. */
  131293. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  131294. /**
  131295. * Gets camera class name
  131296. * @returns StereoscopicFreeCamera
  131297. */
  131298. getClassName(): string;
  131299. }
  131300. }
  131301. declare module BABYLON {
  131302. /**
  131303. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  131304. * @see https://doc.babylonjs.com/features/cameras
  131305. */
  131306. export class StereoscopicGamepadCamera extends GamepadCamera {
  131307. /**
  131308. * Creates a new StereoscopicGamepadCamera
  131309. * @param name defines camera name
  131310. * @param position defines initial position
  131311. * @param interaxialDistance defines distance between each color axis
  131312. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  131313. * @param scene defines the hosting scene
  131314. */
  131315. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  131316. /**
  131317. * Gets camera class name
  131318. * @returns StereoscopicGamepadCamera
  131319. */
  131320. getClassName(): string;
  131321. }
  131322. }
  131323. declare module BABYLON {
  131324. /**
  131325. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  131326. * @see https://doc.babylonjs.com/features/cameras
  131327. */
  131328. export class StereoscopicUniversalCamera extends UniversalCamera {
  131329. /**
  131330. * Creates a new StereoscopicUniversalCamera
  131331. * @param name defines camera name
  131332. * @param position defines initial position
  131333. * @param interaxialDistance defines distance between each color axis
  131334. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  131335. * @param scene defines the hosting scene
  131336. */
  131337. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  131338. /**
  131339. * Gets camera class name
  131340. * @returns StereoscopicUniversalCamera
  131341. */
  131342. getClassName(): string;
  131343. }
  131344. }
  131345. declare module BABYLON {
  131346. /**
  131347. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  131348. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  131349. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  131350. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  131351. */
  131352. export class VirtualJoysticksCamera extends FreeCamera {
  131353. /**
  131354. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  131355. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  131356. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  131357. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  131358. * @param name Define the name of the camera in the scene
  131359. * @param position Define the start position of the camera in the scene
  131360. * @param scene Define the scene the camera belongs to
  131361. */
  131362. constructor(name: string, position: Vector3, scene: Scene);
  131363. /**
  131364. * Gets the current object class name.
  131365. * @return the class name
  131366. */
  131367. getClassName(): string;
  131368. }
  131369. }
  131370. declare module BABYLON {
  131371. /**
  131372. * This represents all the required metrics to create a VR camera.
  131373. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  131374. */
  131375. export class VRCameraMetrics {
  131376. /**
  131377. * Define the horizontal resolution off the screen.
  131378. */
  131379. hResolution: number;
  131380. /**
  131381. * Define the vertical resolution off the screen.
  131382. */
  131383. vResolution: number;
  131384. /**
  131385. * Define the horizontal screen size.
  131386. */
  131387. hScreenSize: number;
  131388. /**
  131389. * Define the vertical screen size.
  131390. */
  131391. vScreenSize: number;
  131392. /**
  131393. * Define the vertical screen center position.
  131394. */
  131395. vScreenCenter: number;
  131396. /**
  131397. * Define the distance of the eyes to the screen.
  131398. */
  131399. eyeToScreenDistance: number;
  131400. /**
  131401. * Define the distance between both lenses
  131402. */
  131403. lensSeparationDistance: number;
  131404. /**
  131405. * Define the distance between both viewer's eyes.
  131406. */
  131407. interpupillaryDistance: number;
  131408. /**
  131409. * Define the distortion factor of the VR postprocess.
  131410. * Please, touch with care.
  131411. */
  131412. distortionK: number[];
  131413. /**
  131414. * Define the chromatic aberration correction factors for the VR post process.
  131415. */
  131416. chromaAbCorrection: number[];
  131417. /**
  131418. * Define the scale factor of the post process.
  131419. * The smaller the better but the slower.
  131420. */
  131421. postProcessScaleFactor: number;
  131422. /**
  131423. * Define an offset for the lens center.
  131424. */
  131425. lensCenterOffset: number;
  131426. /**
  131427. * Define if the current vr camera should compensate the distortion of the lense or not.
  131428. */
  131429. compensateDistortion: boolean;
  131430. /**
  131431. * Defines if multiview should be enabled when rendering (Default: false)
  131432. */
  131433. multiviewEnabled: boolean;
  131434. /**
  131435. * Gets the rendering aspect ratio based on the provided resolutions.
  131436. */
  131437. get aspectRatio(): number;
  131438. /**
  131439. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  131440. */
  131441. get aspectRatioFov(): number;
  131442. /**
  131443. * @hidden
  131444. */
  131445. get leftHMatrix(): Matrix;
  131446. /**
  131447. * @hidden
  131448. */
  131449. get rightHMatrix(): Matrix;
  131450. /**
  131451. * @hidden
  131452. */
  131453. get leftPreViewMatrix(): Matrix;
  131454. /**
  131455. * @hidden
  131456. */
  131457. get rightPreViewMatrix(): Matrix;
  131458. /**
  131459. * Get the default VRMetrics based on the most generic setup.
  131460. * @returns the default vr metrics
  131461. */
  131462. static GetDefault(): VRCameraMetrics;
  131463. }
  131464. }
  131465. declare module BABYLON {
  131466. /** @hidden */
  131467. export var vrDistortionCorrectionPixelShader: {
  131468. name: string;
  131469. shader: string;
  131470. };
  131471. }
  131472. declare module BABYLON {
  131473. /**
  131474. * VRDistortionCorrectionPostProcess used for mobile VR
  131475. */
  131476. export class VRDistortionCorrectionPostProcess extends PostProcess {
  131477. private _isRightEye;
  131478. private _distortionFactors;
  131479. private _postProcessScaleFactor;
  131480. private _lensCenterOffset;
  131481. private _scaleIn;
  131482. private _scaleFactor;
  131483. private _lensCenter;
  131484. /**
  131485. * Gets a string identifying the name of the class
  131486. * @returns "VRDistortionCorrectionPostProcess" string
  131487. */
  131488. getClassName(): string;
  131489. /**
  131490. * Initializes the VRDistortionCorrectionPostProcess
  131491. * @param name The name of the effect.
  131492. * @param camera The camera to apply the render pass to.
  131493. * @param isRightEye If this is for the right eye distortion
  131494. * @param vrMetrics All the required metrics for the VR camera
  131495. */
  131496. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  131497. }
  131498. }
  131499. declare module BABYLON {
  131500. /**
  131501. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  131502. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131503. */
  131504. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  131505. /**
  131506. * Creates a new VRDeviceOrientationArcRotateCamera
  131507. * @param name defines camera name
  131508. * @param alpha defines the camera rotation along the logitudinal axis
  131509. * @param beta defines the camera rotation along the latitudinal axis
  131510. * @param radius defines the camera distance from its target
  131511. * @param target defines the camera target
  131512. * @param scene defines the scene the camera belongs to
  131513. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131514. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131515. */
  131516. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131517. /**
  131518. * Gets camera class name
  131519. * @returns VRDeviceOrientationArcRotateCamera
  131520. */
  131521. getClassName(): string;
  131522. }
  131523. }
  131524. declare module BABYLON {
  131525. /**
  131526. * Camera used to simulate VR rendering (based on FreeCamera)
  131527. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131528. */
  131529. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  131530. /**
  131531. * Creates a new VRDeviceOrientationFreeCamera
  131532. * @param name defines camera name
  131533. * @param position defines the start position of the camera
  131534. * @param scene defines the scene the camera belongs to
  131535. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131536. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131537. */
  131538. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131539. /**
  131540. * Gets camera class name
  131541. * @returns VRDeviceOrientationFreeCamera
  131542. */
  131543. getClassName(): string;
  131544. }
  131545. }
  131546. declare module BABYLON {
  131547. /**
  131548. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  131549. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131550. */
  131551. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  131552. /**
  131553. * Creates a new VRDeviceOrientationGamepadCamera
  131554. * @param name defines camera name
  131555. * @param position defines the start position of the camera
  131556. * @param scene defines the scene the camera belongs to
  131557. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131558. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131559. */
  131560. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131561. /**
  131562. * Gets camera class name
  131563. * @returns VRDeviceOrientationGamepadCamera
  131564. */
  131565. getClassName(): string;
  131566. }
  131567. }
  131568. declare module BABYLON {
  131569. /**
  131570. * A class extending Texture allowing drawing on a texture
  131571. * @see https://doc.babylonjs.com/how_to/dynamictexture
  131572. */
  131573. export class DynamicTexture extends Texture {
  131574. private _generateMipMaps;
  131575. private _canvas;
  131576. private _context;
  131577. /**
  131578. * Creates a DynamicTexture
  131579. * @param name defines the name of the texture
  131580. * @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
  131581. * @param scene defines the scene where you want the texture
  131582. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  131583. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131584. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  131585. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  131586. */
  131587. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  131588. /**
  131589. * Get the current class name of the texture useful for serialization or dynamic coding.
  131590. * @returns "DynamicTexture"
  131591. */
  131592. getClassName(): string;
  131593. /**
  131594. * Gets the current state of canRescale
  131595. */
  131596. get canRescale(): boolean;
  131597. private _recreate;
  131598. /**
  131599. * Scales the texture
  131600. * @param ratio the scale factor to apply to both width and height
  131601. */
  131602. scale(ratio: number): void;
  131603. /**
  131604. * Resizes the texture
  131605. * @param width the new width
  131606. * @param height the new height
  131607. */
  131608. scaleTo(width: number, height: number): void;
  131609. /**
  131610. * Gets the context of the canvas used by the texture
  131611. * @returns the canvas context of the dynamic texture
  131612. */
  131613. getContext(): CanvasRenderingContext2D;
  131614. /**
  131615. * Clears the texture
  131616. */
  131617. clear(): void;
  131618. /**
  131619. * Updates the texture
  131620. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  131621. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  131622. */
  131623. update(invertY?: boolean, premulAlpha?: boolean): void;
  131624. /**
  131625. * Draws text onto the texture
  131626. * @param text defines the text to be drawn
  131627. * @param x defines the placement of the text from the left
  131628. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  131629. * @param font defines the font to be used with font-style, font-size, font-name
  131630. * @param color defines the color used for the text
  131631. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  131632. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  131633. * @param update defines whether texture is immediately update (default is true)
  131634. */
  131635. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  131636. /**
  131637. * Clones the texture
  131638. * @returns the clone of the texture.
  131639. */
  131640. clone(): DynamicTexture;
  131641. /**
  131642. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  131643. * @returns a serialized dynamic texture object
  131644. */
  131645. serialize(): any;
  131646. private _IsCanvasElement;
  131647. /** @hidden */
  131648. _rebuild(): void;
  131649. }
  131650. }
  131651. declare module BABYLON {
  131652. /**
  131653. * Class containing static functions to help procedurally build meshes
  131654. */
  131655. export class GroundBuilder {
  131656. /**
  131657. * Creates a ground mesh
  131658. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  131659. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  131660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131661. * @param name defines the name of the mesh
  131662. * @param options defines the options used to create the mesh
  131663. * @param scene defines the hosting scene
  131664. * @returns the ground mesh
  131665. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  131666. */
  131667. static CreateGround(name: string, options: {
  131668. width?: number;
  131669. height?: number;
  131670. subdivisions?: number;
  131671. subdivisionsX?: number;
  131672. subdivisionsY?: number;
  131673. updatable?: boolean;
  131674. }, scene: any): Mesh;
  131675. /**
  131676. * Creates a tiled ground mesh
  131677. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  131678. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  131679. * * 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
  131680. * * 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
  131681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131682. * @param name defines the name of the mesh
  131683. * @param options defines the options used to create the mesh
  131684. * @param scene defines the hosting scene
  131685. * @returns the tiled ground mesh
  131686. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  131687. */
  131688. static CreateTiledGround(name: string, options: {
  131689. xmin: number;
  131690. zmin: number;
  131691. xmax: number;
  131692. zmax: number;
  131693. subdivisions?: {
  131694. w: number;
  131695. h: number;
  131696. };
  131697. precision?: {
  131698. w: number;
  131699. h: number;
  131700. };
  131701. updatable?: boolean;
  131702. }, scene?: Nullable<Scene>): Mesh;
  131703. /**
  131704. * Creates a ground mesh from a height map
  131705. * * The parameter `url` sets the URL of the height map image resource.
  131706. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  131707. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  131708. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  131709. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  131710. * * 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.
  131711. * * 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).
  131712. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  131713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131714. * @param name defines the name of the mesh
  131715. * @param url defines the url to the height map
  131716. * @param options defines the options used to create the mesh
  131717. * @param scene defines the hosting scene
  131718. * @returns the ground mesh
  131719. * @see https://doc.babylonjs.com/babylon101/height_map
  131720. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  131721. */
  131722. static CreateGroundFromHeightMap(name: string, url: string, options: {
  131723. width?: number;
  131724. height?: number;
  131725. subdivisions?: number;
  131726. minHeight?: number;
  131727. maxHeight?: number;
  131728. colorFilter?: Color3;
  131729. alphaFilter?: number;
  131730. updatable?: boolean;
  131731. onReady?: (mesh: GroundMesh) => void;
  131732. }, scene?: Nullable<Scene>): GroundMesh;
  131733. }
  131734. }
  131735. declare module BABYLON {
  131736. /**
  131737. * Class containing static functions to help procedurally build meshes
  131738. */
  131739. export class TorusBuilder {
  131740. /**
  131741. * Creates a torus mesh
  131742. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  131743. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  131744. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  131745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131746. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131748. * @param name defines the name of the mesh
  131749. * @param options defines the options used to create the mesh
  131750. * @param scene defines the hosting scene
  131751. * @returns the torus mesh
  131752. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  131753. */
  131754. static CreateTorus(name: string, options: {
  131755. diameter?: number;
  131756. thickness?: number;
  131757. tessellation?: number;
  131758. updatable?: boolean;
  131759. sideOrientation?: number;
  131760. frontUVs?: Vector4;
  131761. backUVs?: Vector4;
  131762. }, scene: any): Mesh;
  131763. }
  131764. }
  131765. declare module BABYLON {
  131766. /**
  131767. * Class containing static functions to help procedurally build meshes
  131768. */
  131769. export class CylinderBuilder {
  131770. /**
  131771. * Creates a cylinder or a cone mesh
  131772. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  131773. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  131774. * * 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.
  131775. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  131776. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  131777. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  131778. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  131779. * * 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).
  131780. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  131781. * * 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).
  131782. * * 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
  131783. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  131784. * * 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
  131785. * * 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.
  131786. * * If `enclose` is false, a ring surface is one element.
  131787. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  131788. * * 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
  131789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131790. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131792. * @param name defines the name of the mesh
  131793. * @param options defines the options used to create the mesh
  131794. * @param scene defines the hosting scene
  131795. * @returns the cylinder mesh
  131796. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  131797. */
  131798. static CreateCylinder(name: string, options: {
  131799. height?: number;
  131800. diameterTop?: number;
  131801. diameterBottom?: number;
  131802. diameter?: number;
  131803. tessellation?: number;
  131804. subdivisions?: number;
  131805. arc?: number;
  131806. faceColors?: Color4[];
  131807. faceUV?: Vector4[];
  131808. updatable?: boolean;
  131809. hasRings?: boolean;
  131810. enclose?: boolean;
  131811. cap?: number;
  131812. sideOrientation?: number;
  131813. frontUVs?: Vector4;
  131814. backUVs?: Vector4;
  131815. }, scene: any): Mesh;
  131816. }
  131817. }
  131818. declare module BABYLON {
  131819. /**
  131820. * States of the webXR experience
  131821. */
  131822. export enum WebXRState {
  131823. /**
  131824. * Transitioning to being in XR mode
  131825. */
  131826. ENTERING_XR = 0,
  131827. /**
  131828. * Transitioning to non XR mode
  131829. */
  131830. EXITING_XR = 1,
  131831. /**
  131832. * In XR mode and presenting
  131833. */
  131834. IN_XR = 2,
  131835. /**
  131836. * Not entered XR mode
  131837. */
  131838. NOT_IN_XR = 3
  131839. }
  131840. /**
  131841. * The state of the XR camera's tracking
  131842. */
  131843. export enum WebXRTrackingState {
  131844. /**
  131845. * No transformation received, device is not being tracked
  131846. */
  131847. NOT_TRACKING = 0,
  131848. /**
  131849. * Tracking lost - using emulated position
  131850. */
  131851. TRACKING_LOST = 1,
  131852. /**
  131853. * Transformation tracking works normally
  131854. */
  131855. TRACKING = 2
  131856. }
  131857. /**
  131858. * Abstraction of the XR render target
  131859. */
  131860. export interface WebXRRenderTarget extends IDisposable {
  131861. /**
  131862. * xrpresent context of the canvas which can be used to display/mirror xr content
  131863. */
  131864. canvasContext: WebGLRenderingContext;
  131865. /**
  131866. * xr layer for the canvas
  131867. */
  131868. xrLayer: Nullable<XRWebGLLayer>;
  131869. /**
  131870. * Initializes the xr layer for the session
  131871. * @param xrSession xr session
  131872. * @returns a promise that will resolve once the XR Layer has been created
  131873. */
  131874. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  131875. }
  131876. }
  131877. declare module BABYLON {
  131878. /**
  131879. * COnfiguration object for WebXR output canvas
  131880. */
  131881. export class WebXRManagedOutputCanvasOptions {
  131882. /**
  131883. * An optional canvas in case you wish to create it yourself and provide it here.
  131884. * If not provided, a new canvas will be created
  131885. */
  131886. canvasElement?: HTMLCanvasElement;
  131887. /**
  131888. * Options for this XR Layer output
  131889. */
  131890. canvasOptions?: XRWebGLLayerInit;
  131891. /**
  131892. * CSS styling for a newly created canvas (if not provided)
  131893. */
  131894. newCanvasCssStyle?: string;
  131895. /**
  131896. * Get the default values of the configuration object
  131897. * @param engine defines the engine to use (can be null)
  131898. * @returns default values of this configuration object
  131899. */
  131900. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  131901. }
  131902. /**
  131903. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  131904. */
  131905. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  131906. private _options;
  131907. private _canvas;
  131908. private _engine;
  131909. private _originalCanvasSize;
  131910. /**
  131911. * Rendering context of the canvas which can be used to display/mirror xr content
  131912. */
  131913. canvasContext: WebGLRenderingContext;
  131914. /**
  131915. * xr layer for the canvas
  131916. */
  131917. xrLayer: Nullable<XRWebGLLayer>;
  131918. /**
  131919. * Obseervers registered here will be triggered when the xr layer was initialized
  131920. */
  131921. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  131922. /**
  131923. * Initializes the canvas to be added/removed upon entering/exiting xr
  131924. * @param _xrSessionManager The XR Session manager
  131925. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  131926. */
  131927. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  131928. /**
  131929. * Disposes of the object
  131930. */
  131931. dispose(): void;
  131932. /**
  131933. * Initializes the xr layer for the session
  131934. * @param xrSession xr session
  131935. * @returns a promise that will resolve once the XR Layer has been created
  131936. */
  131937. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  131938. private _addCanvas;
  131939. private _removeCanvas;
  131940. private _setCanvasSize;
  131941. private _setManagedOutputCanvas;
  131942. }
  131943. }
  131944. declare module BABYLON {
  131945. /**
  131946. * Manages an XRSession to work with Babylon's engine
  131947. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  131948. */
  131949. export class WebXRSessionManager implements IDisposable {
  131950. /** The scene which the session should be created for */
  131951. scene: Scene;
  131952. private _referenceSpace;
  131953. private _rttProvider;
  131954. private _sessionEnded;
  131955. private _xrNavigator;
  131956. private baseLayer;
  131957. /**
  131958. * The base reference space from which the session started. good if you want to reset your
  131959. * reference space
  131960. */
  131961. baseReferenceSpace: XRReferenceSpace;
  131962. /**
  131963. * Current XR frame
  131964. */
  131965. currentFrame: Nullable<XRFrame>;
  131966. /** WebXR timestamp updated every frame */
  131967. currentTimestamp: number;
  131968. /**
  131969. * Used just in case of a failure to initialize an immersive session.
  131970. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  131971. */
  131972. defaultHeightCompensation: number;
  131973. /**
  131974. * Fires every time a new xrFrame arrives which can be used to update the camera
  131975. */
  131976. onXRFrameObservable: Observable<XRFrame>;
  131977. /**
  131978. * Fires when the reference space changed
  131979. */
  131980. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  131981. /**
  131982. * Fires when the xr session is ended either by the device or manually done
  131983. */
  131984. onXRSessionEnded: Observable<any>;
  131985. /**
  131986. * Fires when the xr session is ended either by the device or manually done
  131987. */
  131988. onXRSessionInit: Observable<XRSession>;
  131989. /**
  131990. * Underlying xr session
  131991. */
  131992. session: XRSession;
  131993. /**
  131994. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  131995. * or get the offset the player is currently at.
  131996. */
  131997. viewerReferenceSpace: XRReferenceSpace;
  131998. /**
  131999. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  132000. * @param scene The scene which the session should be created for
  132001. */
  132002. constructor(
  132003. /** The scene which the session should be created for */
  132004. scene: Scene);
  132005. /**
  132006. * The current reference space used in this session. This reference space can constantly change!
  132007. * It is mainly used to offset the camera's position.
  132008. */
  132009. get referenceSpace(): XRReferenceSpace;
  132010. /**
  132011. * Set a new reference space and triggers the observable
  132012. */
  132013. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  132014. /**
  132015. * Disposes of the session manager
  132016. */
  132017. dispose(): void;
  132018. /**
  132019. * Stops the xrSession and restores the render loop
  132020. * @returns Promise which resolves after it exits XR
  132021. */
  132022. exitXRAsync(): Promise<void>;
  132023. /**
  132024. * Gets the correct render target texture to be rendered this frame for this eye
  132025. * @param eye the eye for which to get the render target
  132026. * @returns the render target for the specified eye
  132027. */
  132028. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  132029. /**
  132030. * Creates a WebXRRenderTarget object for the XR session
  132031. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  132032. * @param options optional options to provide when creating a new render target
  132033. * @returns a WebXR render target to which the session can render
  132034. */
  132035. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  132036. /**
  132037. * Initializes the manager
  132038. * After initialization enterXR can be called to start an XR session
  132039. * @returns Promise which resolves after it is initialized
  132040. */
  132041. initializeAsync(): Promise<void>;
  132042. /**
  132043. * Initializes an xr session
  132044. * @param xrSessionMode mode to initialize
  132045. * @param xrSessionInit defines optional and required values to pass to the session builder
  132046. * @returns a promise which will resolve once the session has been initialized
  132047. */
  132048. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  132049. /**
  132050. * Checks if a session would be supported for the creation options specified
  132051. * @param sessionMode session mode to check if supported eg. immersive-vr
  132052. * @returns A Promise that resolves to true if supported and false if not
  132053. */
  132054. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  132055. /**
  132056. * Resets the reference space to the one started the session
  132057. */
  132058. resetReferenceSpace(): void;
  132059. /**
  132060. * Starts rendering to the xr layer
  132061. */
  132062. runXRRenderLoop(): void;
  132063. /**
  132064. * Sets the reference space on the xr session
  132065. * @param referenceSpaceType space to set
  132066. * @returns a promise that will resolve once the reference space has been set
  132067. */
  132068. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  132069. /**
  132070. * Updates the render state of the session
  132071. * @param state state to set
  132072. * @returns a promise that resolves once the render state has been updated
  132073. */
  132074. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  132075. /**
  132076. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  132077. * @param sessionMode defines the session to test
  132078. * @returns a promise with boolean as final value
  132079. */
  132080. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  132081. private _createRenderTargetTexture;
  132082. }
  132083. }
  132084. declare module BABYLON {
  132085. /**
  132086. * WebXR Camera which holds the views for the xrSession
  132087. * @see https://doc.babylonjs.com/how_to/webxr_camera
  132088. */
  132089. export class WebXRCamera extends FreeCamera {
  132090. private _xrSessionManager;
  132091. private _firstFrame;
  132092. private _referenceQuaternion;
  132093. private _referencedPosition;
  132094. private _xrInvPositionCache;
  132095. private _xrInvQuaternionCache;
  132096. private _trackingState;
  132097. /**
  132098. * Observable raised before camera teleportation
  132099. */
  132100. onBeforeCameraTeleport: Observable<Vector3>;
  132101. /**
  132102. * Observable raised after camera teleportation
  132103. */
  132104. onAfterCameraTeleport: Observable<Vector3>;
  132105. /**
  132106. * Notifies when the camera's tracking state has changed.
  132107. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  132108. */
  132109. onTrackingStateChanged: Observable<WebXRTrackingState>;
  132110. /**
  132111. * Should position compensation execute on first frame.
  132112. * This is used when copying the position from a native (non XR) camera
  132113. */
  132114. compensateOnFirstFrame: boolean;
  132115. /**
  132116. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  132117. * @param name the name of the camera
  132118. * @param scene the scene to add the camera to
  132119. * @param _xrSessionManager a constructed xr session manager
  132120. */
  132121. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  132122. /**
  132123. * Get the current XR tracking state of the camera
  132124. */
  132125. get trackingState(): WebXRTrackingState;
  132126. private _setTrackingState;
  132127. /**
  132128. * Return the user's height, unrelated to the current ground.
  132129. * This will be the y position of this camera, when ground level is 0.
  132130. */
  132131. get realWorldHeight(): number;
  132132. /** @hidden */
  132133. _updateForDualEyeDebugging(): void;
  132134. /**
  132135. * Sets this camera's transformation based on a non-vr camera
  132136. * @param otherCamera the non-vr camera to copy the transformation from
  132137. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  132138. */
  132139. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  132140. /**
  132141. * Gets the current instance class name ("WebXRCamera").
  132142. * @returns the class name
  132143. */
  132144. getClassName(): string;
  132145. private _rotate180;
  132146. private _updateFromXRSession;
  132147. private _updateNumberOfRigCameras;
  132148. private _updateReferenceSpace;
  132149. private _updateReferenceSpaceOffset;
  132150. }
  132151. }
  132152. declare module BABYLON {
  132153. /**
  132154. * Defining the interface required for a (webxr) feature
  132155. */
  132156. export interface IWebXRFeature extends IDisposable {
  132157. /**
  132158. * Is this feature attached
  132159. */
  132160. attached: boolean;
  132161. /**
  132162. * Should auto-attach be disabled?
  132163. */
  132164. disableAutoAttach: boolean;
  132165. /**
  132166. * Attach the feature to the session
  132167. * Will usually be called by the features manager
  132168. *
  132169. * @param force should attachment be forced (even when already attached)
  132170. * @returns true if successful.
  132171. */
  132172. attach(force?: boolean): boolean;
  132173. /**
  132174. * Detach the feature from the session
  132175. * Will usually be called by the features manager
  132176. *
  132177. * @returns true if successful.
  132178. */
  132179. detach(): boolean;
  132180. /**
  132181. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  132182. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  132183. *
  132184. * @returns whether or not the feature is compatible in this environment
  132185. */
  132186. isCompatible(): boolean;
  132187. /**
  132188. * Was this feature disposed;
  132189. */
  132190. isDisposed: boolean;
  132191. /**
  132192. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  132193. */
  132194. xrNativeFeatureName?: string;
  132195. /**
  132196. * A list of (Babylon WebXR) features this feature depends on
  132197. */
  132198. dependsOn?: string[];
  132199. }
  132200. /**
  132201. * A list of the currently available features without referencing them
  132202. */
  132203. export class WebXRFeatureName {
  132204. /**
  132205. * The name of the anchor system feature
  132206. */
  132207. static readonly ANCHOR_SYSTEM: string;
  132208. /**
  132209. * The name of the background remover feature
  132210. */
  132211. static readonly BACKGROUND_REMOVER: string;
  132212. /**
  132213. * The name of the hit test feature
  132214. */
  132215. static readonly HIT_TEST: string;
  132216. /**
  132217. * physics impostors for xr controllers feature
  132218. */
  132219. static readonly PHYSICS_CONTROLLERS: string;
  132220. /**
  132221. * The name of the plane detection feature
  132222. */
  132223. static readonly PLANE_DETECTION: string;
  132224. /**
  132225. * The name of the pointer selection feature
  132226. */
  132227. static readonly POINTER_SELECTION: string;
  132228. /**
  132229. * The name of the teleportation feature
  132230. */
  132231. static readonly TELEPORTATION: string;
  132232. /**
  132233. * The name of the feature points feature.
  132234. */
  132235. static readonly FEATURE_POINTS: string;
  132236. /**
  132237. * The name of the hand tracking feature.
  132238. */
  132239. static readonly HAND_TRACKING: string;
  132240. }
  132241. /**
  132242. * Defining the constructor of a feature. Used to register the modules.
  132243. */
  132244. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  132245. /**
  132246. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  132247. * It is mainly used in AR sessions.
  132248. *
  132249. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  132250. */
  132251. export class WebXRFeaturesManager implements IDisposable {
  132252. private _xrSessionManager;
  132253. private static readonly _AvailableFeatures;
  132254. private _features;
  132255. /**
  132256. * constructs a new features manages.
  132257. *
  132258. * @param _xrSessionManager an instance of WebXRSessionManager
  132259. */
  132260. constructor(_xrSessionManager: WebXRSessionManager);
  132261. /**
  132262. * Used to register a module. After calling this function a developer can use this feature in the scene.
  132263. * Mainly used internally.
  132264. *
  132265. * @param featureName the name of the feature to register
  132266. * @param constructorFunction the function used to construct the module
  132267. * @param version the (babylon) version of the module
  132268. * @param stable is that a stable version of this module
  132269. */
  132270. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  132271. /**
  132272. * Returns a constructor of a specific feature.
  132273. *
  132274. * @param featureName the name of the feature to construct
  132275. * @param version the version of the feature to load
  132276. * @param xrSessionManager the xrSessionManager. Used to construct the module
  132277. * @param options optional options provided to the module.
  132278. * @returns a function that, when called, will return a new instance of this feature
  132279. */
  132280. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  132281. /**
  132282. * Can be used to return the list of features currently registered
  132283. *
  132284. * @returns an Array of available features
  132285. */
  132286. static GetAvailableFeatures(): string[];
  132287. /**
  132288. * Gets the versions available for a specific feature
  132289. * @param featureName the name of the feature
  132290. * @returns an array with the available versions
  132291. */
  132292. static GetAvailableVersions(featureName: string): string[];
  132293. /**
  132294. * Return the latest unstable version of this feature
  132295. * @param featureName the name of the feature to search
  132296. * @returns the version number. if not found will return -1
  132297. */
  132298. static GetLatestVersionOfFeature(featureName: string): number;
  132299. /**
  132300. * Return the latest stable version of this feature
  132301. * @param featureName the name of the feature to search
  132302. * @returns the version number. if not found will return -1
  132303. */
  132304. static GetStableVersionOfFeature(featureName: string): number;
  132305. /**
  132306. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  132307. * Can be used during a session to start a feature
  132308. * @param featureName the name of feature to attach
  132309. */
  132310. attachFeature(featureName: string): void;
  132311. /**
  132312. * Can be used inside a session or when the session ends to detach a specific feature
  132313. * @param featureName the name of the feature to detach
  132314. */
  132315. detachFeature(featureName: string): void;
  132316. /**
  132317. * Used to disable an already-enabled feature
  132318. * The feature will be disposed and will be recreated once enabled.
  132319. * @param featureName the feature to disable
  132320. * @returns true if disable was successful
  132321. */
  132322. disableFeature(featureName: string | {
  132323. Name: string;
  132324. }): boolean;
  132325. /**
  132326. * dispose this features manager
  132327. */
  132328. dispose(): void;
  132329. /**
  132330. * 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.
  132331. * 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.
  132332. *
  132333. * @param featureName the name of the feature to load or the class of the feature
  132334. * @param version optional version to load. if not provided the latest version will be enabled
  132335. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  132336. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  132337. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  132338. * @returns a new constructed feature or throws an error if feature not found.
  132339. */
  132340. enableFeature(featureName: string | {
  132341. Name: string;
  132342. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  132343. /**
  132344. * get the implementation of an enabled feature.
  132345. * @param featureName the name of the feature to load
  132346. * @returns the feature class, if found
  132347. */
  132348. getEnabledFeature(featureName: string): IWebXRFeature;
  132349. /**
  132350. * Get the list of enabled features
  132351. * @returns an array of enabled features
  132352. */
  132353. getEnabledFeatures(): string[];
  132354. /**
  132355. * This function will exten the session creation configuration object with enabled features.
  132356. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  132357. * according to the defined "required" variable, provided during enableFeature call
  132358. * @param xrSessionInit the xr Session init object to extend
  132359. *
  132360. * @returns an extended XRSessionInit object
  132361. */
  132362. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  132363. }
  132364. }
  132365. declare module BABYLON {
  132366. /**
  132367. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  132368. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  132369. */
  132370. export class WebXRExperienceHelper implements IDisposable {
  132371. private scene;
  132372. private _nonVRCamera;
  132373. private _originalSceneAutoClear;
  132374. private _supported;
  132375. /**
  132376. * Camera used to render xr content
  132377. */
  132378. camera: WebXRCamera;
  132379. /** A features manager for this xr session */
  132380. featuresManager: WebXRFeaturesManager;
  132381. /**
  132382. * Observers registered here will be triggered after the camera's initial transformation is set
  132383. * This can be used to set a different ground level or an extra rotation.
  132384. *
  132385. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  132386. * to the position set after this observable is done executing.
  132387. */
  132388. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  132389. /**
  132390. * Fires when the state of the experience helper has changed
  132391. */
  132392. onStateChangedObservable: Observable<WebXRState>;
  132393. /** Session manager used to keep track of xr session */
  132394. sessionManager: WebXRSessionManager;
  132395. /**
  132396. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  132397. */
  132398. state: WebXRState;
  132399. /**
  132400. * Creates a WebXRExperienceHelper
  132401. * @param scene The scene the helper should be created in
  132402. */
  132403. private constructor();
  132404. /**
  132405. * Creates the experience helper
  132406. * @param scene the scene to attach the experience helper to
  132407. * @returns a promise for the experience helper
  132408. */
  132409. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  132410. /**
  132411. * Disposes of the experience helper
  132412. */
  132413. dispose(): void;
  132414. /**
  132415. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  132416. * @param sessionMode options for the XR session
  132417. * @param referenceSpaceType frame of reference of the XR session
  132418. * @param renderTarget the output canvas that will be used to enter XR mode
  132419. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  132420. * @returns promise that resolves after xr mode has entered
  132421. */
  132422. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  132423. /**
  132424. * Exits XR mode and returns the scene to its original state
  132425. * @returns promise that resolves after xr mode has exited
  132426. */
  132427. exitXRAsync(): Promise<void>;
  132428. private _nonXRToXRCamera;
  132429. private _setState;
  132430. }
  132431. }
  132432. declare module BABYLON {
  132433. /**
  132434. * X-Y values for axes in WebXR
  132435. */
  132436. export interface IWebXRMotionControllerAxesValue {
  132437. /**
  132438. * The value of the x axis
  132439. */
  132440. x: number;
  132441. /**
  132442. * The value of the y-axis
  132443. */
  132444. y: number;
  132445. }
  132446. /**
  132447. * changed / previous values for the values of this component
  132448. */
  132449. export interface IWebXRMotionControllerComponentChangesValues<T> {
  132450. /**
  132451. * current (this frame) value
  132452. */
  132453. current: T;
  132454. /**
  132455. * previous (last change) value
  132456. */
  132457. previous: T;
  132458. }
  132459. /**
  132460. * Represents changes in the component between current frame and last values recorded
  132461. */
  132462. export interface IWebXRMotionControllerComponentChanges {
  132463. /**
  132464. * will be populated with previous and current values if axes changed
  132465. */
  132466. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  132467. /**
  132468. * will be populated with previous and current values if pressed changed
  132469. */
  132470. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  132471. /**
  132472. * will be populated with previous and current values if touched changed
  132473. */
  132474. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  132475. /**
  132476. * will be populated with previous and current values if value changed
  132477. */
  132478. value?: IWebXRMotionControllerComponentChangesValues<number>;
  132479. }
  132480. /**
  132481. * This class represents a single component (for example button or thumbstick) of a motion controller
  132482. */
  132483. export class WebXRControllerComponent implements IDisposable {
  132484. /**
  132485. * the id of this component
  132486. */
  132487. id: string;
  132488. /**
  132489. * the type of the component
  132490. */
  132491. type: MotionControllerComponentType;
  132492. private _buttonIndex;
  132493. private _axesIndices;
  132494. private _axes;
  132495. private _changes;
  132496. private _currentValue;
  132497. private _hasChanges;
  132498. private _pressed;
  132499. private _touched;
  132500. /**
  132501. * button component type
  132502. */
  132503. static BUTTON_TYPE: MotionControllerComponentType;
  132504. /**
  132505. * squeeze component type
  132506. */
  132507. static SQUEEZE_TYPE: MotionControllerComponentType;
  132508. /**
  132509. * Thumbstick component type
  132510. */
  132511. static THUMBSTICK_TYPE: MotionControllerComponentType;
  132512. /**
  132513. * Touchpad component type
  132514. */
  132515. static TOUCHPAD_TYPE: MotionControllerComponentType;
  132516. /**
  132517. * trigger component type
  132518. */
  132519. static TRIGGER_TYPE: MotionControllerComponentType;
  132520. /**
  132521. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  132522. * the axes data changes
  132523. */
  132524. onAxisValueChangedObservable: Observable<{
  132525. x: number;
  132526. y: number;
  132527. }>;
  132528. /**
  132529. * Observers registered here will be triggered when the state of a button changes
  132530. * State change is either pressed / touched / value
  132531. */
  132532. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  132533. /**
  132534. * Creates a new component for a motion controller.
  132535. * It is created by the motion controller itself
  132536. *
  132537. * @param id the id of this component
  132538. * @param type the type of the component
  132539. * @param _buttonIndex index in the buttons array of the gamepad
  132540. * @param _axesIndices indices of the values in the axes array of the gamepad
  132541. */
  132542. constructor(
  132543. /**
  132544. * the id of this component
  132545. */
  132546. id: string,
  132547. /**
  132548. * the type of the component
  132549. */
  132550. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  132551. /**
  132552. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  132553. */
  132554. get axes(): IWebXRMotionControllerAxesValue;
  132555. /**
  132556. * Get the changes. Elements will be populated only if they changed with their previous and current value
  132557. */
  132558. get changes(): IWebXRMotionControllerComponentChanges;
  132559. /**
  132560. * Return whether or not the component changed the last frame
  132561. */
  132562. get hasChanges(): boolean;
  132563. /**
  132564. * is the button currently pressed
  132565. */
  132566. get pressed(): boolean;
  132567. /**
  132568. * is the button currently touched
  132569. */
  132570. get touched(): boolean;
  132571. /**
  132572. * Get the current value of this component
  132573. */
  132574. get value(): number;
  132575. /**
  132576. * Dispose this component
  132577. */
  132578. dispose(): void;
  132579. /**
  132580. * Are there axes correlating to this component
  132581. * @return true is axes data is available
  132582. */
  132583. isAxes(): boolean;
  132584. /**
  132585. * Is this component a button (hence - pressable)
  132586. * @returns true if can be pressed
  132587. */
  132588. isButton(): boolean;
  132589. /**
  132590. * update this component using the gamepad object it is in. Called on every frame
  132591. * @param nativeController the native gamepad controller object
  132592. */
  132593. update(nativeController: IMinimalMotionControllerObject): void;
  132594. }
  132595. }
  132596. declare module BABYLON {
  132597. /**
  132598. * Interface used to represent data loading progression
  132599. */
  132600. export interface ISceneLoaderProgressEvent {
  132601. /**
  132602. * Defines if data length to load can be evaluated
  132603. */
  132604. readonly lengthComputable: boolean;
  132605. /**
  132606. * Defines the loaded data length
  132607. */
  132608. readonly loaded: number;
  132609. /**
  132610. * Defines the data length to load
  132611. */
  132612. readonly total: number;
  132613. }
  132614. /**
  132615. * Interface used by SceneLoader plugins to define supported file extensions
  132616. */
  132617. export interface ISceneLoaderPluginExtensions {
  132618. /**
  132619. * Defines the list of supported extensions
  132620. */
  132621. [extension: string]: {
  132622. isBinary: boolean;
  132623. };
  132624. }
  132625. /**
  132626. * Interface used by SceneLoader plugin factory
  132627. */
  132628. export interface ISceneLoaderPluginFactory {
  132629. /**
  132630. * Defines the name of the factory
  132631. */
  132632. name: string;
  132633. /**
  132634. * Function called to create a new plugin
  132635. * @return the new plugin
  132636. */
  132637. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  132638. /**
  132639. * The callback that returns true if the data can be directly loaded.
  132640. * @param data string containing the file data
  132641. * @returns if the data can be loaded directly
  132642. */
  132643. canDirectLoad?(data: string): boolean;
  132644. }
  132645. /**
  132646. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  132647. */
  132648. export interface ISceneLoaderPluginBase {
  132649. /**
  132650. * The friendly name of this plugin.
  132651. */
  132652. name: string;
  132653. /**
  132654. * The file extensions supported by this plugin.
  132655. */
  132656. extensions: string | ISceneLoaderPluginExtensions;
  132657. /**
  132658. * The callback called when loading from a url.
  132659. * @param scene scene loading this url
  132660. * @param url url to load
  132661. * @param onSuccess callback called when the file successfully loads
  132662. * @param onProgress callback called while file is loading (if the server supports this mode)
  132663. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  132664. * @param onError callback called when the file fails to load
  132665. * @returns a file request object
  132666. */
  132667. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  132668. /**
  132669. * The callback called when loading from a file object.
  132670. * @param scene scene loading this file
  132671. * @param file defines the file to load
  132672. * @param onSuccess defines the callback to call when data is loaded
  132673. * @param onProgress defines the callback to call during loading process
  132674. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  132675. * @param onError defines the callback to call when an error occurs
  132676. * @returns a file request object
  132677. */
  132678. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  132679. /**
  132680. * The callback that returns true if the data can be directly loaded.
  132681. * @param data string containing the file data
  132682. * @returns if the data can be loaded directly
  132683. */
  132684. canDirectLoad?(data: string): boolean;
  132685. /**
  132686. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  132687. * @param scene scene loading this data
  132688. * @param data string containing the data
  132689. * @returns data to pass to the plugin
  132690. */
  132691. directLoad?(scene: Scene, data: string): any;
  132692. /**
  132693. * The callback that allows custom handling of the root url based on the response url.
  132694. * @param rootUrl the original root url
  132695. * @param responseURL the response url if available
  132696. * @returns the new root url
  132697. */
  132698. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  132699. }
  132700. /**
  132701. * Interface used to define a SceneLoader plugin
  132702. */
  132703. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  132704. /**
  132705. * Import meshes into a scene.
  132706. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132707. * @param scene The scene to import into
  132708. * @param data The data to import
  132709. * @param rootUrl The root url for scene and resources
  132710. * @param meshes The meshes array to import into
  132711. * @param particleSystems The particle systems array to import into
  132712. * @param skeletons The skeletons array to import into
  132713. * @param onError The callback when import fails
  132714. * @returns True if successful or false otherwise
  132715. */
  132716. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  132717. /**
  132718. * Load into a scene.
  132719. * @param scene The scene to load into
  132720. * @param data The data to import
  132721. * @param rootUrl The root url for scene and resources
  132722. * @param onError The callback when import fails
  132723. * @returns True if successful or false otherwise
  132724. */
  132725. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  132726. /**
  132727. * Load into an asset container.
  132728. * @param scene The scene to load into
  132729. * @param data The data to import
  132730. * @param rootUrl The root url for scene and resources
  132731. * @param onError The callback when import fails
  132732. * @returns The loaded asset container
  132733. */
  132734. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  132735. }
  132736. /**
  132737. * Interface used to define an async SceneLoader plugin
  132738. */
  132739. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  132740. /**
  132741. * Import meshes into a scene.
  132742. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132743. * @param scene The scene to import into
  132744. * @param data The data to import
  132745. * @param rootUrl The root url for scene and resources
  132746. * @param onProgress The callback when the load progresses
  132747. * @param fileName Defines the name of the file to load
  132748. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  132749. */
  132750. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  132751. meshes: AbstractMesh[];
  132752. particleSystems: IParticleSystem[];
  132753. skeletons: Skeleton[];
  132754. animationGroups: AnimationGroup[];
  132755. }>;
  132756. /**
  132757. * Load into a scene.
  132758. * @param scene The scene to load into
  132759. * @param data The data to import
  132760. * @param rootUrl The root url for scene and resources
  132761. * @param onProgress The callback when the load progresses
  132762. * @param fileName Defines the name of the file to load
  132763. * @returns Nothing
  132764. */
  132765. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  132766. /**
  132767. * Load into an asset container.
  132768. * @param scene The scene to load into
  132769. * @param data The data to import
  132770. * @param rootUrl The root url for scene and resources
  132771. * @param onProgress The callback when the load progresses
  132772. * @param fileName Defines the name of the file to load
  132773. * @returns The loaded asset container
  132774. */
  132775. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  132776. }
  132777. /**
  132778. * Mode that determines how to handle old animation groups before loading new ones.
  132779. */
  132780. export enum SceneLoaderAnimationGroupLoadingMode {
  132781. /**
  132782. * Reset all old animations to initial state then dispose them.
  132783. */
  132784. Clean = 0,
  132785. /**
  132786. * Stop all old animations.
  132787. */
  132788. Stop = 1,
  132789. /**
  132790. * Restart old animations from first frame.
  132791. */
  132792. Sync = 2,
  132793. /**
  132794. * Old animations remains untouched.
  132795. */
  132796. NoSync = 3
  132797. }
  132798. /**
  132799. * Defines a plugin registered by the SceneLoader
  132800. */
  132801. interface IRegisteredPlugin {
  132802. /**
  132803. * Defines the plugin to use
  132804. */
  132805. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  132806. /**
  132807. * Defines if the plugin supports binary data
  132808. */
  132809. isBinary: boolean;
  132810. }
  132811. /**
  132812. * Class used to load scene from various file formats using registered plugins
  132813. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  132814. */
  132815. export class SceneLoader {
  132816. /**
  132817. * No logging while loading
  132818. */
  132819. static readonly NO_LOGGING: number;
  132820. /**
  132821. * Minimal logging while loading
  132822. */
  132823. static readonly MINIMAL_LOGGING: number;
  132824. /**
  132825. * Summary logging while loading
  132826. */
  132827. static readonly SUMMARY_LOGGING: number;
  132828. /**
  132829. * Detailled logging while loading
  132830. */
  132831. static readonly DETAILED_LOGGING: number;
  132832. /**
  132833. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  132834. */
  132835. static get ForceFullSceneLoadingForIncremental(): boolean;
  132836. static set ForceFullSceneLoadingForIncremental(value: boolean);
  132837. /**
  132838. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  132839. */
  132840. static get ShowLoadingScreen(): boolean;
  132841. static set ShowLoadingScreen(value: boolean);
  132842. /**
  132843. * Defines the current logging level (while loading the scene)
  132844. * @ignorenaming
  132845. */
  132846. static get loggingLevel(): number;
  132847. static set loggingLevel(value: number);
  132848. /**
  132849. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  132850. */
  132851. static get CleanBoneMatrixWeights(): boolean;
  132852. static set CleanBoneMatrixWeights(value: boolean);
  132853. /**
  132854. * Event raised when a plugin is used to load a scene
  132855. */
  132856. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  132857. private static _registeredPlugins;
  132858. private static _showingLoadingScreen;
  132859. /**
  132860. * Gets the default plugin (used to load Babylon files)
  132861. * @returns the .babylon plugin
  132862. */
  132863. static GetDefaultPlugin(): IRegisteredPlugin;
  132864. private static _GetPluginForExtension;
  132865. private static _GetPluginForDirectLoad;
  132866. private static _GetPluginForFilename;
  132867. private static _GetDirectLoad;
  132868. private static _LoadData;
  132869. private static _GetFileInfo;
  132870. /**
  132871. * Gets a plugin that can load the given extension
  132872. * @param extension defines the extension to load
  132873. * @returns a plugin or null if none works
  132874. */
  132875. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  132876. /**
  132877. * Gets a boolean indicating that the given extension can be loaded
  132878. * @param extension defines the extension to load
  132879. * @returns true if the extension is supported
  132880. */
  132881. static IsPluginForExtensionAvailable(extension: string): boolean;
  132882. /**
  132883. * Adds a new plugin to the list of registered plugins
  132884. * @param plugin defines the plugin to add
  132885. */
  132886. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  132887. /**
  132888. * Import meshes into a scene
  132889. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132890. * @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)
  132891. * @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)
  132892. * @param scene the instance of BABYLON.Scene to append to
  132893. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  132894. * @param onProgress a callback with a progress event for each file being loaded
  132895. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132896. * @param pluginExtension the extension used to determine the plugin
  132897. * @returns The loaded plugin
  132898. */
  132899. 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>;
  132900. /**
  132901. * Import meshes into a scene
  132902. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132903. * @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)
  132904. * @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)
  132905. * @param scene the instance of BABYLON.Scene to append to
  132906. * @param onProgress a callback with a progress event for each file being loaded
  132907. * @param pluginExtension the extension used to determine the plugin
  132908. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  132909. */
  132910. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  132911. meshes: AbstractMesh[];
  132912. particleSystems: IParticleSystem[];
  132913. skeletons: Skeleton[];
  132914. animationGroups: AnimationGroup[];
  132915. }>;
  132916. /**
  132917. * Load a scene
  132918. * @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)
  132919. * @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)
  132920. * @param engine is the instance of BABYLON.Engine to use to create the scene
  132921. * @param onSuccess a callback with the scene when import succeeds
  132922. * @param onProgress a callback with a progress event for each file being loaded
  132923. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132924. * @param pluginExtension the extension used to determine the plugin
  132925. * @returns The loaded plugin
  132926. */
  132927. 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>;
  132928. /**
  132929. * Load a scene
  132930. * @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)
  132931. * @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)
  132932. * @param engine is the instance of BABYLON.Engine to use to create the scene
  132933. * @param onProgress a callback with a progress event for each file being loaded
  132934. * @param pluginExtension the extension used to determine the plugin
  132935. * @returns The loaded scene
  132936. */
  132937. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  132938. /**
  132939. * Append a scene
  132940. * @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)
  132941. * @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)
  132942. * @param scene is the instance of BABYLON.Scene to append to
  132943. * @param onSuccess a callback with the scene when import succeeds
  132944. * @param onProgress a callback with a progress event for each file being loaded
  132945. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132946. * @param pluginExtension the extension used to determine the plugin
  132947. * @returns The loaded plugin
  132948. */
  132949. 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>;
  132950. /**
  132951. * Append a scene
  132952. * @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)
  132953. * @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)
  132954. * @param scene is the instance of BABYLON.Scene to append to
  132955. * @param onProgress a callback with a progress event for each file being loaded
  132956. * @param pluginExtension the extension used to determine the plugin
  132957. * @returns The given scene
  132958. */
  132959. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  132960. /**
  132961. * Load a scene into an asset container
  132962. * @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)
  132963. * @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)
  132964. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  132965. * @param onSuccess a callback with the scene when import succeeds
  132966. * @param onProgress a callback with a progress event for each file being loaded
  132967. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132968. * @param pluginExtension the extension used to determine the plugin
  132969. * @returns The loaded plugin
  132970. */
  132971. 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>;
  132972. /**
  132973. * Load a scene into an asset container
  132974. * @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)
  132975. * @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)
  132976. * @param scene is the instance of Scene to append to
  132977. * @param onProgress a callback with a progress event for each file being loaded
  132978. * @param pluginExtension the extension used to determine the plugin
  132979. * @returns The loaded asset container
  132980. */
  132981. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  132982. /**
  132983. * Import animations from a file into a scene
  132984. * @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)
  132985. * @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)
  132986. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  132987. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  132988. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  132989. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  132990. * @param onSuccess a callback with the scene when import succeeds
  132991. * @param onProgress a callback with a progress event for each file being loaded
  132992. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132993. * @param pluginExtension the extension used to determine the plugin
  132994. */
  132995. 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;
  132996. /**
  132997. * Import animations from a file into a scene
  132998. * @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)
  132999. * @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)
  133000. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  133001. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  133002. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  133003. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  133004. * @param onSuccess a callback with the scene when import succeeds
  133005. * @param onProgress a callback with a progress event for each file being loaded
  133006. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133007. * @param pluginExtension the extension used to determine the plugin
  133008. * @returns the updated scene with imported animations
  133009. */
  133010. 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>;
  133011. }
  133012. }
  133013. declare module BABYLON {
  133014. /**
  133015. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  133016. */
  133017. export type MotionControllerHandedness = "none" | "left" | "right";
  133018. /**
  133019. * The type of components available in motion controllers.
  133020. * This is not the name of the component.
  133021. */
  133022. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  133023. /**
  133024. * The state of a controller component
  133025. */
  133026. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  133027. /**
  133028. * The schema of motion controller layout.
  133029. * No object will be initialized using this interface
  133030. * This is used just to define the profile.
  133031. */
  133032. export interface IMotionControllerLayout {
  133033. /**
  133034. * Path to load the assets. Usually relative to the base path
  133035. */
  133036. assetPath: string;
  133037. /**
  133038. * Available components (unsorted)
  133039. */
  133040. components: {
  133041. /**
  133042. * A map of component Ids
  133043. */
  133044. [componentId: string]: {
  133045. /**
  133046. * The type of input the component outputs
  133047. */
  133048. type: MotionControllerComponentType;
  133049. /**
  133050. * The indices of this component in the gamepad object
  133051. */
  133052. gamepadIndices: {
  133053. /**
  133054. * Index of button
  133055. */
  133056. button?: number;
  133057. /**
  133058. * If available, index of x-axis
  133059. */
  133060. xAxis?: number;
  133061. /**
  133062. * If available, index of y-axis
  133063. */
  133064. yAxis?: number;
  133065. };
  133066. /**
  133067. * The mesh's root node name
  133068. */
  133069. rootNodeName: string;
  133070. /**
  133071. * Animation definitions for this model
  133072. */
  133073. visualResponses: {
  133074. [stateKey: string]: {
  133075. /**
  133076. * What property will be animated
  133077. */
  133078. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  133079. /**
  133080. * What states influence this visual response
  133081. */
  133082. states: MotionControllerComponentStateType[];
  133083. /**
  133084. * Type of animation - movement or visibility
  133085. */
  133086. valueNodeProperty: "transform" | "visibility";
  133087. /**
  133088. * Base node name to move. Its position will be calculated according to the min and max nodes
  133089. */
  133090. valueNodeName?: string;
  133091. /**
  133092. * Minimum movement node
  133093. */
  133094. minNodeName?: string;
  133095. /**
  133096. * Max movement node
  133097. */
  133098. maxNodeName?: string;
  133099. };
  133100. };
  133101. /**
  133102. * If touch enabled, what is the name of node to display user feedback
  133103. */
  133104. touchPointNodeName?: string;
  133105. };
  133106. };
  133107. /**
  133108. * Is it xr standard mapping or not
  133109. */
  133110. gamepadMapping: "" | "xr-standard";
  133111. /**
  133112. * Base root node of this entire model
  133113. */
  133114. rootNodeName: string;
  133115. /**
  133116. * Defines the main button component id
  133117. */
  133118. selectComponentId: string;
  133119. }
  133120. /**
  133121. * A definition for the layout map in the input profile
  133122. */
  133123. export interface IMotionControllerLayoutMap {
  133124. /**
  133125. * Layouts with handedness type as a key
  133126. */
  133127. [handedness: string]: IMotionControllerLayout;
  133128. }
  133129. /**
  133130. * The XR Input profile schema
  133131. * Profiles can be found here:
  133132. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  133133. */
  133134. export interface IMotionControllerProfile {
  133135. /**
  133136. * fallback profiles for this profileId
  133137. */
  133138. fallbackProfileIds: string[];
  133139. /**
  133140. * The layout map, with handedness as key
  133141. */
  133142. layouts: IMotionControllerLayoutMap;
  133143. /**
  133144. * The id of this profile
  133145. * correlates to the profile(s) in the xrInput.profiles array
  133146. */
  133147. profileId: string;
  133148. }
  133149. /**
  133150. * A helper-interface for the 3 meshes needed for controller button animation
  133151. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  133152. */
  133153. export interface IMotionControllerButtonMeshMap {
  133154. /**
  133155. * the mesh that defines the pressed value mesh position.
  133156. * This is used to find the max-position of this button
  133157. */
  133158. pressedMesh: AbstractMesh;
  133159. /**
  133160. * the mesh that defines the unpressed value mesh position.
  133161. * This is used to find the min (or initial) position of this button
  133162. */
  133163. unpressedMesh: AbstractMesh;
  133164. /**
  133165. * The mesh that will be changed when value changes
  133166. */
  133167. valueMesh: AbstractMesh;
  133168. }
  133169. /**
  133170. * A helper-interface for the 3 meshes needed for controller axis animation.
  133171. * This will be expanded when touchpad animations are fully supported
  133172. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  133173. */
  133174. export interface IMotionControllerMeshMap {
  133175. /**
  133176. * the mesh that defines the maximum value mesh position.
  133177. */
  133178. maxMesh?: AbstractMesh;
  133179. /**
  133180. * the mesh that defines the minimum value mesh position.
  133181. */
  133182. minMesh?: AbstractMesh;
  133183. /**
  133184. * The mesh that will be changed when axis value changes
  133185. */
  133186. valueMesh?: AbstractMesh;
  133187. }
  133188. /**
  133189. * The elements needed for change-detection of the gamepad objects in motion controllers
  133190. */
  133191. export interface IMinimalMotionControllerObject {
  133192. /**
  133193. * Available axes of this controller
  133194. */
  133195. axes: number[];
  133196. /**
  133197. * An array of available buttons
  133198. */
  133199. buttons: Array<{
  133200. /**
  133201. * Value of the button/trigger
  133202. */
  133203. value: number;
  133204. /**
  133205. * If the button/trigger is currently touched
  133206. */
  133207. touched: boolean;
  133208. /**
  133209. * If the button/trigger is currently pressed
  133210. */
  133211. pressed: boolean;
  133212. }>;
  133213. /**
  133214. * EXPERIMENTAL haptic support.
  133215. */
  133216. hapticActuators?: Array<{
  133217. pulse: (value: number, duration: number) => Promise<boolean>;
  133218. }>;
  133219. }
  133220. /**
  133221. * An Abstract Motion controller
  133222. * This class receives an xrInput and a profile layout and uses those to initialize the components
  133223. * Each component has an observable to check for changes in value and state
  133224. */
  133225. export abstract class WebXRAbstractMotionController implements IDisposable {
  133226. protected scene: Scene;
  133227. protected layout: IMotionControllerLayout;
  133228. /**
  133229. * The gamepad object correlating to this controller
  133230. */
  133231. gamepadObject: IMinimalMotionControllerObject;
  133232. /**
  133233. * handedness (left/right/none) of this controller
  133234. */
  133235. handedness: MotionControllerHandedness;
  133236. private _initComponent;
  133237. private _modelReady;
  133238. /**
  133239. * A map of components (WebXRControllerComponent) in this motion controller
  133240. * Components have a ComponentType and can also have both button and axis definitions
  133241. */
  133242. readonly components: {
  133243. [id: string]: WebXRControllerComponent;
  133244. };
  133245. /**
  133246. * Disable the model's animation. Can be set at any time.
  133247. */
  133248. disableAnimation: boolean;
  133249. /**
  133250. * Observers registered here will be triggered when the model of this controller is done loading
  133251. */
  133252. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  133253. /**
  133254. * The profile id of this motion controller
  133255. */
  133256. abstract profileId: string;
  133257. /**
  133258. * The root mesh of the model. It is null if the model was not yet initialized
  133259. */
  133260. rootMesh: Nullable<AbstractMesh>;
  133261. /**
  133262. * constructs a new abstract motion controller
  133263. * @param scene the scene to which the model of the controller will be added
  133264. * @param layout The profile layout to load
  133265. * @param gamepadObject The gamepad object correlating to this controller
  133266. * @param handedness handedness (left/right/none) of this controller
  133267. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  133268. */
  133269. constructor(scene: Scene, layout: IMotionControllerLayout,
  133270. /**
  133271. * The gamepad object correlating to this controller
  133272. */
  133273. gamepadObject: IMinimalMotionControllerObject,
  133274. /**
  133275. * handedness (left/right/none) of this controller
  133276. */
  133277. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  133278. /**
  133279. * Dispose this controller, the model mesh and all its components
  133280. */
  133281. dispose(): void;
  133282. /**
  133283. * Returns all components of specific type
  133284. * @param type the type to search for
  133285. * @return an array of components with this type
  133286. */
  133287. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  133288. /**
  133289. * get a component based an its component id as defined in layout.components
  133290. * @param id the id of the component
  133291. * @returns the component correlates to the id or undefined if not found
  133292. */
  133293. getComponent(id: string): WebXRControllerComponent;
  133294. /**
  133295. * Get the list of components available in this motion controller
  133296. * @returns an array of strings correlating to available components
  133297. */
  133298. getComponentIds(): string[];
  133299. /**
  133300. * Get the first component of specific type
  133301. * @param type type of component to find
  133302. * @return a controller component or null if not found
  133303. */
  133304. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  133305. /**
  133306. * Get the main (Select) component of this controller as defined in the layout
  133307. * @returns the main component of this controller
  133308. */
  133309. getMainComponent(): WebXRControllerComponent;
  133310. /**
  133311. * Loads the model correlating to this controller
  133312. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  133313. * @returns A promise fulfilled with the result of the model loading
  133314. */
  133315. loadModel(): Promise<boolean>;
  133316. /**
  133317. * Update this model using the current XRFrame
  133318. * @param xrFrame the current xr frame to use and update the model
  133319. */
  133320. updateFromXRFrame(xrFrame: XRFrame): void;
  133321. /**
  133322. * Backwards compatibility due to a deeply-integrated typo
  133323. */
  133324. get handness(): XREye;
  133325. /**
  133326. * Pulse (vibrate) this controller
  133327. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  133328. * Consecutive calls to this function will cancel the last pulse call
  133329. *
  133330. * @param value the strength of the pulse in 0.0...1.0 range
  133331. * @param duration Duration of the pulse in milliseconds
  133332. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  133333. * @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
  133334. */
  133335. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  133336. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  133337. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  133338. /**
  133339. * Moves the axis on the controller mesh based on its current state
  133340. * @param axis the index of the axis
  133341. * @param axisValue the value of the axis which determines the meshes new position
  133342. * @hidden
  133343. */
  133344. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  133345. /**
  133346. * Update the model itself with the current frame data
  133347. * @param xrFrame the frame to use for updating the model mesh
  133348. */
  133349. protected updateModel(xrFrame: XRFrame): void;
  133350. /**
  133351. * Get the filename and path for this controller's model
  133352. * @returns a map of filename and path
  133353. */
  133354. protected abstract _getFilenameAndPath(): {
  133355. filename: string;
  133356. path: string;
  133357. };
  133358. /**
  133359. * This function is called before the mesh is loaded. It checks for loading constraints.
  133360. * For example, this function can check if the GLB loader is available
  133361. * If this function returns false, the generic controller will be loaded instead
  133362. * @returns Is the client ready to load the mesh
  133363. */
  133364. protected abstract _getModelLoadingConstraints(): boolean;
  133365. /**
  133366. * This function will be called after the model was successfully loaded and can be used
  133367. * for mesh transformations before it is available for the user
  133368. * @param meshes the loaded meshes
  133369. */
  133370. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  133371. /**
  133372. * Set the root mesh for this controller. Important for the WebXR controller class
  133373. * @param meshes the loaded meshes
  133374. */
  133375. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  133376. /**
  133377. * A function executed each frame that updates the mesh (if needed)
  133378. * @param xrFrame the current xrFrame
  133379. */
  133380. protected abstract _updateModel(xrFrame: XRFrame): void;
  133381. private _getGenericFilenameAndPath;
  133382. private _getGenericParentMesh;
  133383. }
  133384. }
  133385. declare module BABYLON {
  133386. /**
  133387. * A generic trigger-only motion controller for WebXR
  133388. */
  133389. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  133390. /**
  133391. * Static version of the profile id of this controller
  133392. */
  133393. static ProfileId: string;
  133394. profileId: string;
  133395. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  133396. protected _getFilenameAndPath(): {
  133397. filename: string;
  133398. path: string;
  133399. };
  133400. protected _getModelLoadingConstraints(): boolean;
  133401. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  133402. protected _setRootMesh(meshes: AbstractMesh[]): void;
  133403. protected _updateModel(): void;
  133404. }
  133405. }
  133406. declare module BABYLON {
  133407. /**
  133408. * Class containing static functions to help procedurally build meshes
  133409. */
  133410. export class SphereBuilder {
  133411. /**
  133412. * Creates a sphere mesh
  133413. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  133414. * * 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`)
  133415. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  133416. * * 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
  133417. * * 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)
  133418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133419. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133421. * @param name defines the name of the mesh
  133422. * @param options defines the options used to create the mesh
  133423. * @param scene defines the hosting scene
  133424. * @returns the sphere mesh
  133425. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  133426. */
  133427. static CreateSphere(name: string, options: {
  133428. segments?: number;
  133429. diameter?: number;
  133430. diameterX?: number;
  133431. diameterY?: number;
  133432. diameterZ?: number;
  133433. arc?: number;
  133434. slice?: number;
  133435. sideOrientation?: number;
  133436. frontUVs?: Vector4;
  133437. backUVs?: Vector4;
  133438. updatable?: boolean;
  133439. }, scene?: Nullable<Scene>): Mesh;
  133440. }
  133441. }
  133442. declare module BABYLON {
  133443. /**
  133444. * A profiled motion controller has its profile loaded from an online repository.
  133445. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  133446. */
  133447. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  133448. private _repositoryUrl;
  133449. private _buttonMeshMapping;
  133450. private _touchDots;
  133451. /**
  133452. * The profile ID of this controller. Will be populated when the controller initializes.
  133453. */
  133454. profileId: string;
  133455. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  133456. dispose(): void;
  133457. protected _getFilenameAndPath(): {
  133458. filename: string;
  133459. path: string;
  133460. };
  133461. protected _getModelLoadingConstraints(): boolean;
  133462. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  133463. protected _setRootMesh(meshes: AbstractMesh[]): void;
  133464. protected _updateModel(_xrFrame: XRFrame): void;
  133465. }
  133466. }
  133467. declare module BABYLON {
  133468. /**
  133469. * A construction function type to create a new controller based on an xrInput object
  133470. */
  133471. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  133472. /**
  133473. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  133474. *
  133475. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  133476. * it should be replaced with auto-loaded controllers.
  133477. *
  133478. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  133479. */
  133480. export class WebXRMotionControllerManager {
  133481. private static _AvailableControllers;
  133482. private static _Fallbacks;
  133483. private static _ProfileLoadingPromises;
  133484. private static _ProfilesList;
  133485. /**
  133486. * The base URL of the online controller repository. Can be changed at any time.
  133487. */
  133488. static BaseRepositoryUrl: string;
  133489. /**
  133490. * Which repository gets priority - local or online
  133491. */
  133492. static PrioritizeOnlineRepository: boolean;
  133493. /**
  133494. * Use the online repository, or use only locally-defined controllers
  133495. */
  133496. static UseOnlineRepository: boolean;
  133497. /**
  133498. * Clear the cache used for profile loading and reload when requested again
  133499. */
  133500. static ClearProfilesCache(): void;
  133501. /**
  133502. * Register the default fallbacks.
  133503. * This function is called automatically when this file is imported.
  133504. */
  133505. static DefaultFallbacks(): void;
  133506. /**
  133507. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  133508. * @param profileId the profile to which a fallback needs to be found
  133509. * @return an array with corresponding fallback profiles
  133510. */
  133511. static FindFallbackWithProfileId(profileId: string): string[];
  133512. /**
  133513. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  133514. * The order of search:
  133515. *
  133516. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  133517. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  133518. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  133519. * 4) return the generic trigger controller if none were found
  133520. *
  133521. * @param xrInput the xrInput to which a new controller is initialized
  133522. * @param scene the scene to which the model will be added
  133523. * @param forceProfile force a certain profile for this controller
  133524. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  133525. */
  133526. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  133527. /**
  133528. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  133529. *
  133530. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  133531. *
  133532. * @param type the profile type to register
  133533. * @param constructFunction the function to be called when loading this profile
  133534. */
  133535. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  133536. /**
  133537. * Register a fallback to a specific profile.
  133538. * @param profileId the profileId that will receive the fallbacks
  133539. * @param fallbacks A list of fallback profiles
  133540. */
  133541. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  133542. /**
  133543. * Will update the list of profiles available in the repository
  133544. * @return a promise that resolves to a map of profiles available online
  133545. */
  133546. static UpdateProfilesList(): Promise<{
  133547. [profile: string]: string;
  133548. }>;
  133549. private static _LoadProfileFromRepository;
  133550. private static _LoadProfilesFromAvailableControllers;
  133551. }
  133552. }
  133553. declare module BABYLON {
  133554. /**
  133555. * Configuration options for the WebXR controller creation
  133556. */
  133557. export interface IWebXRControllerOptions {
  133558. /**
  133559. * Should the controller mesh be animated when a user interacts with it
  133560. * The pressed buttons / thumbstick and touchpad animations will be disabled
  133561. */
  133562. disableMotionControllerAnimation?: boolean;
  133563. /**
  133564. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  133565. */
  133566. doNotLoadControllerMesh?: boolean;
  133567. /**
  133568. * Force a specific controller type for this controller.
  133569. * This can be used when creating your own profile or when testing different controllers
  133570. */
  133571. forceControllerProfile?: string;
  133572. /**
  133573. * Defines a rendering group ID for meshes that will be loaded.
  133574. * This is for the default controllers only.
  133575. */
  133576. renderingGroupId?: number;
  133577. }
  133578. /**
  133579. * Represents an XR controller
  133580. */
  133581. export class WebXRInputSource {
  133582. private _scene;
  133583. /** The underlying input source for the controller */
  133584. inputSource: XRInputSource;
  133585. private _options;
  133586. private _tmpVector;
  133587. private _uniqueId;
  133588. private _disposed;
  133589. /**
  133590. * 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
  133591. */
  133592. grip?: AbstractMesh;
  133593. /**
  133594. * If available, this is the gamepad object related to this controller.
  133595. * Using this object it is possible to get click events and trackpad changes of the
  133596. * webxr controller that is currently being used.
  133597. */
  133598. motionController?: WebXRAbstractMotionController;
  133599. /**
  133600. * Event that fires when the controller is removed/disposed.
  133601. * The object provided as event data is this controller, after associated assets were disposed.
  133602. * uniqueId is still available.
  133603. */
  133604. onDisposeObservable: Observable<WebXRInputSource>;
  133605. /**
  133606. * Will be triggered when the mesh associated with the motion controller is done loading.
  133607. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  133608. * A shortened version of controller -> motion controller -> on mesh loaded.
  133609. */
  133610. onMeshLoadedObservable: Observable<AbstractMesh>;
  133611. /**
  133612. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  133613. */
  133614. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  133615. /**
  133616. * Pointer which can be used to select objects or attach a visible laser to
  133617. */
  133618. pointer: AbstractMesh;
  133619. /**
  133620. * Creates the input source object
  133621. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  133622. * @param _scene the scene which the controller should be associated to
  133623. * @param inputSource the underlying input source for the controller
  133624. * @param _options options for this controller creation
  133625. */
  133626. constructor(_scene: Scene,
  133627. /** The underlying input source for the controller */
  133628. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  133629. /**
  133630. * Get this controllers unique id
  133631. */
  133632. get uniqueId(): string;
  133633. /**
  133634. * Disposes of the object
  133635. */
  133636. dispose(): void;
  133637. /**
  133638. * Gets a world space ray coming from the pointer or grip
  133639. * @param result the resulting ray
  133640. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  133641. */
  133642. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  133643. /**
  133644. * Updates the controller pose based on the given XRFrame
  133645. * @param xrFrame xr frame to update the pose with
  133646. * @param referenceSpace reference space to use
  133647. */
  133648. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  133649. }
  133650. }
  133651. declare module BABYLON {
  133652. /**
  133653. * The schema for initialization options of the XR Input class
  133654. */
  133655. export interface IWebXRInputOptions {
  133656. /**
  133657. * If set to true no model will be automatically loaded
  133658. */
  133659. doNotLoadControllerMeshes?: boolean;
  133660. /**
  133661. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  133662. * If not found, the xr input profile data will be used.
  133663. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  133664. */
  133665. forceInputProfile?: string;
  133666. /**
  133667. * Do not send a request to the controller repository to load the profile.
  133668. *
  133669. * Instead, use the controllers available in babylon itself.
  133670. */
  133671. disableOnlineControllerRepository?: boolean;
  133672. /**
  133673. * A custom URL for the controllers repository
  133674. */
  133675. customControllersRepositoryURL?: string;
  133676. /**
  133677. * Should the controller model's components not move according to the user input
  133678. */
  133679. disableControllerAnimation?: boolean;
  133680. /**
  133681. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  133682. */
  133683. controllerOptions?: IWebXRControllerOptions;
  133684. }
  133685. /**
  133686. * XR input used to track XR inputs such as controllers/rays
  133687. */
  133688. export class WebXRInput implements IDisposable {
  133689. /**
  133690. * the xr session manager for this session
  133691. */
  133692. xrSessionManager: WebXRSessionManager;
  133693. /**
  133694. * the WebXR camera for this session. Mainly used for teleportation
  133695. */
  133696. xrCamera: WebXRCamera;
  133697. private readonly options;
  133698. /**
  133699. * XR controllers being tracked
  133700. */
  133701. controllers: Array<WebXRInputSource>;
  133702. private _frameObserver;
  133703. private _sessionEndedObserver;
  133704. private _sessionInitObserver;
  133705. /**
  133706. * Event when a controller has been connected/added
  133707. */
  133708. onControllerAddedObservable: Observable<WebXRInputSource>;
  133709. /**
  133710. * Event when a controller has been removed/disconnected
  133711. */
  133712. onControllerRemovedObservable: Observable<WebXRInputSource>;
  133713. /**
  133714. * Initializes the WebXRInput
  133715. * @param xrSessionManager the xr session manager for this session
  133716. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  133717. * @param options = initialization options for this xr input
  133718. */
  133719. constructor(
  133720. /**
  133721. * the xr session manager for this session
  133722. */
  133723. xrSessionManager: WebXRSessionManager,
  133724. /**
  133725. * the WebXR camera for this session. Mainly used for teleportation
  133726. */
  133727. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  133728. private _onInputSourcesChange;
  133729. private _addAndRemoveControllers;
  133730. /**
  133731. * Disposes of the object
  133732. */
  133733. dispose(): void;
  133734. }
  133735. }
  133736. declare module BABYLON {
  133737. /**
  133738. * This is the base class for all WebXR features.
  133739. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  133740. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  133741. */
  133742. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  133743. protected _xrSessionManager: WebXRSessionManager;
  133744. private _attached;
  133745. private _removeOnDetach;
  133746. /**
  133747. * Is this feature disposed?
  133748. */
  133749. isDisposed: boolean;
  133750. /**
  133751. * Should auto-attach be disabled?
  133752. */
  133753. disableAutoAttach: boolean;
  133754. /**
  133755. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  133756. */
  133757. xrNativeFeatureName: string;
  133758. /**
  133759. * Construct a new (abstract) WebXR feature
  133760. * @param _xrSessionManager the xr session manager for this feature
  133761. */
  133762. constructor(_xrSessionManager: WebXRSessionManager);
  133763. /**
  133764. * Is this feature attached
  133765. */
  133766. get attached(): boolean;
  133767. /**
  133768. * attach this feature
  133769. *
  133770. * @param force should attachment be forced (even when already attached)
  133771. * @returns true if successful, false is failed or already attached
  133772. */
  133773. attach(force?: boolean): boolean;
  133774. /**
  133775. * detach this feature.
  133776. *
  133777. * @returns true if successful, false if failed or already detached
  133778. */
  133779. detach(): boolean;
  133780. /**
  133781. * Dispose this feature and all of the resources attached
  133782. */
  133783. dispose(): void;
  133784. /**
  133785. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  133786. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  133787. *
  133788. * @returns whether or not the feature is compatible in this environment
  133789. */
  133790. isCompatible(): boolean;
  133791. /**
  133792. * This is used to register callbacks that will automatically be removed when detach is called.
  133793. * @param observable the observable to which the observer will be attached
  133794. * @param callback the callback to register
  133795. */
  133796. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  133797. /**
  133798. * Code in this function will be executed on each xrFrame received from the browser.
  133799. * This function will not execute after the feature is detached.
  133800. * @param _xrFrame the current frame
  133801. */
  133802. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  133803. }
  133804. }
  133805. declare module BABYLON {
  133806. /**
  133807. * Renders a layer on top of an existing scene
  133808. */
  133809. export class UtilityLayerRenderer implements IDisposable {
  133810. /** the original scene that will be rendered on top of */
  133811. originalScene: Scene;
  133812. private _pointerCaptures;
  133813. private _lastPointerEvents;
  133814. private static _DefaultUtilityLayer;
  133815. private static _DefaultKeepDepthUtilityLayer;
  133816. private _sharedGizmoLight;
  133817. private _renderCamera;
  133818. /**
  133819. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  133820. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  133821. * @returns the camera that is used when rendering the utility layer
  133822. */
  133823. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  133824. /**
  133825. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  133826. * @param cam the camera that should be used when rendering the utility layer
  133827. */
  133828. setRenderCamera(cam: Nullable<Camera>): void;
  133829. /**
  133830. * @hidden
  133831. * Light which used by gizmos to get light shading
  133832. */
  133833. _getSharedGizmoLight(): HemisphericLight;
  133834. /**
  133835. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  133836. */
  133837. pickUtilitySceneFirst: boolean;
  133838. /**
  133839. * 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)
  133840. */
  133841. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  133842. /**
  133843. * 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)
  133844. */
  133845. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  133846. /**
  133847. * The scene that is rendered on top of the original scene
  133848. */
  133849. utilityLayerScene: Scene;
  133850. /**
  133851. * If the utility layer should automatically be rendered on top of existing scene
  133852. */
  133853. shouldRender: boolean;
  133854. /**
  133855. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  133856. */
  133857. onlyCheckPointerDownEvents: boolean;
  133858. /**
  133859. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  133860. */
  133861. processAllEvents: boolean;
  133862. /**
  133863. * Observable raised when the pointer move from the utility layer scene to the main scene
  133864. */
  133865. onPointerOutObservable: Observable<number>;
  133866. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  133867. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  133868. private _afterRenderObserver;
  133869. private _sceneDisposeObserver;
  133870. private _originalPointerObserver;
  133871. /**
  133872. * Instantiates a UtilityLayerRenderer
  133873. * @param originalScene the original scene that will be rendered on top of
  133874. * @param handleEvents boolean indicating if the utility layer should handle events
  133875. */
  133876. constructor(
  133877. /** the original scene that will be rendered on top of */
  133878. originalScene: Scene, handleEvents?: boolean);
  133879. private _notifyObservers;
  133880. /**
  133881. * Renders the utility layers scene on top of the original scene
  133882. */
  133883. render(): void;
  133884. /**
  133885. * Disposes of the renderer
  133886. */
  133887. dispose(): void;
  133888. private _updateCamera;
  133889. }
  133890. }
  133891. declare module BABYLON {
  133892. /**
  133893. * Options interface for the pointer selection module
  133894. */
  133895. export interface IWebXRControllerPointerSelectionOptions {
  133896. /**
  133897. * if provided, this scene will be used to render meshes.
  133898. */
  133899. customUtilityLayerScene?: Scene;
  133900. /**
  133901. * 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)
  133902. * If not disabled, the last picked point will be used to execute a pointer up event
  133903. * If disabled, pointer up event will be triggered right after the pointer down event.
  133904. * Used in screen and gaze target ray mode only
  133905. */
  133906. disablePointerUpOnTouchOut: boolean;
  133907. /**
  133908. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  133909. */
  133910. forceGazeMode: boolean;
  133911. /**
  133912. * 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
  133913. * to start a new countdown to the pointer down event.
  133914. * Defaults to 1.
  133915. */
  133916. gazeModePointerMovedFactor?: number;
  133917. /**
  133918. * Different button type to use instead of the main component
  133919. */
  133920. overrideButtonId?: string;
  133921. /**
  133922. * use this rendering group id for the meshes (optional)
  133923. */
  133924. renderingGroupId?: number;
  133925. /**
  133926. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  133927. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  133928. * 3000 means 3 seconds between pointing at something and selecting it
  133929. */
  133930. timeToSelect?: number;
  133931. /**
  133932. * Should meshes created here be added to a utility layer or the main scene
  133933. */
  133934. useUtilityLayer?: boolean;
  133935. /**
  133936. * Optional WebXR camera to be used for gaze selection
  133937. */
  133938. gazeCamera?: WebXRCamera;
  133939. /**
  133940. * the xr input to use with this pointer selection
  133941. */
  133942. xrInput: WebXRInput;
  133943. /**
  133944. * Should the scene pointerX and pointerY update be disabled
  133945. * This is required for fullscreen AR GUI, but might slow down other experiences.
  133946. * Disable in VR, if not needed.
  133947. * The first rig camera (left eye) will be used to calculate the projection
  133948. */
  133949. disableScenePointerVectorUpdate: boolean;
  133950. /**
  133951. * Enable pointer selection on all controllers instead of switching between them
  133952. */
  133953. enablePointerSelectionOnAllControllers?: boolean;
  133954. /**
  133955. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  133956. * If switch is enabled, it will still allow the user to switch between the different controllers
  133957. */
  133958. preferredHandedness?: XRHandedness;
  133959. /**
  133960. * Disable switching the pointer selection from one controller to the other.
  133961. * If the preferred hand is set it will be fixed on this hand, and if not it will be fixed on the first controller added to the scene
  133962. */
  133963. disableSwitchOnClick?: boolean;
  133964. /**
  133965. * The maximum distance of the pointer selection feature. Defaults to 100.
  133966. */
  133967. maxPointerDistance?: number;
  133968. }
  133969. /**
  133970. * A module that will enable pointer selection for motion controllers of XR Input Sources
  133971. */
  133972. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  133973. private readonly _options;
  133974. private static _idCounter;
  133975. private _attachController;
  133976. private _controllers;
  133977. private _scene;
  133978. private _tmpVectorForPickCompare;
  133979. private _attachedController;
  133980. /**
  133981. * The module's name
  133982. */
  133983. static readonly Name: string;
  133984. /**
  133985. * The (Babylon) version of this module.
  133986. * This is an integer representing the implementation version.
  133987. * This number does not correspond to the WebXR specs version
  133988. */
  133989. static readonly Version: number;
  133990. /**
  133991. * Disable lighting on the laser pointer (so it will always be visible)
  133992. */
  133993. disablePointerLighting: boolean;
  133994. /**
  133995. * Disable lighting on the selection mesh (so it will always be visible)
  133996. */
  133997. disableSelectionMeshLighting: boolean;
  133998. /**
  133999. * Should the laser pointer be displayed
  134000. */
  134001. displayLaserPointer: boolean;
  134002. /**
  134003. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  134004. */
  134005. displaySelectionMesh: boolean;
  134006. /**
  134007. * This color will be set to the laser pointer when selection is triggered
  134008. */
  134009. laserPointerPickedColor: Color3;
  134010. /**
  134011. * Default color of the laser pointer
  134012. */
  134013. laserPointerDefaultColor: Color3;
  134014. /**
  134015. * default color of the selection ring
  134016. */
  134017. selectionMeshDefaultColor: Color3;
  134018. /**
  134019. * This color will be applied to the selection ring when selection is triggered
  134020. */
  134021. selectionMeshPickedColor: Color3;
  134022. /**
  134023. * Optional filter to be used for ray selection. This predicate shares behavior with
  134024. * scene.pointerMovePredicate which takes priority if it is also assigned.
  134025. */
  134026. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  134027. /**
  134028. * constructs a new background remover module
  134029. * @param _xrSessionManager the session manager for this module
  134030. * @param _options read-only options to be used in this module
  134031. */
  134032. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  134033. /**
  134034. * attach this feature
  134035. * Will usually be called by the features manager
  134036. *
  134037. * @returns true if successful.
  134038. */
  134039. attach(): boolean;
  134040. /**
  134041. * detach this feature.
  134042. * Will usually be called by the features manager
  134043. *
  134044. * @returns true if successful.
  134045. */
  134046. detach(): boolean;
  134047. /**
  134048. * Will get the mesh under a specific pointer.
  134049. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  134050. * @param controllerId the controllerId to check
  134051. * @returns The mesh under pointer or null if no mesh is under the pointer
  134052. */
  134053. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  134054. /**
  134055. * Get the xr controller that correlates to the pointer id in the pointer event
  134056. *
  134057. * @param id the pointer id to search for
  134058. * @returns the controller that correlates to this id or null if not found
  134059. */
  134060. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  134061. private _identityMatrix;
  134062. private _screenCoordinatesRef;
  134063. private _viewportRef;
  134064. protected _onXRFrame(_xrFrame: XRFrame): void;
  134065. private _attachGazeMode;
  134066. private _attachScreenRayMode;
  134067. private _attachTrackedPointerRayMode;
  134068. private _convertNormalToDirectionOfRay;
  134069. private _detachController;
  134070. private _generateNewMeshPair;
  134071. private _pickingMoved;
  134072. private _updatePointerDistance;
  134073. /** @hidden */
  134074. get lasterPointerDefaultColor(): Color3;
  134075. }
  134076. }
  134077. declare module BABYLON {
  134078. /**
  134079. * Button which can be used to enter a different mode of XR
  134080. */
  134081. export class WebXREnterExitUIButton {
  134082. /** button element */
  134083. element: HTMLElement;
  134084. /** XR initialization options for the button */
  134085. sessionMode: XRSessionMode;
  134086. /** Reference space type */
  134087. referenceSpaceType: XRReferenceSpaceType;
  134088. /**
  134089. * Creates a WebXREnterExitUIButton
  134090. * @param element button element
  134091. * @param sessionMode XR initialization session mode
  134092. * @param referenceSpaceType the type of reference space to be used
  134093. */
  134094. constructor(
  134095. /** button element */
  134096. element: HTMLElement,
  134097. /** XR initialization options for the button */
  134098. sessionMode: XRSessionMode,
  134099. /** Reference space type */
  134100. referenceSpaceType: XRReferenceSpaceType);
  134101. /**
  134102. * Extendable function which can be used to update the button's visuals when the state changes
  134103. * @param activeButton the current active button in the UI
  134104. */
  134105. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  134106. }
  134107. /**
  134108. * Options to create the webXR UI
  134109. */
  134110. export class WebXREnterExitUIOptions {
  134111. /**
  134112. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  134113. */
  134114. customButtons?: Array<WebXREnterExitUIButton>;
  134115. /**
  134116. * A reference space type to use when creating the default button.
  134117. * Default is local-floor
  134118. */
  134119. referenceSpaceType?: XRReferenceSpaceType;
  134120. /**
  134121. * Context to enter xr with
  134122. */
  134123. renderTarget?: Nullable<WebXRRenderTarget>;
  134124. /**
  134125. * A session mode to use when creating the default button.
  134126. * Default is immersive-vr
  134127. */
  134128. sessionMode?: XRSessionMode;
  134129. /**
  134130. * A list of optional features to init the session with
  134131. */
  134132. optionalFeatures?: string[];
  134133. /**
  134134. * A list of optional features to init the session with
  134135. */
  134136. requiredFeatures?: string[];
  134137. /**
  134138. * If defined, this function will be executed if the UI encounters an error when entering XR
  134139. */
  134140. onError?: (error: any) => void;
  134141. }
  134142. /**
  134143. * UI to allow the user to enter/exit XR mode
  134144. */
  134145. export class WebXREnterExitUI implements IDisposable {
  134146. private scene;
  134147. /** version of the options passed to this UI */
  134148. options: WebXREnterExitUIOptions;
  134149. private _activeButton;
  134150. private _buttons;
  134151. /**
  134152. * The HTML Div Element to which buttons are added.
  134153. */
  134154. readonly overlay: HTMLDivElement;
  134155. /**
  134156. * Fired every time the active button is changed.
  134157. *
  134158. * When xr is entered via a button that launches xr that button will be the callback parameter
  134159. *
  134160. * When exiting xr the callback parameter will be null)
  134161. */
  134162. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  134163. /**
  134164. *
  134165. * @param scene babylon scene object to use
  134166. * @param options (read-only) version of the options passed to this UI
  134167. */
  134168. private constructor();
  134169. /**
  134170. * Creates UI to allow the user to enter/exit XR mode
  134171. * @param scene the scene to add the ui to
  134172. * @param helper the xr experience helper to enter/exit xr with
  134173. * @param options options to configure the UI
  134174. * @returns the created ui
  134175. */
  134176. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  134177. /**
  134178. * Disposes of the XR UI component
  134179. */
  134180. dispose(): void;
  134181. private _updateButtons;
  134182. }
  134183. }
  134184. declare module BABYLON {
  134185. /**
  134186. * Class containing static functions to help procedurally build meshes
  134187. */
  134188. export class LinesBuilder {
  134189. /**
  134190. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134191. * * 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
  134192. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134193. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134194. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134195. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134196. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134197. * * 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
  134198. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134200. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134201. * @param name defines the name of the new line system
  134202. * @param options defines the options used to create the line system
  134203. * @param scene defines the hosting scene
  134204. * @returns a new line system mesh
  134205. */
  134206. static CreateLineSystem(name: string, options: {
  134207. lines: Vector3[][];
  134208. updatable?: boolean;
  134209. instance?: Nullable<LinesMesh>;
  134210. colors?: Nullable<Color4[][]>;
  134211. useVertexAlpha?: boolean;
  134212. }, scene: Nullable<Scene>): LinesMesh;
  134213. /**
  134214. * Creates a line mesh
  134215. * 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
  134216. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134217. * * The parameter `points` is an array successive Vector3
  134218. * * 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
  134219. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134220. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134221. * * When updating an instance, remember that only point positions can change, not the number of points
  134222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134223. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134224. * @param name defines the name of the new line system
  134225. * @param options defines the options used to create the line system
  134226. * @param scene defines the hosting scene
  134227. * @returns a new line mesh
  134228. */
  134229. static CreateLines(name: string, options: {
  134230. points: Vector3[];
  134231. updatable?: boolean;
  134232. instance?: Nullable<LinesMesh>;
  134233. colors?: Color4[];
  134234. useVertexAlpha?: boolean;
  134235. }, scene?: Nullable<Scene>): LinesMesh;
  134236. /**
  134237. * Creates a dashed line mesh
  134238. * * 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
  134239. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134240. * * The parameter `points` is an array successive Vector3
  134241. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134242. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134243. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134244. * * 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
  134245. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134246. * * When updating an instance, remember that only point positions can change, not the number of points
  134247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134248. * @param name defines the name of the mesh
  134249. * @param options defines the options used to create the mesh
  134250. * @param scene defines the hosting scene
  134251. * @returns the dashed line mesh
  134252. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134253. */
  134254. static CreateDashedLines(name: string, options: {
  134255. points: Vector3[];
  134256. dashSize?: number;
  134257. gapSize?: number;
  134258. dashNb?: number;
  134259. updatable?: boolean;
  134260. instance?: LinesMesh;
  134261. useVertexAlpha?: boolean;
  134262. }, scene?: Nullable<Scene>): LinesMesh;
  134263. }
  134264. }
  134265. declare module BABYLON {
  134266. /**
  134267. * Construction options for a timer
  134268. */
  134269. export interface ITimerOptions<T> {
  134270. /**
  134271. * Time-to-end
  134272. */
  134273. timeout: number;
  134274. /**
  134275. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  134276. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  134277. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  134278. */
  134279. contextObservable: Observable<T>;
  134280. /**
  134281. * Optional parameters when adding an observer to the observable
  134282. */
  134283. observableParameters?: {
  134284. mask?: number;
  134285. insertFirst?: boolean;
  134286. scope?: any;
  134287. };
  134288. /**
  134289. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  134290. */
  134291. breakCondition?: (data?: ITimerData<T>) => boolean;
  134292. /**
  134293. * Will be triggered when the time condition has met
  134294. */
  134295. onEnded?: (data: ITimerData<any>) => void;
  134296. /**
  134297. * Will be triggered when the break condition has met (prematurely ended)
  134298. */
  134299. onAborted?: (data: ITimerData<any>) => void;
  134300. /**
  134301. * Optional function to execute on each tick (or count)
  134302. */
  134303. onTick?: (data: ITimerData<any>) => void;
  134304. }
  134305. /**
  134306. * An interface defining the data sent by the timer
  134307. */
  134308. export interface ITimerData<T> {
  134309. /**
  134310. * When did it start
  134311. */
  134312. startTime: number;
  134313. /**
  134314. * Time now
  134315. */
  134316. currentTime: number;
  134317. /**
  134318. * Time passed since started
  134319. */
  134320. deltaTime: number;
  134321. /**
  134322. * How much is completed, in [0.0...1.0].
  134323. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  134324. */
  134325. completeRate: number;
  134326. /**
  134327. * What the registered observable sent in the last count
  134328. */
  134329. payload: T;
  134330. }
  134331. /**
  134332. * The current state of the timer
  134333. */
  134334. export enum TimerState {
  134335. /**
  134336. * Timer initialized, not yet started
  134337. */
  134338. INIT = 0,
  134339. /**
  134340. * Timer started and counting
  134341. */
  134342. STARTED = 1,
  134343. /**
  134344. * Timer ended (whether aborted or time reached)
  134345. */
  134346. ENDED = 2
  134347. }
  134348. /**
  134349. * A simple version of the timer. Will take options and start the timer immediately after calling it
  134350. *
  134351. * @param options options with which to initialize this timer
  134352. */
  134353. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  134354. /**
  134355. * An advanced implementation of a timer class
  134356. */
  134357. export class AdvancedTimer<T = any> implements IDisposable {
  134358. /**
  134359. * Will notify each time the timer calculates the remaining time
  134360. */
  134361. onEachCountObservable: Observable<ITimerData<T>>;
  134362. /**
  134363. * Will trigger when the timer was aborted due to the break condition
  134364. */
  134365. onTimerAbortedObservable: Observable<ITimerData<T>>;
  134366. /**
  134367. * Will trigger when the timer ended successfully
  134368. */
  134369. onTimerEndedObservable: Observable<ITimerData<T>>;
  134370. /**
  134371. * Will trigger when the timer state has changed
  134372. */
  134373. onStateChangedObservable: Observable<TimerState>;
  134374. private _observer;
  134375. private _contextObservable;
  134376. private _observableParameters;
  134377. private _startTime;
  134378. private _timer;
  134379. private _state;
  134380. private _breakCondition;
  134381. private _timeToEnd;
  134382. private _breakOnNextTick;
  134383. /**
  134384. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  134385. * @param options construction options for this advanced timer
  134386. */
  134387. constructor(options: ITimerOptions<T>);
  134388. /**
  134389. * set a breaking condition for this timer. Default is to never break during count
  134390. * @param predicate the new break condition. Returns true to break, false otherwise
  134391. */
  134392. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  134393. /**
  134394. * Reset ALL associated observables in this advanced timer
  134395. */
  134396. clearObservables(): void;
  134397. /**
  134398. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  134399. *
  134400. * @param timeToEnd how much time to measure until timer ended
  134401. */
  134402. start(timeToEnd?: number): void;
  134403. /**
  134404. * Will force a stop on the next tick.
  134405. */
  134406. stop(): void;
  134407. /**
  134408. * Dispose this timer, clearing all resources
  134409. */
  134410. dispose(): void;
  134411. private _setState;
  134412. private _tick;
  134413. private _stop;
  134414. }
  134415. }
  134416. declare module BABYLON {
  134417. /**
  134418. * The options container for the teleportation module
  134419. */
  134420. export interface IWebXRTeleportationOptions {
  134421. /**
  134422. * if provided, this scene will be used to render meshes.
  134423. */
  134424. customUtilityLayerScene?: Scene;
  134425. /**
  134426. * Values to configure the default target mesh
  134427. */
  134428. defaultTargetMeshOptions?: {
  134429. /**
  134430. * Fill color of the teleportation area
  134431. */
  134432. teleportationFillColor?: string;
  134433. /**
  134434. * Border color for the teleportation area
  134435. */
  134436. teleportationBorderColor?: string;
  134437. /**
  134438. * Disable the mesh's animation sequence
  134439. */
  134440. disableAnimation?: boolean;
  134441. /**
  134442. * Disable lighting on the material or the ring and arrow
  134443. */
  134444. disableLighting?: boolean;
  134445. /**
  134446. * Override the default material of the torus and arrow
  134447. */
  134448. torusArrowMaterial?: Material;
  134449. };
  134450. /**
  134451. * A list of meshes to use as floor meshes.
  134452. * Meshes can be added and removed after initializing the feature using the
  134453. * addFloorMesh and removeFloorMesh functions
  134454. * If empty, rotation will still work
  134455. */
  134456. floorMeshes?: AbstractMesh[];
  134457. /**
  134458. * use this rendering group id for the meshes (optional)
  134459. */
  134460. renderingGroupId?: number;
  134461. /**
  134462. * Should teleportation move only to snap points
  134463. */
  134464. snapPointsOnly?: boolean;
  134465. /**
  134466. * An array of points to which the teleportation will snap to.
  134467. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  134468. */
  134469. snapPositions?: Vector3[];
  134470. /**
  134471. * How close should the teleportation ray be in order to snap to position.
  134472. * Default to 0.8 units (meters)
  134473. */
  134474. snapToPositionRadius?: number;
  134475. /**
  134476. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  134477. * If you want to support rotation, make sure your mesh has a direction indicator.
  134478. *
  134479. * When left untouched, the default mesh will be initialized.
  134480. */
  134481. teleportationTargetMesh?: AbstractMesh;
  134482. /**
  134483. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  134484. */
  134485. timeToTeleport?: number;
  134486. /**
  134487. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  134488. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  134489. */
  134490. useMainComponentOnly?: boolean;
  134491. /**
  134492. * Should meshes created here be added to a utility layer or the main scene
  134493. */
  134494. useUtilityLayer?: boolean;
  134495. /**
  134496. * Babylon XR Input class for controller
  134497. */
  134498. xrInput: WebXRInput;
  134499. /**
  134500. * Meshes that the teleportation ray cannot go through
  134501. */
  134502. pickBlockerMeshes?: AbstractMesh[];
  134503. }
  134504. /**
  134505. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  134506. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  134507. * the input of the attached controllers.
  134508. */
  134509. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  134510. private _options;
  134511. private _controllers;
  134512. private _currentTeleportationControllerId;
  134513. private _floorMeshes;
  134514. private _quadraticBezierCurve;
  134515. private _selectionFeature;
  134516. private _snapToPositions;
  134517. private _snappedToPoint;
  134518. private _teleportationRingMaterial?;
  134519. private _tmpRay;
  134520. private _tmpVector;
  134521. private _tmpQuaternion;
  134522. /**
  134523. * The module's name
  134524. */
  134525. static readonly Name: string;
  134526. /**
  134527. * The (Babylon) version of this module.
  134528. * This is an integer representing the implementation version.
  134529. * This number does not correspond to the webxr specs version
  134530. */
  134531. static readonly Version: number;
  134532. /**
  134533. * Is movement backwards enabled
  134534. */
  134535. backwardsMovementEnabled: boolean;
  134536. /**
  134537. * Distance to travel when moving backwards
  134538. */
  134539. backwardsTeleportationDistance: number;
  134540. /**
  134541. * The distance from the user to the inspection point in the direction of the controller
  134542. * A higher number will allow the user to move further
  134543. * defaults to 5 (meters, in xr units)
  134544. */
  134545. parabolicCheckRadius: number;
  134546. /**
  134547. * Should the module support parabolic ray on top of direct ray
  134548. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  134549. * Very helpful when moving between floors / different heights
  134550. */
  134551. parabolicRayEnabled: boolean;
  134552. /**
  134553. * How much rotation should be applied when rotating right and left
  134554. */
  134555. rotationAngle: number;
  134556. /**
  134557. * Is rotation enabled when moving forward?
  134558. * Disabling this feature will prevent the user from deciding the direction when teleporting
  134559. */
  134560. rotationEnabled: boolean;
  134561. /**
  134562. * constructs a new anchor system
  134563. * @param _xrSessionManager an instance of WebXRSessionManager
  134564. * @param _options configuration object for this feature
  134565. */
  134566. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  134567. /**
  134568. * Get the snapPointsOnly flag
  134569. */
  134570. get snapPointsOnly(): boolean;
  134571. /**
  134572. * Sets the snapPointsOnly flag
  134573. * @param snapToPoints should teleportation be exclusively to snap points
  134574. */
  134575. set snapPointsOnly(snapToPoints: boolean);
  134576. /**
  134577. * Add a new mesh to the floor meshes array
  134578. * @param mesh the mesh to use as floor mesh
  134579. */
  134580. addFloorMesh(mesh: AbstractMesh): void;
  134581. /**
  134582. * Add a new snap-to point to fix teleportation to this position
  134583. * @param newSnapPoint The new Snap-To point
  134584. */
  134585. addSnapPoint(newSnapPoint: Vector3): void;
  134586. attach(): boolean;
  134587. detach(): boolean;
  134588. dispose(): void;
  134589. /**
  134590. * Remove a mesh from the floor meshes array
  134591. * @param mesh the mesh to remove
  134592. */
  134593. removeFloorMesh(mesh: AbstractMesh): void;
  134594. /**
  134595. * Remove a mesh from the floor meshes array using its name
  134596. * @param name the mesh name to remove
  134597. */
  134598. removeFloorMeshByName(name: string): void;
  134599. /**
  134600. * 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
  134601. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  134602. * @returns was the point found and removed or not
  134603. */
  134604. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  134605. /**
  134606. * This function sets a selection feature that will be disabled when
  134607. * the forward ray is shown and will be reattached when hidden.
  134608. * This is used to remove the selection rays when moving.
  134609. * @param selectionFeature the feature to disable when forward movement is enabled
  134610. */
  134611. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  134612. protected _onXRFrame(_xrFrame: XRFrame): void;
  134613. private _attachController;
  134614. private _createDefaultTargetMesh;
  134615. private _detachController;
  134616. private _findClosestSnapPointWithRadius;
  134617. private _setTargetMeshPosition;
  134618. private _setTargetMeshVisibility;
  134619. private _showParabolicPath;
  134620. private _teleportForward;
  134621. }
  134622. }
  134623. declare module BABYLON {
  134624. /**
  134625. * Options for the default xr helper
  134626. */
  134627. export class WebXRDefaultExperienceOptions {
  134628. /**
  134629. * Enable or disable default UI to enter XR
  134630. */
  134631. disableDefaultUI?: boolean;
  134632. /**
  134633. * Should teleportation not initialize. defaults to false.
  134634. */
  134635. disableTeleportation?: boolean;
  134636. /**
  134637. * Floor meshes that will be used for teleport
  134638. */
  134639. floorMeshes?: Array<AbstractMesh>;
  134640. /**
  134641. * If set to true, the first frame will not be used to reset position
  134642. * The first frame is mainly used when copying transformation from the old camera
  134643. * Mainly used in AR
  134644. */
  134645. ignoreNativeCameraTransformation?: boolean;
  134646. /**
  134647. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  134648. */
  134649. inputOptions?: IWebXRInputOptions;
  134650. /**
  134651. * optional configuration for the output canvas
  134652. */
  134653. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  134654. /**
  134655. * optional UI options. This can be used among other to change session mode and reference space type
  134656. */
  134657. uiOptions?: WebXREnterExitUIOptions;
  134658. /**
  134659. * When loading teleportation and pointer select, use stable versions instead of latest.
  134660. */
  134661. useStablePlugins?: boolean;
  134662. /**
  134663. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  134664. */
  134665. renderingGroupId?: number;
  134666. /**
  134667. * A list of optional features to init the session with
  134668. * If set to true, all features we support will be added
  134669. */
  134670. optionalFeatures?: boolean | string[];
  134671. }
  134672. /**
  134673. * Default experience which provides a similar setup to the previous webVRExperience
  134674. */
  134675. export class WebXRDefaultExperience {
  134676. /**
  134677. * Base experience
  134678. */
  134679. baseExperience: WebXRExperienceHelper;
  134680. /**
  134681. * Enables ui for entering/exiting xr
  134682. */
  134683. enterExitUI: WebXREnterExitUI;
  134684. /**
  134685. * Input experience extension
  134686. */
  134687. input: WebXRInput;
  134688. /**
  134689. * Enables laser pointer and selection
  134690. */
  134691. pointerSelection: WebXRControllerPointerSelection;
  134692. /**
  134693. * Default target xr should render to
  134694. */
  134695. renderTarget: WebXRRenderTarget;
  134696. /**
  134697. * Enables teleportation
  134698. */
  134699. teleportation: WebXRMotionControllerTeleportation;
  134700. private constructor();
  134701. /**
  134702. * Creates the default xr experience
  134703. * @param scene scene
  134704. * @param options options for basic configuration
  134705. * @returns resulting WebXRDefaultExperience
  134706. */
  134707. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  134708. /**
  134709. * DIsposes of the experience helper
  134710. */
  134711. dispose(): void;
  134712. }
  134713. }
  134714. declare module BABYLON {
  134715. /**
  134716. * Options to modify the vr teleportation behavior.
  134717. */
  134718. export interface VRTeleportationOptions {
  134719. /**
  134720. * The name of the mesh which should be used as the teleportation floor. (default: null)
  134721. */
  134722. floorMeshName?: string;
  134723. /**
  134724. * A list of meshes to be used as the teleportation floor. (default: empty)
  134725. */
  134726. floorMeshes?: Mesh[];
  134727. /**
  134728. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  134729. */
  134730. teleportationMode?: number;
  134731. /**
  134732. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  134733. */
  134734. teleportationTime?: number;
  134735. /**
  134736. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  134737. */
  134738. teleportationSpeed?: number;
  134739. /**
  134740. * The easing function used in the animation or null for Linear. (default CircleEase)
  134741. */
  134742. easingFunction?: EasingFunction;
  134743. }
  134744. /**
  134745. * Options to modify the vr experience helper's behavior.
  134746. */
  134747. export interface VRExperienceHelperOptions extends WebVROptions {
  134748. /**
  134749. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  134750. */
  134751. createDeviceOrientationCamera?: boolean;
  134752. /**
  134753. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  134754. */
  134755. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  134756. /**
  134757. * Uses the main button on the controller to toggle the laser casted. (default: true)
  134758. */
  134759. laserToggle?: boolean;
  134760. /**
  134761. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  134762. */
  134763. floorMeshes?: Mesh[];
  134764. /**
  134765. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  134766. */
  134767. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  134768. /**
  134769. * Defines if WebXR should be used instead of WebVR (if available)
  134770. */
  134771. useXR?: boolean;
  134772. }
  134773. /**
  134774. * Event containing information after VR has been entered
  134775. */
  134776. export class OnAfterEnteringVRObservableEvent {
  134777. /**
  134778. * If entering vr was successful
  134779. */
  134780. success: boolean;
  134781. }
  134782. /**
  134783. * Helps to quickly add VR support to an existing scene.
  134784. * See https://doc.babylonjs.com/how_to/webvr_helper
  134785. */
  134786. export class VRExperienceHelper {
  134787. /** Options to modify the vr experience helper's behavior. */
  134788. webVROptions: VRExperienceHelperOptions;
  134789. private _scene;
  134790. private _position;
  134791. private _btnVR;
  134792. private _btnVRDisplayed;
  134793. private _webVRsupported;
  134794. private _webVRready;
  134795. private _webVRrequesting;
  134796. private _webVRpresenting;
  134797. private _hasEnteredVR;
  134798. private _fullscreenVRpresenting;
  134799. private _inputElement;
  134800. private _webVRCamera;
  134801. private _vrDeviceOrientationCamera;
  134802. private _deviceOrientationCamera;
  134803. private _existingCamera;
  134804. private _onKeyDown;
  134805. private _onVrDisplayPresentChange;
  134806. private _onVRDisplayChanged;
  134807. private _onVRRequestPresentStart;
  134808. private _onVRRequestPresentComplete;
  134809. /**
  134810. * 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)
  134811. */
  134812. enableGazeEvenWhenNoPointerLock: boolean;
  134813. /**
  134814. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  134815. */
  134816. exitVROnDoubleTap: boolean;
  134817. /**
  134818. * Observable raised right before entering VR.
  134819. */
  134820. onEnteringVRObservable: Observable<VRExperienceHelper>;
  134821. /**
  134822. * Observable raised when entering VR has completed.
  134823. */
  134824. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  134825. /**
  134826. * Observable raised when exiting VR.
  134827. */
  134828. onExitingVRObservable: Observable<VRExperienceHelper>;
  134829. /**
  134830. * Observable raised when controller mesh is loaded.
  134831. */
  134832. onControllerMeshLoadedObservable: Observable<WebVRController>;
  134833. /** Return this.onEnteringVRObservable
  134834. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  134835. */
  134836. get onEnteringVR(): Observable<VRExperienceHelper>;
  134837. /** Return this.onExitingVRObservable
  134838. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  134839. */
  134840. get onExitingVR(): Observable<VRExperienceHelper>;
  134841. /** Return this.onControllerMeshLoadedObservable
  134842. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  134843. */
  134844. get onControllerMeshLoaded(): Observable<WebVRController>;
  134845. private _rayLength;
  134846. private _useCustomVRButton;
  134847. private _teleportationRequested;
  134848. private _teleportActive;
  134849. private _floorMeshName;
  134850. private _floorMeshesCollection;
  134851. private _teleportationMode;
  134852. private _teleportationTime;
  134853. private _teleportationSpeed;
  134854. private _teleportationEasing;
  134855. private _rotationAllowed;
  134856. private _teleportBackwardsVector;
  134857. private _teleportationTarget;
  134858. private _isDefaultTeleportationTarget;
  134859. private _postProcessMove;
  134860. private _teleportationFillColor;
  134861. private _teleportationBorderColor;
  134862. private _rotationAngle;
  134863. private _haloCenter;
  134864. private _cameraGazer;
  134865. private _padSensibilityUp;
  134866. private _padSensibilityDown;
  134867. private _leftController;
  134868. private _rightController;
  134869. private _gazeColor;
  134870. private _laserColor;
  134871. private _pickedLaserColor;
  134872. private _pickedGazeColor;
  134873. /**
  134874. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  134875. */
  134876. onNewMeshSelected: Observable<AbstractMesh>;
  134877. /**
  134878. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  134879. * This observable will provide the mesh and the controller used to select the mesh
  134880. */
  134881. onMeshSelectedWithController: Observable<{
  134882. mesh: AbstractMesh;
  134883. controller: WebVRController;
  134884. }>;
  134885. /**
  134886. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  134887. */
  134888. onNewMeshPicked: Observable<PickingInfo>;
  134889. private _circleEase;
  134890. /**
  134891. * Observable raised before camera teleportation
  134892. */
  134893. onBeforeCameraTeleport: Observable<Vector3>;
  134894. /**
  134895. * Observable raised after camera teleportation
  134896. */
  134897. onAfterCameraTeleport: Observable<Vector3>;
  134898. /**
  134899. * Observable raised when current selected mesh gets unselected
  134900. */
  134901. onSelectedMeshUnselected: Observable<AbstractMesh>;
  134902. private _raySelectionPredicate;
  134903. /**
  134904. * To be optionaly changed by user to define custom ray selection
  134905. */
  134906. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  134907. /**
  134908. * To be optionaly changed by user to define custom selection logic (after ray selection)
  134909. */
  134910. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  134911. /**
  134912. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  134913. */
  134914. teleportationEnabled: boolean;
  134915. private _defaultHeight;
  134916. private _teleportationInitialized;
  134917. private _interactionsEnabled;
  134918. private _interactionsRequested;
  134919. private _displayGaze;
  134920. private _displayLaserPointer;
  134921. /**
  134922. * The mesh used to display where the user is going to teleport.
  134923. */
  134924. get teleportationTarget(): Mesh;
  134925. /**
  134926. * Sets the mesh to be used to display where the user is going to teleport.
  134927. */
  134928. set teleportationTarget(value: Mesh);
  134929. /**
  134930. * 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
  134931. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  134932. * See https://doc.babylonjs.com/resources/baking_transformations
  134933. */
  134934. get gazeTrackerMesh(): Mesh;
  134935. set gazeTrackerMesh(value: Mesh);
  134936. /**
  134937. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  134938. */
  134939. updateGazeTrackerScale: boolean;
  134940. /**
  134941. * If the gaze trackers color should be updated when selecting meshes
  134942. */
  134943. updateGazeTrackerColor: boolean;
  134944. /**
  134945. * If the controller laser color should be updated when selecting meshes
  134946. */
  134947. updateControllerLaserColor: boolean;
  134948. /**
  134949. * The gaze tracking mesh corresponding to the left controller
  134950. */
  134951. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  134952. /**
  134953. * The gaze tracking mesh corresponding to the right controller
  134954. */
  134955. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  134956. /**
  134957. * If the ray of the gaze should be displayed.
  134958. */
  134959. get displayGaze(): boolean;
  134960. /**
  134961. * Sets if the ray of the gaze should be displayed.
  134962. */
  134963. set displayGaze(value: boolean);
  134964. /**
  134965. * If the ray of the LaserPointer should be displayed.
  134966. */
  134967. get displayLaserPointer(): boolean;
  134968. /**
  134969. * Sets if the ray of the LaserPointer should be displayed.
  134970. */
  134971. set displayLaserPointer(value: boolean);
  134972. /**
  134973. * The deviceOrientationCamera used as the camera when not in VR.
  134974. */
  134975. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  134976. /**
  134977. * Based on the current WebVR support, returns the current VR camera used.
  134978. */
  134979. get currentVRCamera(): Nullable<Camera>;
  134980. /**
  134981. * The webVRCamera which is used when in VR.
  134982. */
  134983. get webVRCamera(): WebVRFreeCamera;
  134984. /**
  134985. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  134986. */
  134987. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  134988. /**
  134989. * The html button that is used to trigger entering into VR.
  134990. */
  134991. get vrButton(): Nullable<HTMLButtonElement>;
  134992. private get _teleportationRequestInitiated();
  134993. /**
  134994. * Defines whether or not Pointer lock should be requested when switching to
  134995. * full screen.
  134996. */
  134997. requestPointerLockOnFullScreen: boolean;
  134998. /**
  134999. * If asking to force XR, this will be populated with the default xr experience
  135000. */
  135001. xr: WebXRDefaultExperience;
  135002. /**
  135003. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  135004. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  135005. */
  135006. xrTestDone: boolean;
  135007. /**
  135008. * Instantiates a VRExperienceHelper.
  135009. * Helps to quickly add VR support to an existing scene.
  135010. * @param scene The scene the VRExperienceHelper belongs to.
  135011. * @param webVROptions Options to modify the vr experience helper's behavior.
  135012. */
  135013. constructor(scene: Scene,
  135014. /** Options to modify the vr experience helper's behavior. */
  135015. webVROptions?: VRExperienceHelperOptions);
  135016. private completeVRInit;
  135017. private _onDefaultMeshLoaded;
  135018. private _onResize;
  135019. private _onFullscreenChange;
  135020. /**
  135021. * Gets a value indicating if we are currently in VR mode.
  135022. */
  135023. get isInVRMode(): boolean;
  135024. private onVrDisplayPresentChange;
  135025. private onVRDisplayChanged;
  135026. private moveButtonToBottomRight;
  135027. private displayVRButton;
  135028. private updateButtonVisibility;
  135029. private _cachedAngularSensibility;
  135030. /**
  135031. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  135032. * Otherwise, will use the fullscreen API.
  135033. */
  135034. enterVR(): void;
  135035. /**
  135036. * Attempt to exit VR, or fullscreen.
  135037. */
  135038. exitVR(): void;
  135039. /**
  135040. * The position of the vr experience helper.
  135041. */
  135042. get position(): Vector3;
  135043. /**
  135044. * Sets the position of the vr experience helper.
  135045. */
  135046. set position(value: Vector3);
  135047. /**
  135048. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  135049. */
  135050. enableInteractions(): void;
  135051. private get _noControllerIsActive();
  135052. private beforeRender;
  135053. private _isTeleportationFloor;
  135054. /**
  135055. * Adds a floor mesh to be used for teleportation.
  135056. * @param floorMesh the mesh to be used for teleportation.
  135057. */
  135058. addFloorMesh(floorMesh: Mesh): void;
  135059. /**
  135060. * Removes a floor mesh from being used for teleportation.
  135061. * @param floorMesh the mesh to be removed.
  135062. */
  135063. removeFloorMesh(floorMesh: Mesh): void;
  135064. /**
  135065. * Enables interactions and teleportation using the VR controllers and gaze.
  135066. * @param vrTeleportationOptions options to modify teleportation behavior.
  135067. */
  135068. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  135069. private _onNewGamepadConnected;
  135070. private _tryEnableInteractionOnController;
  135071. private _onNewGamepadDisconnected;
  135072. private _enableInteractionOnController;
  135073. private _checkTeleportWithRay;
  135074. private _checkRotate;
  135075. private _checkTeleportBackwards;
  135076. private _enableTeleportationOnController;
  135077. private _createTeleportationCircles;
  135078. private _displayTeleportationTarget;
  135079. private _hideTeleportationTarget;
  135080. private _rotateCamera;
  135081. private _moveTeleportationSelectorTo;
  135082. private _workingVector;
  135083. private _workingQuaternion;
  135084. private _workingMatrix;
  135085. /**
  135086. * Time Constant Teleportation Mode
  135087. */
  135088. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  135089. /**
  135090. * Speed Constant Teleportation Mode
  135091. */
  135092. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  135093. /**
  135094. * Teleports the users feet to the desired location
  135095. * @param location The location where the user's feet should be placed
  135096. */
  135097. teleportCamera(location: Vector3): void;
  135098. private _convertNormalToDirectionOfRay;
  135099. private _castRayAndSelectObject;
  135100. private _notifySelectedMeshUnselected;
  135101. /**
  135102. * Permanently set new colors for the laser pointer
  135103. * @param color the new laser color
  135104. * @param pickedColor the new laser color when picked mesh detected
  135105. */
  135106. setLaserColor(color: Color3, pickedColor?: Color3): void;
  135107. /**
  135108. * Set lighting enabled / disabled on the laser pointer of both controllers
  135109. * @param enabled should the lighting be enabled on the laser pointer
  135110. */
  135111. setLaserLightingState(enabled?: boolean): void;
  135112. /**
  135113. * Permanently set new colors for the gaze pointer
  135114. * @param color the new gaze color
  135115. * @param pickedColor the new gaze color when picked mesh detected
  135116. */
  135117. setGazeColor(color: Color3, pickedColor?: Color3): void;
  135118. /**
  135119. * Sets the color of the laser ray from the vr controllers.
  135120. * @param color new color for the ray.
  135121. */
  135122. changeLaserColor(color: Color3): void;
  135123. /**
  135124. * Sets the color of the ray from the vr headsets gaze.
  135125. * @param color new color for the ray.
  135126. */
  135127. changeGazeColor(color: Color3): void;
  135128. /**
  135129. * Exits VR and disposes of the vr experience helper
  135130. */
  135131. dispose(): void;
  135132. /**
  135133. * Gets the name of the VRExperienceHelper class
  135134. * @returns "VRExperienceHelper"
  135135. */
  135136. getClassName(): string;
  135137. }
  135138. }
  135139. declare module BABYLON {
  135140. /**
  135141. * Contains an array of blocks representing the octree
  135142. */
  135143. export interface IOctreeContainer<T> {
  135144. /**
  135145. * Blocks within the octree
  135146. */
  135147. blocks: Array<OctreeBlock<T>>;
  135148. }
  135149. /**
  135150. * Class used to store a cell in an octree
  135151. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135152. */
  135153. export class OctreeBlock<T> {
  135154. /**
  135155. * Gets the content of the current block
  135156. */
  135157. entries: T[];
  135158. /**
  135159. * Gets the list of block children
  135160. */
  135161. blocks: Array<OctreeBlock<T>>;
  135162. private _depth;
  135163. private _maxDepth;
  135164. private _capacity;
  135165. private _minPoint;
  135166. private _maxPoint;
  135167. private _boundingVectors;
  135168. private _creationFunc;
  135169. /**
  135170. * Creates a new block
  135171. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  135172. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  135173. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  135174. * @param depth defines the current depth of this block in the octree
  135175. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  135176. * @param creationFunc defines a callback to call when an element is added to the block
  135177. */
  135178. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  135179. /**
  135180. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  135181. */
  135182. get capacity(): number;
  135183. /**
  135184. * Gets the minimum vector (in world space) of the block's bounding box
  135185. */
  135186. get minPoint(): Vector3;
  135187. /**
  135188. * Gets the maximum vector (in world space) of the block's bounding box
  135189. */
  135190. get maxPoint(): Vector3;
  135191. /**
  135192. * Add a new element to this block
  135193. * @param entry defines the element to add
  135194. */
  135195. addEntry(entry: T): void;
  135196. /**
  135197. * Remove an element from this block
  135198. * @param entry defines the element to remove
  135199. */
  135200. removeEntry(entry: T): void;
  135201. /**
  135202. * Add an array of elements to this block
  135203. * @param entries defines the array of elements to add
  135204. */
  135205. addEntries(entries: T[]): void;
  135206. /**
  135207. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  135208. * @param frustumPlanes defines the frustum planes to test
  135209. * @param selection defines the array to store current content if selection is positive
  135210. * @param allowDuplicate defines if the selection array can contains duplicated entries
  135211. */
  135212. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  135213. /**
  135214. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  135215. * @param sphereCenter defines the bounding sphere center
  135216. * @param sphereRadius defines the bounding sphere radius
  135217. * @param selection defines the array to store current content if selection is positive
  135218. * @param allowDuplicate defines if the selection array can contains duplicated entries
  135219. */
  135220. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  135221. /**
  135222. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  135223. * @param ray defines the ray to test with
  135224. * @param selection defines the array to store current content if selection is positive
  135225. */
  135226. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  135227. /**
  135228. * Subdivide the content into child blocks (this block will then be empty)
  135229. */
  135230. createInnerBlocks(): void;
  135231. /**
  135232. * @hidden
  135233. */
  135234. 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;
  135235. }
  135236. }
  135237. declare module BABYLON {
  135238. /**
  135239. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  135240. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135241. */
  135242. export class Octree<T> {
  135243. /** 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.) */
  135244. maxDepth: number;
  135245. /**
  135246. * Blocks within the octree containing objects
  135247. */
  135248. blocks: Array<OctreeBlock<T>>;
  135249. /**
  135250. * Content stored in the octree
  135251. */
  135252. dynamicContent: T[];
  135253. private _maxBlockCapacity;
  135254. private _selectionContent;
  135255. private _creationFunc;
  135256. /**
  135257. * Creates a octree
  135258. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135259. * @param creationFunc function to be used to instatiate the octree
  135260. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  135261. * @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.)
  135262. */
  135263. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  135264. /** 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.) */
  135265. maxDepth?: number);
  135266. /**
  135267. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  135268. * @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);
  135269. * @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);
  135270. * @param entries meshes to be added to the octree blocks
  135271. */
  135272. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  135273. /**
  135274. * Adds a mesh to the octree
  135275. * @param entry Mesh to add to the octree
  135276. */
  135277. addMesh(entry: T): void;
  135278. /**
  135279. * Remove an element from the octree
  135280. * @param entry defines the element to remove
  135281. */
  135282. removeMesh(entry: T): void;
  135283. /**
  135284. * Selects an array of meshes within the frustum
  135285. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  135286. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  135287. * @returns array of meshes within the frustum
  135288. */
  135289. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  135290. /**
  135291. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  135292. * @param sphereCenter defines the bounding sphere center
  135293. * @param sphereRadius defines the bounding sphere radius
  135294. * @param allowDuplicate defines if the selection array can contains duplicated entries
  135295. * @returns an array of objects that intersect the sphere
  135296. */
  135297. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  135298. /**
  135299. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  135300. * @param ray defines the ray to test with
  135301. * @returns array of intersected objects
  135302. */
  135303. intersectsRay(ray: Ray): SmartArray<T>;
  135304. /**
  135305. * Adds a mesh into the octree block if it intersects the block
  135306. */
  135307. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  135308. /**
  135309. * Adds a submesh into the octree block if it intersects the block
  135310. */
  135311. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  135312. }
  135313. }
  135314. declare module BABYLON {
  135315. interface Scene {
  135316. /**
  135317. * @hidden
  135318. * Backing Filed
  135319. */
  135320. _selectionOctree: Octree<AbstractMesh>;
  135321. /**
  135322. * Gets the octree used to boost mesh selection (picking)
  135323. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135324. */
  135325. selectionOctree: Octree<AbstractMesh>;
  135326. /**
  135327. * Creates or updates the octree used to boost selection (picking)
  135328. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135329. * @param maxCapacity defines the maximum capacity per leaf
  135330. * @param maxDepth defines the maximum depth of the octree
  135331. * @returns an octree of AbstractMesh
  135332. */
  135333. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  135334. }
  135335. interface AbstractMesh {
  135336. /**
  135337. * @hidden
  135338. * Backing Field
  135339. */
  135340. _submeshesOctree: Octree<SubMesh>;
  135341. /**
  135342. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  135343. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  135344. * @param maxCapacity defines the maximum size of each block (64 by default)
  135345. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  135346. * @returns the new octree
  135347. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  135348. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135349. */
  135350. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  135351. }
  135352. /**
  135353. * Defines the octree scene component responsible to manage any octrees
  135354. * in a given scene.
  135355. */
  135356. export class OctreeSceneComponent {
  135357. /**
  135358. * The component name help to identify the component in the list of scene components.
  135359. */
  135360. readonly name: string;
  135361. /**
  135362. * The scene the component belongs to.
  135363. */
  135364. scene: Scene;
  135365. /**
  135366. * Indicates if the meshes have been checked to make sure they are isEnabled()
  135367. */
  135368. readonly checksIsEnabled: boolean;
  135369. /**
  135370. * Creates a new instance of the component for the given scene
  135371. * @param scene Defines the scene to register the component in
  135372. */
  135373. constructor(scene: Scene);
  135374. /**
  135375. * Registers the component in a given scene
  135376. */
  135377. register(): void;
  135378. /**
  135379. * Return the list of active meshes
  135380. * @returns the list of active meshes
  135381. */
  135382. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  135383. /**
  135384. * Return the list of active sub meshes
  135385. * @param mesh The mesh to get the candidates sub meshes from
  135386. * @returns the list of active sub meshes
  135387. */
  135388. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  135389. private _tempRay;
  135390. /**
  135391. * Return the list of sub meshes intersecting with a given local ray
  135392. * @param mesh defines the mesh to find the submesh for
  135393. * @param localRay defines the ray in local space
  135394. * @returns the list of intersecting sub meshes
  135395. */
  135396. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  135397. /**
  135398. * Return the list of sub meshes colliding with a collider
  135399. * @param mesh defines the mesh to find the submesh for
  135400. * @param collider defines the collider to evaluate the collision against
  135401. * @returns the list of colliding sub meshes
  135402. */
  135403. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  135404. /**
  135405. * Rebuilds the elements related to this component in case of
  135406. * context lost for instance.
  135407. */
  135408. rebuild(): void;
  135409. /**
  135410. * Disposes the component and the associated ressources.
  135411. */
  135412. dispose(): void;
  135413. }
  135414. }
  135415. declare module BABYLON {
  135416. /**
  135417. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  135418. */
  135419. export interface GizmoAxisCache {
  135420. /** Mesh used to runder the Gizmo */
  135421. gizmoMeshes: Mesh[];
  135422. /** Mesh used to detect user interaction with Gizmo */
  135423. colliderMeshes: Mesh[];
  135424. /** Material used to inicate color of gizmo mesh */
  135425. material: StandardMaterial;
  135426. /** Material used to inicate hover state of the Gizmo */
  135427. hoverMaterial: StandardMaterial;
  135428. /** Material used to inicate disabled state of the Gizmo */
  135429. disableMaterial: StandardMaterial;
  135430. /** Used to indicate Active state of the Gizmo */
  135431. active: boolean;
  135432. }
  135433. /**
  135434. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  135435. */
  135436. export class Gizmo implements IDisposable {
  135437. /** The utility layer the gizmo will be added to */
  135438. gizmoLayer: UtilityLayerRenderer;
  135439. /**
  135440. * The root mesh of the gizmo
  135441. */
  135442. _rootMesh: Mesh;
  135443. private _attachedMesh;
  135444. private _attachedNode;
  135445. /**
  135446. * Ratio for the scale of the gizmo (Default: 1)
  135447. */
  135448. protected _scaleRatio: number;
  135449. /**
  135450. * boolean updated by pointermove when a gizmo mesh is hovered
  135451. */
  135452. protected _isHovered: boolean;
  135453. /**
  135454. * Ratio for the scale of the gizmo (Default: 1)
  135455. */
  135456. set scaleRatio(value: number);
  135457. get scaleRatio(): number;
  135458. /**
  135459. * True when the mouse pointer is hovered a gizmo mesh
  135460. */
  135461. get isHovered(): boolean;
  135462. /**
  135463. * If a custom mesh has been set (Default: false)
  135464. */
  135465. protected _customMeshSet: boolean;
  135466. /**
  135467. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  135468. * * When set, interactions will be enabled
  135469. */
  135470. get attachedMesh(): Nullable<AbstractMesh>;
  135471. set attachedMesh(value: Nullable<AbstractMesh>);
  135472. /**
  135473. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  135474. * * When set, interactions will be enabled
  135475. */
  135476. get attachedNode(): Nullable<Node>;
  135477. set attachedNode(value: Nullable<Node>);
  135478. /**
  135479. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  135480. * @param mesh The mesh to replace the default mesh of the gizmo
  135481. */
  135482. setCustomMesh(mesh: Mesh): void;
  135483. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  135484. /**
  135485. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  135486. */
  135487. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  135488. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  135489. /**
  135490. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  135491. */
  135492. updateGizmoPositionToMatchAttachedMesh: boolean;
  135493. /**
  135494. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  135495. */
  135496. updateScale: boolean;
  135497. protected _interactionsEnabled: boolean;
  135498. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135499. private _beforeRenderObserver;
  135500. private _tempQuaternion;
  135501. private _tempVector;
  135502. private _tempVector2;
  135503. private _tempMatrix1;
  135504. private _tempMatrix2;
  135505. private _rightHandtoLeftHandMatrix;
  135506. /**
  135507. * Creates a gizmo
  135508. * @param gizmoLayer The utility layer the gizmo will be added to
  135509. */
  135510. constructor(
  135511. /** The utility layer the gizmo will be added to */
  135512. gizmoLayer?: UtilityLayerRenderer);
  135513. /**
  135514. * Updates the gizmo to match the attached mesh's position/rotation
  135515. */
  135516. protected _update(): void;
  135517. /**
  135518. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  135519. * @param value Node, TransformNode or mesh
  135520. */
  135521. protected _matrixChanged(): void;
  135522. /**
  135523. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  135524. * @param gizmoLayer The utility layer the gizmo will be added to
  135525. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  135526. * @returns {Observer<PointerInfo>} pointerObserver
  135527. */
  135528. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  135529. /**
  135530. * Disposes of the gizmo
  135531. */
  135532. dispose(): void;
  135533. }
  135534. }
  135535. declare module BABYLON {
  135536. /**
  135537. * Single plane drag gizmo
  135538. */
  135539. export class PlaneDragGizmo extends Gizmo {
  135540. /**
  135541. * Drag behavior responsible for the gizmos dragging interactions
  135542. */
  135543. dragBehavior: PointerDragBehavior;
  135544. private _pointerObserver;
  135545. /**
  135546. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  135547. */
  135548. snapDistance: number;
  135549. /**
  135550. * Event that fires each time the gizmo snaps to a new location.
  135551. * * snapDistance is the the change in distance
  135552. */
  135553. onSnapObservable: Observable<{
  135554. snapDistance: number;
  135555. }>;
  135556. private _gizmoMesh;
  135557. private _coloredMaterial;
  135558. private _hoverMaterial;
  135559. private _disableMaterial;
  135560. private _isEnabled;
  135561. private _parent;
  135562. private _dragging;
  135563. /** @hidden */
  135564. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  135565. /**
  135566. * Creates a PlaneDragGizmo
  135567. * @param gizmoLayer The utility layer the gizmo will be added to
  135568. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  135569. * @param color The color of the gizmo
  135570. */
  135571. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  135572. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135573. /**
  135574. * If the gizmo is enabled
  135575. */
  135576. set isEnabled(value: boolean);
  135577. get isEnabled(): boolean;
  135578. /**
  135579. * Disposes of the gizmo
  135580. */
  135581. dispose(): void;
  135582. }
  135583. }
  135584. declare module BABYLON {
  135585. /**
  135586. * Single plane rotation gizmo
  135587. */
  135588. export class PlaneRotationGizmo extends Gizmo {
  135589. /**
  135590. * Drag behavior responsible for the gizmos dragging interactions
  135591. */
  135592. dragBehavior: PointerDragBehavior;
  135593. private _pointerObserver;
  135594. /**
  135595. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  135596. */
  135597. snapDistance: number;
  135598. /**
  135599. * Event that fires each time the gizmo snaps to a new location.
  135600. * * snapDistance is the the change in distance
  135601. */
  135602. onSnapObservable: Observable<{
  135603. snapDistance: number;
  135604. }>;
  135605. private _isEnabled;
  135606. private _parent;
  135607. private _coloredMaterial;
  135608. private _hoverMaterial;
  135609. private _disableMaterial;
  135610. private _gizmoMesh;
  135611. private _rotationCircle;
  135612. private _dragging;
  135613. private static _CircleConstants;
  135614. /**
  135615. * Creates a PlaneRotationGizmo
  135616. * @param gizmoLayer The utility layer the gizmo will be added to
  135617. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  135618. * @param color The color of the gizmo
  135619. * @param tessellation Amount of tessellation to be used when creating rotation circles
  135620. * @param useEulerRotation Use and update Euler angle instead of quaternion
  135621. * @param thickness display gizmo axis thickness
  135622. */
  135623. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  135624. /** Create Geometry for Gizmo */
  135625. private _createGizmoMesh;
  135626. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135627. private setupRotationCircle;
  135628. private updateRotationPath;
  135629. private updateRotationCircle;
  135630. /**
  135631. * If the gizmo is enabled
  135632. */
  135633. set isEnabled(value: boolean);
  135634. get isEnabled(): boolean;
  135635. /**
  135636. * Disposes of the gizmo
  135637. */
  135638. dispose(): void;
  135639. }
  135640. }
  135641. declare module BABYLON {
  135642. /**
  135643. * Gizmo that enables rotating a mesh along 3 axis
  135644. */
  135645. export class RotationGizmo extends Gizmo {
  135646. /**
  135647. * Internal gizmo used for interactions on the x axis
  135648. */
  135649. xGizmo: PlaneRotationGizmo;
  135650. /**
  135651. * Internal gizmo used for interactions on the y axis
  135652. */
  135653. yGizmo: PlaneRotationGizmo;
  135654. /**
  135655. * Internal gizmo used for interactions on the z axis
  135656. */
  135657. zGizmo: PlaneRotationGizmo;
  135658. /** Fires an event when any of it's sub gizmos are dragged */
  135659. onDragStartObservable: Observable<unknown>;
  135660. /** Fires an event when any of it's sub gizmos are released from dragging */
  135661. onDragEndObservable: Observable<unknown>;
  135662. private _meshAttached;
  135663. private _nodeAttached;
  135664. private _observables;
  135665. /** Node Caching for quick lookup */
  135666. private _gizmoAxisCache;
  135667. get attachedMesh(): Nullable<AbstractMesh>;
  135668. set attachedMesh(mesh: Nullable<AbstractMesh>);
  135669. get attachedNode(): Nullable<Node>;
  135670. set attachedNode(node: Nullable<Node>);
  135671. protected _checkBillboardTransform(): void;
  135672. /**
  135673. * True when the mouse pointer is hovering a gizmo mesh
  135674. */
  135675. get isHovered(): boolean;
  135676. /**
  135677. * Creates a RotationGizmo
  135678. * @param gizmoLayer The utility layer the gizmo will be added to
  135679. * @param tessellation Amount of tessellation to be used when creating rotation circles
  135680. * @param useEulerRotation Use and update Euler angle instead of quaternion
  135681. * @param thickness display gizmo axis thickness
  135682. */
  135683. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  135684. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  135685. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  135686. /**
  135687. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  135688. */
  135689. set snapDistance(value: number);
  135690. get snapDistance(): number;
  135691. /**
  135692. * Ratio for the scale of the gizmo (Default: 1)
  135693. */
  135694. set scaleRatio(value: number);
  135695. get scaleRatio(): number;
  135696. /**
  135697. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  135698. * @param mesh Axis gizmo mesh
  135699. * @param cache Gizmo axis definition used for reactive gizmo UI
  135700. */
  135701. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  135702. /**
  135703. * Disposes of the gizmo
  135704. */
  135705. dispose(): void;
  135706. /**
  135707. * CustomMeshes are not supported by this gizmo
  135708. * @param mesh The mesh to replace the default mesh of the gizmo
  135709. */
  135710. setCustomMesh(mesh: Mesh): void;
  135711. }
  135712. }
  135713. declare module BABYLON {
  135714. /**
  135715. * Class containing static functions to help procedurally build meshes
  135716. */
  135717. export class PolyhedronBuilder {
  135718. /**
  135719. * Creates a polyhedron mesh
  135720. * * 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
  135721. * * The parameter `size` (positive float, default 1) sets the polygon size
  135722. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  135723. * * 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`
  135724. * * 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
  135725. * * 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)`)
  135726. * * 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
  135727. * * 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
  135728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135729. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135731. * @param name defines the name of the mesh
  135732. * @param options defines the options used to create the mesh
  135733. * @param scene defines the hosting scene
  135734. * @returns the polyhedron mesh
  135735. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  135736. */
  135737. static CreatePolyhedron(name: string, options: {
  135738. type?: number;
  135739. size?: number;
  135740. sizeX?: number;
  135741. sizeY?: number;
  135742. sizeZ?: number;
  135743. custom?: any;
  135744. faceUV?: Vector4[];
  135745. faceColors?: Color4[];
  135746. flat?: boolean;
  135747. updatable?: boolean;
  135748. sideOrientation?: number;
  135749. frontUVs?: Vector4;
  135750. backUVs?: Vector4;
  135751. }, scene?: Nullable<Scene>): Mesh;
  135752. }
  135753. }
  135754. declare module BABYLON {
  135755. /**
  135756. * Class containing static functions to help procedurally build meshes
  135757. */
  135758. export class BoxBuilder {
  135759. /**
  135760. * Creates a box mesh
  135761. * * The parameter `size` sets the size (float) of each box side (default 1)
  135762. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  135763. * * 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)
  135764. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135765. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135766. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135768. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  135769. * @param name defines the name of the mesh
  135770. * @param options defines the options used to create the mesh
  135771. * @param scene defines the hosting scene
  135772. * @returns the box mesh
  135773. */
  135774. static CreateBox(name: string, options: {
  135775. size?: number;
  135776. width?: number;
  135777. height?: number;
  135778. depth?: number;
  135779. faceUV?: Vector4[];
  135780. faceColors?: Color4[];
  135781. sideOrientation?: number;
  135782. frontUVs?: Vector4;
  135783. backUVs?: Vector4;
  135784. wrap?: boolean;
  135785. topBaseAt?: number;
  135786. bottomBaseAt?: number;
  135787. updatable?: boolean;
  135788. }, scene?: Nullable<Scene>): Mesh;
  135789. }
  135790. }
  135791. declare module BABYLON {
  135792. /**
  135793. * Single axis scale gizmo
  135794. */
  135795. export class AxisScaleGizmo extends Gizmo {
  135796. /**
  135797. * Drag behavior responsible for the gizmos dragging interactions
  135798. */
  135799. dragBehavior: PointerDragBehavior;
  135800. private _pointerObserver;
  135801. /**
  135802. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  135803. */
  135804. snapDistance: number;
  135805. /**
  135806. * Event that fires each time the gizmo snaps to a new location.
  135807. * * snapDistance is the the change in distance
  135808. */
  135809. onSnapObservable: Observable<{
  135810. snapDistance: number;
  135811. }>;
  135812. /**
  135813. * If the scaling operation should be done on all axis (default: false)
  135814. */
  135815. uniformScaling: boolean;
  135816. /**
  135817. * Custom sensitivity value for the drag strength
  135818. */
  135819. sensitivity: number;
  135820. private _isEnabled;
  135821. private _parent;
  135822. private _gizmoMesh;
  135823. private _coloredMaterial;
  135824. private _hoverMaterial;
  135825. private _disableMaterial;
  135826. private _dragging;
  135827. /**
  135828. * Creates an AxisScaleGizmo
  135829. * @param gizmoLayer The utility layer the gizmo will be added to
  135830. * @param dragAxis The axis which the gizmo will be able to scale on
  135831. * @param color The color of the gizmo
  135832. * @param thickness display gizmo axis thickness
  135833. */
  135834. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  135835. /** Create Geometry for Gizmo */
  135836. private _createGizmoMesh;
  135837. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135838. /**
  135839. * If the gizmo is enabled
  135840. */
  135841. set isEnabled(value: boolean);
  135842. get isEnabled(): boolean;
  135843. /**
  135844. * Disposes of the gizmo
  135845. */
  135846. dispose(): void;
  135847. /**
  135848. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  135849. * @param mesh The mesh to replace the default mesh of the gizmo
  135850. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  135851. */
  135852. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  135853. }
  135854. }
  135855. declare module BABYLON {
  135856. /**
  135857. * Gizmo that enables scaling a mesh along 3 axis
  135858. */
  135859. export class ScaleGizmo extends Gizmo {
  135860. /**
  135861. * Internal gizmo used for interactions on the x axis
  135862. */
  135863. xGizmo: AxisScaleGizmo;
  135864. /**
  135865. * Internal gizmo used for interactions on the y axis
  135866. */
  135867. yGizmo: AxisScaleGizmo;
  135868. /**
  135869. * Internal gizmo used for interactions on the z axis
  135870. */
  135871. zGizmo: AxisScaleGizmo;
  135872. /**
  135873. * Internal gizmo used to scale all axis equally
  135874. */
  135875. uniformScaleGizmo: AxisScaleGizmo;
  135876. private _meshAttached;
  135877. private _nodeAttached;
  135878. private _snapDistance;
  135879. private _uniformScalingMesh;
  135880. private _octahedron;
  135881. private _sensitivity;
  135882. private _coloredMaterial;
  135883. private _hoverMaterial;
  135884. private _disableMaterial;
  135885. private _observables;
  135886. /** Node Caching for quick lookup */
  135887. private _gizmoAxisCache;
  135888. /** Fires an event when any of it's sub gizmos are dragged */
  135889. onDragStartObservable: Observable<unknown>;
  135890. /** Fires an event when any of it's sub gizmos are released from dragging */
  135891. onDragEndObservable: Observable<unknown>;
  135892. get attachedMesh(): Nullable<AbstractMesh>;
  135893. set attachedMesh(mesh: Nullable<AbstractMesh>);
  135894. get attachedNode(): Nullable<Node>;
  135895. set attachedNode(node: Nullable<Node>);
  135896. /**
  135897. * True when the mouse pointer is hovering a gizmo mesh
  135898. */
  135899. get isHovered(): boolean;
  135900. /**
  135901. * Creates a ScaleGizmo
  135902. * @param gizmoLayer The utility layer the gizmo will be added to
  135903. * @param thickness display gizmo axis thickness
  135904. */
  135905. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  135906. /** Create Geometry for Gizmo */
  135907. private _createUniformScaleMesh;
  135908. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  135909. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  135910. /**
  135911. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  135912. */
  135913. set snapDistance(value: number);
  135914. get snapDistance(): number;
  135915. /**
  135916. * Ratio for the scale of the gizmo (Default: 1)
  135917. */
  135918. set scaleRatio(value: number);
  135919. get scaleRatio(): number;
  135920. /**
  135921. * Sensitivity factor for dragging (Default: 1)
  135922. */
  135923. set sensitivity(value: number);
  135924. get sensitivity(): number;
  135925. /**
  135926. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  135927. * @param mesh Axis gizmo mesh
  135928. * @param cache Gizmo axis definition used for reactive gizmo UI
  135929. */
  135930. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  135931. /**
  135932. * Disposes of the gizmo
  135933. */
  135934. dispose(): void;
  135935. }
  135936. }
  135937. declare module BABYLON {
  135938. /**
  135939. * Bounding box gizmo
  135940. */
  135941. export class BoundingBoxGizmo extends Gizmo {
  135942. private _lineBoundingBox;
  135943. private _rotateSpheresParent;
  135944. private _scaleBoxesParent;
  135945. private _boundingDimensions;
  135946. private _renderObserver;
  135947. private _pointerObserver;
  135948. private _scaleDragSpeed;
  135949. private _tmpQuaternion;
  135950. private _tmpVector;
  135951. private _tmpRotationMatrix;
  135952. /**
  135953. * 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)
  135954. */
  135955. ignoreChildren: boolean;
  135956. /**
  135957. * 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)
  135958. */
  135959. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  135960. /**
  135961. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  135962. */
  135963. rotationSphereSize: number;
  135964. /**
  135965. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  135966. */
  135967. scaleBoxSize: number;
  135968. /**
  135969. * 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)
  135970. */
  135971. fixedDragMeshScreenSize: boolean;
  135972. /**
  135973. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  135974. */
  135975. fixedDragMeshScreenSizeDistanceFactor: number;
  135976. /**
  135977. * Fired when a rotation sphere or scale box is dragged
  135978. */
  135979. onDragStartObservable: Observable<{}>;
  135980. /**
  135981. * Fired when a scale box is dragged
  135982. */
  135983. onScaleBoxDragObservable: Observable<{}>;
  135984. /**
  135985. * Fired when a scale box drag is ended
  135986. */
  135987. onScaleBoxDragEndObservable: Observable<{}>;
  135988. /**
  135989. * Fired when a rotation sphere is dragged
  135990. */
  135991. onRotationSphereDragObservable: Observable<{}>;
  135992. /**
  135993. * Fired when a rotation sphere drag is ended
  135994. */
  135995. onRotationSphereDragEndObservable: Observable<{}>;
  135996. /**
  135997. * 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)
  135998. */
  135999. scalePivot: Nullable<Vector3>;
  136000. /**
  136001. * Mesh used as a pivot to rotate the attached node
  136002. */
  136003. private _anchorMesh;
  136004. private _existingMeshScale;
  136005. private _dragMesh;
  136006. private pointerDragBehavior;
  136007. private coloredMaterial;
  136008. private hoverColoredMaterial;
  136009. /**
  136010. * Sets the color of the bounding box gizmo
  136011. * @param color the color to set
  136012. */
  136013. setColor(color: Color3): void;
  136014. /**
  136015. * Creates an BoundingBoxGizmo
  136016. * @param gizmoLayer The utility layer the gizmo will be added to
  136017. * @param color The color of the gizmo
  136018. */
  136019. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  136020. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  136021. private _selectNode;
  136022. /**
  136023. * Updates the bounding box information for the Gizmo
  136024. */
  136025. updateBoundingBox(): void;
  136026. private _updateRotationSpheres;
  136027. private _updateScaleBoxes;
  136028. /**
  136029. * Enables rotation on the specified axis and disables rotation on the others
  136030. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  136031. */
  136032. setEnabledRotationAxis(axis: string): void;
  136033. /**
  136034. * Enables/disables scaling
  136035. * @param enable if scaling should be enabled
  136036. * @param homogeneousScaling defines if scaling should only be homogeneous
  136037. */
  136038. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  136039. private _updateDummy;
  136040. /**
  136041. * Enables a pointer drag behavior on the bounding box of the gizmo
  136042. */
  136043. enableDragBehavior(): void;
  136044. /**
  136045. * Disposes of the gizmo
  136046. */
  136047. dispose(): void;
  136048. /**
  136049. * 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)
  136050. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  136051. * @returns the bounding box mesh with the passed in mesh as a child
  136052. */
  136053. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  136054. /**
  136055. * CustomMeshes are not supported by this gizmo
  136056. * @param mesh The mesh to replace the default mesh of the gizmo
  136057. */
  136058. setCustomMesh(mesh: Mesh): void;
  136059. }
  136060. }
  136061. declare module BABYLON {
  136062. /**
  136063. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  136064. */
  136065. export class GizmoManager implements IDisposable {
  136066. private scene;
  136067. /**
  136068. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  136069. */
  136070. gizmos: {
  136071. positionGizmo: Nullable<PositionGizmo>;
  136072. rotationGizmo: Nullable<RotationGizmo>;
  136073. scaleGizmo: Nullable<ScaleGizmo>;
  136074. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  136075. };
  136076. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  136077. clearGizmoOnEmptyPointerEvent: boolean;
  136078. /** Fires an event when the manager is attached to a mesh */
  136079. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  136080. /** Fires an event when the manager is attached to a node */
  136081. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  136082. private _gizmosEnabled;
  136083. private _pointerObservers;
  136084. private _attachedMesh;
  136085. private _attachedNode;
  136086. private _boundingBoxColor;
  136087. private _defaultUtilityLayer;
  136088. private _defaultKeepDepthUtilityLayer;
  136089. private _thickness;
  136090. /** Node Caching for quick lookup */
  136091. private _gizmoAxisCache;
  136092. /**
  136093. * When bounding box gizmo is enabled, this can be used to track drag/end events
  136094. */
  136095. boundingBoxDragBehavior: SixDofDragBehavior;
  136096. /**
  136097. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  136098. */
  136099. attachableMeshes: Nullable<Array<AbstractMesh>>;
  136100. /**
  136101. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  136102. */
  136103. attachableNodes: Nullable<Array<Node>>;
  136104. /**
  136105. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  136106. */
  136107. usePointerToAttachGizmos: boolean;
  136108. /**
  136109. * Utility layer that the bounding box gizmo belongs to
  136110. */
  136111. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  136112. /**
  136113. * Utility layer that all gizmos besides bounding box belong to
  136114. */
  136115. get utilityLayer(): UtilityLayerRenderer;
  136116. /**
  136117. * True when the mouse pointer is hovering a gizmo mesh
  136118. */
  136119. get isHovered(): boolean;
  136120. /**
  136121. * Instatiates a gizmo manager
  136122. * @param scene the scene to overlay the gizmos on top of
  136123. * @param thickness display gizmo axis thickness
  136124. * @param utilityLayer the layer where gizmos are rendered
  136125. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  136126. */
  136127. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  136128. /**
  136129. * Subscribes to pointer down events, for attaching and detaching mesh
  136130. * @param scene The sceme layer the observer will be added to
  136131. */
  136132. private _attachToMeshPointerObserver;
  136133. /**
  136134. * Attaches a set of gizmos to the specified mesh
  136135. * @param mesh The mesh the gizmo's should be attached to
  136136. */
  136137. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  136138. /**
  136139. * Attaches a set of gizmos to the specified node
  136140. * @param node The node the gizmo's should be attached to
  136141. */
  136142. attachToNode(node: Nullable<Node>): void;
  136143. /**
  136144. * If the position gizmo is enabled
  136145. */
  136146. set positionGizmoEnabled(value: boolean);
  136147. get positionGizmoEnabled(): boolean;
  136148. /**
  136149. * If the rotation gizmo is enabled
  136150. */
  136151. set rotationGizmoEnabled(value: boolean);
  136152. get rotationGizmoEnabled(): boolean;
  136153. /**
  136154. * If the scale gizmo is enabled
  136155. */
  136156. set scaleGizmoEnabled(value: boolean);
  136157. get scaleGizmoEnabled(): boolean;
  136158. /**
  136159. * If the boundingBox gizmo is enabled
  136160. */
  136161. set boundingBoxGizmoEnabled(value: boolean);
  136162. get boundingBoxGizmoEnabled(): boolean;
  136163. /**
  136164. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  136165. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  136166. */
  136167. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  136168. /**
  136169. * Disposes of the gizmo manager
  136170. */
  136171. dispose(): void;
  136172. }
  136173. }
  136174. declare module BABYLON {
  136175. /**
  136176. * Gizmo that enables dragging a mesh along 3 axis
  136177. */
  136178. export class PositionGizmo extends Gizmo {
  136179. /**
  136180. * Internal gizmo used for interactions on the x axis
  136181. */
  136182. xGizmo: AxisDragGizmo;
  136183. /**
  136184. * Internal gizmo used for interactions on the y axis
  136185. */
  136186. yGizmo: AxisDragGizmo;
  136187. /**
  136188. * Internal gizmo used for interactions on the z axis
  136189. */
  136190. zGizmo: AxisDragGizmo;
  136191. /**
  136192. * Internal gizmo used for interactions on the yz plane
  136193. */
  136194. xPlaneGizmo: PlaneDragGizmo;
  136195. /**
  136196. * Internal gizmo used for interactions on the xz plane
  136197. */
  136198. yPlaneGizmo: PlaneDragGizmo;
  136199. /**
  136200. * Internal gizmo used for interactions on the xy plane
  136201. */
  136202. zPlaneGizmo: PlaneDragGizmo;
  136203. /**
  136204. * private variables
  136205. */
  136206. private _meshAttached;
  136207. private _nodeAttached;
  136208. private _snapDistance;
  136209. private _observables;
  136210. /** Node Caching for quick lookup */
  136211. private _gizmoAxisCache;
  136212. /** Fires an event when any of it's sub gizmos are dragged */
  136213. onDragStartObservable: Observable<unknown>;
  136214. /** Fires an event when any of it's sub gizmos are released from dragging */
  136215. onDragEndObservable: Observable<unknown>;
  136216. /**
  136217. * If set to true, planar drag is enabled
  136218. */
  136219. private _planarGizmoEnabled;
  136220. get attachedMesh(): Nullable<AbstractMesh>;
  136221. set attachedMesh(mesh: Nullable<AbstractMesh>);
  136222. get attachedNode(): Nullable<Node>;
  136223. set attachedNode(node: Nullable<Node>);
  136224. /**
  136225. * True when the mouse pointer is hovering a gizmo mesh
  136226. */
  136227. get isHovered(): boolean;
  136228. /**
  136229. * Creates a PositionGizmo
  136230. * @param gizmoLayer The utility layer the gizmo will be added to
  136231. @param thickness display gizmo axis thickness
  136232. */
  136233. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  136234. /**
  136235. * If the planar drag gizmo is enabled
  136236. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  136237. */
  136238. set planarGizmoEnabled(value: boolean);
  136239. get planarGizmoEnabled(): boolean;
  136240. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  136241. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  136242. /**
  136243. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  136244. */
  136245. set snapDistance(value: number);
  136246. get snapDistance(): number;
  136247. /**
  136248. * Ratio for the scale of the gizmo (Default: 1)
  136249. */
  136250. set scaleRatio(value: number);
  136251. get scaleRatio(): number;
  136252. /**
  136253. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  136254. * @param mesh Axis gizmo mesh
  136255. * @param cache Gizmo axis definition used for reactive gizmo UI
  136256. */
  136257. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  136258. /**
  136259. * Disposes of the gizmo
  136260. */
  136261. dispose(): void;
  136262. /**
  136263. * CustomMeshes are not supported by this gizmo
  136264. * @param mesh The mesh to replace the default mesh of the gizmo
  136265. */
  136266. setCustomMesh(mesh: Mesh): void;
  136267. }
  136268. }
  136269. declare module BABYLON {
  136270. /**
  136271. * Single axis drag gizmo
  136272. */
  136273. export class AxisDragGizmo extends Gizmo {
  136274. /**
  136275. * Drag behavior responsible for the gizmos dragging interactions
  136276. */
  136277. dragBehavior: PointerDragBehavior;
  136278. private _pointerObserver;
  136279. /**
  136280. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  136281. */
  136282. snapDistance: number;
  136283. /**
  136284. * Event that fires each time the gizmo snaps to a new location.
  136285. * * snapDistance is the the change in distance
  136286. */
  136287. onSnapObservable: Observable<{
  136288. snapDistance: number;
  136289. }>;
  136290. private _isEnabled;
  136291. private _parent;
  136292. private _gizmoMesh;
  136293. private _coloredMaterial;
  136294. private _hoverMaterial;
  136295. private _disableMaterial;
  136296. private _dragging;
  136297. /** @hidden */
  136298. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  136299. /** @hidden */
  136300. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  136301. /**
  136302. * Creates an AxisDragGizmo
  136303. * @param gizmoLayer The utility layer the gizmo will be added to
  136304. * @param dragAxis The axis which the gizmo will be able to drag on
  136305. * @param color The color of the gizmo
  136306. * @param thickness display gizmo axis thickness
  136307. */
  136308. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  136309. protected _attachedNodeChanged(value: Nullable<Node>): void;
  136310. /**
  136311. * If the gizmo is enabled
  136312. */
  136313. set isEnabled(value: boolean);
  136314. get isEnabled(): boolean;
  136315. /**
  136316. * Disposes of the gizmo
  136317. */
  136318. dispose(): void;
  136319. }
  136320. }
  136321. declare module BABYLON.Debug {
  136322. /**
  136323. * The Axes viewer will show 3 axes in a specific point in space
  136324. */
  136325. export class AxesViewer {
  136326. private _xAxis;
  136327. private _yAxis;
  136328. private _zAxis;
  136329. private _scaleLinesFactor;
  136330. private _instanced;
  136331. /**
  136332. * Gets the hosting scene
  136333. */
  136334. scene: Nullable<Scene>;
  136335. /**
  136336. * Gets or sets a number used to scale line length
  136337. */
  136338. scaleLines: number;
  136339. /** Gets the node hierarchy used to render x-axis */
  136340. get xAxis(): TransformNode;
  136341. /** Gets the node hierarchy used to render y-axis */
  136342. get yAxis(): TransformNode;
  136343. /** Gets the node hierarchy used to render z-axis */
  136344. get zAxis(): TransformNode;
  136345. /**
  136346. * Creates a new AxesViewer
  136347. * @param scene defines the hosting scene
  136348. * @param scaleLines defines a number used to scale line length (1 by default)
  136349. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  136350. * @param xAxis defines the node hierarchy used to render the x-axis
  136351. * @param yAxis defines the node hierarchy used to render the y-axis
  136352. * @param zAxis defines the node hierarchy used to render the z-axis
  136353. */
  136354. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  136355. /**
  136356. * Force the viewer to update
  136357. * @param position defines the position of the viewer
  136358. * @param xaxis defines the x axis of the viewer
  136359. * @param yaxis defines the y axis of the viewer
  136360. * @param zaxis defines the z axis of the viewer
  136361. */
  136362. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  136363. /**
  136364. * Creates an instance of this axes viewer.
  136365. * @returns a new axes viewer with instanced meshes
  136366. */
  136367. createInstance(): AxesViewer;
  136368. /** Releases resources */
  136369. dispose(): void;
  136370. private static _SetRenderingGroupId;
  136371. }
  136372. }
  136373. declare module BABYLON.Debug {
  136374. /**
  136375. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  136376. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  136377. */
  136378. export class BoneAxesViewer extends AxesViewer {
  136379. /**
  136380. * Gets or sets the target mesh where to display the axes viewer
  136381. */
  136382. mesh: Nullable<Mesh>;
  136383. /**
  136384. * Gets or sets the target bone where to display the axes viewer
  136385. */
  136386. bone: Nullable<Bone>;
  136387. /** Gets current position */
  136388. pos: Vector3;
  136389. /** Gets direction of X axis */
  136390. xaxis: Vector3;
  136391. /** Gets direction of Y axis */
  136392. yaxis: Vector3;
  136393. /** Gets direction of Z axis */
  136394. zaxis: Vector3;
  136395. /**
  136396. * Creates a new BoneAxesViewer
  136397. * @param scene defines the hosting scene
  136398. * @param bone defines the target bone
  136399. * @param mesh defines the target mesh
  136400. * @param scaleLines defines a scaling factor for line length (1 by default)
  136401. */
  136402. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  136403. /**
  136404. * Force the viewer to update
  136405. */
  136406. update(): void;
  136407. /** Releases resources */
  136408. dispose(): void;
  136409. }
  136410. }
  136411. declare module BABYLON {
  136412. /**
  136413. * Interface used to define scene explorer extensibility option
  136414. */
  136415. export interface IExplorerExtensibilityOption {
  136416. /**
  136417. * Define the option label
  136418. */
  136419. label: string;
  136420. /**
  136421. * Defines the action to execute on click
  136422. */
  136423. action: (entity: any) => void;
  136424. }
  136425. /**
  136426. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  136427. */
  136428. export interface IExplorerExtensibilityGroup {
  136429. /**
  136430. * Defines a predicate to test if a given type mut be extended
  136431. */
  136432. predicate: (entity: any) => boolean;
  136433. /**
  136434. * Gets the list of options added to a type
  136435. */
  136436. entries: IExplorerExtensibilityOption[];
  136437. }
  136438. /**
  136439. * Interface used to define the options to use to create the Inspector
  136440. */
  136441. export interface IInspectorOptions {
  136442. /**
  136443. * Display in overlay mode (default: false)
  136444. */
  136445. overlay?: boolean;
  136446. /**
  136447. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  136448. */
  136449. globalRoot?: HTMLElement;
  136450. /**
  136451. * Display the Scene explorer
  136452. */
  136453. showExplorer?: boolean;
  136454. /**
  136455. * Display the property inspector
  136456. */
  136457. showInspector?: boolean;
  136458. /**
  136459. * Display in embed mode (both panes on the right)
  136460. */
  136461. embedMode?: boolean;
  136462. /**
  136463. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  136464. */
  136465. handleResize?: boolean;
  136466. /**
  136467. * Allow the panes to popup (default: true)
  136468. */
  136469. enablePopup?: boolean;
  136470. /**
  136471. * Allow the panes to be closed by users (default: true)
  136472. */
  136473. enableClose?: boolean;
  136474. /**
  136475. * Optional list of extensibility entries
  136476. */
  136477. explorerExtensibility?: IExplorerExtensibilityGroup[];
  136478. /**
  136479. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  136480. */
  136481. inspectorURL?: string;
  136482. /**
  136483. * Optional initial tab (default to DebugLayerTab.Properties)
  136484. */
  136485. initialTab?: DebugLayerTab;
  136486. }
  136487. interface Scene {
  136488. /**
  136489. * @hidden
  136490. * Backing field
  136491. */
  136492. _debugLayer: DebugLayer;
  136493. /**
  136494. * Gets the debug layer (aka Inspector) associated with the scene
  136495. * @see https://doc.babylonjs.com/features/playground_debuglayer
  136496. */
  136497. debugLayer: DebugLayer;
  136498. }
  136499. /**
  136500. * Enum of inspector action tab
  136501. */
  136502. export enum DebugLayerTab {
  136503. /**
  136504. * Properties tag (default)
  136505. */
  136506. Properties = 0,
  136507. /**
  136508. * Debug tab
  136509. */
  136510. Debug = 1,
  136511. /**
  136512. * Statistics tab
  136513. */
  136514. Statistics = 2,
  136515. /**
  136516. * Tools tab
  136517. */
  136518. Tools = 3,
  136519. /**
  136520. * Settings tab
  136521. */
  136522. Settings = 4
  136523. }
  136524. /**
  136525. * The debug layer (aka Inspector) is the go to tool in order to better understand
  136526. * what is happening in your scene
  136527. * @see https://doc.babylonjs.com/features/playground_debuglayer
  136528. */
  136529. export class DebugLayer {
  136530. /**
  136531. * Define the url to get the inspector script from.
  136532. * By default it uses the babylonjs CDN.
  136533. * @ignoreNaming
  136534. */
  136535. static InspectorURL: string;
  136536. private _scene;
  136537. private BJSINSPECTOR;
  136538. private _onPropertyChangedObservable?;
  136539. /**
  136540. * Observable triggered when a property is changed through the inspector.
  136541. */
  136542. get onPropertyChangedObservable(): any;
  136543. /**
  136544. * Instantiates a new debug layer.
  136545. * The debug layer (aka Inspector) is the go to tool in order to better understand
  136546. * what is happening in your scene
  136547. * @see https://doc.babylonjs.com/features/playground_debuglayer
  136548. * @param scene Defines the scene to inspect
  136549. */
  136550. constructor(scene: Scene);
  136551. /** Creates the inspector window. */
  136552. private _createInspector;
  136553. /**
  136554. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  136555. * @param entity defines the entity to select
  136556. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  136557. */
  136558. select(entity: any, lineContainerTitles?: string | string[]): void;
  136559. /** Get the inspector from bundle or global */
  136560. private _getGlobalInspector;
  136561. /**
  136562. * Get if the inspector is visible or not.
  136563. * @returns true if visible otherwise, false
  136564. */
  136565. isVisible(): boolean;
  136566. /**
  136567. * Hide the inspector and close its window.
  136568. */
  136569. hide(): void;
  136570. /**
  136571. * Update the scene in the inspector
  136572. */
  136573. setAsActiveScene(): void;
  136574. /**
  136575. * Launch the debugLayer.
  136576. * @param config Define the configuration of the inspector
  136577. * @return a promise fulfilled when the debug layer is visible
  136578. */
  136579. show(config?: IInspectorOptions): Promise<DebugLayer>;
  136580. }
  136581. }
  136582. declare module BABYLON.Debug {
  136583. /**
  136584. * Used to show the physics impostor around the specific mesh
  136585. */
  136586. export class PhysicsViewer {
  136587. /** @hidden */
  136588. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  136589. /** @hidden */
  136590. protected _meshes: Array<Nullable<AbstractMesh>>;
  136591. /** @hidden */
  136592. protected _scene: Nullable<Scene>;
  136593. /** @hidden */
  136594. protected _numMeshes: number;
  136595. /** @hidden */
  136596. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  136597. private _renderFunction;
  136598. private _utilityLayer;
  136599. private _debugBoxMesh;
  136600. private _debugSphereMesh;
  136601. private _debugCylinderMesh;
  136602. private _debugMaterial;
  136603. private _debugMeshMeshes;
  136604. /**
  136605. * Creates a new PhysicsViewer
  136606. * @param scene defines the hosting scene
  136607. */
  136608. constructor(scene: Scene);
  136609. /** @hidden */
  136610. protected _updateDebugMeshes(): void;
  136611. /**
  136612. * Renders a specified physic impostor
  136613. * @param impostor defines the impostor to render
  136614. * @param targetMesh defines the mesh represented by the impostor
  136615. * @returns the new debug mesh used to render the impostor
  136616. */
  136617. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  136618. /**
  136619. * Hides a specified physic impostor
  136620. * @param impostor defines the impostor to hide
  136621. */
  136622. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  136623. private _getDebugMaterial;
  136624. private _getDebugBoxMesh;
  136625. private _getDebugSphereMesh;
  136626. private _getDebugCylinderMesh;
  136627. private _getDebugMeshMesh;
  136628. private _getDebugMesh;
  136629. /** Releases all resources */
  136630. dispose(): void;
  136631. }
  136632. }
  136633. declare module BABYLON {
  136634. /**
  136635. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  136636. * in order to better appreciate the issue one might have.
  136637. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  136638. */
  136639. export class RayHelper {
  136640. /**
  136641. * Defines the ray we are currently tryin to visualize.
  136642. */
  136643. ray: Nullable<Ray>;
  136644. private _renderPoints;
  136645. private _renderLine;
  136646. private _renderFunction;
  136647. private _scene;
  136648. private _onAfterRenderObserver;
  136649. private _onAfterStepObserver;
  136650. private _attachedToMesh;
  136651. private _meshSpaceDirection;
  136652. private _meshSpaceOrigin;
  136653. /**
  136654. * Helper function to create a colored helper in a scene in one line.
  136655. * @param ray Defines the ray we are currently tryin to visualize
  136656. * @param scene Defines the scene the ray is used in
  136657. * @param color Defines the color we want to see the ray in
  136658. * @returns The newly created ray helper.
  136659. */
  136660. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  136661. /**
  136662. * Instantiate a new ray helper.
  136663. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  136664. * in order to better appreciate the issue one might have.
  136665. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  136666. * @param ray Defines the ray we are currently tryin to visualize
  136667. */
  136668. constructor(ray: Ray);
  136669. /**
  136670. * Shows the ray we are willing to debug.
  136671. * @param scene Defines the scene the ray needs to be rendered in
  136672. * @param color Defines the color the ray needs to be rendered in
  136673. */
  136674. show(scene: Scene, color?: Color3): void;
  136675. /**
  136676. * Hides the ray we are debugging.
  136677. */
  136678. hide(): void;
  136679. private _render;
  136680. /**
  136681. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  136682. * @param mesh Defines the mesh we want the helper attached to
  136683. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  136684. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  136685. * @param length Defines the length of the ray
  136686. */
  136687. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  136688. /**
  136689. * Detach the ray helper from the mesh it has previously been attached to.
  136690. */
  136691. detachFromMesh(): void;
  136692. private _updateToMesh;
  136693. /**
  136694. * Dispose the helper and release its associated resources.
  136695. */
  136696. dispose(): void;
  136697. }
  136698. }
  136699. declare module BABYLON {
  136700. /**
  136701. * Defines the options associated with the creation of a SkeletonViewer.
  136702. */
  136703. export interface ISkeletonViewerOptions {
  136704. /** Should the system pause animations before building the Viewer? */
  136705. pauseAnimations: boolean;
  136706. /** Should the system return the skeleton to rest before building? */
  136707. returnToRest: boolean;
  136708. /** public Display Mode of the Viewer */
  136709. displayMode: number;
  136710. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  136711. displayOptions: ISkeletonViewerDisplayOptions;
  136712. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  136713. computeBonesUsingShaders: boolean;
  136714. /** Flag ignore non weighted bones */
  136715. useAllBones: boolean;
  136716. }
  136717. /**
  136718. * Defines how to display the various bone meshes for the viewer.
  136719. */
  136720. export interface ISkeletonViewerDisplayOptions {
  136721. /** How far down to start tapering the bone spurs */
  136722. midStep?: number;
  136723. /** How big is the midStep? */
  136724. midStepFactor?: number;
  136725. /** Base for the Sphere Size */
  136726. sphereBaseSize?: number;
  136727. /** The ratio of the sphere to the longest bone in units */
  136728. sphereScaleUnit?: number;
  136729. /** Ratio for the Sphere Size */
  136730. sphereFactor?: number;
  136731. /** Whether a spur should attach its far end to the child bone position */
  136732. spurFollowsChild?: boolean;
  136733. /** Whether to show local axes or not */
  136734. showLocalAxes?: boolean;
  136735. /** Length of each local axis */
  136736. localAxesSize?: number;
  136737. }
  136738. /**
  136739. * Defines the constructor options for the BoneWeight Shader.
  136740. */
  136741. export interface IBoneWeightShaderOptions {
  136742. /** Skeleton to Map */
  136743. skeleton: Skeleton;
  136744. /** Colors for Uninfluenced bones */
  136745. colorBase?: Color3;
  136746. /** Colors for 0.0-0.25 Weight bones */
  136747. colorZero?: Color3;
  136748. /** Color for 0.25-0.5 Weight Influence */
  136749. colorQuarter?: Color3;
  136750. /** Color for 0.5-0.75 Weight Influence */
  136751. colorHalf?: Color3;
  136752. /** Color for 0.75-1 Weight Influence */
  136753. colorFull?: Color3;
  136754. /** Color for Zero Weight Influence */
  136755. targetBoneIndex?: number;
  136756. }
  136757. /**
  136758. * Simple structure of the gradient steps for the Color Map.
  136759. */
  136760. export interface ISkeletonMapShaderColorMapKnot {
  136761. /** Color of the Knot */
  136762. color: Color3;
  136763. /** Location of the Knot */
  136764. location: number;
  136765. }
  136766. /**
  136767. * Defines the constructor options for the SkeletonMap Shader.
  136768. */
  136769. export interface ISkeletonMapShaderOptions {
  136770. /** Skeleton to Map */
  136771. skeleton: Skeleton;
  136772. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  136773. colorMap?: ISkeletonMapShaderColorMapKnot[];
  136774. }
  136775. }
  136776. declare module BABYLON {
  136777. /**
  136778. * Class containing static functions to help procedurally build meshes
  136779. */
  136780. export class RibbonBuilder {
  136781. /**
  136782. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  136783. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  136784. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  136785. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  136786. * * 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
  136787. * * 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
  136788. * * 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
  136789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136790. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136791. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136792. * * 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
  136793. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  136794. * * 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
  136795. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  136796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136797. * @param name defines the name of the mesh
  136798. * @param options defines the options used to create the mesh
  136799. * @param scene defines the hosting scene
  136800. * @returns the ribbon mesh
  136801. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  136802. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136803. */
  136804. static CreateRibbon(name: string, options: {
  136805. pathArray: Vector3[][];
  136806. closeArray?: boolean;
  136807. closePath?: boolean;
  136808. offset?: number;
  136809. updatable?: boolean;
  136810. sideOrientation?: number;
  136811. frontUVs?: Vector4;
  136812. backUVs?: Vector4;
  136813. instance?: Mesh;
  136814. invertUV?: boolean;
  136815. uvs?: Vector2[];
  136816. colors?: Color4[];
  136817. }, scene?: Nullable<Scene>): Mesh;
  136818. }
  136819. }
  136820. declare module BABYLON {
  136821. /**
  136822. * Class containing static functions to help procedurally build meshes
  136823. */
  136824. export class ShapeBuilder {
  136825. /**
  136826. * 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.
  136827. * * 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.
  136828. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136829. * * 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.
  136830. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  136831. * * 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
  136832. * * 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
  136833. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  136834. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136835. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136836. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  136837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136838. * @param name defines the name of the mesh
  136839. * @param options defines the options used to create the mesh
  136840. * @param scene defines the hosting scene
  136841. * @returns the extruded shape mesh
  136842. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136843. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136844. */
  136845. static ExtrudeShape(name: string, options: {
  136846. shape: Vector3[];
  136847. path: Vector3[];
  136848. scale?: number;
  136849. rotation?: number;
  136850. cap?: number;
  136851. updatable?: boolean;
  136852. sideOrientation?: number;
  136853. frontUVs?: Vector4;
  136854. backUVs?: Vector4;
  136855. instance?: Mesh;
  136856. invertUV?: boolean;
  136857. }, scene?: Nullable<Scene>): Mesh;
  136858. /**
  136859. * Creates an custom extruded shape mesh.
  136860. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  136861. * * 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.
  136862. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136863. * * 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
  136864. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  136865. * * 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
  136866. * * It must returns a float value that will be the scale value applied to the shape on each path point
  136867. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  136868. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  136869. * * 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
  136870. * * 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
  136871. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  136872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136873. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136874. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136876. * @param name defines the name of the mesh
  136877. * @param options defines the options used to create the mesh
  136878. * @param scene defines the hosting scene
  136879. * @returns the custom extruded shape mesh
  136880. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  136881. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136882. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136883. */
  136884. static ExtrudeShapeCustom(name: string, options: {
  136885. shape: Vector3[];
  136886. path: Vector3[];
  136887. scaleFunction?: any;
  136888. rotationFunction?: any;
  136889. ribbonCloseArray?: boolean;
  136890. ribbonClosePath?: boolean;
  136891. cap?: number;
  136892. updatable?: boolean;
  136893. sideOrientation?: number;
  136894. frontUVs?: Vector4;
  136895. backUVs?: Vector4;
  136896. instance?: Mesh;
  136897. invertUV?: boolean;
  136898. }, scene?: Nullable<Scene>): Mesh;
  136899. private static _ExtrudeShapeGeneric;
  136900. }
  136901. }
  136902. declare module BABYLON.Debug {
  136903. /**
  136904. * Class used to render a debug view of a given skeleton
  136905. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  136906. */
  136907. export class SkeletonViewer {
  136908. /** defines the skeleton to render */
  136909. skeleton: Skeleton;
  136910. /** defines the mesh attached to the skeleton */
  136911. mesh: AbstractMesh;
  136912. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  136913. autoUpdateBonesMatrices: boolean;
  136914. /** defines the rendering group id to use with the viewer */
  136915. renderingGroupId: number;
  136916. /** is the options for the viewer */
  136917. options: Partial<ISkeletonViewerOptions>;
  136918. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  136919. static readonly DISPLAY_LINES: number;
  136920. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  136921. static readonly DISPLAY_SPHERES: number;
  136922. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  136923. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  136924. /** public static method to create a BoneWeight Shader
  136925. * @param options The constructor options
  136926. * @param scene The scene that the shader is scoped to
  136927. * @returns The created ShaderMaterial
  136928. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  136929. */
  136930. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  136931. /** public static method to create a BoneWeight Shader
  136932. * @param options The constructor options
  136933. * @param scene The scene that the shader is scoped to
  136934. * @returns The created ShaderMaterial
  136935. */
  136936. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  136937. /** private static method to create a BoneWeight Shader
  136938. * @param size The size of the buffer to create (usually the bone count)
  136939. * @param colorMap The gradient data to generate
  136940. * @param scene The scene that the shader is scoped to
  136941. * @returns an Array of floats from the color gradient values
  136942. */
  136943. private static _CreateBoneMapColorBuffer;
  136944. /** If SkeletonViewer scene scope. */
  136945. private _scene;
  136946. /** Gets or sets the color used to render the skeleton */
  136947. color: Color3;
  136948. /** Array of the points of the skeleton fo the line view. */
  136949. private _debugLines;
  136950. /** The SkeletonViewers Mesh. */
  136951. private _debugMesh;
  136952. /** The local axes Meshes. */
  136953. private _localAxes;
  136954. /** If SkeletonViewer is enabled. */
  136955. private _isEnabled;
  136956. /** If SkeletonViewer is ready. */
  136957. private _ready;
  136958. /** SkeletonViewer render observable. */
  136959. private _obs;
  136960. /** The Utility Layer to render the gizmos in. */
  136961. private _utilityLayer;
  136962. private _boneIndices;
  136963. /** Gets the Scene. */
  136964. get scene(): Scene;
  136965. /** Gets the utilityLayer. */
  136966. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  136967. /** Checks Ready Status. */
  136968. get isReady(): Boolean;
  136969. /** Sets Ready Status. */
  136970. set ready(value: boolean);
  136971. /** Gets the debugMesh */
  136972. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  136973. /** Sets the debugMesh */
  136974. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  136975. /** Gets the displayMode */
  136976. get displayMode(): number;
  136977. /** Sets the displayMode */
  136978. set displayMode(value: number);
  136979. /**
  136980. * Creates a new SkeletonViewer
  136981. * @param skeleton defines the skeleton to render
  136982. * @param mesh defines the mesh attached to the skeleton
  136983. * @param scene defines the hosting scene
  136984. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  136985. * @param renderingGroupId defines the rendering group id to use with the viewer
  136986. * @param options All of the extra constructor options for the SkeletonViewer
  136987. */
  136988. constructor(
  136989. /** defines the skeleton to render */
  136990. skeleton: Skeleton,
  136991. /** defines the mesh attached to the skeleton */
  136992. mesh: AbstractMesh,
  136993. /** The Scene scope*/
  136994. scene: Scene,
  136995. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  136996. autoUpdateBonesMatrices?: boolean,
  136997. /** defines the rendering group id to use with the viewer */
  136998. renderingGroupId?: number,
  136999. /** is the options for the viewer */
  137000. options?: Partial<ISkeletonViewerOptions>);
  137001. /** The Dynamic bindings for the update functions */
  137002. private _bindObs;
  137003. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  137004. update(): void;
  137005. /** Gets or sets a boolean indicating if the viewer is enabled */
  137006. set isEnabled(value: boolean);
  137007. get isEnabled(): boolean;
  137008. private _getBonePosition;
  137009. private _getLinesForBonesWithLength;
  137010. private _getLinesForBonesNoLength;
  137011. /** function to revert the mesh and scene back to the initial state. */
  137012. private _revert;
  137013. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  137014. private _getAbsoluteBindPoseToRef;
  137015. /** function to build and bind sphere joint points and spur bone representations. */
  137016. private _buildSpheresAndSpurs;
  137017. private _buildLocalAxes;
  137018. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  137019. private _displayLinesUpdate;
  137020. /** Changes the displayMode of the skeleton viewer
  137021. * @param mode The displayMode numerical value
  137022. */
  137023. changeDisplayMode(mode: number): void;
  137024. /** Sets a display option of the skeleton viewer
  137025. *
  137026. * | Option | Type | Default | Description |
  137027. * | ---------------- | ------- | ------- | ----------- |
  137028. * | 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`. |
  137029. * | 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`. |
  137030. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  137031. * | 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`. |
  137032. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  137033. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  137034. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  137035. *
  137036. * @param option String of the option name
  137037. * @param value The numerical option value
  137038. */
  137039. changeDisplayOptions(option: string, value: number): void;
  137040. /** Release associated resources */
  137041. dispose(): void;
  137042. }
  137043. }
  137044. declare module BABYLON {
  137045. /**
  137046. * Enum for Device Types
  137047. */
  137048. export enum DeviceType {
  137049. /** Generic */
  137050. Generic = 0,
  137051. /** Keyboard */
  137052. Keyboard = 1,
  137053. /** Mouse */
  137054. Mouse = 2,
  137055. /** Touch Pointers */
  137056. Touch = 3,
  137057. /** PS4 Dual Shock */
  137058. DualShock = 4,
  137059. /** Xbox */
  137060. Xbox = 5,
  137061. /** Switch Controller */
  137062. Switch = 6
  137063. }
  137064. /**
  137065. * Enum for All Pointers (Touch/Mouse)
  137066. */
  137067. export enum PointerInput {
  137068. /** Horizontal Axis */
  137069. Horizontal = 0,
  137070. /** Vertical Axis */
  137071. Vertical = 1,
  137072. /** Left Click or Touch */
  137073. LeftClick = 2,
  137074. /** Middle Click */
  137075. MiddleClick = 3,
  137076. /** Right Click */
  137077. RightClick = 4,
  137078. /** Browser Back */
  137079. BrowserBack = 5,
  137080. /** Browser Forward */
  137081. BrowserForward = 6
  137082. }
  137083. /**
  137084. * Enum for Dual Shock Gamepad
  137085. */
  137086. export enum DualShockInput {
  137087. /** Cross */
  137088. Cross = 0,
  137089. /** Circle */
  137090. Circle = 1,
  137091. /** Square */
  137092. Square = 2,
  137093. /** Triangle */
  137094. Triangle = 3,
  137095. /** L1 */
  137096. L1 = 4,
  137097. /** R1 */
  137098. R1 = 5,
  137099. /** L2 */
  137100. L2 = 6,
  137101. /** R2 */
  137102. R2 = 7,
  137103. /** Share */
  137104. Share = 8,
  137105. /** Options */
  137106. Options = 9,
  137107. /** L3 */
  137108. L3 = 10,
  137109. /** R3 */
  137110. R3 = 11,
  137111. /** DPadUp */
  137112. DPadUp = 12,
  137113. /** DPadDown */
  137114. DPadDown = 13,
  137115. /** DPadLeft */
  137116. DPadLeft = 14,
  137117. /** DRight */
  137118. DPadRight = 15,
  137119. /** Home */
  137120. Home = 16,
  137121. /** TouchPad */
  137122. TouchPad = 17,
  137123. /** LStickXAxis */
  137124. LStickXAxis = 18,
  137125. /** LStickYAxis */
  137126. LStickYAxis = 19,
  137127. /** RStickXAxis */
  137128. RStickXAxis = 20,
  137129. /** RStickYAxis */
  137130. RStickYAxis = 21
  137131. }
  137132. /**
  137133. * Enum for Xbox Gamepad
  137134. */
  137135. export enum XboxInput {
  137136. /** A */
  137137. A = 0,
  137138. /** B */
  137139. B = 1,
  137140. /** X */
  137141. X = 2,
  137142. /** Y */
  137143. Y = 3,
  137144. /** LB */
  137145. LB = 4,
  137146. /** RB */
  137147. RB = 5,
  137148. /** LT */
  137149. LT = 6,
  137150. /** RT */
  137151. RT = 7,
  137152. /** Back */
  137153. Back = 8,
  137154. /** Start */
  137155. Start = 9,
  137156. /** LS */
  137157. LS = 10,
  137158. /** RS */
  137159. RS = 11,
  137160. /** DPadUp */
  137161. DPadUp = 12,
  137162. /** DPadDown */
  137163. DPadDown = 13,
  137164. /** DPadLeft */
  137165. DPadLeft = 14,
  137166. /** DRight */
  137167. DPadRight = 15,
  137168. /** Home */
  137169. Home = 16,
  137170. /** LStickXAxis */
  137171. LStickXAxis = 17,
  137172. /** LStickYAxis */
  137173. LStickYAxis = 18,
  137174. /** RStickXAxis */
  137175. RStickXAxis = 19,
  137176. /** RStickYAxis */
  137177. RStickYAxis = 20
  137178. }
  137179. /**
  137180. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  137181. */
  137182. export enum SwitchInput {
  137183. /** B */
  137184. B = 0,
  137185. /** A */
  137186. A = 1,
  137187. /** Y */
  137188. Y = 2,
  137189. /** X */
  137190. X = 3,
  137191. /** L */
  137192. L = 4,
  137193. /** R */
  137194. R = 5,
  137195. /** ZL */
  137196. ZL = 6,
  137197. /** ZR */
  137198. ZR = 7,
  137199. /** Minus */
  137200. Minus = 8,
  137201. /** Plus */
  137202. Plus = 9,
  137203. /** LS */
  137204. LS = 10,
  137205. /** RS */
  137206. RS = 11,
  137207. /** DPadUp */
  137208. DPadUp = 12,
  137209. /** DPadDown */
  137210. DPadDown = 13,
  137211. /** DPadLeft */
  137212. DPadLeft = 14,
  137213. /** DRight */
  137214. DPadRight = 15,
  137215. /** Home */
  137216. Home = 16,
  137217. /** Capture */
  137218. Capture = 17,
  137219. /** LStickXAxis */
  137220. LStickXAxis = 18,
  137221. /** LStickYAxis */
  137222. LStickYAxis = 19,
  137223. /** RStickXAxis */
  137224. RStickXAxis = 20,
  137225. /** RStickYAxis */
  137226. RStickYAxis = 21
  137227. }
  137228. }
  137229. declare module BABYLON {
  137230. /**
  137231. * This class will take all inputs from Keyboard, Pointer, and
  137232. * any Gamepads and provide a polling system that all devices
  137233. * will use. This class assumes that there will only be one
  137234. * pointer device and one keyboard.
  137235. */
  137236. export class DeviceInputSystem implements IDisposable {
  137237. /**
  137238. * Returns onDeviceConnected callback property
  137239. * @returns Callback with function to execute when a device is connected
  137240. */
  137241. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  137242. /**
  137243. * Sets callback function when a device is connected and executes against all connected devices
  137244. * @param callback Function to execute when a device is connected
  137245. */
  137246. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  137247. /**
  137248. * Callback to be triggered when a device is disconnected
  137249. */
  137250. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  137251. /**
  137252. * Callback to be triggered when event driven input is updated
  137253. */
  137254. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  137255. private _inputs;
  137256. private _gamepads;
  137257. private _keyboardActive;
  137258. private _pointerActive;
  137259. private _elementToAttachTo;
  137260. private _keyboardDownEvent;
  137261. private _keyboardUpEvent;
  137262. private _pointerMoveEvent;
  137263. private _pointerDownEvent;
  137264. private _pointerUpEvent;
  137265. private _gamepadConnectedEvent;
  137266. private _gamepadDisconnectedEvent;
  137267. private _onDeviceConnected;
  137268. private static _MAX_KEYCODES;
  137269. private static _MAX_POINTER_INPUTS;
  137270. private constructor();
  137271. /**
  137272. * Creates a new DeviceInputSystem instance
  137273. * @param engine Engine to pull input element from
  137274. * @returns The new instance
  137275. */
  137276. static Create(engine: Engine): DeviceInputSystem;
  137277. /**
  137278. * Checks for current device input value, given an id and input index
  137279. * @param deviceName Id of connected device
  137280. * @param inputIndex Index of device input
  137281. * @returns Current value of input
  137282. */
  137283. /**
  137284. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  137285. * @param deviceType Enum specifiying device type
  137286. * @param deviceSlot "Slot" or index that device is referenced in
  137287. * @param inputIndex Id of input to be checked
  137288. * @returns Current value of input
  137289. */
  137290. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  137291. /**
  137292. * Dispose of all the eventlisteners
  137293. */
  137294. dispose(): void;
  137295. /**
  137296. * Checks for existing connections to devices and register them, if necessary
  137297. * Currently handles gamepads and mouse
  137298. */
  137299. private _checkForConnectedDevices;
  137300. /**
  137301. * Add a gamepad to the DeviceInputSystem
  137302. * @param gamepad A single DOM Gamepad object
  137303. */
  137304. private _addGamePad;
  137305. /**
  137306. * Add pointer device to DeviceInputSystem
  137307. * @param deviceType Type of Pointer to add
  137308. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  137309. * @param currentX Current X at point of adding
  137310. * @param currentY Current Y at point of adding
  137311. */
  137312. private _addPointerDevice;
  137313. /**
  137314. * Add device and inputs to device array
  137315. * @param deviceType Enum specifiying device type
  137316. * @param deviceSlot "Slot" or index that device is referenced in
  137317. * @param numberOfInputs Number of input entries to create for given device
  137318. */
  137319. private _registerDevice;
  137320. /**
  137321. * Given a specific device name, remove that device from the device map
  137322. * @param deviceType Enum specifiying device type
  137323. * @param deviceSlot "Slot" or index that device is referenced in
  137324. */
  137325. private _unregisterDevice;
  137326. /**
  137327. * Handle all actions that come from keyboard interaction
  137328. */
  137329. private _handleKeyActions;
  137330. /**
  137331. * Handle all actions that come from pointer interaction
  137332. */
  137333. private _handlePointerActions;
  137334. /**
  137335. * Handle all actions that come from gamepad interaction
  137336. */
  137337. private _handleGamepadActions;
  137338. /**
  137339. * Update all non-event based devices with each frame
  137340. * @param deviceType Enum specifiying device type
  137341. * @param deviceSlot "Slot" or index that device is referenced in
  137342. * @param inputIndex Id of input to be checked
  137343. */
  137344. private _updateDevice;
  137345. /**
  137346. * Gets DeviceType from the device name
  137347. * @param deviceName Name of Device from DeviceInputSystem
  137348. * @returns DeviceType enum value
  137349. */
  137350. private _getGamepadDeviceType;
  137351. }
  137352. }
  137353. declare module BABYLON {
  137354. /**
  137355. * Type to handle enforcement of inputs
  137356. */
  137357. 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;
  137358. }
  137359. declare module BABYLON {
  137360. /**
  137361. * Class that handles all input for a specific device
  137362. */
  137363. export class DeviceSource<T extends DeviceType> {
  137364. /** Type of device */
  137365. readonly deviceType: DeviceType;
  137366. /** "Slot" or index that device is referenced in */
  137367. readonly deviceSlot: number;
  137368. /**
  137369. * Observable to handle device input changes per device
  137370. */
  137371. readonly onInputChangedObservable: Observable<{
  137372. inputIndex: DeviceInput<T>;
  137373. previousState: Nullable<number>;
  137374. currentState: Nullable<number>;
  137375. }>;
  137376. private readonly _deviceInputSystem;
  137377. /**
  137378. * Default Constructor
  137379. * @param deviceInputSystem Reference to DeviceInputSystem
  137380. * @param deviceType Type of device
  137381. * @param deviceSlot "Slot" or index that device is referenced in
  137382. */
  137383. constructor(deviceInputSystem: DeviceInputSystem,
  137384. /** Type of device */
  137385. deviceType: DeviceType,
  137386. /** "Slot" or index that device is referenced in */
  137387. deviceSlot?: number);
  137388. /**
  137389. * Get input for specific input
  137390. * @param inputIndex index of specific input on device
  137391. * @returns Input value from DeviceInputSystem
  137392. */
  137393. getInput(inputIndex: DeviceInput<T>): number;
  137394. }
  137395. /**
  137396. * Class to keep track of devices
  137397. */
  137398. export class DeviceSourceManager implements IDisposable {
  137399. /**
  137400. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  137401. */
  137402. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  137403. /**
  137404. * Observable to be triggered when after a device is disconnected
  137405. */
  137406. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  137407. private readonly _devices;
  137408. private readonly _firstDevice;
  137409. private readonly _deviceInputSystem;
  137410. /**
  137411. * Default Constructor
  137412. * @param engine engine to pull input element from
  137413. */
  137414. constructor(engine: Engine);
  137415. /**
  137416. * Gets a DeviceSource, given a type and slot
  137417. * @param deviceType Enum specifying device type
  137418. * @param deviceSlot "Slot" or index that device is referenced in
  137419. * @returns DeviceSource object
  137420. */
  137421. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  137422. /**
  137423. * Gets an array of DeviceSource objects for a given device type
  137424. * @param deviceType Enum specifying device type
  137425. * @returns Array of DeviceSource objects
  137426. */
  137427. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  137428. /**
  137429. * Returns a read-only list of all available devices
  137430. * @returns Read-only array with active devices
  137431. */
  137432. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  137433. /**
  137434. * Dispose of DeviceInputSystem and other parts
  137435. */
  137436. dispose(): void;
  137437. /**
  137438. * Function to add device name to device list
  137439. * @param deviceType Enum specifying device type
  137440. * @param deviceSlot "Slot" or index that device is referenced in
  137441. */
  137442. private _addDevice;
  137443. /**
  137444. * Function to remove device name to device list
  137445. * @param deviceType Enum specifying device type
  137446. * @param deviceSlot "Slot" or index that device is referenced in
  137447. */
  137448. private _removeDevice;
  137449. /**
  137450. * Updates array storing first connected device of each type
  137451. * @param type Type of Device
  137452. */
  137453. private _updateFirstDevices;
  137454. }
  137455. }
  137456. declare module BABYLON {
  137457. /**
  137458. * Options to create the null engine
  137459. */
  137460. export class NullEngineOptions {
  137461. /**
  137462. * Render width (Default: 512)
  137463. */
  137464. renderWidth: number;
  137465. /**
  137466. * Render height (Default: 256)
  137467. */
  137468. renderHeight: number;
  137469. /**
  137470. * Texture size (Default: 512)
  137471. */
  137472. textureSize: number;
  137473. /**
  137474. * If delta time between frames should be constant
  137475. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137476. */
  137477. deterministicLockstep: boolean;
  137478. /**
  137479. * Maximum about of steps between frames (Default: 4)
  137480. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137481. */
  137482. lockstepMaxSteps: number;
  137483. /**
  137484. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  137485. */
  137486. useHighPrecisionMatrix?: boolean;
  137487. }
  137488. /**
  137489. * The null engine class provides support for headless version of babylon.js.
  137490. * This can be used in server side scenario or for testing purposes
  137491. */
  137492. export class NullEngine extends Engine {
  137493. private _options;
  137494. /**
  137495. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  137496. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137497. * @returns true if engine is in deterministic lock step mode
  137498. */
  137499. isDeterministicLockStep(): boolean;
  137500. /**
  137501. * Gets the max steps when engine is running in deterministic lock step
  137502. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137503. * @returns the max steps
  137504. */
  137505. getLockstepMaxSteps(): number;
  137506. /**
  137507. * Gets the current hardware scaling level.
  137508. * By default the hardware scaling level is computed from the window device ratio.
  137509. * 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.
  137510. * @returns a number indicating the current hardware scaling level
  137511. */
  137512. getHardwareScalingLevel(): number;
  137513. constructor(options?: NullEngineOptions);
  137514. /**
  137515. * Creates a vertex buffer
  137516. * @param vertices the data for the vertex buffer
  137517. * @returns the new WebGL static buffer
  137518. */
  137519. createVertexBuffer(vertices: FloatArray): DataBuffer;
  137520. /**
  137521. * Creates a new index buffer
  137522. * @param indices defines the content of the index buffer
  137523. * @param updatable defines if the index buffer must be updatable
  137524. * @returns a new webGL buffer
  137525. */
  137526. createIndexBuffer(indices: IndicesArray): DataBuffer;
  137527. /**
  137528. * Clear the current render buffer or the current render target (if any is set up)
  137529. * @param color defines the color to use
  137530. * @param backBuffer defines if the back buffer must be cleared
  137531. * @param depth defines if the depth buffer must be cleared
  137532. * @param stencil defines if the stencil buffer must be cleared
  137533. */
  137534. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  137535. /**
  137536. * Gets the current render width
  137537. * @param useScreen defines if screen size must be used (or the current render target if any)
  137538. * @returns a number defining the current render width
  137539. */
  137540. getRenderWidth(useScreen?: boolean): number;
  137541. /**
  137542. * Gets the current render height
  137543. * @param useScreen defines if screen size must be used (or the current render target if any)
  137544. * @returns a number defining the current render height
  137545. */
  137546. getRenderHeight(useScreen?: boolean): number;
  137547. /**
  137548. * Set the WebGL's viewport
  137549. * @param viewport defines the viewport element to be used
  137550. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  137551. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  137552. */
  137553. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  137554. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  137555. /**
  137556. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  137557. * @param pipelineContext defines the pipeline context to use
  137558. * @param uniformsNames defines the list of uniform names
  137559. * @returns an array of webGL uniform locations
  137560. */
  137561. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  137562. /**
  137563. * Gets the lsit of active attributes for a given webGL program
  137564. * @param pipelineContext defines the pipeline context to use
  137565. * @param attributesNames defines the list of attribute names to get
  137566. * @returns an array of indices indicating the offset of each attribute
  137567. */
  137568. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  137569. /**
  137570. * Binds an effect to the webGL context
  137571. * @param effect defines the effect to bind
  137572. */
  137573. bindSamplers(effect: Effect): void;
  137574. /**
  137575. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  137576. * @param effect defines the effect to activate
  137577. */
  137578. enableEffect(effect: Effect): void;
  137579. /**
  137580. * Set various states to the webGL context
  137581. * @param culling defines backface culling state
  137582. * @param zOffset defines the value to apply to zOffset (0 by default)
  137583. * @param force defines if states must be applied even if cache is up to date
  137584. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  137585. */
  137586. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  137587. /**
  137588. * Set the value of an uniform to an array of int32
  137589. * @param uniform defines the webGL uniform location where to store the value
  137590. * @param array defines the array of int32 to store
  137591. * @returns true if value was set
  137592. */
  137593. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137594. /**
  137595. * Set the value of an uniform to an array of int32 (stored as vec2)
  137596. * @param uniform defines the webGL uniform location where to store the value
  137597. * @param array defines the array of int32 to store
  137598. * @returns true if value was set
  137599. */
  137600. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137601. /**
  137602. * Set the value of an uniform to an array of int32 (stored as vec3)
  137603. * @param uniform defines the webGL uniform location where to store the value
  137604. * @param array defines the array of int32 to store
  137605. * @returns true if value was set
  137606. */
  137607. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137608. /**
  137609. * Set the value of an uniform to an array of int32 (stored as vec4)
  137610. * @param uniform defines the webGL uniform location where to store the value
  137611. * @param array defines the array of int32 to store
  137612. * @returns true if value was set
  137613. */
  137614. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137615. /**
  137616. * Set the value of an uniform to an array of float32
  137617. * @param uniform defines the webGL uniform location where to store the value
  137618. * @param array defines the array of float32 to store
  137619. * @returns true if value was set
  137620. */
  137621. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137622. /**
  137623. * Set the value of an uniform to an array of float32 (stored as vec2)
  137624. * @param uniform defines the webGL uniform location where to store the value
  137625. * @param array defines the array of float32 to store
  137626. * @returns true if value was set
  137627. */
  137628. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137629. /**
  137630. * Set the value of an uniform to an array of float32 (stored as vec3)
  137631. * @param uniform defines the webGL uniform location where to store the value
  137632. * @param array defines the array of float32 to store
  137633. * @returns true if value was set
  137634. */
  137635. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137636. /**
  137637. * Set the value of an uniform to an array of float32 (stored as vec4)
  137638. * @param uniform defines the webGL uniform location where to store the value
  137639. * @param array defines the array of float32 to store
  137640. * @returns true if value was set
  137641. */
  137642. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137643. /**
  137644. * Set the value of an uniform to an array of number
  137645. * @param uniform defines the webGL uniform location where to store the value
  137646. * @param array defines the array of number to store
  137647. * @returns true if value was set
  137648. */
  137649. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  137650. /**
  137651. * Set the value of an uniform to an array of number (stored as vec2)
  137652. * @param uniform defines the webGL uniform location where to store the value
  137653. * @param array defines the array of number to store
  137654. * @returns true if value was set
  137655. */
  137656. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  137657. /**
  137658. * Set the value of an uniform to an array of number (stored as vec3)
  137659. * @param uniform defines the webGL uniform location where to store the value
  137660. * @param array defines the array of number to store
  137661. * @returns true if value was set
  137662. */
  137663. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  137664. /**
  137665. * Set the value of an uniform to an array of number (stored as vec4)
  137666. * @param uniform defines the webGL uniform location where to store the value
  137667. * @param array defines the array of number to store
  137668. * @returns true if value was set
  137669. */
  137670. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  137671. /**
  137672. * Set the value of an uniform to an array of float32 (stored as matrices)
  137673. * @param uniform defines the webGL uniform location where to store the value
  137674. * @param matrices defines the array of float32 to store
  137675. * @returns true if value was set
  137676. */
  137677. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  137678. /**
  137679. * Set the value of an uniform to a matrix (3x3)
  137680. * @param uniform defines the webGL uniform location where to store the value
  137681. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  137682. * @returns true if value was set
  137683. */
  137684. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  137685. /**
  137686. * Set the value of an uniform to a matrix (2x2)
  137687. * @param uniform defines the webGL uniform location where to store the value
  137688. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  137689. * @returns true if value was set
  137690. */
  137691. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  137692. /**
  137693. * Set the value of an uniform to a number (float)
  137694. * @param uniform defines the webGL uniform location where to store the value
  137695. * @param value defines the float number to store
  137696. * @returns true if value was set
  137697. */
  137698. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  137699. /**
  137700. * Set the value of an uniform to a vec2
  137701. * @param uniform defines the webGL uniform location where to store the value
  137702. * @param x defines the 1st component of the value
  137703. * @param y defines the 2nd component of the value
  137704. * @returns true if value was set
  137705. */
  137706. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  137707. /**
  137708. * Set the value of an uniform to a vec3
  137709. * @param uniform defines the webGL uniform location where to store the value
  137710. * @param x defines the 1st component of the value
  137711. * @param y defines the 2nd component of the value
  137712. * @param z defines the 3rd component of the value
  137713. * @returns true if value was set
  137714. */
  137715. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  137716. /**
  137717. * Set the value of an uniform to a boolean
  137718. * @param uniform defines the webGL uniform location where to store the value
  137719. * @param bool defines the boolean to store
  137720. * @returns true if value was set
  137721. */
  137722. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  137723. /**
  137724. * Set the value of an uniform to a vec4
  137725. * @param uniform defines the webGL uniform location where to store the value
  137726. * @param x defines the 1st component of the value
  137727. * @param y defines the 2nd component of the value
  137728. * @param z defines the 3rd component of the value
  137729. * @param w defines the 4th component of the value
  137730. * @returns true if value was set
  137731. */
  137732. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  137733. /**
  137734. * Sets the current alpha mode
  137735. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  137736. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  137737. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  137738. */
  137739. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  137740. /**
  137741. * Bind webGl buffers directly to the webGL context
  137742. * @param vertexBuffers defines the vertex buffer to bind
  137743. * @param indexBuffer defines the index buffer to bind
  137744. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  137745. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  137746. * @param effect defines the effect associated with the vertex buffer
  137747. */
  137748. bindBuffers(vertexBuffers: {
  137749. [key: string]: VertexBuffer;
  137750. }, indexBuffer: DataBuffer, effect: Effect): void;
  137751. /**
  137752. * Force the entire cache to be cleared
  137753. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  137754. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  137755. */
  137756. wipeCaches(bruteForce?: boolean): void;
  137757. /**
  137758. * Send a draw order
  137759. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  137760. * @param indexStart defines the starting index
  137761. * @param indexCount defines the number of index to draw
  137762. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  137763. */
  137764. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  137765. /**
  137766. * Draw a list of indexed primitives
  137767. * @param fillMode defines the primitive to use
  137768. * @param indexStart defines the starting index
  137769. * @param indexCount defines the number of index to draw
  137770. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  137771. */
  137772. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  137773. /**
  137774. * Draw a list of unindexed primitives
  137775. * @param fillMode defines the primitive to use
  137776. * @param verticesStart defines the index of first vertex to draw
  137777. * @param verticesCount defines the count of vertices to draw
  137778. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  137779. */
  137780. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  137781. /** @hidden */
  137782. _createTexture(): WebGLTexture;
  137783. /** @hidden */
  137784. _releaseTexture(texture: InternalTexture): void;
  137785. /**
  137786. * Usually called from Texture.ts.
  137787. * Passed information to create a WebGLTexture
  137788. * @param urlArg defines a value which contains one of the following:
  137789. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  137790. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  137791. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  137792. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  137793. * @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)
  137794. * @param scene needed for loading to the correct scene
  137795. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  137796. * @param onLoad optional callback to be called upon successful completion
  137797. * @param onError optional callback to be called upon failure
  137798. * @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
  137799. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  137800. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  137801. * @param forcedExtension defines the extension to use to pick the right loader
  137802. * @param mimeType defines an optional mime type
  137803. * @returns a InternalTexture for assignment back into BABYLON.Texture
  137804. */
  137805. 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;
  137806. /**
  137807. * Creates a new render target texture
  137808. * @param size defines the size of the texture
  137809. * @param options defines the options used to create the texture
  137810. * @returns a new render target texture stored in an InternalTexture
  137811. */
  137812. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  137813. /**
  137814. * Update the sampling mode of a given texture
  137815. * @param samplingMode defines the required sampling mode
  137816. * @param texture defines the texture to update
  137817. */
  137818. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  137819. /**
  137820. * Binds the frame buffer to the specified texture.
  137821. * @param texture The texture to render to or null for the default canvas
  137822. * @param faceIndex The face of the texture to render to in case of cube texture
  137823. * @param requiredWidth The width of the target to render to
  137824. * @param requiredHeight The height of the target to render to
  137825. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  137826. * @param lodLevel defines le lod level to bind to the frame buffer
  137827. */
  137828. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  137829. /**
  137830. * Unbind the current render target texture from the webGL context
  137831. * @param texture defines the render target texture to unbind
  137832. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  137833. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  137834. */
  137835. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  137836. /**
  137837. * Creates a dynamic vertex buffer
  137838. * @param vertices the data for the dynamic vertex buffer
  137839. * @returns the new WebGL dynamic buffer
  137840. */
  137841. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  137842. /**
  137843. * Update the content of a dynamic texture
  137844. * @param texture defines the texture to update
  137845. * @param canvas defines the canvas containing the source
  137846. * @param invertY defines if data must be stored with Y axis inverted
  137847. * @param premulAlpha defines if alpha is stored as premultiplied
  137848. * @param format defines the format of the data
  137849. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  137850. */
  137851. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  137852. /**
  137853. * Gets a boolean indicating if all created effects are ready
  137854. * @returns true if all effects are ready
  137855. */
  137856. areAllEffectsReady(): boolean;
  137857. /**
  137858. * @hidden
  137859. * Get the current error code of the webGL context
  137860. * @returns the error code
  137861. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  137862. */
  137863. getError(): number;
  137864. /** @hidden */
  137865. _getUnpackAlignement(): number;
  137866. /** @hidden */
  137867. _unpackFlipY(value: boolean): void;
  137868. /**
  137869. * Update a dynamic index buffer
  137870. * @param indexBuffer defines the target index buffer
  137871. * @param indices defines the data to update
  137872. * @param offset defines the offset in the target index buffer where update should start
  137873. */
  137874. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  137875. /**
  137876. * Updates a dynamic vertex buffer.
  137877. * @param vertexBuffer the vertex buffer to update
  137878. * @param vertices the data used to update the vertex buffer
  137879. * @param byteOffset the byte offset of the data (optional)
  137880. * @param byteLength the byte length of the data (optional)
  137881. */
  137882. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  137883. /** @hidden */
  137884. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  137885. /** @hidden */
  137886. _bindTexture(channel: number, texture: InternalTexture): void;
  137887. protected _deleteBuffer(buffer: WebGLBuffer): void;
  137888. /**
  137889. * 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
  137890. */
  137891. releaseEffects(): void;
  137892. displayLoadingUI(): void;
  137893. hideLoadingUI(): void;
  137894. /** @hidden */
  137895. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  137896. /** @hidden */
  137897. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  137898. /** @hidden */
  137899. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  137900. /** @hidden */
  137901. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  137902. }
  137903. }
  137904. declare module BABYLON {
  137905. /**
  137906. * @hidden
  137907. **/
  137908. export class _TimeToken {
  137909. _startTimeQuery: Nullable<WebGLQuery>;
  137910. _endTimeQuery: Nullable<WebGLQuery>;
  137911. _timeElapsedQuery: Nullable<WebGLQuery>;
  137912. _timeElapsedQueryEnded: boolean;
  137913. }
  137914. }
  137915. declare module BABYLON {
  137916. /** @hidden */
  137917. export class _OcclusionDataStorage {
  137918. /** @hidden */
  137919. occlusionInternalRetryCounter: number;
  137920. /** @hidden */
  137921. isOcclusionQueryInProgress: boolean;
  137922. /** @hidden */
  137923. isOccluded: boolean;
  137924. /** @hidden */
  137925. occlusionRetryCount: number;
  137926. /** @hidden */
  137927. occlusionType: number;
  137928. /** @hidden */
  137929. occlusionQueryAlgorithmType: number;
  137930. }
  137931. interface Engine {
  137932. /**
  137933. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  137934. * @return the new query
  137935. */
  137936. createQuery(): WebGLQuery;
  137937. /**
  137938. * Delete and release a webGL query
  137939. * @param query defines the query to delete
  137940. * @return the current engine
  137941. */
  137942. deleteQuery(query: WebGLQuery): Engine;
  137943. /**
  137944. * Check if a given query has resolved and got its value
  137945. * @param query defines the query to check
  137946. * @returns true if the query got its value
  137947. */
  137948. isQueryResultAvailable(query: WebGLQuery): boolean;
  137949. /**
  137950. * Gets the value of a given query
  137951. * @param query defines the query to check
  137952. * @returns the value of the query
  137953. */
  137954. getQueryResult(query: WebGLQuery): number;
  137955. /**
  137956. * Initiates an occlusion query
  137957. * @param algorithmType defines the algorithm to use
  137958. * @param query defines the query to use
  137959. * @returns the current engine
  137960. * @see https://doc.babylonjs.com/features/occlusionquery
  137961. */
  137962. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  137963. /**
  137964. * Ends an occlusion query
  137965. * @see https://doc.babylonjs.com/features/occlusionquery
  137966. * @param algorithmType defines the algorithm to use
  137967. * @returns the current engine
  137968. */
  137969. endOcclusionQuery(algorithmType: number): Engine;
  137970. /**
  137971. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  137972. * Please note that only one query can be issued at a time
  137973. * @returns a time token used to track the time span
  137974. */
  137975. startTimeQuery(): Nullable<_TimeToken>;
  137976. /**
  137977. * Ends a time query
  137978. * @param token defines the token used to measure the time span
  137979. * @returns the time spent (in ns)
  137980. */
  137981. endTimeQuery(token: _TimeToken): int;
  137982. /** @hidden */
  137983. _currentNonTimestampToken: Nullable<_TimeToken>;
  137984. /** @hidden */
  137985. _createTimeQuery(): WebGLQuery;
  137986. /** @hidden */
  137987. _deleteTimeQuery(query: WebGLQuery): void;
  137988. /** @hidden */
  137989. _getGlAlgorithmType(algorithmType: number): number;
  137990. /** @hidden */
  137991. _getTimeQueryResult(query: WebGLQuery): any;
  137992. /** @hidden */
  137993. _getTimeQueryAvailability(query: WebGLQuery): any;
  137994. }
  137995. interface AbstractMesh {
  137996. /**
  137997. * Backing filed
  137998. * @hidden
  137999. */
  138000. __occlusionDataStorage: _OcclusionDataStorage;
  138001. /**
  138002. * Access property
  138003. * @hidden
  138004. */
  138005. _occlusionDataStorage: _OcclusionDataStorage;
  138006. /**
  138007. * 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.
  138008. * The default value is -1 which means don't break the query and wait till the result
  138009. * @see https://doc.babylonjs.com/features/occlusionquery
  138010. */
  138011. occlusionRetryCount: number;
  138012. /**
  138013. * 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:
  138014. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  138015. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  138016. * * 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.
  138017. * @see https://doc.babylonjs.com/features/occlusionquery
  138018. */
  138019. occlusionType: number;
  138020. /**
  138021. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  138022. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  138023. * * 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.
  138024. * @see https://doc.babylonjs.com/features/occlusionquery
  138025. */
  138026. occlusionQueryAlgorithmType: number;
  138027. /**
  138028. * 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
  138029. * @see https://doc.babylonjs.com/features/occlusionquery
  138030. */
  138031. isOccluded: boolean;
  138032. /**
  138033. * Flag to check the progress status of the query
  138034. * @see https://doc.babylonjs.com/features/occlusionquery
  138035. */
  138036. isOcclusionQueryInProgress: boolean;
  138037. }
  138038. }
  138039. declare module BABYLON {
  138040. /** @hidden */
  138041. export var _forceTransformFeedbackToBundle: boolean;
  138042. interface Engine {
  138043. /**
  138044. * Creates a webGL transform feedback object
  138045. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  138046. * @returns the webGL transform feedback object
  138047. */
  138048. createTransformFeedback(): WebGLTransformFeedback;
  138049. /**
  138050. * Delete a webGL transform feedback object
  138051. * @param value defines the webGL transform feedback object to delete
  138052. */
  138053. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  138054. /**
  138055. * Bind a webGL transform feedback object to the webgl context
  138056. * @param value defines the webGL transform feedback object to bind
  138057. */
  138058. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  138059. /**
  138060. * Begins a transform feedback operation
  138061. * @param usePoints defines if points or triangles must be used
  138062. */
  138063. beginTransformFeedback(usePoints: boolean): void;
  138064. /**
  138065. * Ends a transform feedback operation
  138066. */
  138067. endTransformFeedback(): void;
  138068. /**
  138069. * Specify the varyings to use with transform feedback
  138070. * @param program defines the associated webGL program
  138071. * @param value defines the list of strings representing the varying names
  138072. */
  138073. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  138074. /**
  138075. * Bind a webGL buffer for a transform feedback operation
  138076. * @param value defines the webGL buffer to bind
  138077. */
  138078. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  138079. }
  138080. }
  138081. declare module BABYLON {
  138082. /**
  138083. * Class used to define an additional view for the engine
  138084. * @see https://doc.babylonjs.com/how_to/multi_canvases
  138085. */
  138086. export class EngineView {
  138087. /** Defines the canvas where to render the view */
  138088. target: HTMLCanvasElement;
  138089. /** Defines an optional camera used to render the view (will use active camera else) */
  138090. camera?: Camera;
  138091. }
  138092. interface Engine {
  138093. /**
  138094. * Gets or sets the HTML element to use for attaching events
  138095. */
  138096. inputElement: Nullable<HTMLElement>;
  138097. /**
  138098. * Gets the current engine view
  138099. * @see https://doc.babylonjs.com/how_to/multi_canvases
  138100. */
  138101. activeView: Nullable<EngineView>;
  138102. /** Gets or sets the list of views */
  138103. views: EngineView[];
  138104. /**
  138105. * Register a new child canvas
  138106. * @param canvas defines the canvas to register
  138107. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  138108. * @returns the associated view
  138109. */
  138110. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  138111. /**
  138112. * Remove a registered child canvas
  138113. * @param canvas defines the canvas to remove
  138114. * @returns the current engine
  138115. */
  138116. unRegisterView(canvas: HTMLCanvasElement): Engine;
  138117. }
  138118. }
  138119. declare module BABYLON {
  138120. interface Engine {
  138121. /** @hidden */
  138122. _excludedCompressedTextures: string[];
  138123. /** @hidden */
  138124. _textureFormatInUse: string;
  138125. /**
  138126. * Gets the list of texture formats supported
  138127. */
  138128. readonly texturesSupported: Array<string>;
  138129. /**
  138130. * Gets the texture format in use
  138131. */
  138132. readonly textureFormatInUse: Nullable<string>;
  138133. /**
  138134. * Set the compressed texture extensions or file names to skip.
  138135. *
  138136. * @param skippedFiles defines the list of those texture files you want to skip
  138137. * Example: [".dds", ".env", "myfile.png"]
  138138. */
  138139. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  138140. /**
  138141. * Set the compressed texture format to use, based on the formats you have, and the formats
  138142. * supported by the hardware / browser.
  138143. *
  138144. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  138145. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  138146. * to API arguments needed to compressed textures. This puts the burden on the container
  138147. * generator to house the arcane code for determining these for current & future formats.
  138148. *
  138149. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  138150. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  138151. *
  138152. * Note: The result of this call is not taken into account when a texture is base64.
  138153. *
  138154. * @param formatsAvailable defines the list of those format families you have created
  138155. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  138156. *
  138157. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  138158. * @returns The extension selected.
  138159. */
  138160. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  138161. }
  138162. }
  138163. declare module BABYLON {
  138164. /** @hidden */
  138165. export var rgbdEncodePixelShader: {
  138166. name: string;
  138167. shader: string;
  138168. };
  138169. }
  138170. declare module BABYLON {
  138171. /**
  138172. * Raw texture data and descriptor sufficient for WebGL texture upload
  138173. */
  138174. export interface EnvironmentTextureInfo {
  138175. /**
  138176. * Version of the environment map
  138177. */
  138178. version: number;
  138179. /**
  138180. * Width of image
  138181. */
  138182. width: number;
  138183. /**
  138184. * Irradiance information stored in the file.
  138185. */
  138186. irradiance: any;
  138187. /**
  138188. * Specular information stored in the file.
  138189. */
  138190. specular: any;
  138191. }
  138192. /**
  138193. * Defines One Image in the file. It requires only the position in the file
  138194. * as well as the length.
  138195. */
  138196. interface BufferImageData {
  138197. /**
  138198. * Length of the image data.
  138199. */
  138200. length: number;
  138201. /**
  138202. * Position of the data from the null terminator delimiting the end of the JSON.
  138203. */
  138204. position: number;
  138205. }
  138206. /**
  138207. * Defines the specular data enclosed in the file.
  138208. * This corresponds to the version 1 of the data.
  138209. */
  138210. export interface EnvironmentTextureSpecularInfoV1 {
  138211. /**
  138212. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  138213. */
  138214. specularDataPosition?: number;
  138215. /**
  138216. * This contains all the images data needed to reconstruct the cubemap.
  138217. */
  138218. mipmaps: Array<BufferImageData>;
  138219. /**
  138220. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  138221. */
  138222. lodGenerationScale: number;
  138223. }
  138224. /**
  138225. * Sets of helpers addressing the serialization and deserialization of environment texture
  138226. * stored in a BabylonJS env file.
  138227. * Those files are usually stored as .env files.
  138228. */
  138229. export class EnvironmentTextureTools {
  138230. /**
  138231. * Magic number identifying the env file.
  138232. */
  138233. private static _MagicBytes;
  138234. /**
  138235. * Gets the environment info from an env file.
  138236. * @param data The array buffer containing the .env bytes.
  138237. * @returns the environment file info (the json header) if successfully parsed.
  138238. */
  138239. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  138240. /**
  138241. * Creates an environment texture from a loaded cube texture.
  138242. * @param texture defines the cube texture to convert in env file
  138243. * @return a promise containing the environment data if succesfull.
  138244. */
  138245. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  138246. /**
  138247. * Creates a JSON representation of the spherical data.
  138248. * @param texture defines the texture containing the polynomials
  138249. * @return the JSON representation of the spherical info
  138250. */
  138251. private static _CreateEnvTextureIrradiance;
  138252. /**
  138253. * Creates the ArrayBufferViews used for initializing environment texture image data.
  138254. * @param data the image data
  138255. * @param info parameters that determine what views will be created for accessing the underlying buffer
  138256. * @return the views described by info providing access to the underlying buffer
  138257. */
  138258. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  138259. /**
  138260. * Uploads the texture info contained in the env file to the GPU.
  138261. * @param texture defines the internal texture to upload to
  138262. * @param data defines the data to load
  138263. * @param info defines the texture info retrieved through the GetEnvInfo method
  138264. * @returns a promise
  138265. */
  138266. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  138267. private static _OnImageReadyAsync;
  138268. /**
  138269. * Uploads the levels of image data to the GPU.
  138270. * @param texture defines the internal texture to upload to
  138271. * @param imageData defines the array buffer views of image data [mipmap][face]
  138272. * @returns a promise
  138273. */
  138274. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  138275. /**
  138276. * Uploads spherical polynomials information to the texture.
  138277. * @param texture defines the texture we are trying to upload the information to
  138278. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  138279. */
  138280. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  138281. /** @hidden */
  138282. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  138283. }
  138284. }
  138285. declare module BABYLON {
  138286. /**
  138287. * Class used to inline functions in shader code
  138288. */
  138289. export class ShaderCodeInliner {
  138290. private static readonly _RegexpFindFunctionNameAndType;
  138291. private _sourceCode;
  138292. private _functionDescr;
  138293. private _numMaxIterations;
  138294. /** Gets or sets the token used to mark the functions to inline */
  138295. inlineToken: string;
  138296. /** Gets or sets the debug mode */
  138297. debug: boolean;
  138298. /** Gets the code after the inlining process */
  138299. get code(): string;
  138300. /**
  138301. * Initializes the inliner
  138302. * @param sourceCode shader code source to inline
  138303. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  138304. */
  138305. constructor(sourceCode: string, numMaxIterations?: number);
  138306. /**
  138307. * Start the processing of the shader code
  138308. */
  138309. processCode(): void;
  138310. private _collectFunctions;
  138311. private _processInlining;
  138312. private _extractBetweenMarkers;
  138313. private _skipWhitespaces;
  138314. private _removeComments;
  138315. private _replaceFunctionCallsByCode;
  138316. private _findBackward;
  138317. private _escapeRegExp;
  138318. private _replaceNames;
  138319. }
  138320. }
  138321. declare module BABYLON {
  138322. /**
  138323. * Container for accessors for natively-stored mesh data buffers.
  138324. */
  138325. class NativeDataBuffer extends DataBuffer {
  138326. /**
  138327. * Accessor value used to identify/retrieve a natively-stored index buffer.
  138328. */
  138329. nativeIndexBuffer?: any;
  138330. /**
  138331. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  138332. */
  138333. nativeVertexBuffer?: any;
  138334. }
  138335. /** @hidden */
  138336. class NativeTexture extends InternalTexture {
  138337. getInternalTexture(): InternalTexture;
  138338. getViewCount(): number;
  138339. }
  138340. /** @hidden */
  138341. export class NativeEngine extends Engine {
  138342. private readonly _native;
  138343. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  138344. private readonly INVALID_HANDLE;
  138345. private _boundBuffersVertexArray;
  138346. private _currentDepthTest;
  138347. getHardwareScalingLevel(): number;
  138348. constructor();
  138349. dispose(): void;
  138350. /**
  138351. * Can be used to override the current requestAnimationFrame requester.
  138352. * @hidden
  138353. */
  138354. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  138355. /**
  138356. * Override default engine behavior.
  138357. * @param color
  138358. * @param backBuffer
  138359. * @param depth
  138360. * @param stencil
  138361. */
  138362. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  138363. /**
  138364. * Gets host document
  138365. * @returns the host document object
  138366. */
  138367. getHostDocument(): Nullable<Document>;
  138368. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  138369. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  138370. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  138371. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  138372. [key: string]: VertexBuffer;
  138373. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  138374. bindBuffers(vertexBuffers: {
  138375. [key: string]: VertexBuffer;
  138376. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  138377. recordVertexArrayObject(vertexBuffers: {
  138378. [key: string]: VertexBuffer;
  138379. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  138380. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  138381. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  138382. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  138383. /**
  138384. * Draw a list of indexed primitives
  138385. * @param fillMode defines the primitive to use
  138386. * @param indexStart defines the starting index
  138387. * @param indexCount defines the number of index to draw
  138388. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  138389. */
  138390. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  138391. /**
  138392. * Draw a list of unindexed primitives
  138393. * @param fillMode defines the primitive to use
  138394. * @param verticesStart defines the index of first vertex to draw
  138395. * @param verticesCount defines the count of vertices to draw
  138396. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  138397. */
  138398. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  138399. createPipelineContext(): IPipelineContext;
  138400. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  138401. /** @hidden */
  138402. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  138403. /** @hidden */
  138404. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  138405. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  138406. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  138407. protected _setProgram(program: WebGLProgram): void;
  138408. _releaseEffect(effect: Effect): void;
  138409. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  138410. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  138411. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  138412. bindSamplers(effect: Effect): void;
  138413. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  138414. getRenderWidth(useScreen?: boolean): number;
  138415. getRenderHeight(useScreen?: boolean): number;
  138416. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  138417. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  138418. /**
  138419. * Set the z offset to apply to current rendering
  138420. * @param value defines the offset to apply
  138421. */
  138422. setZOffset(value: number): void;
  138423. /**
  138424. * Gets the current value of the zOffset
  138425. * @returns the current zOffset state
  138426. */
  138427. getZOffset(): number;
  138428. /**
  138429. * Enable or disable depth buffering
  138430. * @param enable defines the state to set
  138431. */
  138432. setDepthBuffer(enable: boolean): void;
  138433. /**
  138434. * Gets a boolean indicating if depth writing is enabled
  138435. * @returns the current depth writing state
  138436. */
  138437. getDepthWrite(): boolean;
  138438. setDepthFunctionToGreater(): void;
  138439. setDepthFunctionToGreaterOrEqual(): void;
  138440. setDepthFunctionToLess(): void;
  138441. setDepthFunctionToLessOrEqual(): void;
  138442. /**
  138443. * Enable or disable depth writing
  138444. * @param enable defines the state to set
  138445. */
  138446. setDepthWrite(enable: boolean): void;
  138447. /**
  138448. * Enable or disable color writing
  138449. * @param enable defines the state to set
  138450. */
  138451. setColorWrite(enable: boolean): void;
  138452. /**
  138453. * Gets a boolean indicating if color writing is enabled
  138454. * @returns the current color writing state
  138455. */
  138456. getColorWrite(): boolean;
  138457. /**
  138458. * Sets alpha constants used by some alpha blending modes
  138459. * @param r defines the red component
  138460. * @param g defines the green component
  138461. * @param b defines the blue component
  138462. * @param a defines the alpha component
  138463. */
  138464. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  138465. /**
  138466. * Sets the current alpha mode
  138467. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  138468. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  138469. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  138470. */
  138471. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  138472. /**
  138473. * Gets the current alpha mode
  138474. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  138475. * @returns the current alpha mode
  138476. */
  138477. getAlphaMode(): number;
  138478. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  138479. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138480. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138481. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138482. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138483. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138484. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138485. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138486. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138487. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  138488. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  138489. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  138490. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  138491. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  138492. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  138493. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  138494. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  138495. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  138496. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  138497. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  138498. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  138499. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  138500. wipeCaches(bruteForce?: boolean): void;
  138501. _createTexture(): WebGLTexture;
  138502. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  138503. /**
  138504. * Update the content of a dynamic texture
  138505. * @param texture defines the texture to update
  138506. * @param canvas defines the canvas containing the source
  138507. * @param invertY defines if data must be stored with Y axis inverted
  138508. * @param premulAlpha defines if alpha is stored as premultiplied
  138509. * @param format defines the format of the data
  138510. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  138511. */
  138512. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  138513. /**
  138514. * Usually called from Texture.ts.
  138515. * Passed information to create a WebGLTexture
  138516. * @param url defines a value which contains one of the following:
  138517. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  138518. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  138519. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  138520. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  138521. * @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)
  138522. * @param scene needed for loading to the correct scene
  138523. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  138524. * @param onLoad optional callback to be called upon successful completion
  138525. * @param onError optional callback to be called upon failure
  138526. * @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
  138527. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  138528. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  138529. * @param forcedExtension defines the extension to use to pick the right loader
  138530. * @param mimeType defines an optional mime type
  138531. * @param loaderOptions options to be passed to the loader
  138532. * @returns a InternalTexture for assignment back into BABYLON.Texture
  138533. */
  138534. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  138535. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  138536. _releaseFramebufferObjects(texture: InternalTexture): void;
  138537. /**
  138538. * Creates a cube texture
  138539. * @param rootUrl defines the url where the files to load is located
  138540. * @param scene defines the current scene
  138541. * @param files defines the list of files to load (1 per face)
  138542. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  138543. * @param onLoad defines an optional callback raised when the texture is loaded
  138544. * @param onError defines an optional callback raised if there is an issue to load the texture
  138545. * @param format defines the format of the data
  138546. * @param forcedExtension defines the extension to use to pick the right loader
  138547. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  138548. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  138549. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  138550. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  138551. * @returns the cube texture as an InternalTexture
  138552. */
  138553. 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;
  138554. createRenderTargetTexture(size: number | {
  138555. width: number;
  138556. height: number;
  138557. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  138558. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  138559. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  138560. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  138561. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  138562. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  138563. /**
  138564. * Updates a dynamic vertex buffer.
  138565. * @param vertexBuffer the vertex buffer to update
  138566. * @param data the data used to update the vertex buffer
  138567. * @param byteOffset the byte offset of the data (optional)
  138568. * @param byteLength the byte length of the data (optional)
  138569. */
  138570. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  138571. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  138572. private _updateAnisotropicLevel;
  138573. private _getAddressMode;
  138574. /** @hidden */
  138575. _bindTexture(channel: number, texture: InternalTexture): void;
  138576. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  138577. releaseEffects(): void;
  138578. /** @hidden */
  138579. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138580. /** @hidden */
  138581. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138582. /** @hidden */
  138583. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138584. /** @hidden */
  138585. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  138586. private _getNativeSamplingMode;
  138587. private _getNativeTextureFormat;
  138588. private _getNativeAlphaMode;
  138589. private _getNativeAttribType;
  138590. }
  138591. }
  138592. declare module BABYLON {
  138593. /**
  138594. * Gather the list of clipboard event types as constants.
  138595. */
  138596. export class ClipboardEventTypes {
  138597. /**
  138598. * The clipboard event is fired when a copy command is active (pressed).
  138599. */
  138600. static readonly COPY: number;
  138601. /**
  138602. * The clipboard event is fired when a cut command is active (pressed).
  138603. */
  138604. static readonly CUT: number;
  138605. /**
  138606. * The clipboard event is fired when a paste command is active (pressed).
  138607. */
  138608. static readonly PASTE: number;
  138609. }
  138610. /**
  138611. * This class is used to store clipboard related info for the onClipboardObservable event.
  138612. */
  138613. export class ClipboardInfo {
  138614. /**
  138615. * Defines the type of event (BABYLON.ClipboardEventTypes)
  138616. */
  138617. type: number;
  138618. /**
  138619. * Defines the related dom event
  138620. */
  138621. event: ClipboardEvent;
  138622. /**
  138623. *Creates an instance of ClipboardInfo.
  138624. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  138625. * @param event Defines the related dom event
  138626. */
  138627. constructor(
  138628. /**
  138629. * Defines the type of event (BABYLON.ClipboardEventTypes)
  138630. */
  138631. type: number,
  138632. /**
  138633. * Defines the related dom event
  138634. */
  138635. event: ClipboardEvent);
  138636. /**
  138637. * Get the clipboard event's type from the keycode.
  138638. * @param keyCode Defines the keyCode for the current keyboard event.
  138639. * @return {number}
  138640. */
  138641. static GetTypeFromCharacter(keyCode: number): number;
  138642. }
  138643. }
  138644. declare module BABYLON {
  138645. /**
  138646. * Google Daydream controller
  138647. */
  138648. export class DaydreamController extends WebVRController {
  138649. /**
  138650. * Base Url for the controller model.
  138651. */
  138652. static MODEL_BASE_URL: string;
  138653. /**
  138654. * File name for the controller model.
  138655. */
  138656. static MODEL_FILENAME: string;
  138657. /**
  138658. * Gamepad Id prefix used to identify Daydream Controller.
  138659. */
  138660. static readonly GAMEPAD_ID_PREFIX: string;
  138661. /**
  138662. * Creates a new DaydreamController from a gamepad
  138663. * @param vrGamepad the gamepad that the controller should be created from
  138664. */
  138665. constructor(vrGamepad: any);
  138666. /**
  138667. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  138668. * @param scene scene in which to add meshes
  138669. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  138670. */
  138671. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  138672. /**
  138673. * Called once for each button that changed state since the last frame
  138674. * @param buttonIdx Which button index changed
  138675. * @param state New state of the button
  138676. * @param changes Which properties on the state changed since last frame
  138677. */
  138678. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  138679. }
  138680. }
  138681. declare module BABYLON {
  138682. /**
  138683. * Gear VR Controller
  138684. */
  138685. export class GearVRController extends WebVRController {
  138686. /**
  138687. * Base Url for the controller model.
  138688. */
  138689. static MODEL_BASE_URL: string;
  138690. /**
  138691. * File name for the controller model.
  138692. */
  138693. static MODEL_FILENAME: string;
  138694. /**
  138695. * Gamepad Id prefix used to identify this controller.
  138696. */
  138697. static readonly GAMEPAD_ID_PREFIX: string;
  138698. private readonly _buttonIndexToObservableNameMap;
  138699. /**
  138700. * Creates a new GearVRController from a gamepad
  138701. * @param vrGamepad the gamepad that the controller should be created from
  138702. */
  138703. constructor(vrGamepad: any);
  138704. /**
  138705. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  138706. * @param scene scene in which to add meshes
  138707. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  138708. */
  138709. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  138710. /**
  138711. * Called once for each button that changed state since the last frame
  138712. * @param buttonIdx Which button index changed
  138713. * @param state New state of the button
  138714. * @param changes Which properties on the state changed since last frame
  138715. */
  138716. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  138717. }
  138718. }
  138719. declare module BABYLON {
  138720. /**
  138721. * Generic Controller
  138722. */
  138723. export class GenericController extends WebVRController {
  138724. /**
  138725. * Base Url for the controller model.
  138726. */
  138727. static readonly MODEL_BASE_URL: string;
  138728. /**
  138729. * File name for the controller model.
  138730. */
  138731. static readonly MODEL_FILENAME: string;
  138732. /**
  138733. * Creates a new GenericController from a gamepad
  138734. * @param vrGamepad the gamepad that the controller should be created from
  138735. */
  138736. constructor(vrGamepad: any);
  138737. /**
  138738. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  138739. * @param scene scene in which to add meshes
  138740. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  138741. */
  138742. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  138743. /**
  138744. * Called once for each button that changed state since the last frame
  138745. * @param buttonIdx Which button index changed
  138746. * @param state New state of the button
  138747. * @param changes Which properties on the state changed since last frame
  138748. */
  138749. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  138750. }
  138751. }
  138752. declare module BABYLON {
  138753. /**
  138754. * Oculus Touch Controller
  138755. */
  138756. export class OculusTouchController extends WebVRController {
  138757. /**
  138758. * Base Url for the controller model.
  138759. */
  138760. static MODEL_BASE_URL: string;
  138761. /**
  138762. * File name for the left controller model.
  138763. */
  138764. static MODEL_LEFT_FILENAME: string;
  138765. /**
  138766. * File name for the right controller model.
  138767. */
  138768. static MODEL_RIGHT_FILENAME: string;
  138769. /**
  138770. * Base Url for the Quest controller model.
  138771. */
  138772. static QUEST_MODEL_BASE_URL: string;
  138773. /**
  138774. * @hidden
  138775. * If the controllers are running on a device that needs the updated Quest controller models
  138776. */
  138777. static _IsQuest: boolean;
  138778. /**
  138779. * Fired when the secondary trigger on this controller is modified
  138780. */
  138781. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  138782. /**
  138783. * Fired when the thumb rest on this controller is modified
  138784. */
  138785. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  138786. /**
  138787. * Creates a new OculusTouchController from a gamepad
  138788. * @param vrGamepad the gamepad that the controller should be created from
  138789. */
  138790. constructor(vrGamepad: any);
  138791. /**
  138792. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  138793. * @param scene scene in which to add meshes
  138794. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  138795. */
  138796. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  138797. /**
  138798. * Fired when the A button on this controller is modified
  138799. */
  138800. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  138801. /**
  138802. * Fired when the B button on this controller is modified
  138803. */
  138804. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  138805. /**
  138806. * Fired when the X button on this controller is modified
  138807. */
  138808. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  138809. /**
  138810. * Fired when the Y button on this controller is modified
  138811. */
  138812. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  138813. /**
  138814. * Called once for each button that changed state since the last frame
  138815. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  138816. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  138817. * 2) secondary trigger (same)
  138818. * 3) A (right) X (left), touch, pressed = value
  138819. * 4) B / Y
  138820. * 5) thumb rest
  138821. * @param buttonIdx Which button index changed
  138822. * @param state New state of the button
  138823. * @param changes Which properties on the state changed since last frame
  138824. */
  138825. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  138826. }
  138827. }
  138828. declare module BABYLON {
  138829. /**
  138830. * Vive Controller
  138831. */
  138832. export class ViveController extends WebVRController {
  138833. /**
  138834. * Base Url for the controller model.
  138835. */
  138836. static MODEL_BASE_URL: string;
  138837. /**
  138838. * File name for the controller model.
  138839. */
  138840. static MODEL_FILENAME: string;
  138841. /**
  138842. * Creates a new ViveController from a gamepad
  138843. * @param vrGamepad the gamepad that the controller should be created from
  138844. */
  138845. constructor(vrGamepad: any);
  138846. /**
  138847. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  138848. * @param scene scene in which to add meshes
  138849. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  138850. */
  138851. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  138852. /**
  138853. * Fired when the left button on this controller is modified
  138854. */
  138855. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  138856. /**
  138857. * Fired when the right button on this controller is modified
  138858. */
  138859. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  138860. /**
  138861. * Fired when the menu button on this controller is modified
  138862. */
  138863. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  138864. /**
  138865. * Called once for each button that changed state since the last frame
  138866. * Vive mapping:
  138867. * 0: touchpad
  138868. * 1: trigger
  138869. * 2: left AND right buttons
  138870. * 3: menu button
  138871. * @param buttonIdx Which button index changed
  138872. * @param state New state of the button
  138873. * @param changes Which properties on the state changed since last frame
  138874. */
  138875. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  138876. }
  138877. }
  138878. declare module BABYLON {
  138879. /**
  138880. * Defines the WindowsMotionController object that the state of the windows motion controller
  138881. */
  138882. export class WindowsMotionController extends WebVRController {
  138883. /**
  138884. * The base url used to load the left and right controller models
  138885. */
  138886. static MODEL_BASE_URL: string;
  138887. /**
  138888. * The name of the left controller model file
  138889. */
  138890. static MODEL_LEFT_FILENAME: string;
  138891. /**
  138892. * The name of the right controller model file
  138893. */
  138894. static MODEL_RIGHT_FILENAME: string;
  138895. /**
  138896. * The controller name prefix for this controller type
  138897. */
  138898. static readonly GAMEPAD_ID_PREFIX: string;
  138899. /**
  138900. * The controller id pattern for this controller type
  138901. */
  138902. private static readonly GAMEPAD_ID_PATTERN;
  138903. private _loadedMeshInfo;
  138904. protected readonly _mapping: {
  138905. buttons: string[];
  138906. buttonMeshNames: {
  138907. trigger: string;
  138908. menu: string;
  138909. grip: string;
  138910. thumbstick: string;
  138911. trackpad: string;
  138912. };
  138913. buttonObservableNames: {
  138914. trigger: string;
  138915. menu: string;
  138916. grip: string;
  138917. thumbstick: string;
  138918. trackpad: string;
  138919. };
  138920. axisMeshNames: string[];
  138921. pointingPoseMeshName: string;
  138922. };
  138923. /**
  138924. * Fired when the trackpad on this controller is clicked
  138925. */
  138926. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  138927. /**
  138928. * Fired when the trackpad on this controller is modified
  138929. */
  138930. onTrackpadValuesChangedObservable: Observable<StickValues>;
  138931. /**
  138932. * The current x and y values of this controller's trackpad
  138933. */
  138934. trackpad: StickValues;
  138935. /**
  138936. * Creates a new WindowsMotionController from a gamepad
  138937. * @param vrGamepad the gamepad that the controller should be created from
  138938. */
  138939. constructor(vrGamepad: any);
  138940. /**
  138941. * Fired when the trigger on this controller is modified
  138942. */
  138943. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  138944. /**
  138945. * Fired when the menu button on this controller is modified
  138946. */
  138947. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  138948. /**
  138949. * Fired when the grip button on this controller is modified
  138950. */
  138951. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  138952. /**
  138953. * Fired when the thumbstick button on this controller is modified
  138954. */
  138955. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  138956. /**
  138957. * Fired when the touchpad button on this controller is modified
  138958. */
  138959. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  138960. /**
  138961. * Fired when the touchpad values on this controller are modified
  138962. */
  138963. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  138964. protected _updateTrackpad(): void;
  138965. /**
  138966. * Called once per frame by the engine.
  138967. */
  138968. update(): void;
  138969. /**
  138970. * Called once for each button that changed state since the last frame
  138971. * @param buttonIdx Which button index changed
  138972. * @param state New state of the button
  138973. * @param changes Which properties on the state changed since last frame
  138974. */
  138975. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  138976. /**
  138977. * Moves the buttons on the controller mesh based on their current state
  138978. * @param buttonName the name of the button to move
  138979. * @param buttonValue the value of the button which determines the buttons new position
  138980. */
  138981. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  138982. /**
  138983. * Moves the axis on the controller mesh based on its current state
  138984. * @param axis the index of the axis
  138985. * @param axisValue the value of the axis which determines the meshes new position
  138986. * @hidden
  138987. */
  138988. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  138989. /**
  138990. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  138991. * @param scene scene in which to add meshes
  138992. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  138993. */
  138994. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  138995. /**
  138996. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  138997. * can be transformed by button presses and axes values, based on this._mapping.
  138998. *
  138999. * @param scene scene in which the meshes exist
  139000. * @param meshes list of meshes that make up the controller model to process
  139001. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  139002. */
  139003. private processModel;
  139004. private createMeshInfo;
  139005. /**
  139006. * Gets the ray of the controller in the direction the controller is pointing
  139007. * @param length the length the resulting ray should be
  139008. * @returns a ray in the direction the controller is pointing
  139009. */
  139010. getForwardRay(length?: number): Ray;
  139011. /**
  139012. * Disposes of the controller
  139013. */
  139014. dispose(): void;
  139015. }
  139016. /**
  139017. * This class represents a new windows motion controller in XR.
  139018. */
  139019. export class XRWindowsMotionController extends WindowsMotionController {
  139020. /**
  139021. * Changing the original WIndowsMotionController mapping to fir the new mapping
  139022. */
  139023. protected readonly _mapping: {
  139024. buttons: string[];
  139025. buttonMeshNames: {
  139026. trigger: string;
  139027. menu: string;
  139028. grip: string;
  139029. thumbstick: string;
  139030. trackpad: string;
  139031. };
  139032. buttonObservableNames: {
  139033. trigger: string;
  139034. menu: string;
  139035. grip: string;
  139036. thumbstick: string;
  139037. trackpad: string;
  139038. };
  139039. axisMeshNames: string[];
  139040. pointingPoseMeshName: string;
  139041. };
  139042. /**
  139043. * Construct a new XR-Based windows motion controller
  139044. *
  139045. * @param gamepadInfo the gamepad object from the browser
  139046. */
  139047. constructor(gamepadInfo: any);
  139048. /**
  139049. * holds the thumbstick values (X,Y)
  139050. */
  139051. thumbstickValues: StickValues;
  139052. /**
  139053. * Fired when the thumbstick on this controller is clicked
  139054. */
  139055. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  139056. /**
  139057. * Fired when the thumbstick on this controller is modified
  139058. */
  139059. onThumbstickValuesChangedObservable: Observable<StickValues>;
  139060. /**
  139061. * Fired when the touchpad button on this controller is modified
  139062. */
  139063. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  139064. /**
  139065. * Fired when the touchpad values on this controller are modified
  139066. */
  139067. onTrackpadValuesChangedObservable: Observable<StickValues>;
  139068. /**
  139069. * Fired when the thumbstick button on this controller is modified
  139070. * here to prevent breaking changes
  139071. */
  139072. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139073. /**
  139074. * updating the thumbstick(!) and not the trackpad.
  139075. * This is named this way due to the difference between WebVR and XR and to avoid
  139076. * changing the parent class.
  139077. */
  139078. protected _updateTrackpad(): void;
  139079. /**
  139080. * Disposes the class with joy
  139081. */
  139082. dispose(): void;
  139083. }
  139084. }
  139085. declare module BABYLON {
  139086. /**
  139087. * A directional light is defined by a direction (what a surprise!).
  139088. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  139089. * 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.
  139090. * Documentation: https://doc.babylonjs.com/babylon101/lights
  139091. */
  139092. export class DirectionalLight extends ShadowLight {
  139093. private _shadowFrustumSize;
  139094. /**
  139095. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  139096. */
  139097. get shadowFrustumSize(): number;
  139098. /**
  139099. * Specifies a fix frustum size for the shadow generation.
  139100. */
  139101. set shadowFrustumSize(value: number);
  139102. private _shadowOrthoScale;
  139103. /**
  139104. * Gets the shadow projection scale against the optimal computed one.
  139105. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  139106. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  139107. */
  139108. get shadowOrthoScale(): number;
  139109. /**
  139110. * Sets the shadow projection scale against the optimal computed one.
  139111. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  139112. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  139113. */
  139114. set shadowOrthoScale(value: number);
  139115. /**
  139116. * Automatically compute the projection matrix to best fit (including all the casters)
  139117. * on each frame.
  139118. */
  139119. autoUpdateExtends: boolean;
  139120. /**
  139121. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  139122. * on each frame. autoUpdateExtends must be set to true for this to work
  139123. */
  139124. autoCalcShadowZBounds: boolean;
  139125. private _orthoLeft;
  139126. private _orthoRight;
  139127. private _orthoTop;
  139128. private _orthoBottom;
  139129. /**
  139130. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  139131. * The directional light is emitted from everywhere in the given direction.
  139132. * It can cast shadows.
  139133. * Documentation : https://doc.babylonjs.com/babylon101/lights
  139134. * @param name The friendly name of the light
  139135. * @param direction The direction of the light
  139136. * @param scene The scene the light belongs to
  139137. */
  139138. constructor(name: string, direction: Vector3, scene: Scene);
  139139. /**
  139140. * Returns the string "DirectionalLight".
  139141. * @return The class name
  139142. */
  139143. getClassName(): string;
  139144. /**
  139145. * Returns the integer 1.
  139146. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  139147. */
  139148. getTypeID(): number;
  139149. /**
  139150. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  139151. * Returns the DirectionalLight Shadow projection matrix.
  139152. */
  139153. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  139154. /**
  139155. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  139156. * Returns the DirectionalLight Shadow projection matrix.
  139157. */
  139158. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  139159. /**
  139160. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  139161. * Returns the DirectionalLight Shadow projection matrix.
  139162. */
  139163. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  139164. protected _buildUniformLayout(): void;
  139165. /**
  139166. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  139167. * @param effect The effect to update
  139168. * @param lightIndex The index of the light in the effect to update
  139169. * @returns The directional light
  139170. */
  139171. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  139172. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  139173. /**
  139174. * Gets the minZ used for shadow according to both the scene and the light.
  139175. *
  139176. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  139177. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  139178. * @param activeCamera The camera we are returning the min for
  139179. * @returns the depth min z
  139180. */
  139181. getDepthMinZ(activeCamera: Camera): number;
  139182. /**
  139183. * Gets the maxZ used for shadow according to both the scene and the light.
  139184. *
  139185. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  139186. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  139187. * @param activeCamera The camera we are returning the max for
  139188. * @returns the depth max z
  139189. */
  139190. getDepthMaxZ(activeCamera: Camera): number;
  139191. /**
  139192. * Prepares the list of defines specific to the light type.
  139193. * @param defines the list of defines
  139194. * @param lightIndex defines the index of the light for the effect
  139195. */
  139196. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  139197. }
  139198. }
  139199. declare module BABYLON {
  139200. /**
  139201. * Class containing static functions to help procedurally build meshes
  139202. */
  139203. export class HemisphereBuilder {
  139204. /**
  139205. * Creates a hemisphere mesh
  139206. * @param name defines the name of the mesh
  139207. * @param options defines the options used to create the mesh
  139208. * @param scene defines the hosting scene
  139209. * @returns the hemisphere mesh
  139210. */
  139211. static CreateHemisphere(name: string, options: {
  139212. segments?: number;
  139213. diameter?: number;
  139214. sideOrientation?: number;
  139215. }, scene: any): Mesh;
  139216. }
  139217. }
  139218. declare module BABYLON {
  139219. /**
  139220. * A spot light is defined by a position, a direction, an angle, and an exponent.
  139221. * These values define a cone of light starting from the position, emitting toward the direction.
  139222. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  139223. * and the exponent defines the speed of the decay of the light with distance (reach).
  139224. * Documentation: https://doc.babylonjs.com/babylon101/lights
  139225. */
  139226. export class SpotLight extends ShadowLight {
  139227. private _angle;
  139228. private _innerAngle;
  139229. private _cosHalfAngle;
  139230. private _lightAngleScale;
  139231. private _lightAngleOffset;
  139232. /**
  139233. * Gets the cone angle of the spot light in Radians.
  139234. */
  139235. get angle(): number;
  139236. /**
  139237. * Sets the cone angle of the spot light in Radians.
  139238. */
  139239. set angle(value: number);
  139240. /**
  139241. * Only used in gltf falloff mode, this defines the angle where
  139242. * the directional falloff will start before cutting at angle which could be seen
  139243. * as outer angle.
  139244. */
  139245. get innerAngle(): number;
  139246. /**
  139247. * Only used in gltf falloff mode, this defines the angle where
  139248. * the directional falloff will start before cutting at angle which could be seen
  139249. * as outer angle.
  139250. */
  139251. set innerAngle(value: number);
  139252. private _shadowAngleScale;
  139253. /**
  139254. * Allows scaling the angle of the light for shadow generation only.
  139255. */
  139256. get shadowAngleScale(): number;
  139257. /**
  139258. * Allows scaling the angle of the light for shadow generation only.
  139259. */
  139260. set shadowAngleScale(value: number);
  139261. /**
  139262. * The light decay speed with the distance from the emission spot.
  139263. */
  139264. exponent: number;
  139265. private _projectionTextureMatrix;
  139266. /**
  139267. * Allows reading the projecton texture
  139268. */
  139269. get projectionTextureMatrix(): Matrix;
  139270. protected _projectionTextureLightNear: number;
  139271. /**
  139272. * Gets the near clip of the Spotlight for texture projection.
  139273. */
  139274. get projectionTextureLightNear(): number;
  139275. /**
  139276. * Sets the near clip of the Spotlight for texture projection.
  139277. */
  139278. set projectionTextureLightNear(value: number);
  139279. protected _projectionTextureLightFar: number;
  139280. /**
  139281. * Gets the far clip of the Spotlight for texture projection.
  139282. */
  139283. get projectionTextureLightFar(): number;
  139284. /**
  139285. * Sets the far clip of the Spotlight for texture projection.
  139286. */
  139287. set projectionTextureLightFar(value: number);
  139288. protected _projectionTextureUpDirection: Vector3;
  139289. /**
  139290. * Gets the Up vector of the Spotlight for texture projection.
  139291. */
  139292. get projectionTextureUpDirection(): Vector3;
  139293. /**
  139294. * Sets the Up vector of the Spotlight for texture projection.
  139295. */
  139296. set projectionTextureUpDirection(value: Vector3);
  139297. private _projectionTexture;
  139298. /**
  139299. * Gets the projection texture of the light.
  139300. */
  139301. get projectionTexture(): Nullable<BaseTexture>;
  139302. /**
  139303. * Sets the projection texture of the light.
  139304. */
  139305. set projectionTexture(value: Nullable<BaseTexture>);
  139306. private static _IsProceduralTexture;
  139307. private static _IsTexture;
  139308. private _projectionTextureViewLightDirty;
  139309. private _projectionTextureProjectionLightDirty;
  139310. private _projectionTextureDirty;
  139311. private _projectionTextureViewTargetVector;
  139312. private _projectionTextureViewLightMatrix;
  139313. private _projectionTextureProjectionLightMatrix;
  139314. private _projectionTextureScalingMatrix;
  139315. /**
  139316. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  139317. * It can cast shadows.
  139318. * Documentation : https://doc.babylonjs.com/babylon101/lights
  139319. * @param name The light friendly name
  139320. * @param position The position of the spot light in the scene
  139321. * @param direction The direction of the light in the scene
  139322. * @param angle The cone angle of the light in Radians
  139323. * @param exponent The light decay speed with the distance from the emission spot
  139324. * @param scene The scene the lights belongs to
  139325. */
  139326. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  139327. /**
  139328. * Returns the string "SpotLight".
  139329. * @returns the class name
  139330. */
  139331. getClassName(): string;
  139332. /**
  139333. * Returns the integer 2.
  139334. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  139335. */
  139336. getTypeID(): number;
  139337. /**
  139338. * Overrides the direction setter to recompute the projection texture view light Matrix.
  139339. */
  139340. protected _setDirection(value: Vector3): void;
  139341. /**
  139342. * Overrides the position setter to recompute the projection texture view light Matrix.
  139343. */
  139344. protected _setPosition(value: Vector3): void;
  139345. /**
  139346. * 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.
  139347. * Returns the SpotLight.
  139348. */
  139349. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  139350. protected _computeProjectionTextureViewLightMatrix(): void;
  139351. protected _computeProjectionTextureProjectionLightMatrix(): void;
  139352. /**
  139353. * Main function for light texture projection matrix computing.
  139354. */
  139355. protected _computeProjectionTextureMatrix(): void;
  139356. protected _buildUniformLayout(): void;
  139357. private _computeAngleValues;
  139358. /**
  139359. * Sets the passed Effect "effect" with the Light textures.
  139360. * @param effect The effect to update
  139361. * @param lightIndex The index of the light in the effect to update
  139362. * @returns The light
  139363. */
  139364. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  139365. /**
  139366. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  139367. * @param effect The effect to update
  139368. * @param lightIndex The index of the light in the effect to update
  139369. * @returns The spot light
  139370. */
  139371. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  139372. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  139373. /**
  139374. * Disposes the light and the associated resources.
  139375. */
  139376. dispose(): void;
  139377. /**
  139378. * Prepares the list of defines specific to the light type.
  139379. * @param defines the list of defines
  139380. * @param lightIndex defines the index of the light for the effect
  139381. */
  139382. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  139383. }
  139384. }
  139385. declare module BABYLON {
  139386. /**
  139387. * Gizmo that enables viewing a light
  139388. */
  139389. export class LightGizmo extends Gizmo {
  139390. private _lightMesh;
  139391. private _material;
  139392. private _cachedPosition;
  139393. private _cachedForward;
  139394. private _attachedMeshParent;
  139395. private _pointerObserver;
  139396. /**
  139397. * Event that fires each time the gizmo is clicked
  139398. */
  139399. onClickedObservable: Observable<Light>;
  139400. /**
  139401. * Creates a LightGizmo
  139402. * @param gizmoLayer The utility layer the gizmo will be added to
  139403. */
  139404. constructor(gizmoLayer?: UtilityLayerRenderer);
  139405. private _light;
  139406. /**
  139407. * The light that the gizmo is attached to
  139408. */
  139409. set light(light: Nullable<Light>);
  139410. get light(): Nullable<Light>;
  139411. /**
  139412. * Gets the material used to render the light gizmo
  139413. */
  139414. get material(): StandardMaterial;
  139415. /**
  139416. * @hidden
  139417. * Updates the gizmo to match the attached mesh's position/rotation
  139418. */
  139419. protected _update(): void;
  139420. private static _Scale;
  139421. /**
  139422. * Creates the lines for a light mesh
  139423. */
  139424. private static _CreateLightLines;
  139425. /**
  139426. * Disposes of the light gizmo
  139427. */
  139428. dispose(): void;
  139429. private static _CreateHemisphericLightMesh;
  139430. private static _CreatePointLightMesh;
  139431. private static _CreateSpotLightMesh;
  139432. private static _CreateDirectionalLightMesh;
  139433. }
  139434. }
  139435. declare module BABYLON {
  139436. /**
  139437. * Gizmo that enables viewing a camera
  139438. */
  139439. export class CameraGizmo extends Gizmo {
  139440. private _cameraMesh;
  139441. private _cameraLinesMesh;
  139442. private _material;
  139443. private _pointerObserver;
  139444. /**
  139445. * Event that fires each time the gizmo is clicked
  139446. */
  139447. onClickedObservable: Observable<Camera>;
  139448. /**
  139449. * Creates a CameraGizmo
  139450. * @param gizmoLayer The utility layer the gizmo will be added to
  139451. */
  139452. constructor(gizmoLayer?: UtilityLayerRenderer);
  139453. private _camera;
  139454. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  139455. get displayFrustum(): boolean;
  139456. set displayFrustum(value: boolean);
  139457. /**
  139458. * The camera that the gizmo is attached to
  139459. */
  139460. set camera(camera: Nullable<Camera>);
  139461. get camera(): Nullable<Camera>;
  139462. /**
  139463. * Gets the material used to render the camera gizmo
  139464. */
  139465. get material(): StandardMaterial;
  139466. /**
  139467. * @hidden
  139468. * Updates the gizmo to match the attached mesh's position/rotation
  139469. */
  139470. protected _update(): void;
  139471. private static _Scale;
  139472. private _invProjection;
  139473. /**
  139474. * Disposes of the camera gizmo
  139475. */
  139476. dispose(): void;
  139477. private static _CreateCameraMesh;
  139478. private static _CreateCameraFrustum;
  139479. }
  139480. }
  139481. declare module BABYLON {
  139482. /** @hidden */
  139483. export var backgroundFragmentDeclaration: {
  139484. name: string;
  139485. shader: string;
  139486. };
  139487. }
  139488. declare module BABYLON {
  139489. /** @hidden */
  139490. export var backgroundUboDeclaration: {
  139491. name: string;
  139492. shader: string;
  139493. };
  139494. }
  139495. declare module BABYLON {
  139496. /** @hidden */
  139497. export var backgroundPixelShader: {
  139498. name: string;
  139499. shader: string;
  139500. };
  139501. }
  139502. declare module BABYLON {
  139503. /** @hidden */
  139504. export var backgroundVertexDeclaration: {
  139505. name: string;
  139506. shader: string;
  139507. };
  139508. }
  139509. declare module BABYLON {
  139510. /** @hidden */
  139511. export var backgroundVertexShader: {
  139512. name: string;
  139513. shader: string;
  139514. };
  139515. }
  139516. declare module BABYLON {
  139517. /**
  139518. * Background material used to create an efficient environement around your scene.
  139519. */
  139520. export class BackgroundMaterial extends PushMaterial {
  139521. /**
  139522. * Standard reflectance value at parallel view angle.
  139523. */
  139524. static StandardReflectance0: number;
  139525. /**
  139526. * Standard reflectance value at grazing angle.
  139527. */
  139528. static StandardReflectance90: number;
  139529. protected _primaryColor: Color3;
  139530. /**
  139531. * Key light Color (multiply against the environement texture)
  139532. */
  139533. primaryColor: Color3;
  139534. protected __perceptualColor: Nullable<Color3>;
  139535. /**
  139536. * Experimental Internal Use Only.
  139537. *
  139538. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  139539. * This acts as a helper to set the primary color to a more "human friendly" value.
  139540. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  139541. * output color as close as possible from the chosen value.
  139542. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  139543. * part of lighting setup.)
  139544. */
  139545. get _perceptualColor(): Nullable<Color3>;
  139546. set _perceptualColor(value: Nullable<Color3>);
  139547. protected _primaryColorShadowLevel: float;
  139548. /**
  139549. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  139550. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  139551. */
  139552. get primaryColorShadowLevel(): float;
  139553. set primaryColorShadowLevel(value: float);
  139554. protected _primaryColorHighlightLevel: float;
  139555. /**
  139556. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  139557. * The primary color is used at the level chosen to define what the white area would look.
  139558. */
  139559. get primaryColorHighlightLevel(): float;
  139560. set primaryColorHighlightLevel(value: float);
  139561. protected _reflectionTexture: Nullable<BaseTexture>;
  139562. /**
  139563. * Reflection Texture used in the material.
  139564. * Should be author in a specific way for the best result (refer to the documentation).
  139565. */
  139566. reflectionTexture: Nullable<BaseTexture>;
  139567. protected _reflectionBlur: float;
  139568. /**
  139569. * Reflection Texture level of blur.
  139570. *
  139571. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  139572. * texture twice.
  139573. */
  139574. reflectionBlur: float;
  139575. protected _diffuseTexture: Nullable<BaseTexture>;
  139576. /**
  139577. * Diffuse Texture used in the material.
  139578. * Should be author in a specific way for the best result (refer to the documentation).
  139579. */
  139580. diffuseTexture: Nullable<BaseTexture>;
  139581. protected _shadowLights: Nullable<IShadowLight[]>;
  139582. /**
  139583. * Specify the list of lights casting shadow on the material.
  139584. * All scene shadow lights will be included if null.
  139585. */
  139586. shadowLights: Nullable<IShadowLight[]>;
  139587. protected _shadowLevel: float;
  139588. /**
  139589. * Helps adjusting the shadow to a softer level if required.
  139590. * 0 means black shadows and 1 means no shadows.
  139591. */
  139592. shadowLevel: float;
  139593. protected _sceneCenter: Vector3;
  139594. /**
  139595. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  139596. * It is usually zero but might be interesting to modify according to your setup.
  139597. */
  139598. sceneCenter: Vector3;
  139599. protected _opacityFresnel: boolean;
  139600. /**
  139601. * This helps specifying that the material is falling off to the sky box at grazing angle.
  139602. * This helps ensuring a nice transition when the camera goes under the ground.
  139603. */
  139604. opacityFresnel: boolean;
  139605. protected _reflectionFresnel: boolean;
  139606. /**
  139607. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  139608. * This helps adding a mirror texture on the ground.
  139609. */
  139610. reflectionFresnel: boolean;
  139611. protected _reflectionFalloffDistance: number;
  139612. /**
  139613. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  139614. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  139615. */
  139616. reflectionFalloffDistance: number;
  139617. protected _reflectionAmount: number;
  139618. /**
  139619. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  139620. */
  139621. reflectionAmount: number;
  139622. protected _reflectionReflectance0: number;
  139623. /**
  139624. * This specifies the weight of the reflection at grazing angle.
  139625. */
  139626. reflectionReflectance0: number;
  139627. protected _reflectionReflectance90: number;
  139628. /**
  139629. * This specifies the weight of the reflection at a perpendicular point of view.
  139630. */
  139631. reflectionReflectance90: number;
  139632. /**
  139633. * Sets the reflection reflectance fresnel values according to the default standard
  139634. * empirically know to work well :-)
  139635. */
  139636. set reflectionStandardFresnelWeight(value: number);
  139637. protected _useRGBColor: boolean;
  139638. /**
  139639. * Helps to directly use the maps channels instead of their level.
  139640. */
  139641. useRGBColor: boolean;
  139642. protected _enableNoise: boolean;
  139643. /**
  139644. * This helps reducing the banding effect that could occur on the background.
  139645. */
  139646. enableNoise: boolean;
  139647. /**
  139648. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  139649. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  139650. * Recommended to be keep at 1.0 except for special cases.
  139651. */
  139652. get fovMultiplier(): number;
  139653. set fovMultiplier(value: number);
  139654. private _fovMultiplier;
  139655. /**
  139656. * Enable the FOV adjustment feature controlled by fovMultiplier.
  139657. */
  139658. useEquirectangularFOV: boolean;
  139659. private _maxSimultaneousLights;
  139660. /**
  139661. * Number of Simultaneous lights allowed on the material.
  139662. */
  139663. maxSimultaneousLights: int;
  139664. private _shadowOnly;
  139665. /**
  139666. * Make the material only render shadows
  139667. */
  139668. shadowOnly: boolean;
  139669. /**
  139670. * Default configuration related to image processing available in the Background Material.
  139671. */
  139672. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  139673. /**
  139674. * Keep track of the image processing observer to allow dispose and replace.
  139675. */
  139676. private _imageProcessingObserver;
  139677. /**
  139678. * Attaches a new image processing configuration to the PBR Material.
  139679. * @param configuration (if null the scene configuration will be use)
  139680. */
  139681. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  139682. /**
  139683. * Gets the image processing configuration used either in this material.
  139684. */
  139685. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  139686. /**
  139687. * Sets the Default image processing configuration used either in the this material.
  139688. *
  139689. * If sets to null, the scene one is in use.
  139690. */
  139691. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  139692. /**
  139693. * Gets wether the color curves effect is enabled.
  139694. */
  139695. get cameraColorCurvesEnabled(): boolean;
  139696. /**
  139697. * Sets wether the color curves effect is enabled.
  139698. */
  139699. set cameraColorCurvesEnabled(value: boolean);
  139700. /**
  139701. * Gets wether the color grading effect is enabled.
  139702. */
  139703. get cameraColorGradingEnabled(): boolean;
  139704. /**
  139705. * Gets wether the color grading effect is enabled.
  139706. */
  139707. set cameraColorGradingEnabled(value: boolean);
  139708. /**
  139709. * Gets wether tonemapping is enabled or not.
  139710. */
  139711. get cameraToneMappingEnabled(): boolean;
  139712. /**
  139713. * Sets wether tonemapping is enabled or not
  139714. */
  139715. set cameraToneMappingEnabled(value: boolean);
  139716. /**
  139717. * The camera exposure used on this material.
  139718. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  139719. * This corresponds to a photographic exposure.
  139720. */
  139721. get cameraExposure(): float;
  139722. /**
  139723. * The camera exposure used on this material.
  139724. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  139725. * This corresponds to a photographic exposure.
  139726. */
  139727. set cameraExposure(value: float);
  139728. /**
  139729. * Gets The camera contrast used on this material.
  139730. */
  139731. get cameraContrast(): float;
  139732. /**
  139733. * Sets The camera contrast used on this material.
  139734. */
  139735. set cameraContrast(value: float);
  139736. /**
  139737. * Gets the Color Grading 2D Lookup Texture.
  139738. */
  139739. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  139740. /**
  139741. * Sets the Color Grading 2D Lookup Texture.
  139742. */
  139743. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  139744. /**
  139745. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  139746. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  139747. * 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;
  139748. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  139749. */
  139750. get cameraColorCurves(): Nullable<ColorCurves>;
  139751. /**
  139752. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  139753. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  139754. * 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;
  139755. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  139756. */
  139757. set cameraColorCurves(value: Nullable<ColorCurves>);
  139758. /**
  139759. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  139760. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  139761. */
  139762. switchToBGR: boolean;
  139763. private _renderTargets;
  139764. private _reflectionControls;
  139765. private _white;
  139766. private _primaryShadowColor;
  139767. private _primaryHighlightColor;
  139768. /**
  139769. * Instantiates a Background Material in the given scene
  139770. * @param name The friendly name of the material
  139771. * @param scene The scene to add the material to
  139772. */
  139773. constructor(name: string, scene: Scene);
  139774. /**
  139775. * Gets a boolean indicating that current material needs to register RTT
  139776. */
  139777. get hasRenderTargetTextures(): boolean;
  139778. /**
  139779. * The entire material has been created in order to prevent overdraw.
  139780. * @returns false
  139781. */
  139782. needAlphaTesting(): boolean;
  139783. /**
  139784. * The entire material has been created in order to prevent overdraw.
  139785. * @returns true if blending is enable
  139786. */
  139787. needAlphaBlending(): boolean;
  139788. /**
  139789. * Checks wether the material is ready to be rendered for a given mesh.
  139790. * @param mesh The mesh to render
  139791. * @param subMesh The submesh to check against
  139792. * @param useInstances Specify wether or not the material is used with instances
  139793. * @returns true if all the dependencies are ready (Textures, Effects...)
  139794. */
  139795. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  139796. /**
  139797. * Compute the primary color according to the chosen perceptual color.
  139798. */
  139799. private _computePrimaryColorFromPerceptualColor;
  139800. /**
  139801. * Compute the highlights and shadow colors according to their chosen levels.
  139802. */
  139803. private _computePrimaryColors;
  139804. /**
  139805. * Build the uniform buffer used in the material.
  139806. */
  139807. buildUniformLayout(): void;
  139808. /**
  139809. * Unbind the material.
  139810. */
  139811. unbind(): void;
  139812. /**
  139813. * Bind only the world matrix to the material.
  139814. * @param world The world matrix to bind.
  139815. */
  139816. bindOnlyWorldMatrix(world: Matrix): void;
  139817. /**
  139818. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  139819. * @param world The world matrix to bind.
  139820. * @param subMesh The submesh to bind for.
  139821. */
  139822. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  139823. /**
  139824. * Checks to see if a texture is used in the material.
  139825. * @param texture - Base texture to use.
  139826. * @returns - Boolean specifying if a texture is used in the material.
  139827. */
  139828. hasTexture(texture: BaseTexture): boolean;
  139829. /**
  139830. * Dispose the material.
  139831. * @param forceDisposeEffect Force disposal of the associated effect.
  139832. * @param forceDisposeTextures Force disposal of the associated textures.
  139833. */
  139834. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  139835. /**
  139836. * Clones the material.
  139837. * @param name The cloned name.
  139838. * @returns The cloned material.
  139839. */
  139840. clone(name: string): BackgroundMaterial;
  139841. /**
  139842. * Serializes the current material to its JSON representation.
  139843. * @returns The JSON representation.
  139844. */
  139845. serialize(): any;
  139846. /**
  139847. * Gets the class name of the material
  139848. * @returns "BackgroundMaterial"
  139849. */
  139850. getClassName(): string;
  139851. /**
  139852. * Parse a JSON input to create back a background material.
  139853. * @param source The JSON data to parse
  139854. * @param scene The scene to create the parsed material in
  139855. * @param rootUrl The root url of the assets the material depends upon
  139856. * @returns the instantiated BackgroundMaterial.
  139857. */
  139858. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  139859. }
  139860. }
  139861. declare module BABYLON {
  139862. /**
  139863. * Represents the different options available during the creation of
  139864. * a Environment helper.
  139865. *
  139866. * This can control the default ground, skybox and image processing setup of your scene.
  139867. */
  139868. export interface IEnvironmentHelperOptions {
  139869. /**
  139870. * Specifies whether or not to create a ground.
  139871. * True by default.
  139872. */
  139873. createGround: boolean;
  139874. /**
  139875. * Specifies the ground size.
  139876. * 15 by default.
  139877. */
  139878. groundSize: number;
  139879. /**
  139880. * The texture used on the ground for the main color.
  139881. * Comes from the BabylonJS CDN by default.
  139882. *
  139883. * Remarks: Can be either a texture or a url.
  139884. */
  139885. groundTexture: string | BaseTexture;
  139886. /**
  139887. * The color mixed in the ground texture by default.
  139888. * BabylonJS clearColor by default.
  139889. */
  139890. groundColor: Color3;
  139891. /**
  139892. * Specifies the ground opacity.
  139893. * 1 by default.
  139894. */
  139895. groundOpacity: number;
  139896. /**
  139897. * Enables the ground to receive shadows.
  139898. * True by default.
  139899. */
  139900. enableGroundShadow: boolean;
  139901. /**
  139902. * Helps preventing the shadow to be fully black on the ground.
  139903. * 0.5 by default.
  139904. */
  139905. groundShadowLevel: number;
  139906. /**
  139907. * Creates a mirror texture attach to the ground.
  139908. * false by default.
  139909. */
  139910. enableGroundMirror: boolean;
  139911. /**
  139912. * Specifies the ground mirror size ratio.
  139913. * 0.3 by default as the default kernel is 64.
  139914. */
  139915. groundMirrorSizeRatio: number;
  139916. /**
  139917. * Specifies the ground mirror blur kernel size.
  139918. * 64 by default.
  139919. */
  139920. groundMirrorBlurKernel: number;
  139921. /**
  139922. * Specifies the ground mirror visibility amount.
  139923. * 1 by default
  139924. */
  139925. groundMirrorAmount: number;
  139926. /**
  139927. * Specifies the ground mirror reflectance weight.
  139928. * This uses the standard weight of the background material to setup the fresnel effect
  139929. * of the mirror.
  139930. * 1 by default.
  139931. */
  139932. groundMirrorFresnelWeight: number;
  139933. /**
  139934. * Specifies the ground mirror Falloff distance.
  139935. * This can helps reducing the size of the reflection.
  139936. * 0 by Default.
  139937. */
  139938. groundMirrorFallOffDistance: number;
  139939. /**
  139940. * Specifies the ground mirror texture type.
  139941. * Unsigned Int by Default.
  139942. */
  139943. groundMirrorTextureType: number;
  139944. /**
  139945. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  139946. * the shown objects.
  139947. */
  139948. groundYBias: number;
  139949. /**
  139950. * Specifies whether or not to create a skybox.
  139951. * True by default.
  139952. */
  139953. createSkybox: boolean;
  139954. /**
  139955. * Specifies the skybox size.
  139956. * 20 by default.
  139957. */
  139958. skyboxSize: number;
  139959. /**
  139960. * The texture used on the skybox for the main color.
  139961. * Comes from the BabylonJS CDN by default.
  139962. *
  139963. * Remarks: Can be either a texture or a url.
  139964. */
  139965. skyboxTexture: string | BaseTexture;
  139966. /**
  139967. * The color mixed in the skybox texture by default.
  139968. * BabylonJS clearColor by default.
  139969. */
  139970. skyboxColor: Color3;
  139971. /**
  139972. * The background rotation around the Y axis of the scene.
  139973. * This helps aligning the key lights of your scene with the background.
  139974. * 0 by default.
  139975. */
  139976. backgroundYRotation: number;
  139977. /**
  139978. * Compute automatically the size of the elements to best fit with the scene.
  139979. */
  139980. sizeAuto: boolean;
  139981. /**
  139982. * Default position of the rootMesh if autoSize is not true.
  139983. */
  139984. rootPosition: Vector3;
  139985. /**
  139986. * Sets up the image processing in the scene.
  139987. * true by default.
  139988. */
  139989. setupImageProcessing: boolean;
  139990. /**
  139991. * The texture used as your environment texture in the scene.
  139992. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  139993. *
  139994. * Remarks: Can be either a texture or a url.
  139995. */
  139996. environmentTexture: string | BaseTexture;
  139997. /**
  139998. * The value of the exposure to apply to the scene.
  139999. * 0.6 by default if setupImageProcessing is true.
  140000. */
  140001. cameraExposure: number;
  140002. /**
  140003. * The value of the contrast to apply to the scene.
  140004. * 1.6 by default if setupImageProcessing is true.
  140005. */
  140006. cameraContrast: number;
  140007. /**
  140008. * Specifies whether or not tonemapping should be enabled in the scene.
  140009. * true by default if setupImageProcessing is true.
  140010. */
  140011. toneMappingEnabled: boolean;
  140012. }
  140013. /**
  140014. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  140015. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  140016. * It also helps with the default setup of your imageProcessing configuration.
  140017. */
  140018. export class EnvironmentHelper {
  140019. /**
  140020. * Default ground texture URL.
  140021. */
  140022. private static _groundTextureCDNUrl;
  140023. /**
  140024. * Default skybox texture URL.
  140025. */
  140026. private static _skyboxTextureCDNUrl;
  140027. /**
  140028. * Default environment texture URL.
  140029. */
  140030. private static _environmentTextureCDNUrl;
  140031. /**
  140032. * Creates the default options for the helper.
  140033. */
  140034. private static _getDefaultOptions;
  140035. private _rootMesh;
  140036. /**
  140037. * Gets the root mesh created by the helper.
  140038. */
  140039. get rootMesh(): Mesh;
  140040. private _skybox;
  140041. /**
  140042. * Gets the skybox created by the helper.
  140043. */
  140044. get skybox(): Nullable<Mesh>;
  140045. private _skyboxTexture;
  140046. /**
  140047. * Gets the skybox texture created by the helper.
  140048. */
  140049. get skyboxTexture(): Nullable<BaseTexture>;
  140050. private _skyboxMaterial;
  140051. /**
  140052. * Gets the skybox material created by the helper.
  140053. */
  140054. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  140055. private _ground;
  140056. /**
  140057. * Gets the ground mesh created by the helper.
  140058. */
  140059. get ground(): Nullable<Mesh>;
  140060. private _groundTexture;
  140061. /**
  140062. * Gets the ground texture created by the helper.
  140063. */
  140064. get groundTexture(): Nullable<BaseTexture>;
  140065. private _groundMirror;
  140066. /**
  140067. * Gets the ground mirror created by the helper.
  140068. */
  140069. get groundMirror(): Nullable<MirrorTexture>;
  140070. /**
  140071. * Gets the ground mirror render list to helps pushing the meshes
  140072. * you wish in the ground reflection.
  140073. */
  140074. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  140075. private _groundMaterial;
  140076. /**
  140077. * Gets the ground material created by the helper.
  140078. */
  140079. get groundMaterial(): Nullable<BackgroundMaterial>;
  140080. /**
  140081. * Stores the creation options.
  140082. */
  140083. private readonly _scene;
  140084. private _options;
  140085. /**
  140086. * This observable will be notified with any error during the creation of the environment,
  140087. * mainly texture creation errors.
  140088. */
  140089. onErrorObservable: Observable<{
  140090. message?: string;
  140091. exception?: any;
  140092. }>;
  140093. /**
  140094. * constructor
  140095. * @param options Defines the options we want to customize the helper
  140096. * @param scene The scene to add the material to
  140097. */
  140098. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  140099. /**
  140100. * Updates the background according to the new options
  140101. * @param options
  140102. */
  140103. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  140104. /**
  140105. * Sets the primary color of all the available elements.
  140106. * @param color the main color to affect to the ground and the background
  140107. */
  140108. setMainColor(color: Color3): void;
  140109. /**
  140110. * Setup the image processing according to the specified options.
  140111. */
  140112. private _setupImageProcessing;
  140113. /**
  140114. * Setup the environment texture according to the specified options.
  140115. */
  140116. private _setupEnvironmentTexture;
  140117. /**
  140118. * Setup the background according to the specified options.
  140119. */
  140120. private _setupBackground;
  140121. /**
  140122. * Get the scene sizes according to the setup.
  140123. */
  140124. private _getSceneSize;
  140125. /**
  140126. * Setup the ground according to the specified options.
  140127. */
  140128. private _setupGround;
  140129. /**
  140130. * Setup the ground material according to the specified options.
  140131. */
  140132. private _setupGroundMaterial;
  140133. /**
  140134. * Setup the ground diffuse texture according to the specified options.
  140135. */
  140136. private _setupGroundDiffuseTexture;
  140137. /**
  140138. * Setup the ground mirror texture according to the specified options.
  140139. */
  140140. private _setupGroundMirrorTexture;
  140141. /**
  140142. * Setup the ground to receive the mirror texture.
  140143. */
  140144. private _setupMirrorInGroundMaterial;
  140145. /**
  140146. * Setup the skybox according to the specified options.
  140147. */
  140148. private _setupSkybox;
  140149. /**
  140150. * Setup the skybox material according to the specified options.
  140151. */
  140152. private _setupSkyboxMaterial;
  140153. /**
  140154. * Setup the skybox reflection texture according to the specified options.
  140155. */
  140156. private _setupSkyboxReflectionTexture;
  140157. private _errorHandler;
  140158. /**
  140159. * Dispose all the elements created by the Helper.
  140160. */
  140161. dispose(): void;
  140162. }
  140163. }
  140164. declare module BABYLON {
  140165. /**
  140166. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  140167. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  140168. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  140169. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  140170. */
  140171. export abstract class TextureDome<T extends Texture> extends TransformNode {
  140172. protected onError: Nullable<(message?: string, exception?: any) => void>;
  140173. /**
  140174. * Define the source as a Monoscopic panoramic 360/180.
  140175. */
  140176. static readonly MODE_MONOSCOPIC: number;
  140177. /**
  140178. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  140179. */
  140180. static readonly MODE_TOPBOTTOM: number;
  140181. /**
  140182. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  140183. */
  140184. static readonly MODE_SIDEBYSIDE: number;
  140185. private _halfDome;
  140186. private _crossEye;
  140187. protected _useDirectMapping: boolean;
  140188. /**
  140189. * The texture being displayed on the sphere
  140190. */
  140191. protected _texture: T;
  140192. /**
  140193. * Gets the texture being displayed on the sphere
  140194. */
  140195. get texture(): T;
  140196. /**
  140197. * Sets the texture being displayed on the sphere
  140198. */
  140199. set texture(newTexture: T);
  140200. /**
  140201. * The skybox material
  140202. */
  140203. protected _material: BackgroundMaterial;
  140204. /**
  140205. * The surface used for the dome
  140206. */
  140207. protected _mesh: Mesh;
  140208. /**
  140209. * Gets the mesh used for the dome.
  140210. */
  140211. get mesh(): Mesh;
  140212. /**
  140213. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  140214. */
  140215. private _halfDomeMask;
  140216. /**
  140217. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  140218. * Also see the options.resolution property.
  140219. */
  140220. get fovMultiplier(): number;
  140221. set fovMultiplier(value: number);
  140222. protected _textureMode: number;
  140223. /**
  140224. * Gets or set the current texture mode for the texture. It can be:
  140225. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  140226. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  140227. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  140228. */
  140229. get textureMode(): number;
  140230. /**
  140231. * Sets the current texture mode for the texture. It can be:
  140232. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  140233. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  140234. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  140235. */
  140236. set textureMode(value: number);
  140237. /**
  140238. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  140239. */
  140240. get halfDome(): boolean;
  140241. /**
  140242. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  140243. */
  140244. set halfDome(enabled: boolean);
  140245. /**
  140246. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  140247. */
  140248. set crossEye(enabled: boolean);
  140249. /**
  140250. * Is it a cross-eye texture?
  140251. */
  140252. get crossEye(): boolean;
  140253. /**
  140254. * The background material of this dome.
  140255. */
  140256. get material(): BackgroundMaterial;
  140257. /**
  140258. * Oberserver used in Stereoscopic VR Mode.
  140259. */
  140260. private _onBeforeCameraRenderObserver;
  140261. /**
  140262. * Observable raised when an error occured while loading the 360 image
  140263. */
  140264. onLoadErrorObservable: Observable<string>;
  140265. /**
  140266. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  140267. * @param name Element's name, child elements will append suffixes for their own names.
  140268. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  140269. * @param options An object containing optional or exposed sub element properties
  140270. */
  140271. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  140272. resolution?: number;
  140273. clickToPlay?: boolean;
  140274. autoPlay?: boolean;
  140275. loop?: boolean;
  140276. size?: number;
  140277. poster?: string;
  140278. faceForward?: boolean;
  140279. useDirectMapping?: boolean;
  140280. halfDomeMode?: boolean;
  140281. crossEyeMode?: boolean;
  140282. generateMipMaps?: boolean;
  140283. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  140284. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  140285. protected _changeTextureMode(value: number): void;
  140286. /**
  140287. * Releases resources associated with this node.
  140288. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  140289. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  140290. */
  140291. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  140292. }
  140293. }
  140294. declare module BABYLON {
  140295. /**
  140296. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  140297. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  140298. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  140299. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  140300. */
  140301. export class PhotoDome extends TextureDome<Texture> {
  140302. /**
  140303. * Define the image as a Monoscopic panoramic 360 image.
  140304. */
  140305. static readonly MODE_MONOSCOPIC: number;
  140306. /**
  140307. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  140308. */
  140309. static readonly MODE_TOPBOTTOM: number;
  140310. /**
  140311. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  140312. */
  140313. static readonly MODE_SIDEBYSIDE: number;
  140314. /**
  140315. * Gets or sets the texture being displayed on the sphere
  140316. */
  140317. get photoTexture(): Texture;
  140318. /**
  140319. * sets the texture being displayed on the sphere
  140320. */
  140321. set photoTexture(value: Texture);
  140322. /**
  140323. * Gets the current video mode for the video. It can be:
  140324. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  140325. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  140326. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  140327. */
  140328. get imageMode(): number;
  140329. /**
  140330. * Sets the current video mode for the video. It can be:
  140331. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  140332. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  140333. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  140334. */
  140335. set imageMode(value: number);
  140336. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  140337. }
  140338. }
  140339. declare module BABYLON {
  140340. /**
  140341. * Direct draw surface info
  140342. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  140343. */
  140344. export interface DDSInfo {
  140345. /**
  140346. * Width of the texture
  140347. */
  140348. width: number;
  140349. /**
  140350. * Width of the texture
  140351. */
  140352. height: number;
  140353. /**
  140354. * Number of Mipmaps for the texture
  140355. * @see https://en.wikipedia.org/wiki/Mipmap
  140356. */
  140357. mipmapCount: number;
  140358. /**
  140359. * If the textures format is a known fourCC format
  140360. * @see https://www.fourcc.org/
  140361. */
  140362. isFourCC: boolean;
  140363. /**
  140364. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  140365. */
  140366. isRGB: boolean;
  140367. /**
  140368. * If the texture is a lumincance format
  140369. */
  140370. isLuminance: boolean;
  140371. /**
  140372. * If this is a cube texture
  140373. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  140374. */
  140375. isCube: boolean;
  140376. /**
  140377. * If the texture is a compressed format eg. FOURCC_DXT1
  140378. */
  140379. isCompressed: boolean;
  140380. /**
  140381. * The dxgiFormat of the texture
  140382. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  140383. */
  140384. dxgiFormat: number;
  140385. /**
  140386. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  140387. */
  140388. textureType: number;
  140389. /**
  140390. * Sphericle polynomial created for the dds texture
  140391. */
  140392. sphericalPolynomial?: SphericalPolynomial;
  140393. }
  140394. /**
  140395. * Class used to provide DDS decompression tools
  140396. */
  140397. export class DDSTools {
  140398. /**
  140399. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  140400. */
  140401. static StoreLODInAlphaChannel: boolean;
  140402. /**
  140403. * Gets DDS information from an array buffer
  140404. * @param data defines the array buffer view to read data from
  140405. * @returns the DDS information
  140406. */
  140407. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  140408. private static _FloatView;
  140409. private static _Int32View;
  140410. private static _ToHalfFloat;
  140411. private static _FromHalfFloat;
  140412. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  140413. private static _GetHalfFloatRGBAArrayBuffer;
  140414. private static _GetFloatRGBAArrayBuffer;
  140415. private static _GetFloatAsUIntRGBAArrayBuffer;
  140416. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  140417. private static _GetRGBAArrayBuffer;
  140418. private static _ExtractLongWordOrder;
  140419. private static _GetRGBArrayBuffer;
  140420. private static _GetLuminanceArrayBuffer;
  140421. /**
  140422. * Uploads DDS Levels to a Babylon Texture
  140423. * @hidden
  140424. */
  140425. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  140426. }
  140427. interface ThinEngine {
  140428. /**
  140429. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  140430. * @param rootUrl defines the url where the file to load is located
  140431. * @param scene defines the current scene
  140432. * @param lodScale defines scale to apply to the mip map selection
  140433. * @param lodOffset defines offset to apply to the mip map selection
  140434. * @param onLoad defines an optional callback raised when the texture is loaded
  140435. * @param onError defines an optional callback raised if there is an issue to load the texture
  140436. * @param format defines the format of the data
  140437. * @param forcedExtension defines the extension to use to pick the right loader
  140438. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  140439. * @returns the cube texture as an InternalTexture
  140440. */
  140441. 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;
  140442. }
  140443. }
  140444. declare module BABYLON {
  140445. /**
  140446. * Implementation of the DDS Texture Loader.
  140447. * @hidden
  140448. */
  140449. export class _DDSTextureLoader implements IInternalTextureLoader {
  140450. /**
  140451. * Defines wether the loader supports cascade loading the different faces.
  140452. */
  140453. readonly supportCascades: boolean;
  140454. /**
  140455. * This returns if the loader support the current file information.
  140456. * @param extension defines the file extension of the file being loaded
  140457. * @returns true if the loader can load the specified file
  140458. */
  140459. canLoad(extension: string): boolean;
  140460. /**
  140461. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140462. * @param data contains the texture data
  140463. * @param texture defines the BabylonJS internal texture
  140464. * @param createPolynomials will be true if polynomials have been requested
  140465. * @param onLoad defines the callback to trigger once the texture is ready
  140466. * @param onError defines the callback to trigger in case of error
  140467. */
  140468. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140469. /**
  140470. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140471. * @param data contains the texture data
  140472. * @param texture defines the BabylonJS internal texture
  140473. * @param callback defines the method to call once ready to upload
  140474. */
  140475. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140476. }
  140477. }
  140478. declare module BABYLON {
  140479. /**
  140480. * Implementation of the ENV Texture Loader.
  140481. * @hidden
  140482. */
  140483. export class _ENVTextureLoader implements IInternalTextureLoader {
  140484. /**
  140485. * Defines wether the loader supports cascade loading the different faces.
  140486. */
  140487. readonly supportCascades: boolean;
  140488. /**
  140489. * This returns if the loader support the current file information.
  140490. * @param extension defines the file extension of the file being loaded
  140491. * @returns true if the loader can load the specified file
  140492. */
  140493. canLoad(extension: string): boolean;
  140494. /**
  140495. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140496. * @param data contains the texture data
  140497. * @param texture defines the BabylonJS internal texture
  140498. * @param createPolynomials will be true if polynomials have been requested
  140499. * @param onLoad defines the callback to trigger once the texture is ready
  140500. * @param onError defines the callback to trigger in case of error
  140501. */
  140502. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140503. /**
  140504. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140505. * @param data contains the texture data
  140506. * @param texture defines the BabylonJS internal texture
  140507. * @param callback defines the method to call once ready to upload
  140508. */
  140509. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140510. }
  140511. }
  140512. declare module BABYLON {
  140513. /**
  140514. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  140515. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  140516. */
  140517. export class KhronosTextureContainer {
  140518. /** contents of the KTX container file */
  140519. data: ArrayBufferView;
  140520. private static HEADER_LEN;
  140521. private static COMPRESSED_2D;
  140522. private static COMPRESSED_3D;
  140523. private static TEX_2D;
  140524. private static TEX_3D;
  140525. /**
  140526. * Gets the openGL type
  140527. */
  140528. glType: number;
  140529. /**
  140530. * Gets the openGL type size
  140531. */
  140532. glTypeSize: number;
  140533. /**
  140534. * Gets the openGL format
  140535. */
  140536. glFormat: number;
  140537. /**
  140538. * Gets the openGL internal format
  140539. */
  140540. glInternalFormat: number;
  140541. /**
  140542. * Gets the base internal format
  140543. */
  140544. glBaseInternalFormat: number;
  140545. /**
  140546. * Gets image width in pixel
  140547. */
  140548. pixelWidth: number;
  140549. /**
  140550. * Gets image height in pixel
  140551. */
  140552. pixelHeight: number;
  140553. /**
  140554. * Gets image depth in pixels
  140555. */
  140556. pixelDepth: number;
  140557. /**
  140558. * Gets the number of array elements
  140559. */
  140560. numberOfArrayElements: number;
  140561. /**
  140562. * Gets the number of faces
  140563. */
  140564. numberOfFaces: number;
  140565. /**
  140566. * Gets the number of mipmap levels
  140567. */
  140568. numberOfMipmapLevels: number;
  140569. /**
  140570. * Gets the bytes of key value data
  140571. */
  140572. bytesOfKeyValueData: number;
  140573. /**
  140574. * Gets the load type
  140575. */
  140576. loadType: number;
  140577. /**
  140578. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  140579. */
  140580. isInvalid: boolean;
  140581. /**
  140582. * Creates a new KhronosTextureContainer
  140583. * @param data contents of the KTX container file
  140584. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  140585. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  140586. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  140587. */
  140588. constructor(
  140589. /** contents of the KTX container file */
  140590. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  140591. /**
  140592. * Uploads KTX content to a Babylon Texture.
  140593. * It is assumed that the texture has already been created & is currently bound
  140594. * @hidden
  140595. */
  140596. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  140597. private _upload2DCompressedLevels;
  140598. /**
  140599. * Checks if the given data starts with a KTX file identifier.
  140600. * @param data the data to check
  140601. * @returns true if the data is a KTX file or false otherwise
  140602. */
  140603. static IsValid(data: ArrayBufferView): boolean;
  140604. }
  140605. }
  140606. declare module BABYLON {
  140607. /**
  140608. * Helper class to push actions to a pool of workers.
  140609. */
  140610. export class WorkerPool implements IDisposable {
  140611. private _workerInfos;
  140612. private _pendingActions;
  140613. /**
  140614. * Constructor
  140615. * @param workers Array of workers to use for actions
  140616. */
  140617. constructor(workers: Array<Worker>);
  140618. /**
  140619. * Terminates all workers and clears any pending actions.
  140620. */
  140621. dispose(): void;
  140622. /**
  140623. * Pushes an action to the worker pool. If all the workers are active, the action will be
  140624. * pended until a worker has completed its action.
  140625. * @param action The action to perform. Call onComplete when the action is complete.
  140626. */
  140627. push(action: (worker: Worker, onComplete: () => void) => void): void;
  140628. private _execute;
  140629. }
  140630. }
  140631. declare module BABYLON {
  140632. /**
  140633. * Class for loading KTX2 files
  140634. */
  140635. export class KhronosTextureContainer2 {
  140636. private static _WorkerPoolPromise?;
  140637. private static _Initialized;
  140638. private static _Ktx2Decoder;
  140639. /**
  140640. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  140641. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  140642. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  140643. * Urls you can change:
  140644. * URLConfig.jsDecoderModule
  140645. * URLConfig.wasmUASTCToASTC
  140646. * URLConfig.wasmUASTCToBC7
  140647. * URLConfig.wasmUASTCToRGBA_UNORM
  140648. * URLConfig.wasmUASTCToRGBA_SRGB
  140649. * URLConfig.jsMSCTranscoder
  140650. * URLConfig.wasmMSCTranscoder
  140651. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  140652. */
  140653. static URLConfig: {
  140654. jsDecoderModule: string;
  140655. wasmUASTCToASTC: null;
  140656. wasmUASTCToBC7: null;
  140657. wasmUASTCToRGBA_UNORM: null;
  140658. wasmUASTCToRGBA_SRGB: null;
  140659. jsMSCTranscoder: null;
  140660. wasmMSCTranscoder: null;
  140661. };
  140662. /**
  140663. * Default number of workers used to handle data decoding
  140664. */
  140665. static DefaultNumWorkers: number;
  140666. private static GetDefaultNumWorkers;
  140667. private _engine;
  140668. private static _CreateWorkerPool;
  140669. /**
  140670. * Constructor
  140671. * @param engine The engine to use
  140672. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  140673. */
  140674. constructor(engine: ThinEngine, numWorkers?: number);
  140675. /** @hidden */
  140676. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  140677. /**
  140678. * Stop all async operations and release resources.
  140679. */
  140680. dispose(): void;
  140681. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  140682. /**
  140683. * Checks if the given data starts with a KTX2 file identifier.
  140684. * @param data the data to check
  140685. * @returns true if the data is a KTX2 file or false otherwise
  140686. */
  140687. static IsValid(data: ArrayBufferView): boolean;
  140688. }
  140689. }
  140690. declare module BABYLON {
  140691. /**
  140692. * Implementation of the KTX Texture Loader.
  140693. * @hidden
  140694. */
  140695. export class _KTXTextureLoader implements IInternalTextureLoader {
  140696. /**
  140697. * Defines wether the loader supports cascade loading the different faces.
  140698. */
  140699. readonly supportCascades: boolean;
  140700. /**
  140701. * This returns if the loader support the current file information.
  140702. * @param extension defines the file extension of the file being loaded
  140703. * @param mimeType defines the optional mime type of the file being loaded
  140704. * @returns true if the loader can load the specified file
  140705. */
  140706. canLoad(extension: string, mimeType?: string): boolean;
  140707. /**
  140708. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140709. * @param data contains the texture data
  140710. * @param texture defines the BabylonJS internal texture
  140711. * @param createPolynomials will be true if polynomials have been requested
  140712. * @param onLoad defines the callback to trigger once the texture is ready
  140713. * @param onError defines the callback to trigger in case of error
  140714. */
  140715. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140716. /**
  140717. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140718. * @param data contains the texture data
  140719. * @param texture defines the BabylonJS internal texture
  140720. * @param callback defines the method to call once ready to upload
  140721. */
  140722. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  140723. }
  140724. }
  140725. declare module BABYLON {
  140726. /** @hidden */
  140727. export var _forceSceneHelpersToBundle: boolean;
  140728. interface Scene {
  140729. /**
  140730. * Creates a default light for the scene.
  140731. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  140732. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  140733. */
  140734. createDefaultLight(replace?: boolean): void;
  140735. /**
  140736. * Creates a default camera for the scene.
  140737. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  140738. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  140739. * @param replace has default false, when true replaces the active camera in the scene
  140740. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  140741. */
  140742. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  140743. /**
  140744. * Creates a default camera and a default light.
  140745. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  140746. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  140747. * @param replace has the default false, when true replaces the active camera/light in the scene
  140748. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  140749. */
  140750. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  140751. /**
  140752. * Creates a new sky box
  140753. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  140754. * @param environmentTexture defines the texture to use as environment texture
  140755. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  140756. * @param scale defines the overall scale of the skybox
  140757. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  140758. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  140759. * @returns a new mesh holding the sky box
  140760. */
  140761. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  140762. /**
  140763. * Creates a new environment
  140764. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  140765. * @param options defines the options you can use to configure the environment
  140766. * @returns the new EnvironmentHelper
  140767. */
  140768. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  140769. /**
  140770. * Creates a new VREXperienceHelper
  140771. * @see https://doc.babylonjs.com/how_to/webvr_helper
  140772. * @param webVROptions defines the options used to create the new VREXperienceHelper
  140773. * @returns a new VREXperienceHelper
  140774. */
  140775. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  140776. /**
  140777. * Creates a new WebXRDefaultExperience
  140778. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  140779. * @param options experience options
  140780. * @returns a promise for a new WebXRDefaultExperience
  140781. */
  140782. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  140783. }
  140784. }
  140785. declare module BABYLON {
  140786. /**
  140787. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  140788. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  140789. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  140790. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  140791. */
  140792. export class VideoDome extends TextureDome<VideoTexture> {
  140793. /**
  140794. * Define the video source as a Monoscopic panoramic 360 video.
  140795. */
  140796. static readonly MODE_MONOSCOPIC: number;
  140797. /**
  140798. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  140799. */
  140800. static readonly MODE_TOPBOTTOM: number;
  140801. /**
  140802. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  140803. */
  140804. static readonly MODE_SIDEBYSIDE: number;
  140805. /**
  140806. * Get the video texture associated with this video dome
  140807. */
  140808. get videoTexture(): VideoTexture;
  140809. /**
  140810. * Get the video mode of this dome
  140811. */
  140812. get videoMode(): number;
  140813. /**
  140814. * Set the video mode of this dome.
  140815. * @see textureMode
  140816. */
  140817. set videoMode(value: number);
  140818. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  140819. }
  140820. }
  140821. declare module BABYLON {
  140822. /**
  140823. * This class can be used to get instrumentation data from a Babylon engine
  140824. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  140825. */
  140826. export class EngineInstrumentation implements IDisposable {
  140827. /**
  140828. * Define the instrumented engine.
  140829. */
  140830. engine: Engine;
  140831. private _captureGPUFrameTime;
  140832. private _gpuFrameTimeToken;
  140833. private _gpuFrameTime;
  140834. private _captureShaderCompilationTime;
  140835. private _shaderCompilationTime;
  140836. private _onBeginFrameObserver;
  140837. private _onEndFrameObserver;
  140838. private _onBeforeShaderCompilationObserver;
  140839. private _onAfterShaderCompilationObserver;
  140840. /**
  140841. * Gets the perf counter used for GPU frame time
  140842. */
  140843. get gpuFrameTimeCounter(): PerfCounter;
  140844. /**
  140845. * Gets the GPU frame time capture status
  140846. */
  140847. get captureGPUFrameTime(): boolean;
  140848. /**
  140849. * Enable or disable the GPU frame time capture
  140850. */
  140851. set captureGPUFrameTime(value: boolean);
  140852. /**
  140853. * Gets the perf counter used for shader compilation time
  140854. */
  140855. get shaderCompilationTimeCounter(): PerfCounter;
  140856. /**
  140857. * Gets the shader compilation time capture status
  140858. */
  140859. get captureShaderCompilationTime(): boolean;
  140860. /**
  140861. * Enable or disable the shader compilation time capture
  140862. */
  140863. set captureShaderCompilationTime(value: boolean);
  140864. /**
  140865. * Instantiates a new engine instrumentation.
  140866. * This class can be used to get instrumentation data from a Babylon engine
  140867. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  140868. * @param engine Defines the engine to instrument
  140869. */
  140870. constructor(
  140871. /**
  140872. * Define the instrumented engine.
  140873. */
  140874. engine: Engine);
  140875. /**
  140876. * Dispose and release associated resources.
  140877. */
  140878. dispose(): void;
  140879. }
  140880. }
  140881. declare module BABYLON {
  140882. /**
  140883. * This class can be used to get instrumentation data from a Babylon engine
  140884. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  140885. */
  140886. export class SceneInstrumentation implements IDisposable {
  140887. /**
  140888. * Defines the scene to instrument
  140889. */
  140890. scene: Scene;
  140891. private _captureActiveMeshesEvaluationTime;
  140892. private _activeMeshesEvaluationTime;
  140893. private _captureRenderTargetsRenderTime;
  140894. private _renderTargetsRenderTime;
  140895. private _captureFrameTime;
  140896. private _frameTime;
  140897. private _captureRenderTime;
  140898. private _renderTime;
  140899. private _captureInterFrameTime;
  140900. private _interFrameTime;
  140901. private _captureParticlesRenderTime;
  140902. private _particlesRenderTime;
  140903. private _captureSpritesRenderTime;
  140904. private _spritesRenderTime;
  140905. private _capturePhysicsTime;
  140906. private _physicsTime;
  140907. private _captureAnimationsTime;
  140908. private _animationsTime;
  140909. private _captureCameraRenderTime;
  140910. private _cameraRenderTime;
  140911. private _onBeforeActiveMeshesEvaluationObserver;
  140912. private _onAfterActiveMeshesEvaluationObserver;
  140913. private _onBeforeRenderTargetsRenderObserver;
  140914. private _onAfterRenderTargetsRenderObserver;
  140915. private _onAfterRenderObserver;
  140916. private _onBeforeDrawPhaseObserver;
  140917. private _onAfterDrawPhaseObserver;
  140918. private _onBeforeAnimationsObserver;
  140919. private _onBeforeParticlesRenderingObserver;
  140920. private _onAfterParticlesRenderingObserver;
  140921. private _onBeforeSpritesRenderingObserver;
  140922. private _onAfterSpritesRenderingObserver;
  140923. private _onBeforePhysicsObserver;
  140924. private _onAfterPhysicsObserver;
  140925. private _onAfterAnimationsObserver;
  140926. private _onBeforeCameraRenderObserver;
  140927. private _onAfterCameraRenderObserver;
  140928. /**
  140929. * Gets the perf counter used for active meshes evaluation time
  140930. */
  140931. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  140932. /**
  140933. * Gets the active meshes evaluation time capture status
  140934. */
  140935. get captureActiveMeshesEvaluationTime(): boolean;
  140936. /**
  140937. * Enable or disable the active meshes evaluation time capture
  140938. */
  140939. set captureActiveMeshesEvaluationTime(value: boolean);
  140940. /**
  140941. * Gets the perf counter used for render targets render time
  140942. */
  140943. get renderTargetsRenderTimeCounter(): PerfCounter;
  140944. /**
  140945. * Gets the render targets render time capture status
  140946. */
  140947. get captureRenderTargetsRenderTime(): boolean;
  140948. /**
  140949. * Enable or disable the render targets render time capture
  140950. */
  140951. set captureRenderTargetsRenderTime(value: boolean);
  140952. /**
  140953. * Gets the perf counter used for particles render time
  140954. */
  140955. get particlesRenderTimeCounter(): PerfCounter;
  140956. /**
  140957. * Gets the particles render time capture status
  140958. */
  140959. get captureParticlesRenderTime(): boolean;
  140960. /**
  140961. * Enable or disable the particles render time capture
  140962. */
  140963. set captureParticlesRenderTime(value: boolean);
  140964. /**
  140965. * Gets the perf counter used for sprites render time
  140966. */
  140967. get spritesRenderTimeCounter(): PerfCounter;
  140968. /**
  140969. * Gets the sprites render time capture status
  140970. */
  140971. get captureSpritesRenderTime(): boolean;
  140972. /**
  140973. * Enable or disable the sprites render time capture
  140974. */
  140975. set captureSpritesRenderTime(value: boolean);
  140976. /**
  140977. * Gets the perf counter used for physics time
  140978. */
  140979. get physicsTimeCounter(): PerfCounter;
  140980. /**
  140981. * Gets the physics time capture status
  140982. */
  140983. get capturePhysicsTime(): boolean;
  140984. /**
  140985. * Enable or disable the physics time capture
  140986. */
  140987. set capturePhysicsTime(value: boolean);
  140988. /**
  140989. * Gets the perf counter used for animations time
  140990. */
  140991. get animationsTimeCounter(): PerfCounter;
  140992. /**
  140993. * Gets the animations time capture status
  140994. */
  140995. get captureAnimationsTime(): boolean;
  140996. /**
  140997. * Enable or disable the animations time capture
  140998. */
  140999. set captureAnimationsTime(value: boolean);
  141000. /**
  141001. * Gets the perf counter used for frame time capture
  141002. */
  141003. get frameTimeCounter(): PerfCounter;
  141004. /**
  141005. * Gets the frame time capture status
  141006. */
  141007. get captureFrameTime(): boolean;
  141008. /**
  141009. * Enable or disable the frame time capture
  141010. */
  141011. set captureFrameTime(value: boolean);
  141012. /**
  141013. * Gets the perf counter used for inter-frames time capture
  141014. */
  141015. get interFrameTimeCounter(): PerfCounter;
  141016. /**
  141017. * Gets the inter-frames time capture status
  141018. */
  141019. get captureInterFrameTime(): boolean;
  141020. /**
  141021. * Enable or disable the inter-frames time capture
  141022. */
  141023. set captureInterFrameTime(value: boolean);
  141024. /**
  141025. * Gets the perf counter used for render time capture
  141026. */
  141027. get renderTimeCounter(): PerfCounter;
  141028. /**
  141029. * Gets the render time capture status
  141030. */
  141031. get captureRenderTime(): boolean;
  141032. /**
  141033. * Enable or disable the render time capture
  141034. */
  141035. set captureRenderTime(value: boolean);
  141036. /**
  141037. * Gets the perf counter used for camera render time capture
  141038. */
  141039. get cameraRenderTimeCounter(): PerfCounter;
  141040. /**
  141041. * Gets the camera render time capture status
  141042. */
  141043. get captureCameraRenderTime(): boolean;
  141044. /**
  141045. * Enable or disable the camera render time capture
  141046. */
  141047. set captureCameraRenderTime(value: boolean);
  141048. /**
  141049. * Gets the perf counter used for draw calls
  141050. */
  141051. get drawCallsCounter(): PerfCounter;
  141052. /**
  141053. * Instantiates a new scene instrumentation.
  141054. * This class can be used to get instrumentation data from a Babylon engine
  141055. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  141056. * @param scene Defines the scene to instrument
  141057. */
  141058. constructor(
  141059. /**
  141060. * Defines the scene to instrument
  141061. */
  141062. scene: Scene);
  141063. /**
  141064. * Dispose and release associated resources.
  141065. */
  141066. dispose(): void;
  141067. }
  141068. }
  141069. declare module BABYLON {
  141070. /** @hidden */
  141071. export var glowMapGenerationPixelShader: {
  141072. name: string;
  141073. shader: string;
  141074. };
  141075. }
  141076. declare module BABYLON {
  141077. /** @hidden */
  141078. export var glowMapGenerationVertexShader: {
  141079. name: string;
  141080. shader: string;
  141081. };
  141082. }
  141083. declare module BABYLON {
  141084. /**
  141085. * Effect layer options. This helps customizing the behaviour
  141086. * of the effect layer.
  141087. */
  141088. export interface IEffectLayerOptions {
  141089. /**
  141090. * Multiplication factor apply to the canvas size to compute the render target size
  141091. * used to generated the objects (the smaller the faster).
  141092. */
  141093. mainTextureRatio: number;
  141094. /**
  141095. * Enforces a fixed size texture to ensure effect stability across devices.
  141096. */
  141097. mainTextureFixedSize?: number;
  141098. /**
  141099. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  141100. */
  141101. alphaBlendingMode: number;
  141102. /**
  141103. * The camera attached to the layer.
  141104. */
  141105. camera: Nullable<Camera>;
  141106. /**
  141107. * The rendering group to draw the layer in.
  141108. */
  141109. renderingGroupId: number;
  141110. }
  141111. /**
  141112. * The effect layer Helps adding post process effect blended with the main pass.
  141113. *
  141114. * This can be for instance use to generate glow or higlight effects on the scene.
  141115. *
  141116. * The effect layer class can not be used directly and is intented to inherited from to be
  141117. * customized per effects.
  141118. */
  141119. export abstract class EffectLayer {
  141120. private _vertexBuffers;
  141121. private _indexBuffer;
  141122. private _cachedDefines;
  141123. private _effectLayerMapGenerationEffect;
  141124. private _effectLayerOptions;
  141125. private _mergeEffect;
  141126. protected _scene: Scene;
  141127. protected _engine: Engine;
  141128. protected _maxSize: number;
  141129. protected _mainTextureDesiredSize: ISize;
  141130. protected _mainTexture: RenderTargetTexture;
  141131. protected _shouldRender: boolean;
  141132. protected _postProcesses: PostProcess[];
  141133. protected _textures: BaseTexture[];
  141134. protected _emissiveTextureAndColor: {
  141135. texture: Nullable<BaseTexture>;
  141136. color: Color4;
  141137. };
  141138. /**
  141139. * The name of the layer
  141140. */
  141141. name: string;
  141142. /**
  141143. * The clear color of the texture used to generate the glow map.
  141144. */
  141145. neutralColor: Color4;
  141146. /**
  141147. * Specifies whether the highlight layer is enabled or not.
  141148. */
  141149. isEnabled: boolean;
  141150. /**
  141151. * Gets the camera attached to the layer.
  141152. */
  141153. get camera(): Nullable<Camera>;
  141154. /**
  141155. * Gets the rendering group id the layer should render in.
  141156. */
  141157. get renderingGroupId(): number;
  141158. set renderingGroupId(renderingGroupId: number);
  141159. /**
  141160. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  141161. */
  141162. disableBoundingBoxesFromEffectLayer: boolean;
  141163. /**
  141164. * An event triggered when the effect layer has been disposed.
  141165. */
  141166. onDisposeObservable: Observable<EffectLayer>;
  141167. /**
  141168. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  141169. */
  141170. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  141171. /**
  141172. * An event triggered when the generated texture is being merged in the scene.
  141173. */
  141174. onBeforeComposeObservable: Observable<EffectLayer>;
  141175. /**
  141176. * An event triggered when the mesh is rendered into the effect render target.
  141177. */
  141178. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  141179. /**
  141180. * An event triggered after the mesh has been rendered into the effect render target.
  141181. */
  141182. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  141183. /**
  141184. * An event triggered when the generated texture has been merged in the scene.
  141185. */
  141186. onAfterComposeObservable: Observable<EffectLayer>;
  141187. /**
  141188. * An event triggered when the efffect layer changes its size.
  141189. */
  141190. onSizeChangedObservable: Observable<EffectLayer>;
  141191. /** @hidden */
  141192. static _SceneComponentInitialization: (scene: Scene) => void;
  141193. /**
  141194. * Instantiates a new effect Layer and references it in the scene.
  141195. * @param name The name of the layer
  141196. * @param scene The scene to use the layer in
  141197. */
  141198. constructor(
  141199. /** The Friendly of the effect in the scene */
  141200. name: string, scene: Scene);
  141201. /**
  141202. * Get the effect name of the layer.
  141203. * @return The effect name
  141204. */
  141205. abstract getEffectName(): string;
  141206. /**
  141207. * Checks for the readiness of the element composing the layer.
  141208. * @param subMesh the mesh to check for
  141209. * @param useInstances specify whether or not to use instances to render the mesh
  141210. * @return true if ready otherwise, false
  141211. */
  141212. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141213. /**
  141214. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  141215. * @returns true if the effect requires stencil during the main canvas render pass.
  141216. */
  141217. abstract needStencil(): boolean;
  141218. /**
  141219. * Create the merge effect. This is the shader use to blit the information back
  141220. * to the main canvas at the end of the scene rendering.
  141221. * @returns The effect containing the shader used to merge the effect on the main canvas
  141222. */
  141223. protected abstract _createMergeEffect(): Effect;
  141224. /**
  141225. * Creates the render target textures and post processes used in the effect layer.
  141226. */
  141227. protected abstract _createTextureAndPostProcesses(): void;
  141228. /**
  141229. * Implementation specific of rendering the generating effect on the main canvas.
  141230. * @param effect The effect used to render through
  141231. */
  141232. protected abstract _internalRender(effect: Effect): void;
  141233. /**
  141234. * Sets the required values for both the emissive texture and and the main color.
  141235. */
  141236. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  141237. /**
  141238. * Free any resources and references associated to a mesh.
  141239. * Internal use
  141240. * @param mesh The mesh to free.
  141241. */
  141242. abstract _disposeMesh(mesh: Mesh): void;
  141243. /**
  141244. * Serializes this layer (Glow or Highlight for example)
  141245. * @returns a serialized layer object
  141246. */
  141247. abstract serialize?(): any;
  141248. /**
  141249. * Initializes the effect layer with the required options.
  141250. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  141251. */
  141252. protected _init(options: Partial<IEffectLayerOptions>): void;
  141253. /**
  141254. * Generates the index buffer of the full screen quad blending to the main canvas.
  141255. */
  141256. private _generateIndexBuffer;
  141257. /**
  141258. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  141259. */
  141260. private _generateVertexBuffer;
  141261. /**
  141262. * Sets the main texture desired size which is the closest power of two
  141263. * of the engine canvas size.
  141264. */
  141265. private _setMainTextureSize;
  141266. /**
  141267. * Creates the main texture for the effect layer.
  141268. */
  141269. protected _createMainTexture(): void;
  141270. /**
  141271. * Adds specific effects defines.
  141272. * @param defines The defines to add specifics to.
  141273. */
  141274. protected _addCustomEffectDefines(defines: string[]): void;
  141275. /**
  141276. * Checks for the readiness of the element composing the layer.
  141277. * @param subMesh the mesh to check for
  141278. * @param useInstances specify whether or not to use instances to render the mesh
  141279. * @param emissiveTexture the associated emissive texture used to generate the glow
  141280. * @return true if ready otherwise, false
  141281. */
  141282. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  141283. /**
  141284. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  141285. */
  141286. render(): void;
  141287. /**
  141288. * Determine if a given mesh will be used in the current effect.
  141289. * @param mesh mesh to test
  141290. * @returns true if the mesh will be used
  141291. */
  141292. hasMesh(mesh: AbstractMesh): boolean;
  141293. /**
  141294. * Returns true if the layer contains information to display, otherwise false.
  141295. * @returns true if the glow layer should be rendered
  141296. */
  141297. shouldRender(): boolean;
  141298. /**
  141299. * Returns true if the mesh should render, otherwise false.
  141300. * @param mesh The mesh to render
  141301. * @returns true if it should render otherwise false
  141302. */
  141303. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  141304. /**
  141305. * Returns true if the mesh can be rendered, otherwise false.
  141306. * @param mesh The mesh to render
  141307. * @param material The material used on the mesh
  141308. * @returns true if it can be rendered otherwise false
  141309. */
  141310. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  141311. /**
  141312. * Returns true if the mesh should render, otherwise false.
  141313. * @param mesh The mesh to render
  141314. * @returns true if it should render otherwise false
  141315. */
  141316. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  141317. /**
  141318. * Renders the submesh passed in parameter to the generation map.
  141319. */
  141320. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  141321. /**
  141322. * Defines whether the current material of the mesh should be use to render the effect.
  141323. * @param mesh defines the current mesh to render
  141324. */
  141325. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  141326. /**
  141327. * Rebuild the required buffers.
  141328. * @hidden Internal use only.
  141329. */
  141330. _rebuild(): void;
  141331. /**
  141332. * Dispose only the render target textures and post process.
  141333. */
  141334. private _disposeTextureAndPostProcesses;
  141335. /**
  141336. * Dispose the highlight layer and free resources.
  141337. */
  141338. dispose(): void;
  141339. /**
  141340. * Gets the class name of the effect layer
  141341. * @returns the string with the class name of the effect layer
  141342. */
  141343. getClassName(): string;
  141344. /**
  141345. * Creates an effect layer from parsed effect layer data
  141346. * @param parsedEffectLayer defines effect layer data
  141347. * @param scene defines the current scene
  141348. * @param rootUrl defines the root URL containing the effect layer information
  141349. * @returns a parsed effect Layer
  141350. */
  141351. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  141352. }
  141353. }
  141354. declare module BABYLON {
  141355. interface AbstractScene {
  141356. /**
  141357. * The list of effect layers (highlights/glow) added to the scene
  141358. * @see https://doc.babylonjs.com/how_to/highlight_layer
  141359. * @see https://doc.babylonjs.com/how_to/glow_layer
  141360. */
  141361. effectLayers: Array<EffectLayer>;
  141362. /**
  141363. * Removes the given effect layer from this scene.
  141364. * @param toRemove defines the effect layer to remove
  141365. * @returns the index of the removed effect layer
  141366. */
  141367. removeEffectLayer(toRemove: EffectLayer): number;
  141368. /**
  141369. * Adds the given effect layer to this scene
  141370. * @param newEffectLayer defines the effect layer to add
  141371. */
  141372. addEffectLayer(newEffectLayer: EffectLayer): void;
  141373. }
  141374. /**
  141375. * Defines the layer scene component responsible to manage any effect layers
  141376. * in a given scene.
  141377. */
  141378. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  141379. /**
  141380. * The component name helpfull to identify the component in the list of scene components.
  141381. */
  141382. readonly name: string;
  141383. /**
  141384. * The scene the component belongs to.
  141385. */
  141386. scene: Scene;
  141387. private _engine;
  141388. private _renderEffects;
  141389. private _needStencil;
  141390. private _previousStencilState;
  141391. /**
  141392. * Creates a new instance of the component for the given scene
  141393. * @param scene Defines the scene to register the component in
  141394. */
  141395. constructor(scene: Scene);
  141396. /**
  141397. * Registers the component in a given scene
  141398. */
  141399. register(): void;
  141400. /**
  141401. * Rebuilds the elements related to this component in case of
  141402. * context lost for instance.
  141403. */
  141404. rebuild(): void;
  141405. /**
  141406. * Serializes the component data to the specified json object
  141407. * @param serializationObject The object to serialize to
  141408. */
  141409. serialize(serializationObject: any): void;
  141410. /**
  141411. * Adds all the elements from the container to the scene
  141412. * @param container the container holding the elements
  141413. */
  141414. addFromContainer(container: AbstractScene): void;
  141415. /**
  141416. * Removes all the elements in the container from the scene
  141417. * @param container contains the elements to remove
  141418. * @param dispose if the removed element should be disposed (default: false)
  141419. */
  141420. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141421. /**
  141422. * Disposes the component and the associated ressources.
  141423. */
  141424. dispose(): void;
  141425. private _isReadyForMesh;
  141426. private _renderMainTexture;
  141427. private _setStencil;
  141428. private _setStencilBack;
  141429. private _draw;
  141430. private _drawCamera;
  141431. private _drawRenderingGroup;
  141432. }
  141433. }
  141434. declare module BABYLON {
  141435. /** @hidden */
  141436. export var glowMapMergePixelShader: {
  141437. name: string;
  141438. shader: string;
  141439. };
  141440. }
  141441. declare module BABYLON {
  141442. /** @hidden */
  141443. export var glowMapMergeVertexShader: {
  141444. name: string;
  141445. shader: string;
  141446. };
  141447. }
  141448. declare module BABYLON {
  141449. interface AbstractScene {
  141450. /**
  141451. * Return a the first highlight layer of the scene with a given name.
  141452. * @param name The name of the highlight layer to look for.
  141453. * @return The highlight layer if found otherwise null.
  141454. */
  141455. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  141456. }
  141457. /**
  141458. * Glow layer options. This helps customizing the behaviour
  141459. * of the glow layer.
  141460. */
  141461. export interface IGlowLayerOptions {
  141462. /**
  141463. * Multiplication factor apply to the canvas size to compute the render target size
  141464. * used to generated the glowing objects (the smaller the faster).
  141465. */
  141466. mainTextureRatio: number;
  141467. /**
  141468. * Enforces a fixed size texture to ensure resize independant blur.
  141469. */
  141470. mainTextureFixedSize?: number;
  141471. /**
  141472. * How big is the kernel of the blur texture.
  141473. */
  141474. blurKernelSize: number;
  141475. /**
  141476. * The camera attached to the layer.
  141477. */
  141478. camera: Nullable<Camera>;
  141479. /**
  141480. * Enable MSAA by chosing the number of samples.
  141481. */
  141482. mainTextureSamples?: number;
  141483. /**
  141484. * The rendering group to draw the layer in.
  141485. */
  141486. renderingGroupId: number;
  141487. }
  141488. /**
  141489. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  141490. *
  141491. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  141492. *
  141493. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  141494. */
  141495. export class GlowLayer extends EffectLayer {
  141496. /**
  141497. * Effect Name of the layer.
  141498. */
  141499. static readonly EffectName: string;
  141500. /**
  141501. * The default blur kernel size used for the glow.
  141502. */
  141503. static DefaultBlurKernelSize: number;
  141504. /**
  141505. * The default texture size ratio used for the glow.
  141506. */
  141507. static DefaultTextureRatio: number;
  141508. /**
  141509. * Sets the kernel size of the blur.
  141510. */
  141511. set blurKernelSize(value: number);
  141512. /**
  141513. * Gets the kernel size of the blur.
  141514. */
  141515. get blurKernelSize(): number;
  141516. /**
  141517. * Sets the glow intensity.
  141518. */
  141519. set intensity(value: number);
  141520. /**
  141521. * Gets the glow intensity.
  141522. */
  141523. get intensity(): number;
  141524. private _options;
  141525. private _intensity;
  141526. private _horizontalBlurPostprocess1;
  141527. private _verticalBlurPostprocess1;
  141528. private _horizontalBlurPostprocess2;
  141529. private _verticalBlurPostprocess2;
  141530. private _blurTexture1;
  141531. private _blurTexture2;
  141532. private _postProcesses1;
  141533. private _postProcesses2;
  141534. private _includedOnlyMeshes;
  141535. private _excludedMeshes;
  141536. private _meshesUsingTheirOwnMaterials;
  141537. /**
  141538. * Callback used to let the user override the color selection on a per mesh basis
  141539. */
  141540. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  141541. /**
  141542. * Callback used to let the user override the texture selection on a per mesh basis
  141543. */
  141544. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  141545. /**
  141546. * Instantiates a new glow Layer and references it to the scene.
  141547. * @param name The name of the layer
  141548. * @param scene The scene to use the layer in
  141549. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  141550. */
  141551. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  141552. /**
  141553. * Get the effect name of the layer.
  141554. * @return The effect name
  141555. */
  141556. getEffectName(): string;
  141557. /**
  141558. * Create the merge effect. This is the shader use to blit the information back
  141559. * to the main canvas at the end of the scene rendering.
  141560. */
  141561. protected _createMergeEffect(): Effect;
  141562. /**
  141563. * Creates the render target textures and post processes used in the glow layer.
  141564. */
  141565. protected _createTextureAndPostProcesses(): void;
  141566. /**
  141567. * Checks for the readiness of the element composing the layer.
  141568. * @param subMesh the mesh to check for
  141569. * @param useInstances specify wether or not to use instances to render the mesh
  141570. * @param emissiveTexture the associated emissive texture used to generate the glow
  141571. * @return true if ready otherwise, false
  141572. */
  141573. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141574. /**
  141575. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  141576. */
  141577. needStencil(): boolean;
  141578. /**
  141579. * Returns true if the mesh can be rendered, otherwise false.
  141580. * @param mesh The mesh to render
  141581. * @param material The material used on the mesh
  141582. * @returns true if it can be rendered otherwise false
  141583. */
  141584. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  141585. /**
  141586. * Implementation specific of rendering the generating effect on the main canvas.
  141587. * @param effect The effect used to render through
  141588. */
  141589. protected _internalRender(effect: Effect): void;
  141590. /**
  141591. * Sets the required values for both the emissive texture and and the main color.
  141592. */
  141593. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  141594. /**
  141595. * Returns true if the mesh should render, otherwise false.
  141596. * @param mesh The mesh to render
  141597. * @returns true if it should render otherwise false
  141598. */
  141599. protected _shouldRenderMesh(mesh: Mesh): boolean;
  141600. /**
  141601. * Adds specific effects defines.
  141602. * @param defines The defines to add specifics to.
  141603. */
  141604. protected _addCustomEffectDefines(defines: string[]): void;
  141605. /**
  141606. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  141607. * @param mesh The mesh to exclude from the glow layer
  141608. */
  141609. addExcludedMesh(mesh: Mesh): void;
  141610. /**
  141611. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  141612. * @param mesh The mesh to remove
  141613. */
  141614. removeExcludedMesh(mesh: Mesh): void;
  141615. /**
  141616. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  141617. * @param mesh The mesh to include in the glow layer
  141618. */
  141619. addIncludedOnlyMesh(mesh: Mesh): void;
  141620. /**
  141621. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  141622. * @param mesh The mesh to remove
  141623. */
  141624. removeIncludedOnlyMesh(mesh: Mesh): void;
  141625. /**
  141626. * Determine if a given mesh will be used in the glow layer
  141627. * @param mesh The mesh to test
  141628. * @returns true if the mesh will be highlighted by the current glow layer
  141629. */
  141630. hasMesh(mesh: AbstractMesh): boolean;
  141631. /**
  141632. * Defines whether the current material of the mesh should be use to render the effect.
  141633. * @param mesh defines the current mesh to render
  141634. */
  141635. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  141636. /**
  141637. * Add a mesh to be rendered through its own material and not with emissive only.
  141638. * @param mesh The mesh for which we need to use its material
  141639. */
  141640. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  141641. /**
  141642. * Remove a mesh from being rendered through its own material and not with emissive only.
  141643. * @param mesh The mesh for which we need to not use its material
  141644. */
  141645. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  141646. /**
  141647. * Free any resources and references associated to a mesh.
  141648. * Internal use
  141649. * @param mesh The mesh to free.
  141650. * @hidden
  141651. */
  141652. _disposeMesh(mesh: Mesh): void;
  141653. /**
  141654. * Gets the class name of the effect layer
  141655. * @returns the string with the class name of the effect layer
  141656. */
  141657. getClassName(): string;
  141658. /**
  141659. * Serializes this glow layer
  141660. * @returns a serialized glow layer object
  141661. */
  141662. serialize(): any;
  141663. /**
  141664. * Creates a Glow Layer from parsed glow layer data
  141665. * @param parsedGlowLayer defines glow layer data
  141666. * @param scene defines the current scene
  141667. * @param rootUrl defines the root URL containing the glow layer information
  141668. * @returns a parsed Glow Layer
  141669. */
  141670. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  141671. }
  141672. }
  141673. declare module BABYLON {
  141674. /** @hidden */
  141675. export var glowBlurPostProcessPixelShader: {
  141676. name: string;
  141677. shader: string;
  141678. };
  141679. }
  141680. declare module BABYLON {
  141681. interface AbstractScene {
  141682. /**
  141683. * Return a the first highlight layer of the scene with a given name.
  141684. * @param name The name of the highlight layer to look for.
  141685. * @return The highlight layer if found otherwise null.
  141686. */
  141687. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  141688. }
  141689. /**
  141690. * Highlight layer options. This helps customizing the behaviour
  141691. * of the highlight layer.
  141692. */
  141693. export interface IHighlightLayerOptions {
  141694. /**
  141695. * Multiplication factor apply to the canvas size to compute the render target size
  141696. * used to generated the glowing objects (the smaller the faster).
  141697. */
  141698. mainTextureRatio: number;
  141699. /**
  141700. * Enforces a fixed size texture to ensure resize independant blur.
  141701. */
  141702. mainTextureFixedSize?: number;
  141703. /**
  141704. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  141705. * of the picture to blur (the smaller the faster).
  141706. */
  141707. blurTextureSizeRatio: number;
  141708. /**
  141709. * How big in texel of the blur texture is the vertical blur.
  141710. */
  141711. blurVerticalSize: number;
  141712. /**
  141713. * How big in texel of the blur texture is the horizontal blur.
  141714. */
  141715. blurHorizontalSize: number;
  141716. /**
  141717. * Alpha blending mode used to apply the blur. Default is combine.
  141718. */
  141719. alphaBlendingMode: number;
  141720. /**
  141721. * The camera attached to the layer.
  141722. */
  141723. camera: Nullable<Camera>;
  141724. /**
  141725. * Should we display highlight as a solid stroke?
  141726. */
  141727. isStroke?: boolean;
  141728. /**
  141729. * The rendering group to draw the layer in.
  141730. */
  141731. renderingGroupId: number;
  141732. }
  141733. /**
  141734. * The highlight layer Helps adding a glow effect around a mesh.
  141735. *
  141736. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  141737. * glowy meshes to your scene.
  141738. *
  141739. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  141740. */
  141741. export class HighlightLayer extends EffectLayer {
  141742. name: string;
  141743. /**
  141744. * Effect Name of the highlight layer.
  141745. */
  141746. static readonly EffectName: string;
  141747. /**
  141748. * The neutral color used during the preparation of the glow effect.
  141749. * This is black by default as the blend operation is a blend operation.
  141750. */
  141751. static NeutralColor: Color4;
  141752. /**
  141753. * Stencil value used for glowing meshes.
  141754. */
  141755. static GlowingMeshStencilReference: number;
  141756. /**
  141757. * Stencil value used for the other meshes in the scene.
  141758. */
  141759. static NormalMeshStencilReference: number;
  141760. /**
  141761. * Specifies whether or not the inner glow is ACTIVE in the layer.
  141762. */
  141763. innerGlow: boolean;
  141764. /**
  141765. * Specifies whether or not the outer glow is ACTIVE in the layer.
  141766. */
  141767. outerGlow: boolean;
  141768. /**
  141769. * Specifies the horizontal size of the blur.
  141770. */
  141771. set blurHorizontalSize(value: number);
  141772. /**
  141773. * Specifies the vertical size of the blur.
  141774. */
  141775. set blurVerticalSize(value: number);
  141776. /**
  141777. * Gets the horizontal size of the blur.
  141778. */
  141779. get blurHorizontalSize(): number;
  141780. /**
  141781. * Gets the vertical size of the blur.
  141782. */
  141783. get blurVerticalSize(): number;
  141784. /**
  141785. * An event triggered when the highlight layer is being blurred.
  141786. */
  141787. onBeforeBlurObservable: Observable<HighlightLayer>;
  141788. /**
  141789. * An event triggered when the highlight layer has been blurred.
  141790. */
  141791. onAfterBlurObservable: Observable<HighlightLayer>;
  141792. private _instanceGlowingMeshStencilReference;
  141793. private _options;
  141794. private _downSamplePostprocess;
  141795. private _horizontalBlurPostprocess;
  141796. private _verticalBlurPostprocess;
  141797. private _blurTexture;
  141798. private _meshes;
  141799. private _excludedMeshes;
  141800. /**
  141801. * Instantiates a new highlight Layer and references it to the scene..
  141802. * @param name The name of the layer
  141803. * @param scene The scene to use the layer in
  141804. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  141805. */
  141806. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  141807. /**
  141808. * Get the effect name of the layer.
  141809. * @return The effect name
  141810. */
  141811. getEffectName(): string;
  141812. /**
  141813. * Create the merge effect. This is the shader use to blit the information back
  141814. * to the main canvas at the end of the scene rendering.
  141815. */
  141816. protected _createMergeEffect(): Effect;
  141817. /**
  141818. * Creates the render target textures and post processes used in the highlight layer.
  141819. */
  141820. protected _createTextureAndPostProcesses(): void;
  141821. /**
  141822. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  141823. */
  141824. needStencil(): boolean;
  141825. /**
  141826. * Checks for the readiness of the element composing the layer.
  141827. * @param subMesh the mesh to check for
  141828. * @param useInstances specify wether or not to use instances to render the mesh
  141829. * @param emissiveTexture the associated emissive texture used to generate the glow
  141830. * @return true if ready otherwise, false
  141831. */
  141832. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141833. /**
  141834. * Implementation specific of rendering the generating effect on the main canvas.
  141835. * @param effect The effect used to render through
  141836. */
  141837. protected _internalRender(effect: Effect): void;
  141838. /**
  141839. * Returns true if the layer contains information to display, otherwise false.
  141840. */
  141841. shouldRender(): boolean;
  141842. /**
  141843. * Returns true if the mesh should render, otherwise false.
  141844. * @param mesh The mesh to render
  141845. * @returns true if it should render otherwise false
  141846. */
  141847. protected _shouldRenderMesh(mesh: Mesh): boolean;
  141848. /**
  141849. * Returns true if the mesh can be rendered, otherwise false.
  141850. * @param mesh The mesh to render
  141851. * @param material The material used on the mesh
  141852. * @returns true if it can be rendered otherwise false
  141853. */
  141854. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  141855. /**
  141856. * Adds specific effects defines.
  141857. * @param defines The defines to add specifics to.
  141858. */
  141859. protected _addCustomEffectDefines(defines: string[]): void;
  141860. /**
  141861. * Sets the required values for both the emissive texture and and the main color.
  141862. */
  141863. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  141864. /**
  141865. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  141866. * @param mesh The mesh to exclude from the highlight layer
  141867. */
  141868. addExcludedMesh(mesh: Mesh): void;
  141869. /**
  141870. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  141871. * @param mesh The mesh to highlight
  141872. */
  141873. removeExcludedMesh(mesh: Mesh): void;
  141874. /**
  141875. * Determine if a given mesh will be highlighted by the current HighlightLayer
  141876. * @param mesh mesh to test
  141877. * @returns true if the mesh will be highlighted by the current HighlightLayer
  141878. */
  141879. hasMesh(mesh: AbstractMesh): boolean;
  141880. /**
  141881. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  141882. * @param mesh The mesh to highlight
  141883. * @param color The color of the highlight
  141884. * @param glowEmissiveOnly Extract the glow from the emissive texture
  141885. */
  141886. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  141887. /**
  141888. * Remove a mesh from the highlight layer in order to make it stop glowing.
  141889. * @param mesh The mesh to highlight
  141890. */
  141891. removeMesh(mesh: Mesh): void;
  141892. /**
  141893. * Remove all the meshes currently referenced in the highlight layer
  141894. */
  141895. removeAllMeshes(): void;
  141896. /**
  141897. * Force the stencil to the normal expected value for none glowing parts
  141898. */
  141899. private _defaultStencilReference;
  141900. /**
  141901. * Free any resources and references associated to a mesh.
  141902. * Internal use
  141903. * @param mesh The mesh to free.
  141904. * @hidden
  141905. */
  141906. _disposeMesh(mesh: Mesh): void;
  141907. /**
  141908. * Dispose the highlight layer and free resources.
  141909. */
  141910. dispose(): void;
  141911. /**
  141912. * Gets the class name of the effect layer
  141913. * @returns the string with the class name of the effect layer
  141914. */
  141915. getClassName(): string;
  141916. /**
  141917. * Serializes this Highlight layer
  141918. * @returns a serialized Highlight layer object
  141919. */
  141920. serialize(): any;
  141921. /**
  141922. * Creates a Highlight layer from parsed Highlight layer data
  141923. * @param parsedHightlightLayer defines the Highlight layer data
  141924. * @param scene defines the current scene
  141925. * @param rootUrl defines the root URL containing the Highlight layer information
  141926. * @returns a parsed Highlight layer
  141927. */
  141928. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  141929. }
  141930. }
  141931. declare module BABYLON {
  141932. interface AbstractScene {
  141933. /**
  141934. * The list of layers (background and foreground) of the scene
  141935. */
  141936. layers: Array<Layer>;
  141937. }
  141938. /**
  141939. * Defines the layer scene component responsible to manage any layers
  141940. * in a given scene.
  141941. */
  141942. export class LayerSceneComponent implements ISceneComponent {
  141943. /**
  141944. * The component name helpfull to identify the component in the list of scene components.
  141945. */
  141946. readonly name: string;
  141947. /**
  141948. * The scene the component belongs to.
  141949. */
  141950. scene: Scene;
  141951. private _engine;
  141952. /**
  141953. * Creates a new instance of the component for the given scene
  141954. * @param scene Defines the scene to register the component in
  141955. */
  141956. constructor(scene: Scene);
  141957. /**
  141958. * Registers the component in a given scene
  141959. */
  141960. register(): void;
  141961. /**
  141962. * Rebuilds the elements related to this component in case of
  141963. * context lost for instance.
  141964. */
  141965. rebuild(): void;
  141966. /**
  141967. * Disposes the component and the associated ressources.
  141968. */
  141969. dispose(): void;
  141970. private _draw;
  141971. private _drawCameraPredicate;
  141972. private _drawCameraBackground;
  141973. private _drawCameraForeground;
  141974. private _drawRenderTargetPredicate;
  141975. private _drawRenderTargetBackground;
  141976. private _drawRenderTargetForeground;
  141977. /**
  141978. * Adds all the elements from the container to the scene
  141979. * @param container the container holding the elements
  141980. */
  141981. addFromContainer(container: AbstractScene): void;
  141982. /**
  141983. * Removes all the elements in the container from the scene
  141984. * @param container contains the elements to remove
  141985. * @param dispose if the removed element should be disposed (default: false)
  141986. */
  141987. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141988. }
  141989. }
  141990. declare module BABYLON {
  141991. /** @hidden */
  141992. export var layerPixelShader: {
  141993. name: string;
  141994. shader: string;
  141995. };
  141996. }
  141997. declare module BABYLON {
  141998. /** @hidden */
  141999. export var layerVertexShader: {
  142000. name: string;
  142001. shader: string;
  142002. };
  142003. }
  142004. declare module BABYLON {
  142005. /**
  142006. * This represents a full screen 2d layer.
  142007. * This can be useful to display a picture in the background of your scene for instance.
  142008. * @see https://www.babylonjs-playground.com/#08A2BS#1
  142009. */
  142010. export class Layer {
  142011. /**
  142012. * Define the name of the layer.
  142013. */
  142014. name: string;
  142015. /**
  142016. * Define the texture the layer should display.
  142017. */
  142018. texture: Nullable<Texture>;
  142019. /**
  142020. * Is the layer in background or foreground.
  142021. */
  142022. isBackground: boolean;
  142023. /**
  142024. * Define the color of the layer (instead of texture).
  142025. */
  142026. color: Color4;
  142027. /**
  142028. * Define the scale of the layer in order to zoom in out of the texture.
  142029. */
  142030. scale: Vector2;
  142031. /**
  142032. * Define an offset for the layer in order to shift the texture.
  142033. */
  142034. offset: Vector2;
  142035. /**
  142036. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  142037. */
  142038. alphaBlendingMode: number;
  142039. /**
  142040. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  142041. * Alpha test will not mix with the background color in case of transparency.
  142042. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  142043. */
  142044. alphaTest: boolean;
  142045. /**
  142046. * Define a mask to restrict the layer to only some of the scene cameras.
  142047. */
  142048. layerMask: number;
  142049. /**
  142050. * Define the list of render target the layer is visible into.
  142051. */
  142052. renderTargetTextures: RenderTargetTexture[];
  142053. /**
  142054. * Define if the layer is only used in renderTarget or if it also
  142055. * renders in the main frame buffer of the canvas.
  142056. */
  142057. renderOnlyInRenderTargetTextures: boolean;
  142058. private _scene;
  142059. private _vertexBuffers;
  142060. private _indexBuffer;
  142061. private _effect;
  142062. private _previousDefines;
  142063. /**
  142064. * An event triggered when the layer is disposed.
  142065. */
  142066. onDisposeObservable: Observable<Layer>;
  142067. private _onDisposeObserver;
  142068. /**
  142069. * Back compatibility with callback before the onDisposeObservable existed.
  142070. * The set callback will be triggered when the layer has been disposed.
  142071. */
  142072. set onDispose(callback: () => void);
  142073. /**
  142074. * An event triggered before rendering the scene
  142075. */
  142076. onBeforeRenderObservable: Observable<Layer>;
  142077. private _onBeforeRenderObserver;
  142078. /**
  142079. * Back compatibility with callback before the onBeforeRenderObservable existed.
  142080. * The set callback will be triggered just before rendering the layer.
  142081. */
  142082. set onBeforeRender(callback: () => void);
  142083. /**
  142084. * An event triggered after rendering the scene
  142085. */
  142086. onAfterRenderObservable: Observable<Layer>;
  142087. private _onAfterRenderObserver;
  142088. /**
  142089. * Back compatibility with callback before the onAfterRenderObservable existed.
  142090. * The set callback will be triggered just after rendering the layer.
  142091. */
  142092. set onAfterRender(callback: () => void);
  142093. /**
  142094. * Instantiates a new layer.
  142095. * This represents a full screen 2d layer.
  142096. * This can be useful to display a picture in the background of your scene for instance.
  142097. * @see https://www.babylonjs-playground.com/#08A2BS#1
  142098. * @param name Define the name of the layer in the scene
  142099. * @param imgUrl Define the url of the texture to display in the layer
  142100. * @param scene Define the scene the layer belongs to
  142101. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  142102. * @param color Defines a color for the layer
  142103. */
  142104. constructor(
  142105. /**
  142106. * Define the name of the layer.
  142107. */
  142108. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  142109. private _createIndexBuffer;
  142110. /** @hidden */
  142111. _rebuild(): void;
  142112. /**
  142113. * Renders the layer in the scene.
  142114. */
  142115. render(): void;
  142116. /**
  142117. * Disposes and releases the associated ressources.
  142118. */
  142119. dispose(): void;
  142120. }
  142121. }
  142122. declare module BABYLON {
  142123. /** @hidden */
  142124. export var lensFlarePixelShader: {
  142125. name: string;
  142126. shader: string;
  142127. };
  142128. }
  142129. declare module BABYLON {
  142130. /** @hidden */
  142131. export var lensFlareVertexShader: {
  142132. name: string;
  142133. shader: string;
  142134. };
  142135. }
  142136. declare module BABYLON {
  142137. /**
  142138. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  142139. * It is usually composed of several `lensFlare`.
  142140. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142141. */
  142142. export class LensFlareSystem {
  142143. /**
  142144. * Define the name of the lens flare system
  142145. */
  142146. name: string;
  142147. /**
  142148. * List of lens flares used in this system.
  142149. */
  142150. lensFlares: LensFlare[];
  142151. /**
  142152. * Define a limit from the border the lens flare can be visible.
  142153. */
  142154. borderLimit: number;
  142155. /**
  142156. * Define a viewport border we do not want to see the lens flare in.
  142157. */
  142158. viewportBorder: number;
  142159. /**
  142160. * Define a predicate which could limit the list of meshes able to occlude the effect.
  142161. */
  142162. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  142163. /**
  142164. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  142165. */
  142166. layerMask: number;
  142167. /**
  142168. * Define the id of the lens flare system in the scene.
  142169. * (equal to name by default)
  142170. */
  142171. id: string;
  142172. private _scene;
  142173. private _emitter;
  142174. private _vertexBuffers;
  142175. private _indexBuffer;
  142176. private _effect;
  142177. private _positionX;
  142178. private _positionY;
  142179. private _isEnabled;
  142180. /** @hidden */
  142181. static _SceneComponentInitialization: (scene: Scene) => void;
  142182. /**
  142183. * Instantiates a lens flare system.
  142184. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  142185. * It is usually composed of several `lensFlare`.
  142186. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142187. * @param name Define the name of the lens flare system in the scene
  142188. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  142189. * @param scene Define the scene the lens flare system belongs to
  142190. */
  142191. constructor(
  142192. /**
  142193. * Define the name of the lens flare system
  142194. */
  142195. name: string, emitter: any, scene: Scene);
  142196. /**
  142197. * Define if the lens flare system is enabled.
  142198. */
  142199. get isEnabled(): boolean;
  142200. set isEnabled(value: boolean);
  142201. /**
  142202. * Get the scene the effects belongs to.
  142203. * @returns the scene holding the lens flare system
  142204. */
  142205. getScene(): Scene;
  142206. /**
  142207. * Get the emitter of the lens flare system.
  142208. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  142209. * @returns the emitter of the lens flare system
  142210. */
  142211. getEmitter(): any;
  142212. /**
  142213. * Set the emitter of the lens flare system.
  142214. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  142215. * @param newEmitter Define the new emitter of the system
  142216. */
  142217. setEmitter(newEmitter: any): void;
  142218. /**
  142219. * Get the lens flare system emitter position.
  142220. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  142221. * @returns the position
  142222. */
  142223. getEmitterPosition(): Vector3;
  142224. /**
  142225. * @hidden
  142226. */
  142227. computeEffectivePosition(globalViewport: Viewport): boolean;
  142228. /** @hidden */
  142229. _isVisible(): boolean;
  142230. /**
  142231. * @hidden
  142232. */
  142233. render(): boolean;
  142234. /**
  142235. * Dispose and release the lens flare with its associated resources.
  142236. */
  142237. dispose(): void;
  142238. /**
  142239. * Parse a lens flare system from a JSON repressentation
  142240. * @param parsedLensFlareSystem Define the JSON to parse
  142241. * @param scene Define the scene the parsed system should be instantiated in
  142242. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  142243. * @returns the parsed system
  142244. */
  142245. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  142246. /**
  142247. * Serialize the current Lens Flare System into a JSON representation.
  142248. * @returns the serialized JSON
  142249. */
  142250. serialize(): any;
  142251. }
  142252. }
  142253. declare module BABYLON {
  142254. /**
  142255. * This represents one of the lens effect in a `lensFlareSystem`.
  142256. * It controls one of the indiviual texture used in the effect.
  142257. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142258. */
  142259. export class LensFlare {
  142260. /**
  142261. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  142262. */
  142263. size: number;
  142264. /**
  142265. * 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.
  142266. */
  142267. position: number;
  142268. /**
  142269. * Define the lens color.
  142270. */
  142271. color: Color3;
  142272. /**
  142273. * Define the lens texture.
  142274. */
  142275. texture: Nullable<Texture>;
  142276. /**
  142277. * Define the alpha mode to render this particular lens.
  142278. */
  142279. alphaMode: number;
  142280. private _system;
  142281. /**
  142282. * Creates a new Lens Flare.
  142283. * This represents one of the lens effect in a `lensFlareSystem`.
  142284. * It controls one of the indiviual texture used in the effect.
  142285. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142286. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  142287. * @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.
  142288. * @param color Define the lens color
  142289. * @param imgUrl Define the lens texture url
  142290. * @param system Define the `lensFlareSystem` this flare is part of
  142291. * @returns The newly created Lens Flare
  142292. */
  142293. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  142294. /**
  142295. * Instantiates a new Lens Flare.
  142296. * This represents one of the lens effect in a `lensFlareSystem`.
  142297. * It controls one of the indiviual texture used in the effect.
  142298. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142299. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  142300. * @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.
  142301. * @param color Define the lens color
  142302. * @param imgUrl Define the lens texture url
  142303. * @param system Define the `lensFlareSystem` this flare is part of
  142304. */
  142305. constructor(
  142306. /**
  142307. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  142308. */
  142309. size: number,
  142310. /**
  142311. * 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.
  142312. */
  142313. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  142314. /**
  142315. * Dispose and release the lens flare with its associated resources.
  142316. */
  142317. dispose(): void;
  142318. }
  142319. }
  142320. declare module BABYLON {
  142321. interface AbstractScene {
  142322. /**
  142323. * The list of lens flare system added to the scene
  142324. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142325. */
  142326. lensFlareSystems: Array<LensFlareSystem>;
  142327. /**
  142328. * Removes the given lens flare system from this scene.
  142329. * @param toRemove The lens flare system to remove
  142330. * @returns The index of the removed lens flare system
  142331. */
  142332. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  142333. /**
  142334. * Adds the given lens flare system to this scene
  142335. * @param newLensFlareSystem The lens flare system to add
  142336. */
  142337. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  142338. /**
  142339. * Gets a lens flare system using its name
  142340. * @param name defines the name to look for
  142341. * @returns the lens flare system or null if not found
  142342. */
  142343. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  142344. /**
  142345. * Gets a lens flare system using its id
  142346. * @param id defines the id to look for
  142347. * @returns the lens flare system or null if not found
  142348. */
  142349. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  142350. }
  142351. /**
  142352. * Defines the lens flare scene component responsible to manage any lens flares
  142353. * in a given scene.
  142354. */
  142355. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  142356. /**
  142357. * The component name helpfull to identify the component in the list of scene components.
  142358. */
  142359. readonly name: string;
  142360. /**
  142361. * The scene the component belongs to.
  142362. */
  142363. scene: Scene;
  142364. /**
  142365. * Creates a new instance of the component for the given scene
  142366. * @param scene Defines the scene to register the component in
  142367. */
  142368. constructor(scene: Scene);
  142369. /**
  142370. * Registers the component in a given scene
  142371. */
  142372. register(): void;
  142373. /**
  142374. * Rebuilds the elements related to this component in case of
  142375. * context lost for instance.
  142376. */
  142377. rebuild(): void;
  142378. /**
  142379. * Adds all the elements from the container to the scene
  142380. * @param container the container holding the elements
  142381. */
  142382. addFromContainer(container: AbstractScene): void;
  142383. /**
  142384. * Removes all the elements in the container from the scene
  142385. * @param container contains the elements to remove
  142386. * @param dispose if the removed element should be disposed (default: false)
  142387. */
  142388. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  142389. /**
  142390. * Serializes the component data to the specified json object
  142391. * @param serializationObject The object to serialize to
  142392. */
  142393. serialize(serializationObject: any): void;
  142394. /**
  142395. * Disposes the component and the associated ressources.
  142396. */
  142397. dispose(): void;
  142398. private _draw;
  142399. }
  142400. }
  142401. declare module BABYLON {
  142402. /** @hidden */
  142403. export var depthPixelShader: {
  142404. name: string;
  142405. shader: string;
  142406. };
  142407. }
  142408. declare module BABYLON {
  142409. /** @hidden */
  142410. export var depthVertexShader: {
  142411. name: string;
  142412. shader: string;
  142413. };
  142414. }
  142415. declare module BABYLON {
  142416. /**
  142417. * This represents a depth renderer in Babylon.
  142418. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  142419. */
  142420. export class DepthRenderer {
  142421. private _scene;
  142422. private _depthMap;
  142423. private _effect;
  142424. private readonly _storeNonLinearDepth;
  142425. private readonly _clearColor;
  142426. /** Get if the depth renderer is using packed depth or not */
  142427. readonly isPacked: boolean;
  142428. private _cachedDefines;
  142429. private _camera;
  142430. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  142431. enabled: boolean;
  142432. /**
  142433. * Specifiess that the depth renderer will only be used within
  142434. * the camera it is created for.
  142435. * This can help forcing its rendering during the camera processing.
  142436. */
  142437. useOnlyInActiveCamera: boolean;
  142438. /** @hidden */
  142439. static _SceneComponentInitialization: (scene: Scene) => void;
  142440. /**
  142441. * Instantiates a depth renderer
  142442. * @param scene The scene the renderer belongs to
  142443. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  142444. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  142445. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  142446. */
  142447. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  142448. /**
  142449. * Creates the depth rendering effect and checks if the effect is ready.
  142450. * @param subMesh The submesh to be used to render the depth map of
  142451. * @param useInstances If multiple world instances should be used
  142452. * @returns if the depth renderer is ready to render the depth map
  142453. */
  142454. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  142455. /**
  142456. * Gets the texture which the depth map will be written to.
  142457. * @returns The depth map texture
  142458. */
  142459. getDepthMap(): RenderTargetTexture;
  142460. /**
  142461. * Disposes of the depth renderer.
  142462. */
  142463. dispose(): void;
  142464. }
  142465. }
  142466. declare module BABYLON {
  142467. /** @hidden */
  142468. export var minmaxReduxPixelShader: {
  142469. name: string;
  142470. shader: string;
  142471. };
  142472. }
  142473. declare module BABYLON {
  142474. /**
  142475. * This class computes a min/max reduction from a texture: it means it computes the minimum
  142476. * and maximum values from all values of the texture.
  142477. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  142478. * The source values are read from the red channel of the texture.
  142479. */
  142480. export class MinMaxReducer {
  142481. /**
  142482. * Observable triggered when the computation has been performed
  142483. */
  142484. onAfterReductionPerformed: Observable<{
  142485. min: number;
  142486. max: number;
  142487. }>;
  142488. protected _camera: Camera;
  142489. protected _sourceTexture: Nullable<RenderTargetTexture>;
  142490. protected _reductionSteps: Nullable<Array<PostProcess>>;
  142491. protected _postProcessManager: PostProcessManager;
  142492. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  142493. protected _forceFullscreenViewport: boolean;
  142494. /**
  142495. * Creates a min/max reducer
  142496. * @param camera The camera to use for the post processes
  142497. */
  142498. constructor(camera: Camera);
  142499. /**
  142500. * Gets the texture used to read the values from.
  142501. */
  142502. get sourceTexture(): Nullable<RenderTargetTexture>;
  142503. /**
  142504. * Sets the source texture to read the values from.
  142505. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  142506. * because in such textures '1' value must not be taken into account to compute the maximum
  142507. * as this value is used to clear the texture.
  142508. * Note that the computation is not activated by calling this function, you must call activate() for that!
  142509. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  142510. * @param depthRedux Indicates if the texture is a depth texture or not
  142511. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  142512. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  142513. */
  142514. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  142515. /**
  142516. * Defines the refresh rate of the computation.
  142517. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  142518. */
  142519. get refreshRate(): number;
  142520. set refreshRate(value: number);
  142521. protected _activated: boolean;
  142522. /**
  142523. * Gets the activation status of the reducer
  142524. */
  142525. get activated(): boolean;
  142526. /**
  142527. * Activates the reduction computation.
  142528. * When activated, the observers registered in onAfterReductionPerformed are
  142529. * called after the compuation is performed
  142530. */
  142531. activate(): void;
  142532. /**
  142533. * Deactivates the reduction computation.
  142534. */
  142535. deactivate(): void;
  142536. /**
  142537. * Disposes the min/max reducer
  142538. * @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.
  142539. */
  142540. dispose(disposeAll?: boolean): void;
  142541. }
  142542. }
  142543. declare module BABYLON {
  142544. /**
  142545. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  142546. */
  142547. export class DepthReducer extends MinMaxReducer {
  142548. private _depthRenderer;
  142549. private _depthRendererId;
  142550. /**
  142551. * Gets the depth renderer used for the computation.
  142552. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  142553. */
  142554. get depthRenderer(): Nullable<DepthRenderer>;
  142555. /**
  142556. * Creates a depth reducer
  142557. * @param camera The camera used to render the depth texture
  142558. */
  142559. constructor(camera: Camera);
  142560. /**
  142561. * Sets the depth renderer to use to generate the depth map
  142562. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  142563. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  142564. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  142565. */
  142566. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  142567. /** @hidden */
  142568. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  142569. /**
  142570. * Activates the reduction computation.
  142571. * When activated, the observers registered in onAfterReductionPerformed are
  142572. * called after the compuation is performed
  142573. */
  142574. activate(): void;
  142575. /**
  142576. * Deactivates the reduction computation.
  142577. */
  142578. deactivate(): void;
  142579. /**
  142580. * Disposes the depth reducer
  142581. * @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.
  142582. */
  142583. dispose(disposeAll?: boolean): void;
  142584. }
  142585. }
  142586. declare module BABYLON {
  142587. /**
  142588. * A CSM implementation allowing casting shadows on large scenes.
  142589. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  142590. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  142591. */
  142592. export class CascadedShadowGenerator extends ShadowGenerator {
  142593. private static readonly frustumCornersNDCSpace;
  142594. /**
  142595. * Name of the CSM class
  142596. */
  142597. static CLASSNAME: string;
  142598. /**
  142599. * Defines the default number of cascades used by the CSM.
  142600. */
  142601. static readonly DEFAULT_CASCADES_COUNT: number;
  142602. /**
  142603. * Defines the minimum number of cascades used by the CSM.
  142604. */
  142605. static readonly MIN_CASCADES_COUNT: number;
  142606. /**
  142607. * Defines the maximum number of cascades used by the CSM.
  142608. */
  142609. static readonly MAX_CASCADES_COUNT: number;
  142610. protected _validateFilter(filter: number): number;
  142611. /**
  142612. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  142613. */
  142614. penumbraDarkness: number;
  142615. private _numCascades;
  142616. /**
  142617. * Gets or set the number of cascades used by the CSM.
  142618. */
  142619. get numCascades(): number;
  142620. set numCascades(value: number);
  142621. /**
  142622. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  142623. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  142624. */
  142625. stabilizeCascades: boolean;
  142626. private _freezeShadowCastersBoundingInfo;
  142627. private _freezeShadowCastersBoundingInfoObservable;
  142628. /**
  142629. * Enables or disables the shadow casters bounding info computation.
  142630. * If your shadow casters don't move, you can disable this feature.
  142631. * If it is enabled, the bounding box computation is done every frame.
  142632. */
  142633. get freezeShadowCastersBoundingInfo(): boolean;
  142634. set freezeShadowCastersBoundingInfo(freeze: boolean);
  142635. private _scbiMin;
  142636. private _scbiMax;
  142637. protected _computeShadowCastersBoundingInfo(): void;
  142638. protected _shadowCastersBoundingInfo: BoundingInfo;
  142639. /**
  142640. * Gets or sets the shadow casters bounding info.
  142641. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  142642. * so that the system won't overwrite the bounds you provide
  142643. */
  142644. get shadowCastersBoundingInfo(): BoundingInfo;
  142645. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  142646. protected _breaksAreDirty: boolean;
  142647. protected _minDistance: number;
  142648. protected _maxDistance: number;
  142649. /**
  142650. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  142651. *
  142652. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  142653. * If you don't know these values, simply leave them to their defaults and don't call this function.
  142654. * @param min minimal distance for the breaks (default to 0.)
  142655. * @param max maximal distance for the breaks (default to 1.)
  142656. */
  142657. setMinMaxDistance(min: number, max: number): void;
  142658. /** Gets the minimal distance used in the cascade break computation */
  142659. get minDistance(): number;
  142660. /** Gets the maximal distance used in the cascade break computation */
  142661. get maxDistance(): number;
  142662. /**
  142663. * Gets the class name of that object
  142664. * @returns "CascadedShadowGenerator"
  142665. */
  142666. getClassName(): string;
  142667. private _cascadeMinExtents;
  142668. private _cascadeMaxExtents;
  142669. /**
  142670. * Gets a cascade minimum extents
  142671. * @param cascadeIndex index of the cascade
  142672. * @returns the minimum cascade extents
  142673. */
  142674. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  142675. /**
  142676. * Gets a cascade maximum extents
  142677. * @param cascadeIndex index of the cascade
  142678. * @returns the maximum cascade extents
  142679. */
  142680. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  142681. private _cascades;
  142682. private _currentLayer;
  142683. private _viewSpaceFrustumsZ;
  142684. private _viewMatrices;
  142685. private _projectionMatrices;
  142686. private _transformMatrices;
  142687. private _transformMatricesAsArray;
  142688. private _frustumLengths;
  142689. private _lightSizeUVCorrection;
  142690. private _depthCorrection;
  142691. private _frustumCornersWorldSpace;
  142692. private _frustumCenter;
  142693. private _shadowCameraPos;
  142694. private _shadowMaxZ;
  142695. /**
  142696. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  142697. * It defaults to camera.maxZ
  142698. */
  142699. get shadowMaxZ(): number;
  142700. /**
  142701. * Sets the shadow max z distance.
  142702. */
  142703. set shadowMaxZ(value: number);
  142704. protected _debug: boolean;
  142705. /**
  142706. * Gets or sets the debug flag.
  142707. * When enabled, the cascades are materialized by different colors on the screen.
  142708. */
  142709. get debug(): boolean;
  142710. set debug(dbg: boolean);
  142711. private _depthClamp;
  142712. /**
  142713. * Gets or sets the depth clamping value.
  142714. *
  142715. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  142716. * to account for the shadow casters far away.
  142717. *
  142718. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  142719. */
  142720. get depthClamp(): boolean;
  142721. set depthClamp(value: boolean);
  142722. private _cascadeBlendPercentage;
  142723. /**
  142724. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  142725. * It defaults to 0.1 (10% blending).
  142726. */
  142727. get cascadeBlendPercentage(): number;
  142728. set cascadeBlendPercentage(value: number);
  142729. private _lambda;
  142730. /**
  142731. * Gets or set the lambda parameter.
  142732. * This parameter is used to split the camera frustum and create the cascades.
  142733. * 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.
  142734. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  142735. */
  142736. get lambda(): number;
  142737. set lambda(value: number);
  142738. /**
  142739. * Gets the view matrix corresponding to a given cascade
  142740. * @param cascadeNum cascade to retrieve the view matrix from
  142741. * @returns the cascade view matrix
  142742. */
  142743. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  142744. /**
  142745. * Gets the projection matrix corresponding to a given cascade
  142746. * @param cascadeNum cascade to retrieve the projection matrix from
  142747. * @returns the cascade projection matrix
  142748. */
  142749. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  142750. /**
  142751. * Gets the transformation matrix corresponding to a given cascade
  142752. * @param cascadeNum cascade to retrieve the transformation matrix from
  142753. * @returns the cascade transformation matrix
  142754. */
  142755. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  142756. private _depthRenderer;
  142757. /**
  142758. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  142759. *
  142760. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  142761. *
  142762. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  142763. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  142764. * @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
  142765. */
  142766. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  142767. private _depthReducer;
  142768. private _autoCalcDepthBounds;
  142769. /**
  142770. * Gets or sets the autoCalcDepthBounds property.
  142771. *
  142772. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  142773. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  142774. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  142775. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  142776. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  142777. */
  142778. get autoCalcDepthBounds(): boolean;
  142779. set autoCalcDepthBounds(value: boolean);
  142780. /**
  142781. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  142782. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  142783. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  142784. * for setting the refresh rate on the renderer yourself!
  142785. */
  142786. get autoCalcDepthBoundsRefreshRate(): number;
  142787. set autoCalcDepthBoundsRefreshRate(value: number);
  142788. /**
  142789. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  142790. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  142791. * you change the camera near/far planes!
  142792. */
  142793. splitFrustum(): void;
  142794. private _splitFrustum;
  142795. private _computeMatrices;
  142796. private _computeFrustumInWorldSpace;
  142797. private _computeCascadeFrustum;
  142798. /**
  142799. * Support test.
  142800. */
  142801. static get IsSupported(): boolean;
  142802. /** @hidden */
  142803. static _SceneComponentInitialization: (scene: Scene) => void;
  142804. /**
  142805. * Creates a Cascaded Shadow Generator object.
  142806. * A ShadowGenerator is the required tool to use the shadows.
  142807. * Each directional light casting shadows needs to use its own ShadowGenerator.
  142808. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  142809. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  142810. * @param light The directional light object generating the shadows.
  142811. * @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.
  142812. */
  142813. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  142814. protected _initializeGenerator(): void;
  142815. protected _createTargetRenderTexture(): void;
  142816. protected _initializeShadowMap(): void;
  142817. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  142818. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  142819. /**
  142820. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  142821. * @param defines Defines of the material we want to update
  142822. * @param lightIndex Index of the light in the enabled light list of the material
  142823. */
  142824. prepareDefines(defines: any, lightIndex: number): void;
  142825. /**
  142826. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  142827. * defined in the generator but impacting the effect).
  142828. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  142829. * @param effect The effect we are binfing the information for
  142830. */
  142831. bindShadowLight(lightIndex: string, effect: Effect): void;
  142832. /**
  142833. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  142834. * (eq to view projection * shadow projection matrices)
  142835. * @returns The transform matrix used to create the shadow map
  142836. */
  142837. getTransformMatrix(): Matrix;
  142838. /**
  142839. * Disposes the ShadowGenerator.
  142840. * Returns nothing.
  142841. */
  142842. dispose(): void;
  142843. /**
  142844. * Serializes the shadow generator setup to a json object.
  142845. * @returns The serialized JSON object
  142846. */
  142847. serialize(): any;
  142848. /**
  142849. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  142850. * @param parsedShadowGenerator The JSON object to parse
  142851. * @param scene The scene to create the shadow map for
  142852. * @returns The parsed shadow generator
  142853. */
  142854. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  142855. }
  142856. }
  142857. declare module BABYLON {
  142858. /**
  142859. * Defines the shadow generator component responsible to manage any shadow generators
  142860. * in a given scene.
  142861. */
  142862. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  142863. /**
  142864. * The component name helpfull to identify the component in the list of scene components.
  142865. */
  142866. readonly name: string;
  142867. /**
  142868. * The scene the component belongs to.
  142869. */
  142870. scene: Scene;
  142871. /**
  142872. * Creates a new instance of the component for the given scene
  142873. * @param scene Defines the scene to register the component in
  142874. */
  142875. constructor(scene: Scene);
  142876. /**
  142877. * Registers the component in a given scene
  142878. */
  142879. register(): void;
  142880. /**
  142881. * Rebuilds the elements related to this component in case of
  142882. * context lost for instance.
  142883. */
  142884. rebuild(): void;
  142885. /**
  142886. * Serializes the component data to the specified json object
  142887. * @param serializationObject The object to serialize to
  142888. */
  142889. serialize(serializationObject: any): void;
  142890. /**
  142891. * Adds all the elements from the container to the scene
  142892. * @param container the container holding the elements
  142893. */
  142894. addFromContainer(container: AbstractScene): void;
  142895. /**
  142896. * Removes all the elements in the container from the scene
  142897. * @param container contains the elements to remove
  142898. * @param dispose if the removed element should be disposed (default: false)
  142899. */
  142900. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  142901. /**
  142902. * Rebuilds the elements related to this component in case of
  142903. * context lost for instance.
  142904. */
  142905. dispose(): void;
  142906. private _gatherRenderTargets;
  142907. }
  142908. }
  142909. declare module BABYLON {
  142910. /**
  142911. * A point light is a light defined by an unique point in world space.
  142912. * The light is emitted in every direction from this point.
  142913. * A good example of a point light is a standard light bulb.
  142914. * Documentation: https://doc.babylonjs.com/babylon101/lights
  142915. */
  142916. export class PointLight extends ShadowLight {
  142917. private _shadowAngle;
  142918. /**
  142919. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  142920. * This specifies what angle the shadow will use to be created.
  142921. *
  142922. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  142923. */
  142924. get shadowAngle(): number;
  142925. /**
  142926. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  142927. * This specifies what angle the shadow will use to be created.
  142928. *
  142929. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  142930. */
  142931. set shadowAngle(value: number);
  142932. /**
  142933. * Gets the direction if it has been set.
  142934. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  142935. */
  142936. get direction(): Vector3;
  142937. /**
  142938. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  142939. */
  142940. set direction(value: Vector3);
  142941. /**
  142942. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  142943. * A PointLight emits the light in every direction.
  142944. * It can cast shadows.
  142945. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  142946. * ```javascript
  142947. * var pointLight = new PointLight("pl", camera.position, scene);
  142948. * ```
  142949. * Documentation : https://doc.babylonjs.com/babylon101/lights
  142950. * @param name The light friendly name
  142951. * @param position The position of the point light in the scene
  142952. * @param scene The scene the lights belongs to
  142953. */
  142954. constructor(name: string, position: Vector3, scene: Scene);
  142955. /**
  142956. * Returns the string "PointLight"
  142957. * @returns the class name
  142958. */
  142959. getClassName(): string;
  142960. /**
  142961. * Returns the integer 0.
  142962. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  142963. */
  142964. getTypeID(): number;
  142965. /**
  142966. * Specifies wether or not the shadowmap should be a cube texture.
  142967. * @returns true if the shadowmap needs to be a cube texture.
  142968. */
  142969. needCube(): boolean;
  142970. /**
  142971. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  142972. * @param faceIndex The index of the face we are computed the direction to generate shadow
  142973. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  142974. */
  142975. getShadowDirection(faceIndex?: number): Vector3;
  142976. /**
  142977. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  142978. * - fov = PI / 2
  142979. * - aspect ratio : 1.0
  142980. * - z-near and far equal to the active camera minZ and maxZ.
  142981. * Returns the PointLight.
  142982. */
  142983. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  142984. protected _buildUniformLayout(): void;
  142985. /**
  142986. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  142987. * @param effect The effect to update
  142988. * @param lightIndex The index of the light in the effect to update
  142989. * @returns The point light
  142990. */
  142991. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  142992. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  142993. /**
  142994. * Prepares the list of defines specific to the light type.
  142995. * @param defines the list of defines
  142996. * @param lightIndex defines the index of the light for the effect
  142997. */
  142998. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  142999. }
  143000. }
  143001. declare module BABYLON {
  143002. /**
  143003. * Header information of HDR texture files.
  143004. */
  143005. export interface HDRInfo {
  143006. /**
  143007. * The height of the texture in pixels.
  143008. */
  143009. height: number;
  143010. /**
  143011. * The width of the texture in pixels.
  143012. */
  143013. width: number;
  143014. /**
  143015. * The index of the beginning of the data in the binary file.
  143016. */
  143017. dataPosition: number;
  143018. }
  143019. /**
  143020. * This groups tools to convert HDR texture to native colors array.
  143021. */
  143022. export class HDRTools {
  143023. private static Ldexp;
  143024. private static Rgbe2float;
  143025. private static readStringLine;
  143026. /**
  143027. * Reads header information from an RGBE texture stored in a native array.
  143028. * More information on this format are available here:
  143029. * https://en.wikipedia.org/wiki/RGBE_image_format
  143030. *
  143031. * @param uint8array The binary file stored in native array.
  143032. * @return The header information.
  143033. */
  143034. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  143035. /**
  143036. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  143037. * This RGBE texture needs to store the information as a panorama.
  143038. *
  143039. * More information on this format are available here:
  143040. * https://en.wikipedia.org/wiki/RGBE_image_format
  143041. *
  143042. * @param buffer The binary file stored in an array buffer.
  143043. * @param size The expected size of the extracted cubemap.
  143044. * @return The Cube Map information.
  143045. */
  143046. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  143047. /**
  143048. * Returns the pixels data extracted from an RGBE texture.
  143049. * This pixels will be stored left to right up to down in the R G B order in one array.
  143050. *
  143051. * More information on this format are available here:
  143052. * https://en.wikipedia.org/wiki/RGBE_image_format
  143053. *
  143054. * @param uint8array The binary file stored in an array buffer.
  143055. * @param hdrInfo The header information of the file.
  143056. * @return The pixels data in RGB right to left up to down order.
  143057. */
  143058. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  143059. private static RGBE_ReadPixels_RLE;
  143060. private static RGBE_ReadPixels_NOT_RLE;
  143061. }
  143062. }
  143063. declare module BABYLON {
  143064. /**
  143065. * Effect Render Options
  143066. */
  143067. export interface IEffectRendererOptions {
  143068. /**
  143069. * Defines the vertices positions.
  143070. */
  143071. positions?: number[];
  143072. /**
  143073. * Defines the indices.
  143074. */
  143075. indices?: number[];
  143076. }
  143077. /**
  143078. * Helper class to render one or more effects.
  143079. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  143080. */
  143081. export class EffectRenderer {
  143082. private engine;
  143083. private static _DefaultOptions;
  143084. private _vertexBuffers;
  143085. private _indexBuffer;
  143086. private _fullscreenViewport;
  143087. /**
  143088. * Creates an effect renderer
  143089. * @param engine the engine to use for rendering
  143090. * @param options defines the options of the effect renderer
  143091. */
  143092. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  143093. /**
  143094. * Sets the current viewport in normalized coordinates 0-1
  143095. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  143096. */
  143097. setViewport(viewport?: Viewport): void;
  143098. /**
  143099. * Binds the embedded attributes buffer to the effect.
  143100. * @param effect Defines the effect to bind the attributes for
  143101. */
  143102. bindBuffers(effect: Effect): void;
  143103. /**
  143104. * Sets the current effect wrapper to use during draw.
  143105. * The effect needs to be ready before calling this api.
  143106. * This also sets the default full screen position attribute.
  143107. * @param effectWrapper Defines the effect to draw with
  143108. */
  143109. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  143110. /**
  143111. * Restores engine states
  143112. */
  143113. restoreStates(): void;
  143114. /**
  143115. * Draws a full screen quad.
  143116. */
  143117. draw(): void;
  143118. private isRenderTargetTexture;
  143119. /**
  143120. * renders one or more effects to a specified texture
  143121. * @param effectWrapper the effect to renderer
  143122. * @param outputTexture texture to draw to, if null it will render to the screen.
  143123. */
  143124. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  143125. /**
  143126. * Disposes of the effect renderer
  143127. */
  143128. dispose(): void;
  143129. }
  143130. /**
  143131. * Options to create an EffectWrapper
  143132. */
  143133. interface EffectWrapperCreationOptions {
  143134. /**
  143135. * Engine to use to create the effect
  143136. */
  143137. engine: ThinEngine;
  143138. /**
  143139. * Fragment shader for the effect
  143140. */
  143141. fragmentShader: string;
  143142. /**
  143143. * Use the shader store instead of direct source code
  143144. */
  143145. useShaderStore?: boolean;
  143146. /**
  143147. * Vertex shader for the effect
  143148. */
  143149. vertexShader?: string;
  143150. /**
  143151. * Attributes to use in the shader
  143152. */
  143153. attributeNames?: Array<string>;
  143154. /**
  143155. * Uniforms to use in the shader
  143156. */
  143157. uniformNames?: Array<string>;
  143158. /**
  143159. * Texture sampler names to use in the shader
  143160. */
  143161. samplerNames?: Array<string>;
  143162. /**
  143163. * Defines to use in the shader
  143164. */
  143165. defines?: Array<string>;
  143166. /**
  143167. * Callback when effect is compiled
  143168. */
  143169. onCompiled?: Nullable<(effect: Effect) => void>;
  143170. /**
  143171. * The friendly name of the effect displayed in Spector.
  143172. */
  143173. name?: string;
  143174. }
  143175. /**
  143176. * Wraps an effect to be used for rendering
  143177. */
  143178. export class EffectWrapper {
  143179. /**
  143180. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  143181. */
  143182. onApplyObservable: Observable<{}>;
  143183. /**
  143184. * The underlying effect
  143185. */
  143186. effect: Effect;
  143187. /**
  143188. * Creates an effect to be renderer
  143189. * @param creationOptions options to create the effect
  143190. */
  143191. constructor(creationOptions: EffectWrapperCreationOptions);
  143192. /**
  143193. * Disposes of the effect wrapper
  143194. */
  143195. dispose(): void;
  143196. }
  143197. }
  143198. declare module BABYLON {
  143199. /** @hidden */
  143200. export var hdrFilteringVertexShader: {
  143201. name: string;
  143202. shader: string;
  143203. };
  143204. }
  143205. declare module BABYLON {
  143206. /** @hidden */
  143207. export var hdrFilteringPixelShader: {
  143208. name: string;
  143209. shader: string;
  143210. };
  143211. }
  143212. declare module BABYLON {
  143213. /**
  143214. * Options for texture filtering
  143215. */
  143216. interface IHDRFilteringOptions {
  143217. /**
  143218. * Scales pixel intensity for the input HDR map.
  143219. */
  143220. hdrScale?: number;
  143221. /**
  143222. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  143223. */
  143224. quality?: number;
  143225. }
  143226. /**
  143227. * Filters HDR maps to get correct renderings of PBR reflections
  143228. */
  143229. export class HDRFiltering {
  143230. private _engine;
  143231. private _effectRenderer;
  143232. private _effectWrapper;
  143233. private _lodGenerationOffset;
  143234. private _lodGenerationScale;
  143235. /**
  143236. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  143237. * you care about baking speed.
  143238. */
  143239. quality: number;
  143240. /**
  143241. * Scales pixel intensity for the input HDR map.
  143242. */
  143243. hdrScale: number;
  143244. /**
  143245. * Instantiates HDR filter for reflection maps
  143246. *
  143247. * @param engine Thin engine
  143248. * @param options Options
  143249. */
  143250. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  143251. private _createRenderTarget;
  143252. private _prefilterInternal;
  143253. private _createEffect;
  143254. /**
  143255. * Get a value indicating if the filter is ready to be used
  143256. * @param texture Texture to filter
  143257. * @returns true if the filter is ready
  143258. */
  143259. isReady(texture: BaseTexture): boolean;
  143260. /**
  143261. * Prefilters a cube texture to have mipmap levels representing roughness values.
  143262. * Prefiltering will be invoked at the end of next rendering pass.
  143263. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  143264. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  143265. * @param texture Texture to filter
  143266. * @param onFinished Callback when filtering is done
  143267. * @return Promise called when prefiltering is done
  143268. */
  143269. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  143270. }
  143271. }
  143272. declare module BABYLON {
  143273. /**
  143274. * This represents a texture coming from an HDR input.
  143275. *
  143276. * The only supported format is currently panorama picture stored in RGBE format.
  143277. * Example of such files can be found on HDRLib: http://hdrlib.com/
  143278. */
  143279. export class HDRCubeTexture extends BaseTexture {
  143280. private static _facesMapping;
  143281. private _generateHarmonics;
  143282. private _noMipmap;
  143283. private _prefilterOnLoad;
  143284. private _textureMatrix;
  143285. private _size;
  143286. private _onLoad;
  143287. private _onError;
  143288. /**
  143289. * The texture URL.
  143290. */
  143291. url: string;
  143292. protected _isBlocking: boolean;
  143293. /**
  143294. * Sets wether or not the texture is blocking during loading.
  143295. */
  143296. set isBlocking(value: boolean);
  143297. /**
  143298. * Gets wether or not the texture is blocking during loading.
  143299. */
  143300. get isBlocking(): boolean;
  143301. protected _rotationY: number;
  143302. /**
  143303. * Sets texture matrix rotation angle around Y axis in radians.
  143304. */
  143305. set rotationY(value: number);
  143306. /**
  143307. * Gets texture matrix rotation angle around Y axis radians.
  143308. */
  143309. get rotationY(): number;
  143310. /**
  143311. * Gets or sets the center of the bounding box associated with the cube texture
  143312. * It must define where the camera used to render the texture was set
  143313. */
  143314. boundingBoxPosition: Vector3;
  143315. private _boundingBoxSize;
  143316. /**
  143317. * Gets or sets the size of the bounding box associated with the cube texture
  143318. * When defined, the cubemap will switch to local mode
  143319. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  143320. * @example https://www.babylonjs-playground.com/#RNASML
  143321. */
  143322. set boundingBoxSize(value: Vector3);
  143323. get boundingBoxSize(): Vector3;
  143324. /**
  143325. * Instantiates an HDRTexture from the following parameters.
  143326. *
  143327. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  143328. * @param sceneOrEngine The scene or engine the texture will be used in
  143329. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  143330. * @param noMipmap Forces to not generate the mipmap if true
  143331. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  143332. * @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)
  143333. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  143334. */
  143335. 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>);
  143336. /**
  143337. * Get the current class name of the texture useful for serialization or dynamic coding.
  143338. * @returns "HDRCubeTexture"
  143339. */
  143340. getClassName(): string;
  143341. /**
  143342. * Occurs when the file is raw .hdr file.
  143343. */
  143344. private loadTexture;
  143345. clone(): HDRCubeTexture;
  143346. delayLoad(): void;
  143347. /**
  143348. * Get the texture reflection matrix used to rotate/transform the reflection.
  143349. * @returns the reflection matrix
  143350. */
  143351. getReflectionTextureMatrix(): Matrix;
  143352. /**
  143353. * Set the texture reflection matrix used to rotate/transform the reflection.
  143354. * @param value Define the reflection matrix to set
  143355. */
  143356. setReflectionTextureMatrix(value: Matrix): void;
  143357. /**
  143358. * Parses a JSON representation of an HDR Texture in order to create the texture
  143359. * @param parsedTexture Define the JSON representation
  143360. * @param scene Define the scene the texture should be created in
  143361. * @param rootUrl Define the root url in case we need to load relative dependencies
  143362. * @returns the newly created texture after parsing
  143363. */
  143364. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  143365. serialize(): any;
  143366. }
  143367. }
  143368. declare module BABYLON {
  143369. /**
  143370. * Class used to control physics engine
  143371. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  143372. */
  143373. export class PhysicsEngine implements IPhysicsEngine {
  143374. private _physicsPlugin;
  143375. /**
  143376. * Global value used to control the smallest number supported by the simulation
  143377. */
  143378. static Epsilon: number;
  143379. private _impostors;
  143380. private _joints;
  143381. private _subTimeStep;
  143382. /**
  143383. * Gets the gravity vector used by the simulation
  143384. */
  143385. gravity: Vector3;
  143386. /**
  143387. * Factory used to create the default physics plugin.
  143388. * @returns The default physics plugin
  143389. */
  143390. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  143391. /**
  143392. * Creates a new Physics Engine
  143393. * @param gravity defines the gravity vector used by the simulation
  143394. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  143395. */
  143396. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  143397. /**
  143398. * Sets the gravity vector used by the simulation
  143399. * @param gravity defines the gravity vector to use
  143400. */
  143401. setGravity(gravity: Vector3): void;
  143402. /**
  143403. * Set the time step of the physics engine.
  143404. * Default is 1/60.
  143405. * To slow it down, enter 1/600 for example.
  143406. * To speed it up, 1/30
  143407. * @param newTimeStep defines the new timestep to apply to this world.
  143408. */
  143409. setTimeStep(newTimeStep?: number): void;
  143410. /**
  143411. * Get the time step of the physics engine.
  143412. * @returns the current time step
  143413. */
  143414. getTimeStep(): number;
  143415. /**
  143416. * Set the sub time step of the physics engine.
  143417. * Default is 0 meaning there is no sub steps
  143418. * To increase physics resolution precision, set a small value (like 1 ms)
  143419. * @param subTimeStep defines the new sub timestep used for physics resolution.
  143420. */
  143421. setSubTimeStep(subTimeStep?: number): void;
  143422. /**
  143423. * Get the sub time step of the physics engine.
  143424. * @returns the current sub time step
  143425. */
  143426. getSubTimeStep(): number;
  143427. /**
  143428. * Release all resources
  143429. */
  143430. dispose(): void;
  143431. /**
  143432. * Gets the name of the current physics plugin
  143433. * @returns the name of the plugin
  143434. */
  143435. getPhysicsPluginName(): string;
  143436. /**
  143437. * Adding a new impostor for the impostor tracking.
  143438. * This will be done by the impostor itself.
  143439. * @param impostor the impostor to add
  143440. */
  143441. addImpostor(impostor: PhysicsImpostor): void;
  143442. /**
  143443. * Remove an impostor from the engine.
  143444. * This impostor and its mesh will not longer be updated by the physics engine.
  143445. * @param impostor the impostor to remove
  143446. */
  143447. removeImpostor(impostor: PhysicsImpostor): void;
  143448. /**
  143449. * Add a joint to the physics engine
  143450. * @param mainImpostor defines the main impostor to which the joint is added.
  143451. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  143452. * @param joint defines the joint that will connect both impostors.
  143453. */
  143454. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  143455. /**
  143456. * Removes a joint from the simulation
  143457. * @param mainImpostor defines the impostor used with the joint
  143458. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  143459. * @param joint defines the joint to remove
  143460. */
  143461. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  143462. /**
  143463. * Called by the scene. No need to call it.
  143464. * @param delta defines the timespam between frames
  143465. */
  143466. _step(delta: number): void;
  143467. /**
  143468. * Gets the current plugin used to run the simulation
  143469. * @returns current plugin
  143470. */
  143471. getPhysicsPlugin(): IPhysicsEnginePlugin;
  143472. /**
  143473. * Gets the list of physic impostors
  143474. * @returns an array of PhysicsImpostor
  143475. */
  143476. getImpostors(): Array<PhysicsImpostor>;
  143477. /**
  143478. * Gets the impostor for a physics enabled object
  143479. * @param object defines the object impersonated by the impostor
  143480. * @returns the PhysicsImpostor or null if not found
  143481. */
  143482. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  143483. /**
  143484. * Gets the impostor for a physics body object
  143485. * @param body defines physics body used by the impostor
  143486. * @returns the PhysicsImpostor or null if not found
  143487. */
  143488. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  143489. /**
  143490. * Does a raycast in the physics world
  143491. * @param from when should the ray start?
  143492. * @param to when should the ray end?
  143493. * @returns PhysicsRaycastResult
  143494. */
  143495. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143496. }
  143497. }
  143498. declare module BABYLON {
  143499. /** @hidden */
  143500. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  143501. private _useDeltaForWorldStep;
  143502. world: any;
  143503. name: string;
  143504. private _physicsMaterials;
  143505. private _fixedTimeStep;
  143506. private _cannonRaycastResult;
  143507. private _raycastResult;
  143508. private _physicsBodysToRemoveAfterStep;
  143509. private _firstFrame;
  143510. BJSCANNON: any;
  143511. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  143512. setGravity(gravity: Vector3): void;
  143513. setTimeStep(timeStep: number): void;
  143514. getTimeStep(): number;
  143515. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  143516. private _removeMarkedPhysicsBodiesFromWorld;
  143517. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143518. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143519. generatePhysicsBody(impostor: PhysicsImpostor): void;
  143520. private _processChildMeshes;
  143521. removePhysicsBody(impostor: PhysicsImpostor): void;
  143522. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  143523. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  143524. private _addMaterial;
  143525. private _checkWithEpsilon;
  143526. private _createShape;
  143527. private _createHeightmap;
  143528. private _minus90X;
  143529. private _plus90X;
  143530. private _tmpPosition;
  143531. private _tmpDeltaPosition;
  143532. private _tmpUnityRotation;
  143533. private _updatePhysicsBodyTransformation;
  143534. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  143535. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  143536. isSupported(): boolean;
  143537. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143538. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143539. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143540. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143541. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  143542. getBodyMass(impostor: PhysicsImpostor): number;
  143543. getBodyFriction(impostor: PhysicsImpostor): number;
  143544. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  143545. getBodyRestitution(impostor: PhysicsImpostor): number;
  143546. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  143547. sleepBody(impostor: PhysicsImpostor): void;
  143548. wakeUpBody(impostor: PhysicsImpostor): void;
  143549. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  143550. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  143551. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  143552. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  143553. getRadius(impostor: PhysicsImpostor): number;
  143554. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  143555. dispose(): void;
  143556. private _extendNamespace;
  143557. /**
  143558. * Does a raycast in the physics world
  143559. * @param from when should the ray start?
  143560. * @param to when should the ray end?
  143561. * @returns PhysicsRaycastResult
  143562. */
  143563. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143564. }
  143565. }
  143566. declare module BABYLON {
  143567. /** @hidden */
  143568. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  143569. private _useDeltaForWorldStep;
  143570. world: any;
  143571. name: string;
  143572. BJSOIMO: any;
  143573. private _raycastResult;
  143574. private _fixedTimeStep;
  143575. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  143576. setGravity(gravity: Vector3): void;
  143577. setTimeStep(timeStep: number): void;
  143578. getTimeStep(): number;
  143579. private _tmpImpostorsArray;
  143580. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  143581. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143582. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143583. generatePhysicsBody(impostor: PhysicsImpostor): void;
  143584. private _tmpPositionVector;
  143585. removePhysicsBody(impostor: PhysicsImpostor): void;
  143586. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  143587. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  143588. isSupported(): boolean;
  143589. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  143590. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  143591. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143592. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143593. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143594. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143595. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  143596. getBodyMass(impostor: PhysicsImpostor): number;
  143597. getBodyFriction(impostor: PhysicsImpostor): number;
  143598. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  143599. getBodyRestitution(impostor: PhysicsImpostor): number;
  143600. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  143601. sleepBody(impostor: PhysicsImpostor): void;
  143602. wakeUpBody(impostor: PhysicsImpostor): void;
  143603. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  143604. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  143605. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  143606. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  143607. getRadius(impostor: PhysicsImpostor): number;
  143608. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  143609. dispose(): void;
  143610. /**
  143611. * Does a raycast in the physics world
  143612. * @param from when should the ray start?
  143613. * @param to when should the ray end?
  143614. * @returns PhysicsRaycastResult
  143615. */
  143616. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143617. }
  143618. }
  143619. declare module BABYLON {
  143620. /**
  143621. * AmmoJS Physics plugin
  143622. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  143623. * @see https://github.com/kripken/ammo.js/
  143624. */
  143625. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  143626. private _useDeltaForWorldStep;
  143627. /**
  143628. * Reference to the Ammo library
  143629. */
  143630. bjsAMMO: any;
  143631. /**
  143632. * Created ammoJS world which physics bodies are added to
  143633. */
  143634. world: any;
  143635. /**
  143636. * Name of the plugin
  143637. */
  143638. name: string;
  143639. private _timeStep;
  143640. private _fixedTimeStep;
  143641. private _maxSteps;
  143642. private _tmpQuaternion;
  143643. private _tmpAmmoTransform;
  143644. private _tmpAmmoQuaternion;
  143645. private _tmpAmmoConcreteContactResultCallback;
  143646. private _collisionConfiguration;
  143647. private _dispatcher;
  143648. private _overlappingPairCache;
  143649. private _solver;
  143650. private _softBodySolver;
  143651. private _tmpAmmoVectorA;
  143652. private _tmpAmmoVectorB;
  143653. private _tmpAmmoVectorC;
  143654. private _tmpAmmoVectorD;
  143655. private _tmpContactCallbackResult;
  143656. private _tmpAmmoVectorRCA;
  143657. private _tmpAmmoVectorRCB;
  143658. private _raycastResult;
  143659. private _tmpContactPoint;
  143660. private static readonly DISABLE_COLLISION_FLAG;
  143661. private static readonly KINEMATIC_FLAG;
  143662. private static readonly DISABLE_DEACTIVATION_FLAG;
  143663. /**
  143664. * Initializes the ammoJS plugin
  143665. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  143666. * @param ammoInjection can be used to inject your own ammo reference
  143667. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  143668. */
  143669. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  143670. /**
  143671. * Sets the gravity of the physics world (m/(s^2))
  143672. * @param gravity Gravity to set
  143673. */
  143674. setGravity(gravity: Vector3): void;
  143675. /**
  143676. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  143677. * @param timeStep timestep to use in seconds
  143678. */
  143679. setTimeStep(timeStep: number): void;
  143680. /**
  143681. * 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)
  143682. * @param fixedTimeStep fixedTimeStep to use in seconds
  143683. */
  143684. setFixedTimeStep(fixedTimeStep: number): void;
  143685. /**
  143686. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  143687. * @param maxSteps the maximum number of steps by the physics engine per frame
  143688. */
  143689. setMaxSteps(maxSteps: number): void;
  143690. /**
  143691. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  143692. * @returns the current timestep in seconds
  143693. */
  143694. getTimeStep(): number;
  143695. /**
  143696. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  143697. */
  143698. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  143699. private _isImpostorInContact;
  143700. private _isImpostorPairInContact;
  143701. private _stepSimulation;
  143702. /**
  143703. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  143704. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  143705. * After the step the babylon meshes are set to the position of the physics imposters
  143706. * @param delta amount of time to step forward
  143707. * @param impostors array of imposters to update before/after the step
  143708. */
  143709. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  143710. /**
  143711. * Update babylon mesh to match physics world object
  143712. * @param impostor imposter to match
  143713. */
  143714. private _afterSoftStep;
  143715. /**
  143716. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  143717. * @param impostor imposter to match
  143718. */
  143719. private _ropeStep;
  143720. /**
  143721. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  143722. * @param impostor imposter to match
  143723. */
  143724. private _softbodyOrClothStep;
  143725. private _tmpMatrix;
  143726. /**
  143727. * Applies an impulse on the imposter
  143728. * @param impostor imposter to apply impulse to
  143729. * @param force amount of force to be applied to the imposter
  143730. * @param contactPoint the location to apply the impulse on the imposter
  143731. */
  143732. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143733. /**
  143734. * Applies a force on the imposter
  143735. * @param impostor imposter to apply force
  143736. * @param force amount of force to be applied to the imposter
  143737. * @param contactPoint the location to apply the force on the imposter
  143738. */
  143739. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143740. /**
  143741. * Creates a physics body using the plugin
  143742. * @param impostor the imposter to create the physics body on
  143743. */
  143744. generatePhysicsBody(impostor: PhysicsImpostor): void;
  143745. /**
  143746. * Removes the physics body from the imposter and disposes of the body's memory
  143747. * @param impostor imposter to remove the physics body from
  143748. */
  143749. removePhysicsBody(impostor: PhysicsImpostor): void;
  143750. /**
  143751. * Generates a joint
  143752. * @param impostorJoint the imposter joint to create the joint with
  143753. */
  143754. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  143755. /**
  143756. * Removes a joint
  143757. * @param impostorJoint the imposter joint to remove the joint from
  143758. */
  143759. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  143760. private _addMeshVerts;
  143761. /**
  143762. * Initialise the soft body vertices to match its object's (mesh) vertices
  143763. * Softbody vertices (nodes) are in world space and to match this
  143764. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  143765. * @param impostor to create the softbody for
  143766. */
  143767. private _softVertexData;
  143768. /**
  143769. * Create an impostor's soft body
  143770. * @param impostor to create the softbody for
  143771. */
  143772. private _createSoftbody;
  143773. /**
  143774. * Create cloth for an impostor
  143775. * @param impostor to create the softbody for
  143776. */
  143777. private _createCloth;
  143778. /**
  143779. * Create rope for an impostor
  143780. * @param impostor to create the softbody for
  143781. */
  143782. private _createRope;
  143783. /**
  143784. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  143785. * @param impostor to create the custom physics shape for
  143786. */
  143787. private _createCustom;
  143788. private _addHullVerts;
  143789. private _createShape;
  143790. /**
  143791. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  143792. * @param impostor imposter containing the physics body and babylon object
  143793. */
  143794. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  143795. /**
  143796. * Sets the babylon object's position/rotation from the physics body's position/rotation
  143797. * @param impostor imposter containing the physics body and babylon object
  143798. * @param newPosition new position
  143799. * @param newRotation new rotation
  143800. */
  143801. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  143802. /**
  143803. * If this plugin is supported
  143804. * @returns true if its supported
  143805. */
  143806. isSupported(): boolean;
  143807. /**
  143808. * Sets the linear velocity of the physics body
  143809. * @param impostor imposter to set the velocity on
  143810. * @param velocity velocity to set
  143811. */
  143812. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143813. /**
  143814. * Sets the angular velocity of the physics body
  143815. * @param impostor imposter to set the velocity on
  143816. * @param velocity velocity to set
  143817. */
  143818. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143819. /**
  143820. * gets the linear velocity
  143821. * @param impostor imposter to get linear velocity from
  143822. * @returns linear velocity
  143823. */
  143824. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143825. /**
  143826. * gets the angular velocity
  143827. * @param impostor imposter to get angular velocity from
  143828. * @returns angular velocity
  143829. */
  143830. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143831. /**
  143832. * Sets the mass of physics body
  143833. * @param impostor imposter to set the mass on
  143834. * @param mass mass to set
  143835. */
  143836. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  143837. /**
  143838. * Gets the mass of the physics body
  143839. * @param impostor imposter to get the mass from
  143840. * @returns mass
  143841. */
  143842. getBodyMass(impostor: PhysicsImpostor): number;
  143843. /**
  143844. * Gets friction of the impostor
  143845. * @param impostor impostor to get friction from
  143846. * @returns friction value
  143847. */
  143848. getBodyFriction(impostor: PhysicsImpostor): number;
  143849. /**
  143850. * Sets friction of the impostor
  143851. * @param impostor impostor to set friction on
  143852. * @param friction friction value
  143853. */
  143854. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  143855. /**
  143856. * Gets restitution of the impostor
  143857. * @param impostor impostor to get restitution from
  143858. * @returns restitution value
  143859. */
  143860. getBodyRestitution(impostor: PhysicsImpostor): number;
  143861. /**
  143862. * Sets resitution of the impostor
  143863. * @param impostor impostor to set resitution on
  143864. * @param restitution resitution value
  143865. */
  143866. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  143867. /**
  143868. * Gets pressure inside the impostor
  143869. * @param impostor impostor to get pressure from
  143870. * @returns pressure value
  143871. */
  143872. getBodyPressure(impostor: PhysicsImpostor): number;
  143873. /**
  143874. * Sets pressure inside a soft body impostor
  143875. * Cloth and rope must remain 0 pressure
  143876. * @param impostor impostor to set pressure on
  143877. * @param pressure pressure value
  143878. */
  143879. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  143880. /**
  143881. * Gets stiffness of the impostor
  143882. * @param impostor impostor to get stiffness from
  143883. * @returns pressure value
  143884. */
  143885. getBodyStiffness(impostor: PhysicsImpostor): number;
  143886. /**
  143887. * Sets stiffness of the impostor
  143888. * @param impostor impostor to set stiffness on
  143889. * @param stiffness stiffness value from 0 to 1
  143890. */
  143891. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  143892. /**
  143893. * Gets velocityIterations of the impostor
  143894. * @param impostor impostor to get velocity iterations from
  143895. * @returns velocityIterations value
  143896. */
  143897. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  143898. /**
  143899. * Sets velocityIterations of the impostor
  143900. * @param impostor impostor to set velocity iterations on
  143901. * @param velocityIterations velocityIterations value
  143902. */
  143903. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  143904. /**
  143905. * Gets positionIterations of the impostor
  143906. * @param impostor impostor to get position iterations from
  143907. * @returns positionIterations value
  143908. */
  143909. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  143910. /**
  143911. * Sets positionIterations of the impostor
  143912. * @param impostor impostor to set position on
  143913. * @param positionIterations positionIterations value
  143914. */
  143915. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  143916. /**
  143917. * Append an anchor to a cloth object
  143918. * @param impostor is the cloth impostor to add anchor to
  143919. * @param otherImpostor is the rigid impostor to anchor to
  143920. * @param width ratio across width from 0 to 1
  143921. * @param height ratio up height from 0 to 1
  143922. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  143923. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  143924. */
  143925. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  143926. /**
  143927. * Append an hook to a rope object
  143928. * @param impostor is the rope impostor to add hook to
  143929. * @param otherImpostor is the rigid impostor to hook to
  143930. * @param length ratio along the rope from 0 to 1
  143931. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  143932. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  143933. */
  143934. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  143935. /**
  143936. * Sleeps the physics body and stops it from being active
  143937. * @param impostor impostor to sleep
  143938. */
  143939. sleepBody(impostor: PhysicsImpostor): void;
  143940. /**
  143941. * Activates the physics body
  143942. * @param impostor impostor to activate
  143943. */
  143944. wakeUpBody(impostor: PhysicsImpostor): void;
  143945. /**
  143946. * Updates the distance parameters of the joint
  143947. * @param joint joint to update
  143948. * @param maxDistance maximum distance of the joint
  143949. * @param minDistance minimum distance of the joint
  143950. */
  143951. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  143952. /**
  143953. * Sets a motor on the joint
  143954. * @param joint joint to set motor on
  143955. * @param speed speed of the motor
  143956. * @param maxForce maximum force of the motor
  143957. * @param motorIndex index of the motor
  143958. */
  143959. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  143960. /**
  143961. * Sets the motors limit
  143962. * @param joint joint to set limit on
  143963. * @param upperLimit upper limit
  143964. * @param lowerLimit lower limit
  143965. */
  143966. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  143967. /**
  143968. * Syncs the position and rotation of a mesh with the impostor
  143969. * @param mesh mesh to sync
  143970. * @param impostor impostor to update the mesh with
  143971. */
  143972. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  143973. /**
  143974. * Gets the radius of the impostor
  143975. * @param impostor impostor to get radius from
  143976. * @returns the radius
  143977. */
  143978. getRadius(impostor: PhysicsImpostor): number;
  143979. /**
  143980. * Gets the box size of the impostor
  143981. * @param impostor impostor to get box size from
  143982. * @param result the resulting box size
  143983. */
  143984. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  143985. /**
  143986. * Disposes of the impostor
  143987. */
  143988. dispose(): void;
  143989. /**
  143990. * Does a raycast in the physics world
  143991. * @param from when should the ray start?
  143992. * @param to when should the ray end?
  143993. * @returns PhysicsRaycastResult
  143994. */
  143995. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143996. }
  143997. }
  143998. declare module BABYLON {
  143999. interface AbstractScene {
  144000. /**
  144001. * The list of reflection probes added to the scene
  144002. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  144003. */
  144004. reflectionProbes: Array<ReflectionProbe>;
  144005. /**
  144006. * Removes the given reflection probe from this scene.
  144007. * @param toRemove The reflection probe to remove
  144008. * @returns The index of the removed reflection probe
  144009. */
  144010. removeReflectionProbe(toRemove: ReflectionProbe): number;
  144011. /**
  144012. * Adds the given reflection probe to this scene.
  144013. * @param newReflectionProbe The reflection probe to add
  144014. */
  144015. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  144016. }
  144017. /**
  144018. * Class used to generate realtime reflection / refraction cube textures
  144019. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  144020. */
  144021. export class ReflectionProbe {
  144022. /** defines the name of the probe */
  144023. name: string;
  144024. private _scene;
  144025. private _renderTargetTexture;
  144026. private _projectionMatrix;
  144027. private _viewMatrix;
  144028. private _target;
  144029. private _add;
  144030. private _attachedMesh;
  144031. private _invertYAxis;
  144032. /** Gets or sets probe position (center of the cube map) */
  144033. position: Vector3;
  144034. /**
  144035. * Creates a new reflection probe
  144036. * @param name defines the name of the probe
  144037. * @param size defines the texture resolution (for each face)
  144038. * @param scene defines the hosting scene
  144039. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  144040. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  144041. */
  144042. constructor(
  144043. /** defines the name of the probe */
  144044. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  144045. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  144046. get samples(): number;
  144047. set samples(value: number);
  144048. /** Gets or sets the refresh rate to use (on every frame by default) */
  144049. get refreshRate(): number;
  144050. set refreshRate(value: number);
  144051. /**
  144052. * Gets the hosting scene
  144053. * @returns a Scene
  144054. */
  144055. getScene(): Scene;
  144056. /** Gets the internal CubeTexture used to render to */
  144057. get cubeTexture(): RenderTargetTexture;
  144058. /** Gets the list of meshes to render */
  144059. get renderList(): Nullable<AbstractMesh[]>;
  144060. /**
  144061. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  144062. * @param mesh defines the mesh to attach to
  144063. */
  144064. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  144065. /**
  144066. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  144067. * @param renderingGroupId The rendering group id corresponding to its index
  144068. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  144069. */
  144070. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  144071. /**
  144072. * Clean all associated resources
  144073. */
  144074. dispose(): void;
  144075. /**
  144076. * Converts the reflection probe information to a readable string for debug purpose.
  144077. * @param fullDetails Supports for multiple levels of logging within scene loading
  144078. * @returns the human readable reflection probe info
  144079. */
  144080. toString(fullDetails?: boolean): string;
  144081. /**
  144082. * Get the class name of the relfection probe.
  144083. * @returns "ReflectionProbe"
  144084. */
  144085. getClassName(): string;
  144086. /**
  144087. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  144088. * @returns The JSON representation of the texture
  144089. */
  144090. serialize(): any;
  144091. /**
  144092. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  144093. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  144094. * @param scene Define the scene the parsed reflection probe should be instantiated in
  144095. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  144096. * @returns The parsed reflection probe if successful
  144097. */
  144098. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  144099. }
  144100. }
  144101. declare module BABYLON {
  144102. /** @hidden */
  144103. export var _BabylonLoaderRegistered: boolean;
  144104. /**
  144105. * Helps setting up some configuration for the babylon file loader.
  144106. */
  144107. export class BabylonFileLoaderConfiguration {
  144108. /**
  144109. * The loader does not allow injecting custom physix engine into the plugins.
  144110. * Unfortunately in ES6, we need to manually inject them into the plugin.
  144111. * So you could set this variable to your engine import to make it work.
  144112. */
  144113. static LoaderInjectedPhysicsEngine: any;
  144114. }
  144115. }
  144116. declare module BABYLON {
  144117. /**
  144118. * The Physically based simple base material of BJS.
  144119. *
  144120. * This enables better naming and convention enforcements on top of the pbrMaterial.
  144121. * It is used as the base class for both the specGloss and metalRough conventions.
  144122. */
  144123. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  144124. /**
  144125. * Number of Simultaneous lights allowed on the material.
  144126. */
  144127. maxSimultaneousLights: number;
  144128. /**
  144129. * If sets to true, disables all the lights affecting the material.
  144130. */
  144131. disableLighting: boolean;
  144132. /**
  144133. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  144134. */
  144135. environmentTexture: BaseTexture;
  144136. /**
  144137. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  144138. */
  144139. invertNormalMapX: boolean;
  144140. /**
  144141. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  144142. */
  144143. invertNormalMapY: boolean;
  144144. /**
  144145. * Normal map used in the model.
  144146. */
  144147. normalTexture: BaseTexture;
  144148. /**
  144149. * Emissivie color used to self-illuminate the model.
  144150. */
  144151. emissiveColor: Color3;
  144152. /**
  144153. * Emissivie texture used to self-illuminate the model.
  144154. */
  144155. emissiveTexture: BaseTexture;
  144156. /**
  144157. * Occlusion Channel Strenght.
  144158. */
  144159. occlusionStrength: number;
  144160. /**
  144161. * Occlusion Texture of the material (adding extra occlusion effects).
  144162. */
  144163. occlusionTexture: BaseTexture;
  144164. /**
  144165. * Defines the alpha limits in alpha test mode.
  144166. */
  144167. alphaCutOff: number;
  144168. /**
  144169. * Gets the current double sided mode.
  144170. */
  144171. get doubleSided(): boolean;
  144172. /**
  144173. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  144174. */
  144175. set doubleSided(value: boolean);
  144176. /**
  144177. * Stores the pre-calculated light information of a mesh in a texture.
  144178. */
  144179. lightmapTexture: BaseTexture;
  144180. /**
  144181. * If true, the light map contains occlusion information instead of lighting info.
  144182. */
  144183. useLightmapAsShadowmap: boolean;
  144184. /**
  144185. * Instantiates a new PBRMaterial instance.
  144186. *
  144187. * @param name The material name
  144188. * @param scene The scene the material will be use in.
  144189. */
  144190. constructor(name: string, scene: Scene);
  144191. getClassName(): string;
  144192. }
  144193. }
  144194. declare module BABYLON {
  144195. /**
  144196. * The PBR material of BJS following the metal roughness convention.
  144197. *
  144198. * This fits to the PBR convention in the GLTF definition:
  144199. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  144200. */
  144201. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  144202. /**
  144203. * The base color has two different interpretations depending on the value of metalness.
  144204. * When the material is a metal, the base color is the specific measured reflectance value
  144205. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  144206. * of the material.
  144207. */
  144208. baseColor: Color3;
  144209. /**
  144210. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  144211. * well as opacity information in the alpha channel.
  144212. */
  144213. baseTexture: BaseTexture;
  144214. /**
  144215. * Specifies the metallic scalar value of the material.
  144216. * Can also be used to scale the metalness values of the metallic texture.
  144217. */
  144218. metallic: number;
  144219. /**
  144220. * Specifies the roughness scalar value of the material.
  144221. * Can also be used to scale the roughness values of the metallic texture.
  144222. */
  144223. roughness: number;
  144224. /**
  144225. * Texture containing both the metallic value in the B channel and the
  144226. * roughness value in the G channel to keep better precision.
  144227. */
  144228. metallicRoughnessTexture: BaseTexture;
  144229. /**
  144230. * Instantiates a new PBRMetalRoughnessMaterial instance.
  144231. *
  144232. * @param name The material name
  144233. * @param scene The scene the material will be use in.
  144234. */
  144235. constructor(name: string, scene: Scene);
  144236. /**
  144237. * Return the currrent class name of the material.
  144238. */
  144239. getClassName(): string;
  144240. /**
  144241. * Makes a duplicate of the current material.
  144242. * @param name - name to use for the new material.
  144243. */
  144244. clone(name: string): PBRMetallicRoughnessMaterial;
  144245. /**
  144246. * Serialize the material to a parsable JSON object.
  144247. */
  144248. serialize(): any;
  144249. /**
  144250. * Parses a JSON object correponding to the serialize function.
  144251. */
  144252. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  144253. }
  144254. }
  144255. declare module BABYLON {
  144256. /**
  144257. * The PBR material of BJS following the specular glossiness convention.
  144258. *
  144259. * This fits to the PBR convention in the GLTF definition:
  144260. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  144261. */
  144262. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  144263. /**
  144264. * Specifies the diffuse color of the material.
  144265. */
  144266. diffuseColor: Color3;
  144267. /**
  144268. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  144269. * channel.
  144270. */
  144271. diffuseTexture: BaseTexture;
  144272. /**
  144273. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  144274. */
  144275. specularColor: Color3;
  144276. /**
  144277. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  144278. */
  144279. glossiness: number;
  144280. /**
  144281. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  144282. */
  144283. specularGlossinessTexture: BaseTexture;
  144284. /**
  144285. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  144286. *
  144287. * @param name The material name
  144288. * @param scene The scene the material will be use in.
  144289. */
  144290. constructor(name: string, scene: Scene);
  144291. /**
  144292. * Return the currrent class name of the material.
  144293. */
  144294. getClassName(): string;
  144295. /**
  144296. * Makes a duplicate of the current material.
  144297. * @param name - name to use for the new material.
  144298. */
  144299. clone(name: string): PBRSpecularGlossinessMaterial;
  144300. /**
  144301. * Serialize the material to a parsable JSON object.
  144302. */
  144303. serialize(): any;
  144304. /**
  144305. * Parses a JSON object correponding to the serialize function.
  144306. */
  144307. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  144308. }
  144309. }
  144310. declare module BABYLON {
  144311. /**
  144312. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  144313. * It can help converting any input color in a desired output one. This can then be used to create effects
  144314. * from sepia, black and white to sixties or futuristic rendering...
  144315. *
  144316. * The only supported format is currently 3dl.
  144317. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  144318. */
  144319. export class ColorGradingTexture extends BaseTexture {
  144320. /**
  144321. * The texture URL.
  144322. */
  144323. url: string;
  144324. /**
  144325. * Empty line regex stored for GC.
  144326. */
  144327. private static _noneEmptyLineRegex;
  144328. private _textureMatrix;
  144329. private _onLoad;
  144330. /**
  144331. * Instantiates a ColorGradingTexture from the following parameters.
  144332. *
  144333. * @param url The location of the color gradind data (currently only supporting 3dl)
  144334. * @param sceneOrEngine The scene or engine the texture will be used in
  144335. * @param onLoad defines a callback triggered when the texture has been loaded
  144336. */
  144337. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  144338. /**
  144339. * Fires the onload event from the constructor if requested.
  144340. */
  144341. private _triggerOnLoad;
  144342. /**
  144343. * Returns the texture matrix used in most of the material.
  144344. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  144345. */
  144346. getTextureMatrix(): Matrix;
  144347. /**
  144348. * Occurs when the file being loaded is a .3dl LUT file.
  144349. */
  144350. private load3dlTexture;
  144351. /**
  144352. * Starts the loading process of the texture.
  144353. */
  144354. private loadTexture;
  144355. /**
  144356. * Clones the color gradind texture.
  144357. */
  144358. clone(): ColorGradingTexture;
  144359. /**
  144360. * Called during delayed load for textures.
  144361. */
  144362. delayLoad(): void;
  144363. /**
  144364. * Parses a color grading texture serialized by Babylon.
  144365. * @param parsedTexture The texture information being parsedTexture
  144366. * @param scene The scene to load the texture in
  144367. * @param rootUrl The root url of the data assets to load
  144368. * @return A color gradind texture
  144369. */
  144370. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  144371. /**
  144372. * Serializes the LUT texture to json format.
  144373. */
  144374. serialize(): any;
  144375. }
  144376. }
  144377. declare module BABYLON {
  144378. /**
  144379. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  144380. */
  144381. export class EquiRectangularCubeTexture extends BaseTexture {
  144382. /** The six faces of the cube. */
  144383. private static _FacesMapping;
  144384. private _noMipmap;
  144385. private _onLoad;
  144386. private _onError;
  144387. /** The size of the cubemap. */
  144388. private _size;
  144389. /** The buffer of the image. */
  144390. private _buffer;
  144391. /** The width of the input image. */
  144392. private _width;
  144393. /** The height of the input image. */
  144394. private _height;
  144395. /** The URL to the image. */
  144396. url: string;
  144397. /**
  144398. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  144399. * @param url The location of the image
  144400. * @param scene The scene the texture will be used in
  144401. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  144402. * @param noMipmap Forces to not generate the mipmap if true
  144403. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  144404. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  144405. * @param onLoad — defines a callback called when texture is loaded
  144406. * @param onError — defines a callback called if there is an error
  144407. */
  144408. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  144409. /**
  144410. * Load the image data, by putting the image on a canvas and extracting its buffer.
  144411. */
  144412. private loadImage;
  144413. /**
  144414. * Convert the image buffer into a cubemap and create a CubeTexture.
  144415. */
  144416. private loadTexture;
  144417. /**
  144418. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  144419. * @param buffer The ArrayBuffer that should be converted.
  144420. * @returns The buffer as Float32Array.
  144421. */
  144422. private getFloat32ArrayFromArrayBuffer;
  144423. /**
  144424. * Get the current class name of the texture useful for serialization or dynamic coding.
  144425. * @returns "EquiRectangularCubeTexture"
  144426. */
  144427. getClassName(): string;
  144428. /**
  144429. * Create a clone of the current EquiRectangularCubeTexture and return it.
  144430. * @returns A clone of the current EquiRectangularCubeTexture.
  144431. */
  144432. clone(): EquiRectangularCubeTexture;
  144433. }
  144434. }
  144435. declare module BABYLON {
  144436. /**
  144437. * Defines the options related to the creation of an HtmlElementTexture
  144438. */
  144439. export interface IHtmlElementTextureOptions {
  144440. /**
  144441. * Defines wether mip maps should be created or not.
  144442. */
  144443. generateMipMaps?: boolean;
  144444. /**
  144445. * Defines the sampling mode of the texture.
  144446. */
  144447. samplingMode?: number;
  144448. /**
  144449. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  144450. */
  144451. engine: Nullable<ThinEngine>;
  144452. /**
  144453. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  144454. */
  144455. scene: Nullable<Scene>;
  144456. }
  144457. /**
  144458. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  144459. * To be as efficient as possible depending on your constraints nothing aside the first upload
  144460. * is automatically managed.
  144461. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  144462. * in your application.
  144463. *
  144464. * As the update is not automatic, you need to call them manually.
  144465. */
  144466. export class HtmlElementTexture extends BaseTexture {
  144467. /**
  144468. * The texture URL.
  144469. */
  144470. element: HTMLVideoElement | HTMLCanvasElement;
  144471. private static readonly DefaultOptions;
  144472. private _textureMatrix;
  144473. private _isVideo;
  144474. private _generateMipMaps;
  144475. private _samplingMode;
  144476. /**
  144477. * Instantiates a HtmlElementTexture from the following parameters.
  144478. *
  144479. * @param name Defines the name of the texture
  144480. * @param element Defines the video or canvas the texture is filled with
  144481. * @param options Defines the other none mandatory texture creation options
  144482. */
  144483. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  144484. private _createInternalTexture;
  144485. /**
  144486. * Returns the texture matrix used in most of the material.
  144487. */
  144488. getTextureMatrix(): Matrix;
  144489. /**
  144490. * Updates the content of the texture.
  144491. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  144492. */
  144493. update(invertY?: Nullable<boolean>): void;
  144494. }
  144495. }
  144496. declare module BABYLON {
  144497. /**
  144498. * Based on jsTGALoader - Javascript loader for TGA file
  144499. * By Vincent Thibault
  144500. * @see http://blog.robrowser.com/javascript-tga-loader.html
  144501. */
  144502. export class TGATools {
  144503. private static _TYPE_INDEXED;
  144504. private static _TYPE_RGB;
  144505. private static _TYPE_GREY;
  144506. private static _TYPE_RLE_INDEXED;
  144507. private static _TYPE_RLE_RGB;
  144508. private static _TYPE_RLE_GREY;
  144509. private static _ORIGIN_MASK;
  144510. private static _ORIGIN_SHIFT;
  144511. private static _ORIGIN_BL;
  144512. private static _ORIGIN_BR;
  144513. private static _ORIGIN_UL;
  144514. private static _ORIGIN_UR;
  144515. /**
  144516. * Gets the header of a TGA file
  144517. * @param data defines the TGA data
  144518. * @returns the header
  144519. */
  144520. static GetTGAHeader(data: Uint8Array): any;
  144521. /**
  144522. * Uploads TGA content to a Babylon Texture
  144523. * @hidden
  144524. */
  144525. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  144526. /** @hidden */
  144527. 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;
  144528. /** @hidden */
  144529. 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;
  144530. /** @hidden */
  144531. 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;
  144532. /** @hidden */
  144533. 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;
  144534. /** @hidden */
  144535. 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;
  144536. /** @hidden */
  144537. 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;
  144538. }
  144539. }
  144540. declare module BABYLON {
  144541. /**
  144542. * Implementation of the TGA Texture Loader.
  144543. * @hidden
  144544. */
  144545. export class _TGATextureLoader implements IInternalTextureLoader {
  144546. /**
  144547. * Defines wether the loader supports cascade loading the different faces.
  144548. */
  144549. readonly supportCascades: boolean;
  144550. /**
  144551. * This returns if the loader support the current file information.
  144552. * @param extension defines the file extension of the file being loaded
  144553. * @returns true if the loader can load the specified file
  144554. */
  144555. canLoad(extension: string): boolean;
  144556. /**
  144557. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  144558. * @param data contains the texture data
  144559. * @param texture defines the BabylonJS internal texture
  144560. * @param createPolynomials will be true if polynomials have been requested
  144561. * @param onLoad defines the callback to trigger once the texture is ready
  144562. * @param onError defines the callback to trigger in case of error
  144563. */
  144564. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  144565. /**
  144566. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  144567. * @param data contains the texture data
  144568. * @param texture defines the BabylonJS internal texture
  144569. * @param callback defines the method to call once ready to upload
  144570. */
  144571. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  144572. }
  144573. }
  144574. declare module BABYLON {
  144575. /**
  144576. * Info about the .basis files
  144577. */
  144578. class BasisFileInfo {
  144579. /**
  144580. * If the file has alpha
  144581. */
  144582. hasAlpha: boolean;
  144583. /**
  144584. * Info about each image of the basis file
  144585. */
  144586. images: Array<{
  144587. levels: Array<{
  144588. width: number;
  144589. height: number;
  144590. transcodedPixels: ArrayBufferView;
  144591. }>;
  144592. }>;
  144593. }
  144594. /**
  144595. * Result of transcoding a basis file
  144596. */
  144597. class TranscodeResult {
  144598. /**
  144599. * Info about the .basis file
  144600. */
  144601. fileInfo: BasisFileInfo;
  144602. /**
  144603. * Format to use when loading the file
  144604. */
  144605. format: number;
  144606. }
  144607. /**
  144608. * Configuration options for the Basis transcoder
  144609. */
  144610. export class BasisTranscodeConfiguration {
  144611. /**
  144612. * Supported compression formats used to determine the supported output format of the transcoder
  144613. */
  144614. supportedCompressionFormats?: {
  144615. /**
  144616. * etc1 compression format
  144617. */
  144618. etc1?: boolean;
  144619. /**
  144620. * s3tc compression format
  144621. */
  144622. s3tc?: boolean;
  144623. /**
  144624. * pvrtc compression format
  144625. */
  144626. pvrtc?: boolean;
  144627. /**
  144628. * etc2 compression format
  144629. */
  144630. etc2?: boolean;
  144631. };
  144632. /**
  144633. * If mipmap levels should be loaded for transcoded images (Default: true)
  144634. */
  144635. loadMipmapLevels?: boolean;
  144636. /**
  144637. * Index of a single image to load (Default: all images)
  144638. */
  144639. loadSingleImage?: number;
  144640. }
  144641. /**
  144642. * Used to load .Basis files
  144643. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  144644. */
  144645. export class BasisTools {
  144646. private static _IgnoreSupportedFormats;
  144647. /**
  144648. * URL to use when loading the basis transcoder
  144649. */
  144650. static JSModuleURL: string;
  144651. /**
  144652. * URL to use when loading the wasm module for the transcoder
  144653. */
  144654. static WasmModuleURL: string;
  144655. /**
  144656. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  144657. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  144658. * @returns internal format corresponding to the Basis format
  144659. */
  144660. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  144661. private static _WorkerPromise;
  144662. private static _Worker;
  144663. private static _actionId;
  144664. private static _CreateWorkerAsync;
  144665. /**
  144666. * Transcodes a loaded image file to compressed pixel data
  144667. * @param data image data to transcode
  144668. * @param config configuration options for the transcoding
  144669. * @returns a promise resulting in the transcoded image
  144670. */
  144671. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  144672. /**
  144673. * Loads a texture from the transcode result
  144674. * @param texture texture load to
  144675. * @param transcodeResult the result of transcoding the basis file to load from
  144676. */
  144677. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  144678. }
  144679. }
  144680. declare module BABYLON {
  144681. /**
  144682. * Loader for .basis file format
  144683. */
  144684. export class _BasisTextureLoader implements IInternalTextureLoader {
  144685. /**
  144686. * Defines whether the loader supports cascade loading the different faces.
  144687. */
  144688. readonly supportCascades: boolean;
  144689. /**
  144690. * This returns if the loader support the current file information.
  144691. * @param extension defines the file extension of the file being loaded
  144692. * @returns true if the loader can load the specified file
  144693. */
  144694. canLoad(extension: string): boolean;
  144695. /**
  144696. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  144697. * @param data contains the texture data
  144698. * @param texture defines the BabylonJS internal texture
  144699. * @param createPolynomials will be true if polynomials have been requested
  144700. * @param onLoad defines the callback to trigger once the texture is ready
  144701. * @param onError defines the callback to trigger in case of error
  144702. */
  144703. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  144704. /**
  144705. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  144706. * @param data contains the texture data
  144707. * @param texture defines the BabylonJS internal texture
  144708. * @param callback defines the method to call once ready to upload
  144709. */
  144710. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  144711. }
  144712. }
  144713. declare module BABYLON {
  144714. /**
  144715. * Defines the basic options interface of a TexturePacker Frame
  144716. */
  144717. export interface ITexturePackerFrame {
  144718. /**
  144719. * The frame ID
  144720. */
  144721. id: number;
  144722. /**
  144723. * The frames Scale
  144724. */
  144725. scale: Vector2;
  144726. /**
  144727. * The Frames offset
  144728. */
  144729. offset: Vector2;
  144730. }
  144731. /**
  144732. * This is a support class for frame Data on texture packer sets.
  144733. */
  144734. export class TexturePackerFrame implements ITexturePackerFrame {
  144735. /**
  144736. * The frame ID
  144737. */
  144738. id: number;
  144739. /**
  144740. * The frames Scale
  144741. */
  144742. scale: Vector2;
  144743. /**
  144744. * The Frames offset
  144745. */
  144746. offset: Vector2;
  144747. /**
  144748. * Initializes a texture package frame.
  144749. * @param id The numerical frame identifier
  144750. * @param scale Scalar Vector2 for UV frame
  144751. * @param offset Vector2 for the frame position in UV units.
  144752. * @returns TexturePackerFrame
  144753. */
  144754. constructor(id: number, scale: Vector2, offset: Vector2);
  144755. }
  144756. }
  144757. declare module BABYLON {
  144758. /**
  144759. * Defines the basic options interface of a TexturePacker
  144760. */
  144761. export interface ITexturePackerOptions {
  144762. /**
  144763. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  144764. */
  144765. map?: string[];
  144766. /**
  144767. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  144768. */
  144769. uvsIn?: string;
  144770. /**
  144771. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  144772. */
  144773. uvsOut?: string;
  144774. /**
  144775. * number representing the layout style. Defaults to LAYOUT_STRIP
  144776. */
  144777. layout?: number;
  144778. /**
  144779. * number of columns if using custom column count layout(2). This defaults to 4.
  144780. */
  144781. colnum?: number;
  144782. /**
  144783. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  144784. */
  144785. updateInputMeshes?: boolean;
  144786. /**
  144787. * boolean flag to dispose all the source textures. Defaults to true.
  144788. */
  144789. disposeSources?: boolean;
  144790. /**
  144791. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  144792. */
  144793. fillBlanks?: boolean;
  144794. /**
  144795. * string value representing the context fill style color. Defaults to 'black'.
  144796. */
  144797. customFillColor?: string;
  144798. /**
  144799. * Width and Height Value of each Frame in the TexturePacker Sets
  144800. */
  144801. frameSize?: number;
  144802. /**
  144803. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  144804. */
  144805. paddingRatio?: number;
  144806. /**
  144807. * Number that declares the fill method for the padding gutter.
  144808. */
  144809. paddingMode?: number;
  144810. /**
  144811. * If in SUBUV_COLOR padding mode what color to use.
  144812. */
  144813. paddingColor?: Color3 | Color4;
  144814. }
  144815. /**
  144816. * Defines the basic interface of a TexturePacker JSON File
  144817. */
  144818. export interface ITexturePackerJSON {
  144819. /**
  144820. * The frame ID
  144821. */
  144822. name: string;
  144823. /**
  144824. * The base64 channel data
  144825. */
  144826. sets: any;
  144827. /**
  144828. * The options of the Packer
  144829. */
  144830. options: ITexturePackerOptions;
  144831. /**
  144832. * The frame data of the Packer
  144833. */
  144834. frames: Array<number>;
  144835. }
  144836. /**
  144837. * This is a support class that generates a series of packed texture sets.
  144838. * @see https://doc.babylonjs.com/babylon101/materials
  144839. */
  144840. export class TexturePacker {
  144841. /** Packer Layout Constant 0 */
  144842. static readonly LAYOUT_STRIP: number;
  144843. /** Packer Layout Constant 1 */
  144844. static readonly LAYOUT_POWER2: number;
  144845. /** Packer Layout Constant 2 */
  144846. static readonly LAYOUT_COLNUM: number;
  144847. /** Packer Layout Constant 0 */
  144848. static readonly SUBUV_WRAP: number;
  144849. /** Packer Layout Constant 1 */
  144850. static readonly SUBUV_EXTEND: number;
  144851. /** Packer Layout Constant 2 */
  144852. static readonly SUBUV_COLOR: number;
  144853. /** The Name of the Texture Package */
  144854. name: string;
  144855. /** The scene scope of the TexturePacker */
  144856. scene: Scene;
  144857. /** The Meshes to target */
  144858. meshes: AbstractMesh[];
  144859. /** Arguments passed with the Constructor */
  144860. options: ITexturePackerOptions;
  144861. /** The promise that is started upon initialization */
  144862. promise: Nullable<Promise<TexturePacker | string>>;
  144863. /** The Container object for the channel sets that are generated */
  144864. sets: object;
  144865. /** The Container array for the frames that are generated */
  144866. frames: TexturePackerFrame[];
  144867. /** The expected number of textures the system is parsing. */
  144868. private _expecting;
  144869. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  144870. private _paddingValue;
  144871. /**
  144872. * Initializes a texture package series from an array of meshes or a single mesh.
  144873. * @param name The name of the package
  144874. * @param meshes The target meshes to compose the package from
  144875. * @param options The arguments that texture packer should follow while building.
  144876. * @param scene The scene which the textures are scoped to.
  144877. * @returns TexturePacker
  144878. */
  144879. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  144880. /**
  144881. * Starts the package process
  144882. * @param resolve The promises resolution function
  144883. * @returns TexturePacker
  144884. */
  144885. private _createFrames;
  144886. /**
  144887. * Calculates the Size of the Channel Sets
  144888. * @returns Vector2
  144889. */
  144890. private _calculateSize;
  144891. /**
  144892. * Calculates the UV data for the frames.
  144893. * @param baseSize the base frameSize
  144894. * @param padding the base frame padding
  144895. * @param dtSize size of the Dynamic Texture for that channel
  144896. * @param dtUnits is 1/dtSize
  144897. * @param update flag to update the input meshes
  144898. */
  144899. private _calculateMeshUVFrames;
  144900. /**
  144901. * Calculates the frames Offset.
  144902. * @param index of the frame
  144903. * @returns Vector2
  144904. */
  144905. private _getFrameOffset;
  144906. /**
  144907. * Updates a Mesh to the frame data
  144908. * @param mesh that is the target
  144909. * @param frameID or the frame index
  144910. */
  144911. private _updateMeshUV;
  144912. /**
  144913. * Updates a Meshes materials to use the texture packer channels
  144914. * @param m is the mesh to target
  144915. * @param force all channels on the packer to be set.
  144916. */
  144917. private _updateTextureReferences;
  144918. /**
  144919. * Public method to set a Mesh to a frame
  144920. * @param m that is the target
  144921. * @param frameID or the frame index
  144922. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  144923. */
  144924. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  144925. /**
  144926. * Starts the async promise to compile the texture packer.
  144927. * @returns Promise<void>
  144928. */
  144929. processAsync(): Promise<void>;
  144930. /**
  144931. * Disposes all textures associated with this packer
  144932. */
  144933. dispose(): void;
  144934. /**
  144935. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  144936. * @param imageType is the image type to use.
  144937. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  144938. */
  144939. download(imageType?: string, quality?: number): void;
  144940. /**
  144941. * Public method to load a texturePacker JSON file.
  144942. * @param data of the JSON file in string format.
  144943. */
  144944. updateFromJSON(data: string): void;
  144945. }
  144946. }
  144947. declare module BABYLON {
  144948. /**
  144949. * 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.
  144950. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  144951. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  144952. */
  144953. export class CustomProceduralTexture extends ProceduralTexture {
  144954. private _animate;
  144955. private _time;
  144956. private _config;
  144957. private _texturePath;
  144958. /**
  144959. * Instantiates a new Custom Procedural Texture.
  144960. * 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.
  144961. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  144962. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  144963. * @param name Define the name of the texture
  144964. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  144965. * @param size Define the size of the texture to create
  144966. * @param scene Define the scene the texture belongs to
  144967. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  144968. * @param generateMipMaps Define if the texture should creates mip maps or not
  144969. */
  144970. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  144971. private _loadJson;
  144972. /**
  144973. * Is the texture ready to be used ? (rendered at least once)
  144974. * @returns true if ready, otherwise, false.
  144975. */
  144976. isReady(): boolean;
  144977. /**
  144978. * Render the texture to its associated render target.
  144979. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  144980. */
  144981. render(useCameraPostProcess?: boolean): void;
  144982. /**
  144983. * Update the list of dependant textures samplers in the shader.
  144984. */
  144985. updateTextures(): void;
  144986. /**
  144987. * Update the uniform values of the procedural texture in the shader.
  144988. */
  144989. updateShaderUniforms(): void;
  144990. /**
  144991. * Define if the texture animates or not.
  144992. */
  144993. get animate(): boolean;
  144994. set animate(value: boolean);
  144995. }
  144996. }
  144997. declare module BABYLON {
  144998. /** @hidden */
  144999. export var noisePixelShader: {
  145000. name: string;
  145001. shader: string;
  145002. };
  145003. }
  145004. declare module BABYLON {
  145005. /**
  145006. * Class used to generate noise procedural textures
  145007. */
  145008. export class NoiseProceduralTexture extends ProceduralTexture {
  145009. /** Gets or sets the start time (default is 0) */
  145010. time: number;
  145011. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  145012. brightness: number;
  145013. /** Defines the number of octaves to process */
  145014. octaves: number;
  145015. /** Defines the level of persistence (0.8 by default) */
  145016. persistence: number;
  145017. /** Gets or sets animation speed factor (default is 1) */
  145018. animationSpeedFactor: number;
  145019. /**
  145020. * Creates a new NoiseProceduralTexture
  145021. * @param name defines the name fo the texture
  145022. * @param size defines the size of the texture (default is 256)
  145023. * @param scene defines the hosting scene
  145024. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  145025. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  145026. */
  145027. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  145028. private _updateShaderUniforms;
  145029. protected _getDefines(): string;
  145030. /** Generate the current state of the procedural texture */
  145031. render(useCameraPostProcess?: boolean): void;
  145032. /**
  145033. * Serializes this noise procedural texture
  145034. * @returns a serialized noise procedural texture object
  145035. */
  145036. serialize(): any;
  145037. /**
  145038. * Clone the texture.
  145039. * @returns the cloned texture
  145040. */
  145041. clone(): NoiseProceduralTexture;
  145042. /**
  145043. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  145044. * @param parsedTexture defines parsed texture data
  145045. * @param scene defines the current scene
  145046. * @param rootUrl defines the root URL containing noise procedural texture information
  145047. * @returns a parsed NoiseProceduralTexture
  145048. */
  145049. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  145050. }
  145051. }
  145052. declare module BABYLON {
  145053. /**
  145054. * Raw cube texture where the raw buffers are passed in
  145055. */
  145056. export class RawCubeTexture extends CubeTexture {
  145057. /**
  145058. * Creates a cube texture where the raw buffers are passed in.
  145059. * @param scene defines the scene the texture is attached to
  145060. * @param data defines the array of data to use to create each face
  145061. * @param size defines the size of the textures
  145062. * @param format defines the format of the data
  145063. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  145064. * @param generateMipMaps defines if the engine should generate the mip levels
  145065. * @param invertY defines if data must be stored with Y axis inverted
  145066. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  145067. * @param compression defines the compression used (null by default)
  145068. */
  145069. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  145070. /**
  145071. * Updates the raw cube texture.
  145072. * @param data defines the data to store
  145073. * @param format defines the data format
  145074. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  145075. * @param invertY defines if data must be stored with Y axis inverted
  145076. * @param compression defines the compression used (null by default)
  145077. * @param level defines which level of the texture to update
  145078. */
  145079. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  145080. /**
  145081. * Updates a raw cube texture with RGBD encoded data.
  145082. * @param data defines the array of data [mipmap][face] to use to create each face
  145083. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  145084. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  145085. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  145086. * @returns a promsie that resolves when the operation is complete
  145087. */
  145088. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  145089. /**
  145090. * Clones the raw cube texture.
  145091. * @return a new cube texture
  145092. */
  145093. clone(): CubeTexture;
  145094. /** @hidden */
  145095. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  145096. }
  145097. }
  145098. declare module BABYLON {
  145099. /**
  145100. * Class used to store 2D array textures containing user data
  145101. */
  145102. export class RawTexture2DArray extends Texture {
  145103. /** Gets or sets the texture format to use */
  145104. format: number;
  145105. /**
  145106. * Create a new RawTexture2DArray
  145107. * @param data defines the data of the texture
  145108. * @param width defines the width of the texture
  145109. * @param height defines the height of the texture
  145110. * @param depth defines the number of layers of the texture
  145111. * @param format defines the texture format to use
  145112. * @param scene defines the hosting scene
  145113. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  145114. * @param invertY defines if texture must be stored with Y axis inverted
  145115. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  145116. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  145117. */
  145118. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  145119. /** Gets or sets the texture format to use */
  145120. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  145121. /**
  145122. * Update the texture with new data
  145123. * @param data defines the data to store in the texture
  145124. */
  145125. update(data: ArrayBufferView): void;
  145126. }
  145127. }
  145128. declare module BABYLON {
  145129. /**
  145130. * Class used to store 3D textures containing user data
  145131. */
  145132. export class RawTexture3D extends Texture {
  145133. /** Gets or sets the texture format to use */
  145134. format: number;
  145135. /**
  145136. * Create a new RawTexture3D
  145137. * @param data defines the data of the texture
  145138. * @param width defines the width of the texture
  145139. * @param height defines the height of the texture
  145140. * @param depth defines the depth of the texture
  145141. * @param format defines the texture format to use
  145142. * @param scene defines the hosting scene
  145143. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  145144. * @param invertY defines if texture must be stored with Y axis inverted
  145145. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  145146. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  145147. */
  145148. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  145149. /** Gets or sets the texture format to use */
  145150. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  145151. /**
  145152. * Update the texture with new data
  145153. * @param data defines the data to store in the texture
  145154. */
  145155. update(data: ArrayBufferView): void;
  145156. }
  145157. }
  145158. declare module BABYLON {
  145159. /**
  145160. * Creates a refraction texture used by refraction channel of the standard material.
  145161. * It is like a mirror but to see through a material.
  145162. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  145163. */
  145164. export class RefractionTexture extends RenderTargetTexture {
  145165. /**
  145166. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  145167. * 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.
  145168. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  145169. */
  145170. refractionPlane: Plane;
  145171. /**
  145172. * Define how deep under the surface we should see.
  145173. */
  145174. depth: number;
  145175. /**
  145176. * Creates a refraction texture used by refraction channel of the standard material.
  145177. * It is like a mirror but to see through a material.
  145178. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  145179. * @param name Define the texture name
  145180. * @param size Define the size of the underlying texture
  145181. * @param scene Define the scene the refraction belongs to
  145182. * @param generateMipMaps Define if we need to generate mips level for the refraction
  145183. */
  145184. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  145185. /**
  145186. * Clone the refraction texture.
  145187. * @returns the cloned texture
  145188. */
  145189. clone(): RefractionTexture;
  145190. /**
  145191. * Serialize the texture to a JSON representation you could use in Parse later on
  145192. * @returns the serialized JSON representation
  145193. */
  145194. serialize(): any;
  145195. }
  145196. }
  145197. declare module BABYLON {
  145198. /**
  145199. * Block used to add support for vertex skinning (bones)
  145200. */
  145201. export class BonesBlock extends NodeMaterialBlock {
  145202. /**
  145203. * Creates a new BonesBlock
  145204. * @param name defines the block name
  145205. */
  145206. constructor(name: string);
  145207. /**
  145208. * Initialize the block and prepare the context for build
  145209. * @param state defines the state that will be used for the build
  145210. */
  145211. initialize(state: NodeMaterialBuildState): void;
  145212. /**
  145213. * Gets the current class name
  145214. * @returns the class name
  145215. */
  145216. getClassName(): string;
  145217. /**
  145218. * Gets the matrix indices input component
  145219. */
  145220. get matricesIndices(): NodeMaterialConnectionPoint;
  145221. /**
  145222. * Gets the matrix weights input component
  145223. */
  145224. get matricesWeights(): NodeMaterialConnectionPoint;
  145225. /**
  145226. * Gets the extra matrix indices input component
  145227. */
  145228. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  145229. /**
  145230. * Gets the extra matrix weights input component
  145231. */
  145232. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  145233. /**
  145234. * Gets the world input component
  145235. */
  145236. get world(): NodeMaterialConnectionPoint;
  145237. /**
  145238. * Gets the output component
  145239. */
  145240. get output(): NodeMaterialConnectionPoint;
  145241. autoConfigure(material: NodeMaterial): void;
  145242. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  145243. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145244. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145245. protected _buildBlock(state: NodeMaterialBuildState): this;
  145246. }
  145247. }
  145248. declare module BABYLON {
  145249. /**
  145250. * Block used to add support for instances
  145251. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  145252. */
  145253. export class InstancesBlock extends NodeMaterialBlock {
  145254. /**
  145255. * Creates a new InstancesBlock
  145256. * @param name defines the block name
  145257. */
  145258. constructor(name: string);
  145259. /**
  145260. * Gets the current class name
  145261. * @returns the class name
  145262. */
  145263. getClassName(): string;
  145264. /**
  145265. * Gets the first world row input component
  145266. */
  145267. get world0(): NodeMaterialConnectionPoint;
  145268. /**
  145269. * Gets the second world row input component
  145270. */
  145271. get world1(): NodeMaterialConnectionPoint;
  145272. /**
  145273. * Gets the third world row input component
  145274. */
  145275. get world2(): NodeMaterialConnectionPoint;
  145276. /**
  145277. * Gets the forth world row input component
  145278. */
  145279. get world3(): NodeMaterialConnectionPoint;
  145280. /**
  145281. * Gets the world input component
  145282. */
  145283. get world(): NodeMaterialConnectionPoint;
  145284. /**
  145285. * Gets the output component
  145286. */
  145287. get output(): NodeMaterialConnectionPoint;
  145288. /**
  145289. * Gets the isntanceID component
  145290. */
  145291. get instanceID(): NodeMaterialConnectionPoint;
  145292. autoConfigure(material: NodeMaterial): void;
  145293. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  145294. protected _buildBlock(state: NodeMaterialBuildState): this;
  145295. }
  145296. }
  145297. declare module BABYLON {
  145298. /**
  145299. * Block used to add morph targets support to vertex shader
  145300. */
  145301. export class MorphTargetsBlock extends NodeMaterialBlock {
  145302. private _repeatableContentAnchor;
  145303. /**
  145304. * Create a new MorphTargetsBlock
  145305. * @param name defines the block name
  145306. */
  145307. constructor(name: string);
  145308. /**
  145309. * Gets the current class name
  145310. * @returns the class name
  145311. */
  145312. getClassName(): string;
  145313. /**
  145314. * Gets the position input component
  145315. */
  145316. get position(): NodeMaterialConnectionPoint;
  145317. /**
  145318. * Gets the normal input component
  145319. */
  145320. get normal(): NodeMaterialConnectionPoint;
  145321. /**
  145322. * Gets the tangent input component
  145323. */
  145324. get tangent(): NodeMaterialConnectionPoint;
  145325. /**
  145326. * Gets the tangent input component
  145327. */
  145328. get uv(): NodeMaterialConnectionPoint;
  145329. /**
  145330. * Gets the position output component
  145331. */
  145332. get positionOutput(): NodeMaterialConnectionPoint;
  145333. /**
  145334. * Gets the normal output component
  145335. */
  145336. get normalOutput(): NodeMaterialConnectionPoint;
  145337. /**
  145338. * Gets the tangent output component
  145339. */
  145340. get tangentOutput(): NodeMaterialConnectionPoint;
  145341. /**
  145342. * Gets the tangent output component
  145343. */
  145344. get uvOutput(): NodeMaterialConnectionPoint;
  145345. initialize(state: NodeMaterialBuildState): void;
  145346. autoConfigure(material: NodeMaterial): void;
  145347. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145348. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145349. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  145350. protected _buildBlock(state: NodeMaterialBuildState): this;
  145351. }
  145352. }
  145353. declare module BABYLON {
  145354. /**
  145355. * Block used to get data information from a light
  145356. */
  145357. export class LightInformationBlock extends NodeMaterialBlock {
  145358. private _lightDataUniformName;
  145359. private _lightColorUniformName;
  145360. private _lightTypeDefineName;
  145361. /**
  145362. * Gets or sets the light associated with this block
  145363. */
  145364. light: Nullable<Light>;
  145365. /**
  145366. * Creates a new LightInformationBlock
  145367. * @param name defines the block name
  145368. */
  145369. constructor(name: string);
  145370. /**
  145371. * Gets the current class name
  145372. * @returns the class name
  145373. */
  145374. getClassName(): string;
  145375. /**
  145376. * Gets the world position input component
  145377. */
  145378. get worldPosition(): NodeMaterialConnectionPoint;
  145379. /**
  145380. * Gets the direction output component
  145381. */
  145382. get direction(): NodeMaterialConnectionPoint;
  145383. /**
  145384. * Gets the direction output component
  145385. */
  145386. get color(): NodeMaterialConnectionPoint;
  145387. /**
  145388. * Gets the direction output component
  145389. */
  145390. get intensity(): NodeMaterialConnectionPoint;
  145391. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145392. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145393. protected _buildBlock(state: NodeMaterialBuildState): this;
  145394. serialize(): any;
  145395. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145396. }
  145397. }
  145398. declare module BABYLON {
  145399. /**
  145400. * Block used to add image processing support to fragment shader
  145401. */
  145402. export class ImageProcessingBlock extends NodeMaterialBlock {
  145403. /**
  145404. * Create a new ImageProcessingBlock
  145405. * @param name defines the block name
  145406. */
  145407. constructor(name: string);
  145408. /**
  145409. * Gets the current class name
  145410. * @returns the class name
  145411. */
  145412. getClassName(): string;
  145413. /**
  145414. * Gets the color input component
  145415. */
  145416. get color(): NodeMaterialConnectionPoint;
  145417. /**
  145418. * Gets the output component
  145419. */
  145420. get output(): NodeMaterialConnectionPoint;
  145421. /**
  145422. * Initialize the block and prepare the context for build
  145423. * @param state defines the state that will be used for the build
  145424. */
  145425. initialize(state: NodeMaterialBuildState): void;
  145426. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  145427. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145428. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145429. protected _buildBlock(state: NodeMaterialBuildState): this;
  145430. }
  145431. }
  145432. declare module BABYLON {
  145433. /**
  145434. * Block used to pertub normals based on a normal map
  145435. */
  145436. export class PerturbNormalBlock extends NodeMaterialBlock {
  145437. private _tangentSpaceParameterName;
  145438. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  145439. invertX: boolean;
  145440. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  145441. invertY: boolean;
  145442. /**
  145443. * Create a new PerturbNormalBlock
  145444. * @param name defines the block name
  145445. */
  145446. constructor(name: string);
  145447. /**
  145448. * Gets the current class name
  145449. * @returns the class name
  145450. */
  145451. getClassName(): string;
  145452. /**
  145453. * Gets the world position input component
  145454. */
  145455. get worldPosition(): NodeMaterialConnectionPoint;
  145456. /**
  145457. * Gets the world normal input component
  145458. */
  145459. get worldNormal(): NodeMaterialConnectionPoint;
  145460. /**
  145461. * Gets the world tangent input component
  145462. */
  145463. get worldTangent(): NodeMaterialConnectionPoint;
  145464. /**
  145465. * Gets the uv input component
  145466. */
  145467. get uv(): NodeMaterialConnectionPoint;
  145468. /**
  145469. * Gets the normal map color input component
  145470. */
  145471. get normalMapColor(): NodeMaterialConnectionPoint;
  145472. /**
  145473. * Gets the strength input component
  145474. */
  145475. get strength(): NodeMaterialConnectionPoint;
  145476. /**
  145477. * Gets the output component
  145478. */
  145479. get output(): NodeMaterialConnectionPoint;
  145480. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145481. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145482. autoConfigure(material: NodeMaterial): void;
  145483. protected _buildBlock(state: NodeMaterialBuildState): this;
  145484. protected _dumpPropertiesCode(): string;
  145485. serialize(): any;
  145486. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145487. }
  145488. }
  145489. declare module BABYLON {
  145490. /**
  145491. * Block used to discard a pixel if a value is smaller than a cutoff
  145492. */
  145493. export class DiscardBlock extends NodeMaterialBlock {
  145494. /**
  145495. * Create a new DiscardBlock
  145496. * @param name defines the block name
  145497. */
  145498. constructor(name: string);
  145499. /**
  145500. * Gets the current class name
  145501. * @returns the class name
  145502. */
  145503. getClassName(): string;
  145504. /**
  145505. * Gets the color input component
  145506. */
  145507. get value(): NodeMaterialConnectionPoint;
  145508. /**
  145509. * Gets the cutoff input component
  145510. */
  145511. get cutoff(): NodeMaterialConnectionPoint;
  145512. protected _buildBlock(state: NodeMaterialBuildState): this;
  145513. }
  145514. }
  145515. declare module BABYLON {
  145516. /**
  145517. * Block used to test if the fragment shader is front facing
  145518. */
  145519. export class FrontFacingBlock extends NodeMaterialBlock {
  145520. /**
  145521. * Creates a new FrontFacingBlock
  145522. * @param name defines the block name
  145523. */
  145524. constructor(name: string);
  145525. /**
  145526. * Gets the current class name
  145527. * @returns the class name
  145528. */
  145529. getClassName(): string;
  145530. /**
  145531. * Gets the output component
  145532. */
  145533. get output(): NodeMaterialConnectionPoint;
  145534. protected _buildBlock(state: NodeMaterialBuildState): this;
  145535. }
  145536. }
  145537. declare module BABYLON {
  145538. /**
  145539. * Block used to get the derivative value on x and y of a given input
  145540. */
  145541. export class DerivativeBlock extends NodeMaterialBlock {
  145542. /**
  145543. * Create a new DerivativeBlock
  145544. * @param name defines the block name
  145545. */
  145546. constructor(name: string);
  145547. /**
  145548. * Gets the current class name
  145549. * @returns the class name
  145550. */
  145551. getClassName(): string;
  145552. /**
  145553. * Gets the input component
  145554. */
  145555. get input(): NodeMaterialConnectionPoint;
  145556. /**
  145557. * Gets the derivative output on x
  145558. */
  145559. get dx(): NodeMaterialConnectionPoint;
  145560. /**
  145561. * Gets the derivative output on y
  145562. */
  145563. get dy(): NodeMaterialConnectionPoint;
  145564. protected _buildBlock(state: NodeMaterialBuildState): this;
  145565. }
  145566. }
  145567. declare module BABYLON {
  145568. /**
  145569. * Block used to make gl_FragCoord available
  145570. */
  145571. export class FragCoordBlock extends NodeMaterialBlock {
  145572. /**
  145573. * Creates a new FragCoordBlock
  145574. * @param name defines the block name
  145575. */
  145576. constructor(name: string);
  145577. /**
  145578. * Gets the current class name
  145579. * @returns the class name
  145580. */
  145581. getClassName(): string;
  145582. /**
  145583. * Gets the xy component
  145584. */
  145585. get xy(): NodeMaterialConnectionPoint;
  145586. /**
  145587. * Gets the xyz component
  145588. */
  145589. get xyz(): NodeMaterialConnectionPoint;
  145590. /**
  145591. * Gets the xyzw component
  145592. */
  145593. get xyzw(): NodeMaterialConnectionPoint;
  145594. /**
  145595. * Gets the x component
  145596. */
  145597. get x(): NodeMaterialConnectionPoint;
  145598. /**
  145599. * Gets the y component
  145600. */
  145601. get y(): NodeMaterialConnectionPoint;
  145602. /**
  145603. * Gets the z component
  145604. */
  145605. get z(): NodeMaterialConnectionPoint;
  145606. /**
  145607. * Gets the w component
  145608. */
  145609. get output(): NodeMaterialConnectionPoint;
  145610. protected writeOutputs(state: NodeMaterialBuildState): string;
  145611. protected _buildBlock(state: NodeMaterialBuildState): this;
  145612. }
  145613. }
  145614. declare module BABYLON {
  145615. /**
  145616. * Block used to get the screen sizes
  145617. */
  145618. export class ScreenSizeBlock extends NodeMaterialBlock {
  145619. private _varName;
  145620. private _scene;
  145621. /**
  145622. * Creates a new ScreenSizeBlock
  145623. * @param name defines the block name
  145624. */
  145625. constructor(name: string);
  145626. /**
  145627. * Gets the current class name
  145628. * @returns the class name
  145629. */
  145630. getClassName(): string;
  145631. /**
  145632. * Gets the xy component
  145633. */
  145634. get xy(): NodeMaterialConnectionPoint;
  145635. /**
  145636. * Gets the x component
  145637. */
  145638. get x(): NodeMaterialConnectionPoint;
  145639. /**
  145640. * Gets the y component
  145641. */
  145642. get y(): NodeMaterialConnectionPoint;
  145643. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145644. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  145645. protected _buildBlock(state: NodeMaterialBuildState): this;
  145646. }
  145647. }
  145648. declare module BABYLON {
  145649. /**
  145650. * Block used to add support for scene fog
  145651. */
  145652. export class FogBlock extends NodeMaterialBlock {
  145653. private _fogDistanceName;
  145654. private _fogParameters;
  145655. /**
  145656. * Create a new FogBlock
  145657. * @param name defines the block name
  145658. */
  145659. constructor(name: string);
  145660. /**
  145661. * Gets the current class name
  145662. * @returns the class name
  145663. */
  145664. getClassName(): string;
  145665. /**
  145666. * Gets the world position input component
  145667. */
  145668. get worldPosition(): NodeMaterialConnectionPoint;
  145669. /**
  145670. * Gets the view input component
  145671. */
  145672. get view(): NodeMaterialConnectionPoint;
  145673. /**
  145674. * Gets the color input component
  145675. */
  145676. get input(): NodeMaterialConnectionPoint;
  145677. /**
  145678. * Gets the fog color input component
  145679. */
  145680. get fogColor(): NodeMaterialConnectionPoint;
  145681. /**
  145682. * Gets the output component
  145683. */
  145684. get output(): NodeMaterialConnectionPoint;
  145685. autoConfigure(material: NodeMaterial): void;
  145686. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145687. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145688. protected _buildBlock(state: NodeMaterialBuildState): this;
  145689. }
  145690. }
  145691. declare module BABYLON {
  145692. /**
  145693. * Block used to add light in the fragment shader
  145694. */
  145695. export class LightBlock extends NodeMaterialBlock {
  145696. private _lightId;
  145697. /**
  145698. * Gets or sets the light associated with this block
  145699. */
  145700. light: Nullable<Light>;
  145701. /**
  145702. * Create a new LightBlock
  145703. * @param name defines the block name
  145704. */
  145705. constructor(name: string);
  145706. /**
  145707. * Gets the current class name
  145708. * @returns the class name
  145709. */
  145710. getClassName(): string;
  145711. /**
  145712. * Gets the world position input component
  145713. */
  145714. get worldPosition(): NodeMaterialConnectionPoint;
  145715. /**
  145716. * Gets the world normal input component
  145717. */
  145718. get worldNormal(): NodeMaterialConnectionPoint;
  145719. /**
  145720. * Gets the camera (or eye) position component
  145721. */
  145722. get cameraPosition(): NodeMaterialConnectionPoint;
  145723. /**
  145724. * Gets the glossiness component
  145725. */
  145726. get glossiness(): NodeMaterialConnectionPoint;
  145727. /**
  145728. * Gets the glossinness power component
  145729. */
  145730. get glossPower(): NodeMaterialConnectionPoint;
  145731. /**
  145732. * Gets the diffuse color component
  145733. */
  145734. get diffuseColor(): NodeMaterialConnectionPoint;
  145735. /**
  145736. * Gets the specular color component
  145737. */
  145738. get specularColor(): NodeMaterialConnectionPoint;
  145739. /**
  145740. * Gets the view matrix component
  145741. */
  145742. get view(): NodeMaterialConnectionPoint;
  145743. /**
  145744. * Gets the diffuse output component
  145745. */
  145746. get diffuseOutput(): NodeMaterialConnectionPoint;
  145747. /**
  145748. * Gets the specular output component
  145749. */
  145750. get specularOutput(): NodeMaterialConnectionPoint;
  145751. /**
  145752. * Gets the shadow output component
  145753. */
  145754. get shadow(): NodeMaterialConnectionPoint;
  145755. autoConfigure(material: NodeMaterial): void;
  145756. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145757. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  145758. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145759. private _injectVertexCode;
  145760. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145761. serialize(): any;
  145762. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145763. }
  145764. }
  145765. declare module BABYLON {
  145766. /**
  145767. * Block used to read a reflection texture from a sampler
  145768. */
  145769. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  145770. /**
  145771. * Create a new ReflectionTextureBlock
  145772. * @param name defines the block name
  145773. */
  145774. constructor(name: string);
  145775. /**
  145776. * Gets the current class name
  145777. * @returns the class name
  145778. */
  145779. getClassName(): string;
  145780. /**
  145781. * Gets the world position input component
  145782. */
  145783. get position(): NodeMaterialConnectionPoint;
  145784. /**
  145785. * Gets the world position input component
  145786. */
  145787. get worldPosition(): NodeMaterialConnectionPoint;
  145788. /**
  145789. * Gets the world normal input component
  145790. */
  145791. get worldNormal(): NodeMaterialConnectionPoint;
  145792. /**
  145793. * Gets the world input component
  145794. */
  145795. get world(): NodeMaterialConnectionPoint;
  145796. /**
  145797. * Gets the camera (or eye) position component
  145798. */
  145799. get cameraPosition(): NodeMaterialConnectionPoint;
  145800. /**
  145801. * Gets the view input component
  145802. */
  145803. get view(): NodeMaterialConnectionPoint;
  145804. /**
  145805. * Gets the rgb output component
  145806. */
  145807. get rgb(): NodeMaterialConnectionPoint;
  145808. /**
  145809. * Gets the rgba output component
  145810. */
  145811. get rgba(): NodeMaterialConnectionPoint;
  145812. /**
  145813. * Gets the r output component
  145814. */
  145815. get r(): NodeMaterialConnectionPoint;
  145816. /**
  145817. * Gets the g output component
  145818. */
  145819. get g(): NodeMaterialConnectionPoint;
  145820. /**
  145821. * Gets the b output component
  145822. */
  145823. get b(): NodeMaterialConnectionPoint;
  145824. /**
  145825. * Gets the a output component
  145826. */
  145827. get a(): NodeMaterialConnectionPoint;
  145828. autoConfigure(material: NodeMaterial): void;
  145829. protected _buildBlock(state: NodeMaterialBuildState): this;
  145830. }
  145831. }
  145832. declare module BABYLON {
  145833. /**
  145834. * Block used to add 2 vectors
  145835. */
  145836. export class AddBlock extends NodeMaterialBlock {
  145837. /**
  145838. * Creates a new AddBlock
  145839. * @param name defines the block name
  145840. */
  145841. constructor(name: string);
  145842. /**
  145843. * Gets the current class name
  145844. * @returns the class name
  145845. */
  145846. getClassName(): string;
  145847. /**
  145848. * Gets the left operand input component
  145849. */
  145850. get left(): NodeMaterialConnectionPoint;
  145851. /**
  145852. * Gets the right operand input component
  145853. */
  145854. get right(): NodeMaterialConnectionPoint;
  145855. /**
  145856. * Gets the output component
  145857. */
  145858. get output(): NodeMaterialConnectionPoint;
  145859. protected _buildBlock(state: NodeMaterialBuildState): this;
  145860. }
  145861. }
  145862. declare module BABYLON {
  145863. /**
  145864. * Block used to scale a vector by a float
  145865. */
  145866. export class ScaleBlock extends NodeMaterialBlock {
  145867. /**
  145868. * Creates a new ScaleBlock
  145869. * @param name defines the block name
  145870. */
  145871. constructor(name: string);
  145872. /**
  145873. * Gets the current class name
  145874. * @returns the class name
  145875. */
  145876. getClassName(): string;
  145877. /**
  145878. * Gets the input component
  145879. */
  145880. get input(): NodeMaterialConnectionPoint;
  145881. /**
  145882. * Gets the factor input component
  145883. */
  145884. get factor(): NodeMaterialConnectionPoint;
  145885. /**
  145886. * Gets the output component
  145887. */
  145888. get output(): NodeMaterialConnectionPoint;
  145889. protected _buildBlock(state: NodeMaterialBuildState): this;
  145890. }
  145891. }
  145892. declare module BABYLON {
  145893. /**
  145894. * Block used to clamp a float
  145895. */
  145896. export class ClampBlock extends NodeMaterialBlock {
  145897. /** Gets or sets the minimum range */
  145898. minimum: number;
  145899. /** Gets or sets the maximum range */
  145900. maximum: number;
  145901. /**
  145902. * Creates a new ClampBlock
  145903. * @param name defines the block name
  145904. */
  145905. constructor(name: string);
  145906. /**
  145907. * Gets the current class name
  145908. * @returns the class name
  145909. */
  145910. getClassName(): string;
  145911. /**
  145912. * Gets the value input component
  145913. */
  145914. get value(): NodeMaterialConnectionPoint;
  145915. /**
  145916. * Gets the output component
  145917. */
  145918. get output(): NodeMaterialConnectionPoint;
  145919. protected _buildBlock(state: NodeMaterialBuildState): this;
  145920. protected _dumpPropertiesCode(): string;
  145921. serialize(): any;
  145922. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145923. }
  145924. }
  145925. declare module BABYLON {
  145926. /**
  145927. * Block used to apply a cross product between 2 vectors
  145928. */
  145929. export class CrossBlock extends NodeMaterialBlock {
  145930. /**
  145931. * Creates a new CrossBlock
  145932. * @param name defines the block name
  145933. */
  145934. constructor(name: string);
  145935. /**
  145936. * Gets the current class name
  145937. * @returns the class name
  145938. */
  145939. getClassName(): string;
  145940. /**
  145941. * Gets the left operand input component
  145942. */
  145943. get left(): NodeMaterialConnectionPoint;
  145944. /**
  145945. * Gets the right operand input component
  145946. */
  145947. get right(): NodeMaterialConnectionPoint;
  145948. /**
  145949. * Gets the output component
  145950. */
  145951. get output(): NodeMaterialConnectionPoint;
  145952. protected _buildBlock(state: NodeMaterialBuildState): this;
  145953. }
  145954. }
  145955. declare module BABYLON {
  145956. /**
  145957. * Block used to apply a dot product between 2 vectors
  145958. */
  145959. export class DotBlock extends NodeMaterialBlock {
  145960. /**
  145961. * Creates a new DotBlock
  145962. * @param name defines the block name
  145963. */
  145964. constructor(name: string);
  145965. /**
  145966. * Gets the current class name
  145967. * @returns the class name
  145968. */
  145969. getClassName(): string;
  145970. /**
  145971. * Gets the left operand input component
  145972. */
  145973. get left(): NodeMaterialConnectionPoint;
  145974. /**
  145975. * Gets the right operand input component
  145976. */
  145977. get right(): NodeMaterialConnectionPoint;
  145978. /**
  145979. * Gets the output component
  145980. */
  145981. get output(): NodeMaterialConnectionPoint;
  145982. protected _buildBlock(state: NodeMaterialBuildState): this;
  145983. }
  145984. }
  145985. declare module BABYLON {
  145986. /**
  145987. * Block used to normalize a vector
  145988. */
  145989. export class NormalizeBlock extends NodeMaterialBlock {
  145990. /**
  145991. * Creates a new NormalizeBlock
  145992. * @param name defines the block name
  145993. */
  145994. constructor(name: string);
  145995. /**
  145996. * Gets the current class name
  145997. * @returns the class name
  145998. */
  145999. getClassName(): string;
  146000. /**
  146001. * Gets the input component
  146002. */
  146003. get input(): NodeMaterialConnectionPoint;
  146004. /**
  146005. * Gets the output component
  146006. */
  146007. get output(): NodeMaterialConnectionPoint;
  146008. protected _buildBlock(state: NodeMaterialBuildState): this;
  146009. }
  146010. }
  146011. declare module BABYLON {
  146012. /**
  146013. * Block used to create a Color3/4 out of individual inputs (one for each component)
  146014. */
  146015. export class ColorMergerBlock extends NodeMaterialBlock {
  146016. /**
  146017. * Create a new ColorMergerBlock
  146018. * @param name defines the block name
  146019. */
  146020. constructor(name: string);
  146021. /**
  146022. * Gets the current class name
  146023. * @returns the class name
  146024. */
  146025. getClassName(): string;
  146026. /**
  146027. * Gets the rgb component (input)
  146028. */
  146029. get rgbIn(): NodeMaterialConnectionPoint;
  146030. /**
  146031. * Gets the r component (input)
  146032. */
  146033. get r(): NodeMaterialConnectionPoint;
  146034. /**
  146035. * Gets the g component (input)
  146036. */
  146037. get g(): NodeMaterialConnectionPoint;
  146038. /**
  146039. * Gets the b component (input)
  146040. */
  146041. get b(): NodeMaterialConnectionPoint;
  146042. /**
  146043. * Gets the a component (input)
  146044. */
  146045. get a(): NodeMaterialConnectionPoint;
  146046. /**
  146047. * Gets the rgba component (output)
  146048. */
  146049. get rgba(): NodeMaterialConnectionPoint;
  146050. /**
  146051. * Gets the rgb component (output)
  146052. */
  146053. get rgbOut(): NodeMaterialConnectionPoint;
  146054. /**
  146055. * Gets the rgb component (output)
  146056. * @deprecated Please use rgbOut instead.
  146057. */
  146058. get rgb(): NodeMaterialConnectionPoint;
  146059. protected _buildBlock(state: NodeMaterialBuildState): this;
  146060. }
  146061. }
  146062. declare module BABYLON {
  146063. /**
  146064. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  146065. */
  146066. export class VectorSplitterBlock extends NodeMaterialBlock {
  146067. /**
  146068. * Create a new VectorSplitterBlock
  146069. * @param name defines the block name
  146070. */
  146071. constructor(name: string);
  146072. /**
  146073. * Gets the current class name
  146074. * @returns the class name
  146075. */
  146076. getClassName(): string;
  146077. /**
  146078. * Gets the xyzw component (input)
  146079. */
  146080. get xyzw(): NodeMaterialConnectionPoint;
  146081. /**
  146082. * Gets the xyz component (input)
  146083. */
  146084. get xyzIn(): NodeMaterialConnectionPoint;
  146085. /**
  146086. * Gets the xy component (input)
  146087. */
  146088. get xyIn(): NodeMaterialConnectionPoint;
  146089. /**
  146090. * Gets the xyz component (output)
  146091. */
  146092. get xyzOut(): NodeMaterialConnectionPoint;
  146093. /**
  146094. * Gets the xy component (output)
  146095. */
  146096. get xyOut(): NodeMaterialConnectionPoint;
  146097. /**
  146098. * Gets the x component (output)
  146099. */
  146100. get x(): NodeMaterialConnectionPoint;
  146101. /**
  146102. * Gets the y component (output)
  146103. */
  146104. get y(): NodeMaterialConnectionPoint;
  146105. /**
  146106. * Gets the z component (output)
  146107. */
  146108. get z(): NodeMaterialConnectionPoint;
  146109. /**
  146110. * Gets the w component (output)
  146111. */
  146112. get w(): NodeMaterialConnectionPoint;
  146113. protected _inputRename(name: string): string;
  146114. protected _outputRename(name: string): string;
  146115. protected _buildBlock(state: NodeMaterialBuildState): this;
  146116. }
  146117. }
  146118. declare module BABYLON {
  146119. /**
  146120. * Block used to lerp between 2 values
  146121. */
  146122. export class LerpBlock extends NodeMaterialBlock {
  146123. /**
  146124. * Creates a new LerpBlock
  146125. * @param name defines the block name
  146126. */
  146127. constructor(name: string);
  146128. /**
  146129. * Gets the current class name
  146130. * @returns the class name
  146131. */
  146132. getClassName(): string;
  146133. /**
  146134. * Gets the left operand input component
  146135. */
  146136. get left(): NodeMaterialConnectionPoint;
  146137. /**
  146138. * Gets the right operand input component
  146139. */
  146140. get right(): NodeMaterialConnectionPoint;
  146141. /**
  146142. * Gets the gradient operand input component
  146143. */
  146144. get gradient(): NodeMaterialConnectionPoint;
  146145. /**
  146146. * Gets the output component
  146147. */
  146148. get output(): NodeMaterialConnectionPoint;
  146149. protected _buildBlock(state: NodeMaterialBuildState): this;
  146150. }
  146151. }
  146152. declare module BABYLON {
  146153. /**
  146154. * Block used to divide 2 vectors
  146155. */
  146156. export class DivideBlock extends NodeMaterialBlock {
  146157. /**
  146158. * Creates a new DivideBlock
  146159. * @param name defines the block name
  146160. */
  146161. constructor(name: string);
  146162. /**
  146163. * Gets the current class name
  146164. * @returns the class name
  146165. */
  146166. getClassName(): string;
  146167. /**
  146168. * Gets the left operand input component
  146169. */
  146170. get left(): NodeMaterialConnectionPoint;
  146171. /**
  146172. * Gets the right operand input component
  146173. */
  146174. get right(): NodeMaterialConnectionPoint;
  146175. /**
  146176. * Gets the output component
  146177. */
  146178. get output(): NodeMaterialConnectionPoint;
  146179. protected _buildBlock(state: NodeMaterialBuildState): this;
  146180. }
  146181. }
  146182. declare module BABYLON {
  146183. /**
  146184. * Block used to subtract 2 vectors
  146185. */
  146186. export class SubtractBlock extends NodeMaterialBlock {
  146187. /**
  146188. * Creates a new SubtractBlock
  146189. * @param name defines the block name
  146190. */
  146191. constructor(name: string);
  146192. /**
  146193. * Gets the current class name
  146194. * @returns the class name
  146195. */
  146196. getClassName(): string;
  146197. /**
  146198. * Gets the left operand input component
  146199. */
  146200. get left(): NodeMaterialConnectionPoint;
  146201. /**
  146202. * Gets the right operand input component
  146203. */
  146204. get right(): NodeMaterialConnectionPoint;
  146205. /**
  146206. * Gets the output component
  146207. */
  146208. get output(): NodeMaterialConnectionPoint;
  146209. protected _buildBlock(state: NodeMaterialBuildState): this;
  146210. }
  146211. }
  146212. declare module BABYLON {
  146213. /**
  146214. * Block used to step a value
  146215. */
  146216. export class StepBlock extends NodeMaterialBlock {
  146217. /**
  146218. * Creates a new StepBlock
  146219. * @param name defines the block name
  146220. */
  146221. constructor(name: string);
  146222. /**
  146223. * Gets the current class name
  146224. * @returns the class name
  146225. */
  146226. getClassName(): string;
  146227. /**
  146228. * Gets the value operand input component
  146229. */
  146230. get value(): NodeMaterialConnectionPoint;
  146231. /**
  146232. * Gets the edge operand input component
  146233. */
  146234. get edge(): NodeMaterialConnectionPoint;
  146235. /**
  146236. * Gets the output component
  146237. */
  146238. get output(): NodeMaterialConnectionPoint;
  146239. protected _buildBlock(state: NodeMaterialBuildState): this;
  146240. }
  146241. }
  146242. declare module BABYLON {
  146243. /**
  146244. * Block used to get the opposite (1 - x) of a value
  146245. */
  146246. export class OneMinusBlock extends NodeMaterialBlock {
  146247. /**
  146248. * Creates a new OneMinusBlock
  146249. * @param name defines the block name
  146250. */
  146251. constructor(name: string);
  146252. /**
  146253. * Gets the current class name
  146254. * @returns the class name
  146255. */
  146256. getClassName(): string;
  146257. /**
  146258. * Gets the input component
  146259. */
  146260. get input(): NodeMaterialConnectionPoint;
  146261. /**
  146262. * Gets the output component
  146263. */
  146264. get output(): NodeMaterialConnectionPoint;
  146265. protected _buildBlock(state: NodeMaterialBuildState): this;
  146266. }
  146267. }
  146268. declare module BABYLON {
  146269. /**
  146270. * Block used to get the view direction
  146271. */
  146272. export class ViewDirectionBlock extends NodeMaterialBlock {
  146273. /**
  146274. * Creates a new ViewDirectionBlock
  146275. * @param name defines the block name
  146276. */
  146277. constructor(name: string);
  146278. /**
  146279. * Gets the current class name
  146280. * @returns the class name
  146281. */
  146282. getClassName(): string;
  146283. /**
  146284. * Gets the world position component
  146285. */
  146286. get worldPosition(): NodeMaterialConnectionPoint;
  146287. /**
  146288. * Gets the camera position component
  146289. */
  146290. get cameraPosition(): NodeMaterialConnectionPoint;
  146291. /**
  146292. * Gets the output component
  146293. */
  146294. get output(): NodeMaterialConnectionPoint;
  146295. autoConfigure(material: NodeMaterial): void;
  146296. protected _buildBlock(state: NodeMaterialBuildState): this;
  146297. }
  146298. }
  146299. declare module BABYLON {
  146300. /**
  146301. * Block used to compute fresnel value
  146302. */
  146303. export class FresnelBlock extends NodeMaterialBlock {
  146304. /**
  146305. * Create a new FresnelBlock
  146306. * @param name defines the block name
  146307. */
  146308. constructor(name: string);
  146309. /**
  146310. * Gets the current class name
  146311. * @returns the class name
  146312. */
  146313. getClassName(): string;
  146314. /**
  146315. * Gets the world normal input component
  146316. */
  146317. get worldNormal(): NodeMaterialConnectionPoint;
  146318. /**
  146319. * Gets the view direction input component
  146320. */
  146321. get viewDirection(): NodeMaterialConnectionPoint;
  146322. /**
  146323. * Gets the bias input component
  146324. */
  146325. get bias(): NodeMaterialConnectionPoint;
  146326. /**
  146327. * Gets the camera (or eye) position component
  146328. */
  146329. get power(): NodeMaterialConnectionPoint;
  146330. /**
  146331. * Gets the fresnel output component
  146332. */
  146333. get fresnel(): NodeMaterialConnectionPoint;
  146334. autoConfigure(material: NodeMaterial): void;
  146335. protected _buildBlock(state: NodeMaterialBuildState): this;
  146336. }
  146337. }
  146338. declare module BABYLON {
  146339. /**
  146340. * Block used to get the max of 2 values
  146341. */
  146342. export class MaxBlock extends NodeMaterialBlock {
  146343. /**
  146344. * Creates a new MaxBlock
  146345. * @param name defines the block name
  146346. */
  146347. constructor(name: string);
  146348. /**
  146349. * Gets the current class name
  146350. * @returns the class name
  146351. */
  146352. getClassName(): string;
  146353. /**
  146354. * Gets the left operand input component
  146355. */
  146356. get left(): NodeMaterialConnectionPoint;
  146357. /**
  146358. * Gets the right operand input component
  146359. */
  146360. get right(): NodeMaterialConnectionPoint;
  146361. /**
  146362. * Gets the output component
  146363. */
  146364. get output(): NodeMaterialConnectionPoint;
  146365. protected _buildBlock(state: NodeMaterialBuildState): this;
  146366. }
  146367. }
  146368. declare module BABYLON {
  146369. /**
  146370. * Block used to get the min of 2 values
  146371. */
  146372. export class MinBlock extends NodeMaterialBlock {
  146373. /**
  146374. * Creates a new MinBlock
  146375. * @param name defines the block name
  146376. */
  146377. constructor(name: string);
  146378. /**
  146379. * Gets the current class name
  146380. * @returns the class name
  146381. */
  146382. getClassName(): string;
  146383. /**
  146384. * Gets the left operand input component
  146385. */
  146386. get left(): NodeMaterialConnectionPoint;
  146387. /**
  146388. * Gets the right operand input component
  146389. */
  146390. get right(): NodeMaterialConnectionPoint;
  146391. /**
  146392. * Gets the output component
  146393. */
  146394. get output(): NodeMaterialConnectionPoint;
  146395. protected _buildBlock(state: NodeMaterialBuildState): this;
  146396. }
  146397. }
  146398. declare module BABYLON {
  146399. /**
  146400. * Block used to get the distance between 2 values
  146401. */
  146402. export class DistanceBlock extends NodeMaterialBlock {
  146403. /**
  146404. * Creates a new DistanceBlock
  146405. * @param name defines the block name
  146406. */
  146407. constructor(name: string);
  146408. /**
  146409. * Gets the current class name
  146410. * @returns the class name
  146411. */
  146412. getClassName(): string;
  146413. /**
  146414. * Gets the left operand input component
  146415. */
  146416. get left(): NodeMaterialConnectionPoint;
  146417. /**
  146418. * Gets the right operand input component
  146419. */
  146420. get right(): NodeMaterialConnectionPoint;
  146421. /**
  146422. * Gets the output component
  146423. */
  146424. get output(): NodeMaterialConnectionPoint;
  146425. protected _buildBlock(state: NodeMaterialBuildState): this;
  146426. }
  146427. }
  146428. declare module BABYLON {
  146429. /**
  146430. * Block used to get the length of a vector
  146431. */
  146432. export class LengthBlock extends NodeMaterialBlock {
  146433. /**
  146434. * Creates a new LengthBlock
  146435. * @param name defines the block name
  146436. */
  146437. constructor(name: string);
  146438. /**
  146439. * Gets the current class name
  146440. * @returns the class name
  146441. */
  146442. getClassName(): string;
  146443. /**
  146444. * Gets the value input component
  146445. */
  146446. get value(): NodeMaterialConnectionPoint;
  146447. /**
  146448. * Gets the output component
  146449. */
  146450. get output(): NodeMaterialConnectionPoint;
  146451. protected _buildBlock(state: NodeMaterialBuildState): this;
  146452. }
  146453. }
  146454. declare module BABYLON {
  146455. /**
  146456. * Block used to get negative version of a value (i.e. x * -1)
  146457. */
  146458. export class NegateBlock extends NodeMaterialBlock {
  146459. /**
  146460. * Creates a new NegateBlock
  146461. * @param name defines the block name
  146462. */
  146463. constructor(name: string);
  146464. /**
  146465. * Gets the current class name
  146466. * @returns the class name
  146467. */
  146468. getClassName(): string;
  146469. /**
  146470. * Gets the value input component
  146471. */
  146472. get value(): NodeMaterialConnectionPoint;
  146473. /**
  146474. * Gets the output component
  146475. */
  146476. get output(): NodeMaterialConnectionPoint;
  146477. protected _buildBlock(state: NodeMaterialBuildState): this;
  146478. }
  146479. }
  146480. declare module BABYLON {
  146481. /**
  146482. * Block used to get the value of the first parameter raised to the power of the second
  146483. */
  146484. export class PowBlock extends NodeMaterialBlock {
  146485. /**
  146486. * Creates a new PowBlock
  146487. * @param name defines the block name
  146488. */
  146489. constructor(name: string);
  146490. /**
  146491. * Gets the current class name
  146492. * @returns the class name
  146493. */
  146494. getClassName(): string;
  146495. /**
  146496. * Gets the value operand input component
  146497. */
  146498. get value(): NodeMaterialConnectionPoint;
  146499. /**
  146500. * Gets the power operand input component
  146501. */
  146502. get power(): NodeMaterialConnectionPoint;
  146503. /**
  146504. * Gets the output component
  146505. */
  146506. get output(): NodeMaterialConnectionPoint;
  146507. protected _buildBlock(state: NodeMaterialBuildState): this;
  146508. }
  146509. }
  146510. declare module BABYLON {
  146511. /**
  146512. * Block used to get a random number
  146513. */
  146514. export class RandomNumberBlock extends NodeMaterialBlock {
  146515. /**
  146516. * Creates a new RandomNumberBlock
  146517. * @param name defines the block name
  146518. */
  146519. constructor(name: string);
  146520. /**
  146521. * Gets the current class name
  146522. * @returns the class name
  146523. */
  146524. getClassName(): string;
  146525. /**
  146526. * Gets the seed input component
  146527. */
  146528. get seed(): NodeMaterialConnectionPoint;
  146529. /**
  146530. * Gets the output component
  146531. */
  146532. get output(): NodeMaterialConnectionPoint;
  146533. protected _buildBlock(state: NodeMaterialBuildState): this;
  146534. }
  146535. }
  146536. declare module BABYLON {
  146537. /**
  146538. * Block used to compute arc tangent of 2 values
  146539. */
  146540. export class ArcTan2Block extends NodeMaterialBlock {
  146541. /**
  146542. * Creates a new ArcTan2Block
  146543. * @param name defines the block name
  146544. */
  146545. constructor(name: string);
  146546. /**
  146547. * Gets the current class name
  146548. * @returns the class name
  146549. */
  146550. getClassName(): string;
  146551. /**
  146552. * Gets the x operand input component
  146553. */
  146554. get x(): NodeMaterialConnectionPoint;
  146555. /**
  146556. * Gets the y operand input component
  146557. */
  146558. get y(): NodeMaterialConnectionPoint;
  146559. /**
  146560. * Gets the output component
  146561. */
  146562. get output(): NodeMaterialConnectionPoint;
  146563. protected _buildBlock(state: NodeMaterialBuildState): this;
  146564. }
  146565. }
  146566. declare module BABYLON {
  146567. /**
  146568. * Block used to smooth step a value
  146569. */
  146570. export class SmoothStepBlock extends NodeMaterialBlock {
  146571. /**
  146572. * Creates a new SmoothStepBlock
  146573. * @param name defines the block name
  146574. */
  146575. constructor(name: string);
  146576. /**
  146577. * Gets the current class name
  146578. * @returns the class name
  146579. */
  146580. getClassName(): string;
  146581. /**
  146582. * Gets the value operand input component
  146583. */
  146584. get value(): NodeMaterialConnectionPoint;
  146585. /**
  146586. * Gets the first edge operand input component
  146587. */
  146588. get edge0(): NodeMaterialConnectionPoint;
  146589. /**
  146590. * Gets the second edge operand input component
  146591. */
  146592. get edge1(): NodeMaterialConnectionPoint;
  146593. /**
  146594. * Gets the output component
  146595. */
  146596. get output(): NodeMaterialConnectionPoint;
  146597. protected _buildBlock(state: NodeMaterialBuildState): this;
  146598. }
  146599. }
  146600. declare module BABYLON {
  146601. /**
  146602. * Block used to get the reciprocal (1 / x) of a value
  146603. */
  146604. export class ReciprocalBlock extends NodeMaterialBlock {
  146605. /**
  146606. * Creates a new ReciprocalBlock
  146607. * @param name defines the block name
  146608. */
  146609. constructor(name: string);
  146610. /**
  146611. * Gets the current class name
  146612. * @returns the class name
  146613. */
  146614. getClassName(): string;
  146615. /**
  146616. * Gets the input component
  146617. */
  146618. get input(): NodeMaterialConnectionPoint;
  146619. /**
  146620. * Gets the output component
  146621. */
  146622. get output(): NodeMaterialConnectionPoint;
  146623. protected _buildBlock(state: NodeMaterialBuildState): this;
  146624. }
  146625. }
  146626. declare module BABYLON {
  146627. /**
  146628. * Block used to replace a color by another one
  146629. */
  146630. export class ReplaceColorBlock extends NodeMaterialBlock {
  146631. /**
  146632. * Creates a new ReplaceColorBlock
  146633. * @param name defines the block name
  146634. */
  146635. constructor(name: string);
  146636. /**
  146637. * Gets the current class name
  146638. * @returns the class name
  146639. */
  146640. getClassName(): string;
  146641. /**
  146642. * Gets the value input component
  146643. */
  146644. get value(): NodeMaterialConnectionPoint;
  146645. /**
  146646. * Gets the reference input component
  146647. */
  146648. get reference(): NodeMaterialConnectionPoint;
  146649. /**
  146650. * Gets the distance input component
  146651. */
  146652. get distance(): NodeMaterialConnectionPoint;
  146653. /**
  146654. * Gets the replacement input component
  146655. */
  146656. get replacement(): NodeMaterialConnectionPoint;
  146657. /**
  146658. * Gets the output component
  146659. */
  146660. get output(): NodeMaterialConnectionPoint;
  146661. protected _buildBlock(state: NodeMaterialBuildState): this;
  146662. }
  146663. }
  146664. declare module BABYLON {
  146665. /**
  146666. * Block used to posterize a value
  146667. * @see https://en.wikipedia.org/wiki/Posterization
  146668. */
  146669. export class PosterizeBlock extends NodeMaterialBlock {
  146670. /**
  146671. * Creates a new PosterizeBlock
  146672. * @param name defines the block name
  146673. */
  146674. constructor(name: string);
  146675. /**
  146676. * Gets the current class name
  146677. * @returns the class name
  146678. */
  146679. getClassName(): string;
  146680. /**
  146681. * Gets the value input component
  146682. */
  146683. get value(): NodeMaterialConnectionPoint;
  146684. /**
  146685. * Gets the steps input component
  146686. */
  146687. get steps(): NodeMaterialConnectionPoint;
  146688. /**
  146689. * Gets the output component
  146690. */
  146691. get output(): NodeMaterialConnectionPoint;
  146692. protected _buildBlock(state: NodeMaterialBuildState): this;
  146693. }
  146694. }
  146695. declare module BABYLON {
  146696. /**
  146697. * Operations supported by the Wave block
  146698. */
  146699. export enum WaveBlockKind {
  146700. /** SawTooth */
  146701. SawTooth = 0,
  146702. /** Square */
  146703. Square = 1,
  146704. /** Triangle */
  146705. Triangle = 2
  146706. }
  146707. /**
  146708. * Block used to apply wave operation to floats
  146709. */
  146710. export class WaveBlock extends NodeMaterialBlock {
  146711. /**
  146712. * Gets or sets the kibnd of wave to be applied by the block
  146713. */
  146714. kind: WaveBlockKind;
  146715. /**
  146716. * Creates a new WaveBlock
  146717. * @param name defines the block name
  146718. */
  146719. constructor(name: string);
  146720. /**
  146721. * Gets the current class name
  146722. * @returns the class name
  146723. */
  146724. getClassName(): string;
  146725. /**
  146726. * Gets the input component
  146727. */
  146728. get input(): NodeMaterialConnectionPoint;
  146729. /**
  146730. * Gets the output component
  146731. */
  146732. get output(): NodeMaterialConnectionPoint;
  146733. protected _buildBlock(state: NodeMaterialBuildState): this;
  146734. serialize(): any;
  146735. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146736. }
  146737. }
  146738. declare module BABYLON {
  146739. /**
  146740. * Class used to store a color step for the GradientBlock
  146741. */
  146742. export class GradientBlockColorStep {
  146743. private _step;
  146744. /**
  146745. * Gets value indicating which step this color is associated with (between 0 and 1)
  146746. */
  146747. get step(): number;
  146748. /**
  146749. * Sets a value indicating which step this color is associated with (between 0 and 1)
  146750. */
  146751. set step(val: number);
  146752. private _color;
  146753. /**
  146754. * Gets the color associated with this step
  146755. */
  146756. get color(): Color3;
  146757. /**
  146758. * Sets the color associated with this step
  146759. */
  146760. set color(val: Color3);
  146761. /**
  146762. * Creates a new GradientBlockColorStep
  146763. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  146764. * @param color defines the color associated with this step
  146765. */
  146766. constructor(step: number, color: Color3);
  146767. }
  146768. /**
  146769. * Block used to return a color from a gradient based on an input value between 0 and 1
  146770. */
  146771. export class GradientBlock extends NodeMaterialBlock {
  146772. /**
  146773. * Gets or sets the list of color steps
  146774. */
  146775. colorSteps: GradientBlockColorStep[];
  146776. /** Gets an observable raised when the value is changed */
  146777. onValueChangedObservable: Observable<GradientBlock>;
  146778. /** calls observable when the value is changed*/
  146779. colorStepsUpdated(): void;
  146780. /**
  146781. * Creates a new GradientBlock
  146782. * @param name defines the block name
  146783. */
  146784. constructor(name: string);
  146785. /**
  146786. * Gets the current class name
  146787. * @returns the class name
  146788. */
  146789. getClassName(): string;
  146790. /**
  146791. * Gets the gradient input component
  146792. */
  146793. get gradient(): NodeMaterialConnectionPoint;
  146794. /**
  146795. * Gets the output component
  146796. */
  146797. get output(): NodeMaterialConnectionPoint;
  146798. private _writeColorConstant;
  146799. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  146800. serialize(): any;
  146801. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146802. protected _dumpPropertiesCode(): string;
  146803. }
  146804. }
  146805. declare module BABYLON {
  146806. /**
  146807. * Block used to normalize lerp between 2 values
  146808. */
  146809. export class NLerpBlock extends NodeMaterialBlock {
  146810. /**
  146811. * Creates a new NLerpBlock
  146812. * @param name defines the block name
  146813. */
  146814. constructor(name: string);
  146815. /**
  146816. * Gets the current class name
  146817. * @returns the class name
  146818. */
  146819. getClassName(): string;
  146820. /**
  146821. * Gets the left operand input component
  146822. */
  146823. get left(): NodeMaterialConnectionPoint;
  146824. /**
  146825. * Gets the right operand input component
  146826. */
  146827. get right(): NodeMaterialConnectionPoint;
  146828. /**
  146829. * Gets the gradient operand input component
  146830. */
  146831. get gradient(): NodeMaterialConnectionPoint;
  146832. /**
  146833. * Gets the output component
  146834. */
  146835. get output(): NodeMaterialConnectionPoint;
  146836. protected _buildBlock(state: NodeMaterialBuildState): this;
  146837. }
  146838. }
  146839. declare module BABYLON {
  146840. /**
  146841. * block used to Generate a Worley Noise 3D Noise Pattern
  146842. */
  146843. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  146844. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  146845. manhattanDistance: boolean;
  146846. /**
  146847. * Creates a new WorleyNoise3DBlock
  146848. * @param name defines the block name
  146849. */
  146850. constructor(name: string);
  146851. /**
  146852. * Gets the current class name
  146853. * @returns the class name
  146854. */
  146855. getClassName(): string;
  146856. /**
  146857. * Gets the seed input component
  146858. */
  146859. get seed(): NodeMaterialConnectionPoint;
  146860. /**
  146861. * Gets the jitter input component
  146862. */
  146863. get jitter(): NodeMaterialConnectionPoint;
  146864. /**
  146865. * Gets the output component
  146866. */
  146867. get output(): NodeMaterialConnectionPoint;
  146868. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  146869. /**
  146870. * Exposes the properties to the UI?
  146871. */
  146872. protected _dumpPropertiesCode(): string;
  146873. /**
  146874. * Exposes the properties to the Seralize?
  146875. */
  146876. serialize(): any;
  146877. /**
  146878. * Exposes the properties to the deseralize?
  146879. */
  146880. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146881. }
  146882. }
  146883. declare module BABYLON {
  146884. /**
  146885. * block used to Generate a Simplex Perlin 3d Noise Pattern
  146886. */
  146887. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  146888. /**
  146889. * Creates a new SimplexPerlin3DBlock
  146890. * @param name defines the block name
  146891. */
  146892. constructor(name: string);
  146893. /**
  146894. * Gets the current class name
  146895. * @returns the class name
  146896. */
  146897. getClassName(): string;
  146898. /**
  146899. * Gets the seed operand input component
  146900. */
  146901. get seed(): NodeMaterialConnectionPoint;
  146902. /**
  146903. * Gets the output component
  146904. */
  146905. get output(): NodeMaterialConnectionPoint;
  146906. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  146907. }
  146908. }
  146909. declare module BABYLON {
  146910. /**
  146911. * Block used to blend normals
  146912. */
  146913. export class NormalBlendBlock extends NodeMaterialBlock {
  146914. /**
  146915. * Creates a new NormalBlendBlock
  146916. * @param name defines the block name
  146917. */
  146918. constructor(name: string);
  146919. /**
  146920. * Gets the current class name
  146921. * @returns the class name
  146922. */
  146923. getClassName(): string;
  146924. /**
  146925. * Gets the first input component
  146926. */
  146927. get normalMap0(): NodeMaterialConnectionPoint;
  146928. /**
  146929. * Gets the second input component
  146930. */
  146931. get normalMap1(): NodeMaterialConnectionPoint;
  146932. /**
  146933. * Gets the output component
  146934. */
  146935. get output(): NodeMaterialConnectionPoint;
  146936. protected _buildBlock(state: NodeMaterialBuildState): this;
  146937. }
  146938. }
  146939. declare module BABYLON {
  146940. /**
  146941. * Block used to rotate a 2d vector by a given angle
  146942. */
  146943. export class Rotate2dBlock extends NodeMaterialBlock {
  146944. /**
  146945. * Creates a new Rotate2dBlock
  146946. * @param name defines the block name
  146947. */
  146948. constructor(name: string);
  146949. /**
  146950. * Gets the current class name
  146951. * @returns the class name
  146952. */
  146953. getClassName(): string;
  146954. /**
  146955. * Gets the input vector
  146956. */
  146957. get input(): NodeMaterialConnectionPoint;
  146958. /**
  146959. * Gets the input angle
  146960. */
  146961. get angle(): NodeMaterialConnectionPoint;
  146962. /**
  146963. * Gets the output component
  146964. */
  146965. get output(): NodeMaterialConnectionPoint;
  146966. autoConfigure(material: NodeMaterial): void;
  146967. protected _buildBlock(state: NodeMaterialBuildState): this;
  146968. }
  146969. }
  146970. declare module BABYLON {
  146971. /**
  146972. * Block used to get the reflected vector from a direction and a normal
  146973. */
  146974. export class ReflectBlock extends NodeMaterialBlock {
  146975. /**
  146976. * Creates a new ReflectBlock
  146977. * @param name defines the block name
  146978. */
  146979. constructor(name: string);
  146980. /**
  146981. * Gets the current class name
  146982. * @returns the class name
  146983. */
  146984. getClassName(): string;
  146985. /**
  146986. * Gets the incident component
  146987. */
  146988. get incident(): NodeMaterialConnectionPoint;
  146989. /**
  146990. * Gets the normal component
  146991. */
  146992. get normal(): NodeMaterialConnectionPoint;
  146993. /**
  146994. * Gets the output component
  146995. */
  146996. get output(): NodeMaterialConnectionPoint;
  146997. protected _buildBlock(state: NodeMaterialBuildState): this;
  146998. }
  146999. }
  147000. declare module BABYLON {
  147001. /**
  147002. * Block used to get the refracted vector from a direction and a normal
  147003. */
  147004. export class RefractBlock extends NodeMaterialBlock {
  147005. /**
  147006. * Creates a new RefractBlock
  147007. * @param name defines the block name
  147008. */
  147009. constructor(name: string);
  147010. /**
  147011. * Gets the current class name
  147012. * @returns the class name
  147013. */
  147014. getClassName(): string;
  147015. /**
  147016. * Gets the incident component
  147017. */
  147018. get incident(): NodeMaterialConnectionPoint;
  147019. /**
  147020. * Gets the normal component
  147021. */
  147022. get normal(): NodeMaterialConnectionPoint;
  147023. /**
  147024. * Gets the index of refraction component
  147025. */
  147026. get ior(): NodeMaterialConnectionPoint;
  147027. /**
  147028. * Gets the output component
  147029. */
  147030. get output(): NodeMaterialConnectionPoint;
  147031. protected _buildBlock(state: NodeMaterialBuildState): this;
  147032. }
  147033. }
  147034. declare module BABYLON {
  147035. /**
  147036. * Block used to desaturate a color
  147037. */
  147038. export class DesaturateBlock extends NodeMaterialBlock {
  147039. /**
  147040. * Creates a new DesaturateBlock
  147041. * @param name defines the block name
  147042. */
  147043. constructor(name: string);
  147044. /**
  147045. * Gets the current class name
  147046. * @returns the class name
  147047. */
  147048. getClassName(): string;
  147049. /**
  147050. * Gets the color operand input component
  147051. */
  147052. get color(): NodeMaterialConnectionPoint;
  147053. /**
  147054. * Gets the level operand input component
  147055. */
  147056. get level(): NodeMaterialConnectionPoint;
  147057. /**
  147058. * Gets the output component
  147059. */
  147060. get output(): NodeMaterialConnectionPoint;
  147061. protected _buildBlock(state: NodeMaterialBuildState): this;
  147062. }
  147063. }
  147064. declare module BABYLON {
  147065. /**
  147066. * Block used to implement the reflection module of the PBR material
  147067. */
  147068. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  147069. /** @hidden */
  147070. _defineLODReflectionAlpha: string;
  147071. /** @hidden */
  147072. _defineLinearSpecularReflection: string;
  147073. private _vEnvironmentIrradianceName;
  147074. /** @hidden */
  147075. _vReflectionMicrosurfaceInfosName: string;
  147076. /** @hidden */
  147077. _vReflectionInfosName: string;
  147078. /** @hidden */
  147079. _vReflectionFilteringInfoName: string;
  147080. private _scene;
  147081. /**
  147082. * The properties below are set by the main PBR block prior to calling methods of this class.
  147083. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  147084. * It's less burden on the user side in the editor part.
  147085. */
  147086. /** @hidden */
  147087. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  147088. /** @hidden */
  147089. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  147090. /** @hidden */
  147091. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  147092. /** @hidden */
  147093. viewConnectionPoint: NodeMaterialConnectionPoint;
  147094. /**
  147095. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  147096. * diffuse part of the IBL.
  147097. */
  147098. useSphericalHarmonics: boolean;
  147099. /**
  147100. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  147101. */
  147102. forceIrradianceInFragment: boolean;
  147103. /**
  147104. * Create a new ReflectionBlock
  147105. * @param name defines the block name
  147106. */
  147107. constructor(name: string);
  147108. /**
  147109. * Gets the current class name
  147110. * @returns the class name
  147111. */
  147112. getClassName(): string;
  147113. /**
  147114. * Gets the position input component
  147115. */
  147116. get position(): NodeMaterialConnectionPoint;
  147117. /**
  147118. * Gets the world position input component
  147119. */
  147120. get worldPosition(): NodeMaterialConnectionPoint;
  147121. /**
  147122. * Gets the world normal input component
  147123. */
  147124. get worldNormal(): NodeMaterialConnectionPoint;
  147125. /**
  147126. * Gets the world input component
  147127. */
  147128. get world(): NodeMaterialConnectionPoint;
  147129. /**
  147130. * Gets the camera (or eye) position component
  147131. */
  147132. get cameraPosition(): NodeMaterialConnectionPoint;
  147133. /**
  147134. * Gets the view input component
  147135. */
  147136. get view(): NodeMaterialConnectionPoint;
  147137. /**
  147138. * Gets the color input component
  147139. */
  147140. get color(): NodeMaterialConnectionPoint;
  147141. /**
  147142. * Gets the reflection object output component
  147143. */
  147144. get reflection(): NodeMaterialConnectionPoint;
  147145. /**
  147146. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  147147. */
  147148. get hasTexture(): boolean;
  147149. /**
  147150. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  147151. */
  147152. get reflectionColor(): string;
  147153. protected _getTexture(): Nullable<BaseTexture>;
  147154. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147155. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  147156. /**
  147157. * Gets the code to inject in the vertex shader
  147158. * @param state current state of the node material building
  147159. * @returns the shader code
  147160. */
  147161. handleVertexSide(state: NodeMaterialBuildState): string;
  147162. /**
  147163. * Gets the main code of the block (fragment side)
  147164. * @param state current state of the node material building
  147165. * @param normalVarName name of the existing variable corresponding to the normal
  147166. * @returns the shader code
  147167. */
  147168. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  147169. protected _buildBlock(state: NodeMaterialBuildState): this;
  147170. protected _dumpPropertiesCode(): string;
  147171. serialize(): any;
  147172. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147173. }
  147174. }
  147175. declare module BABYLON {
  147176. /**
  147177. * Block used to implement the sheen module of the PBR material
  147178. */
  147179. export class SheenBlock extends NodeMaterialBlock {
  147180. /**
  147181. * Create a new SheenBlock
  147182. * @param name defines the block name
  147183. */
  147184. constructor(name: string);
  147185. /**
  147186. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  147187. * It allows the strength of the sheen effect to not depend on the base color of the material,
  147188. * making it easier to setup and tweak the effect
  147189. */
  147190. albedoScaling: boolean;
  147191. /**
  147192. * Defines if the sheen is linked to the sheen color.
  147193. */
  147194. linkSheenWithAlbedo: boolean;
  147195. /**
  147196. * Initialize the block and prepare the context for build
  147197. * @param state defines the state that will be used for the build
  147198. */
  147199. initialize(state: NodeMaterialBuildState): void;
  147200. /**
  147201. * Gets the current class name
  147202. * @returns the class name
  147203. */
  147204. getClassName(): string;
  147205. /**
  147206. * Gets the intensity input component
  147207. */
  147208. get intensity(): NodeMaterialConnectionPoint;
  147209. /**
  147210. * Gets the color input component
  147211. */
  147212. get color(): NodeMaterialConnectionPoint;
  147213. /**
  147214. * Gets the roughness input component
  147215. */
  147216. get roughness(): NodeMaterialConnectionPoint;
  147217. /**
  147218. * Gets the sheen object output component
  147219. */
  147220. get sheen(): NodeMaterialConnectionPoint;
  147221. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147222. /**
  147223. * Gets the main code of the block (fragment side)
  147224. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  147225. * @returns the shader code
  147226. */
  147227. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  147228. protected _buildBlock(state: NodeMaterialBuildState): this;
  147229. protected _dumpPropertiesCode(): string;
  147230. serialize(): any;
  147231. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147232. }
  147233. }
  147234. declare module BABYLON {
  147235. /**
  147236. * Block used to implement the anisotropy module of the PBR material
  147237. */
  147238. export class AnisotropyBlock extends NodeMaterialBlock {
  147239. /**
  147240. * The two properties below are set by the main PBR block prior to calling methods of this class.
  147241. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  147242. * It's less burden on the user side in the editor part.
  147243. */
  147244. /** @hidden */
  147245. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  147246. /** @hidden */
  147247. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  147248. /**
  147249. * Create a new AnisotropyBlock
  147250. * @param name defines the block name
  147251. */
  147252. constructor(name: string);
  147253. /**
  147254. * Initialize the block and prepare the context for build
  147255. * @param state defines the state that will be used for the build
  147256. */
  147257. initialize(state: NodeMaterialBuildState): void;
  147258. /**
  147259. * Gets the current class name
  147260. * @returns the class name
  147261. */
  147262. getClassName(): string;
  147263. /**
  147264. * Gets the intensity input component
  147265. */
  147266. get intensity(): NodeMaterialConnectionPoint;
  147267. /**
  147268. * Gets the direction input component
  147269. */
  147270. get direction(): NodeMaterialConnectionPoint;
  147271. /**
  147272. * Gets the uv input component
  147273. */
  147274. get uv(): NodeMaterialConnectionPoint;
  147275. /**
  147276. * Gets the worldTangent input component
  147277. */
  147278. get worldTangent(): NodeMaterialConnectionPoint;
  147279. /**
  147280. * Gets the anisotropy object output component
  147281. */
  147282. get anisotropy(): NodeMaterialConnectionPoint;
  147283. private _generateTBNSpace;
  147284. /**
  147285. * Gets the main code of the block (fragment side)
  147286. * @param state current state of the node material building
  147287. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  147288. * @returns the shader code
  147289. */
  147290. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  147291. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147292. protected _buildBlock(state: NodeMaterialBuildState): this;
  147293. }
  147294. }
  147295. declare module BABYLON {
  147296. /**
  147297. * Block used to implement the clear coat module of the PBR material
  147298. */
  147299. export class ClearCoatBlock extends NodeMaterialBlock {
  147300. private _scene;
  147301. /**
  147302. * Create a new ClearCoatBlock
  147303. * @param name defines the block name
  147304. */
  147305. constructor(name: string);
  147306. /**
  147307. * Defines if the F0 value should be remapped to account for the interface change in the material.
  147308. */
  147309. remapF0OnInterfaceChange: boolean;
  147310. /**
  147311. * Initialize the block and prepare the context for build
  147312. * @param state defines the state that will be used for the build
  147313. */
  147314. initialize(state: NodeMaterialBuildState): void;
  147315. /**
  147316. * Gets the current class name
  147317. * @returns the class name
  147318. */
  147319. getClassName(): string;
  147320. /**
  147321. * Gets the intensity input component
  147322. */
  147323. get intensity(): NodeMaterialConnectionPoint;
  147324. /**
  147325. * Gets the roughness input component
  147326. */
  147327. get roughness(): NodeMaterialConnectionPoint;
  147328. /**
  147329. * Gets the ior input component
  147330. */
  147331. get indexOfRefraction(): NodeMaterialConnectionPoint;
  147332. /**
  147333. * Gets the bump texture input component
  147334. */
  147335. get normalMapColor(): NodeMaterialConnectionPoint;
  147336. /**
  147337. * Gets the uv input component
  147338. */
  147339. get uv(): NodeMaterialConnectionPoint;
  147340. /**
  147341. * Gets the tint color input component
  147342. */
  147343. get tintColor(): NodeMaterialConnectionPoint;
  147344. /**
  147345. * Gets the tint "at distance" input component
  147346. */
  147347. get tintAtDistance(): NodeMaterialConnectionPoint;
  147348. /**
  147349. * Gets the tint thickness input component
  147350. */
  147351. get tintThickness(): NodeMaterialConnectionPoint;
  147352. /**
  147353. * Gets the world tangent input component
  147354. */
  147355. get worldTangent(): NodeMaterialConnectionPoint;
  147356. /**
  147357. * Gets the clear coat object output component
  147358. */
  147359. get clearcoat(): NodeMaterialConnectionPoint;
  147360. autoConfigure(material: NodeMaterial): void;
  147361. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147362. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  147363. private _generateTBNSpace;
  147364. /**
  147365. * Gets the main code of the block (fragment side)
  147366. * @param state current state of the node material building
  147367. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  147368. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  147369. * @param worldPosVarName name of the variable holding the world position
  147370. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  147371. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  147372. * @param worldNormalVarName name of the variable holding the world normal
  147373. * @returns the shader code
  147374. */
  147375. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  147376. protected _buildBlock(state: NodeMaterialBuildState): this;
  147377. protected _dumpPropertiesCode(): string;
  147378. serialize(): any;
  147379. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147380. }
  147381. }
  147382. declare module BABYLON {
  147383. /**
  147384. * Block used to implement the sub surface module of the PBR material
  147385. */
  147386. export class SubSurfaceBlock extends NodeMaterialBlock {
  147387. /**
  147388. * Create a new SubSurfaceBlock
  147389. * @param name defines the block name
  147390. */
  147391. constructor(name: string);
  147392. /**
  147393. * Initialize the block and prepare the context for build
  147394. * @param state defines the state that will be used for the build
  147395. */
  147396. initialize(state: NodeMaterialBuildState): void;
  147397. /**
  147398. * Gets the current class name
  147399. * @returns the class name
  147400. */
  147401. getClassName(): string;
  147402. /**
  147403. * Gets the thickness component
  147404. */
  147405. get thickness(): NodeMaterialConnectionPoint;
  147406. /**
  147407. * Gets the tint color input component
  147408. */
  147409. get tintColor(): NodeMaterialConnectionPoint;
  147410. /**
  147411. * Gets the translucency intensity input component
  147412. */
  147413. get translucencyIntensity(): NodeMaterialConnectionPoint;
  147414. /**
  147415. * Gets the translucency diffusion distance input component
  147416. */
  147417. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  147418. /**
  147419. * Gets the refraction object parameters
  147420. */
  147421. get refraction(): NodeMaterialConnectionPoint;
  147422. /**
  147423. * Gets the sub surface object output component
  147424. */
  147425. get subsurface(): NodeMaterialConnectionPoint;
  147426. autoConfigure(material: NodeMaterial): void;
  147427. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147428. /**
  147429. * Gets the main code of the block (fragment side)
  147430. * @param state current state of the node material building
  147431. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  147432. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  147433. * @param worldPosVarName name of the variable holding the world position
  147434. * @returns the shader code
  147435. */
  147436. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  147437. protected _buildBlock(state: NodeMaterialBuildState): this;
  147438. }
  147439. }
  147440. declare module BABYLON {
  147441. /**
  147442. * Block used to implement the PBR metallic/roughness model
  147443. */
  147444. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  147445. /**
  147446. * Gets or sets the light associated with this block
  147447. */
  147448. light: Nullable<Light>;
  147449. private _lightId;
  147450. private _scene;
  147451. private _environmentBRDFTexture;
  147452. private _environmentBrdfSamplerName;
  147453. private _vNormalWName;
  147454. private _invertNormalName;
  147455. private _metallicReflectanceColor;
  147456. private _metallicF0Factor;
  147457. private _vMetallicReflectanceFactorsName;
  147458. /**
  147459. * Create a new ReflectionBlock
  147460. * @param name defines the block name
  147461. */
  147462. constructor(name: string);
  147463. /**
  147464. * Intensity of the direct lights e.g. the four lights available in your scene.
  147465. * This impacts both the direct diffuse and specular highlights.
  147466. */
  147467. directIntensity: number;
  147468. /**
  147469. * Intensity of the environment e.g. how much the environment will light the object
  147470. * either through harmonics for rough material or through the refelction for shiny ones.
  147471. */
  147472. environmentIntensity: number;
  147473. /**
  147474. * This is a special control allowing the reduction of the specular highlights coming from the
  147475. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  147476. */
  147477. specularIntensity: number;
  147478. /**
  147479. * Defines the falloff type used in this material.
  147480. * It by default is Physical.
  147481. */
  147482. lightFalloff: number;
  147483. /**
  147484. * Specifies that alpha test should be used
  147485. */
  147486. useAlphaTest: boolean;
  147487. /**
  147488. * Defines the alpha limits in alpha test mode.
  147489. */
  147490. alphaTestCutoff: number;
  147491. /**
  147492. * Specifies that alpha blending should be used
  147493. */
  147494. useAlphaBlending: boolean;
  147495. /**
  147496. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  147497. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  147498. */
  147499. useRadianceOverAlpha: boolean;
  147500. /**
  147501. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  147502. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  147503. */
  147504. useSpecularOverAlpha: boolean;
  147505. /**
  147506. * Enables specular anti aliasing in the PBR shader.
  147507. * It will both interacts on the Geometry for analytical and IBL lighting.
  147508. * It also prefilter the roughness map based on the bump values.
  147509. */
  147510. enableSpecularAntiAliasing: boolean;
  147511. /**
  147512. * Enables realtime filtering on the texture.
  147513. */
  147514. realTimeFiltering: boolean;
  147515. /**
  147516. * Quality switch for realtime filtering
  147517. */
  147518. realTimeFilteringQuality: number;
  147519. /**
  147520. * Defines if the material uses energy conservation.
  147521. */
  147522. useEnergyConservation: boolean;
  147523. /**
  147524. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  147525. * too much the area relying on ambient texture to define their ambient occlusion.
  147526. */
  147527. useRadianceOcclusion: boolean;
  147528. /**
  147529. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  147530. * makes the reflect vector face the model (under horizon).
  147531. */
  147532. useHorizonOcclusion: boolean;
  147533. /**
  147534. * If set to true, no lighting calculations will be applied.
  147535. */
  147536. unlit: boolean;
  147537. /**
  147538. * Force normal to face away from face.
  147539. */
  147540. forceNormalForward: boolean;
  147541. /**
  147542. * Defines the material debug mode.
  147543. * It helps seeing only some components of the material while troubleshooting.
  147544. */
  147545. debugMode: number;
  147546. /**
  147547. * Specify from where on screen the debug mode should start.
  147548. * The value goes from -1 (full screen) to 1 (not visible)
  147549. * It helps with side by side comparison against the final render
  147550. * This defaults to 0
  147551. */
  147552. debugLimit: number;
  147553. /**
  147554. * As the default viewing range might not be enough (if the ambient is really small for instance)
  147555. * You can use the factor to better multiply the final value.
  147556. */
  147557. debugFactor: number;
  147558. /**
  147559. * Initialize the block and prepare the context for build
  147560. * @param state defines the state that will be used for the build
  147561. */
  147562. initialize(state: NodeMaterialBuildState): void;
  147563. /**
  147564. * Gets the current class name
  147565. * @returns the class name
  147566. */
  147567. getClassName(): string;
  147568. /**
  147569. * Gets the world position input component
  147570. */
  147571. get worldPosition(): NodeMaterialConnectionPoint;
  147572. /**
  147573. * Gets the world normal input component
  147574. */
  147575. get worldNormal(): NodeMaterialConnectionPoint;
  147576. /**
  147577. * Gets the view matrix parameter
  147578. */
  147579. get view(): NodeMaterialConnectionPoint;
  147580. /**
  147581. * Gets the camera position input component
  147582. */
  147583. get cameraPosition(): NodeMaterialConnectionPoint;
  147584. /**
  147585. * Gets the perturbed normal input component
  147586. */
  147587. get perturbedNormal(): NodeMaterialConnectionPoint;
  147588. /**
  147589. * Gets the base color input component
  147590. */
  147591. get baseColor(): NodeMaterialConnectionPoint;
  147592. /**
  147593. * Gets the metallic input component
  147594. */
  147595. get metallic(): NodeMaterialConnectionPoint;
  147596. /**
  147597. * Gets the roughness input component
  147598. */
  147599. get roughness(): NodeMaterialConnectionPoint;
  147600. /**
  147601. * Gets the ambient occlusion input component
  147602. */
  147603. get ambientOcc(): NodeMaterialConnectionPoint;
  147604. /**
  147605. * Gets the opacity input component
  147606. */
  147607. get opacity(): NodeMaterialConnectionPoint;
  147608. /**
  147609. * Gets the index of refraction input component
  147610. */
  147611. get indexOfRefraction(): NodeMaterialConnectionPoint;
  147612. /**
  147613. * Gets the ambient color input component
  147614. */
  147615. get ambientColor(): NodeMaterialConnectionPoint;
  147616. /**
  147617. * Gets the reflection object parameters
  147618. */
  147619. get reflection(): NodeMaterialConnectionPoint;
  147620. /**
  147621. * Gets the clear coat object parameters
  147622. */
  147623. get clearcoat(): NodeMaterialConnectionPoint;
  147624. /**
  147625. * Gets the sheen object parameters
  147626. */
  147627. get sheen(): NodeMaterialConnectionPoint;
  147628. /**
  147629. * Gets the sub surface object parameters
  147630. */
  147631. get subsurface(): NodeMaterialConnectionPoint;
  147632. /**
  147633. * Gets the anisotropy object parameters
  147634. */
  147635. get anisotropy(): NodeMaterialConnectionPoint;
  147636. /**
  147637. * Gets the ambient output component
  147638. */
  147639. get ambientClr(): NodeMaterialConnectionPoint;
  147640. /**
  147641. * Gets the diffuse output component
  147642. */
  147643. get diffuseDir(): NodeMaterialConnectionPoint;
  147644. /**
  147645. * Gets the specular output component
  147646. */
  147647. get specularDir(): NodeMaterialConnectionPoint;
  147648. /**
  147649. * Gets the clear coat output component
  147650. */
  147651. get clearcoatDir(): NodeMaterialConnectionPoint;
  147652. /**
  147653. * Gets the sheen output component
  147654. */
  147655. get sheenDir(): NodeMaterialConnectionPoint;
  147656. /**
  147657. * Gets the indirect diffuse output component
  147658. */
  147659. get diffuseIndirect(): NodeMaterialConnectionPoint;
  147660. /**
  147661. * Gets the indirect specular output component
  147662. */
  147663. get specularIndirect(): NodeMaterialConnectionPoint;
  147664. /**
  147665. * Gets the indirect clear coat output component
  147666. */
  147667. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  147668. /**
  147669. * Gets the indirect sheen output component
  147670. */
  147671. get sheenIndirect(): NodeMaterialConnectionPoint;
  147672. /**
  147673. * Gets the refraction output component
  147674. */
  147675. get refraction(): NodeMaterialConnectionPoint;
  147676. /**
  147677. * Gets the global lighting output component
  147678. */
  147679. get lighting(): NodeMaterialConnectionPoint;
  147680. /**
  147681. * Gets the shadow output component
  147682. */
  147683. get shadow(): NodeMaterialConnectionPoint;
  147684. /**
  147685. * Gets the alpha output component
  147686. */
  147687. get alpha(): NodeMaterialConnectionPoint;
  147688. autoConfigure(material: NodeMaterial): void;
  147689. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147690. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  147691. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  147692. private _injectVertexCode;
  147693. private _getAlbedoOpacityCode;
  147694. private _getAmbientOcclusionCode;
  147695. private _getReflectivityCode;
  147696. protected _buildBlock(state: NodeMaterialBuildState): this;
  147697. protected _dumpPropertiesCode(): string;
  147698. serialize(): any;
  147699. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147700. }
  147701. }
  147702. declare module BABYLON {
  147703. /**
  147704. * Block used to compute value of one parameter modulo another
  147705. */
  147706. export class ModBlock extends NodeMaterialBlock {
  147707. /**
  147708. * Creates a new ModBlock
  147709. * @param name defines the block name
  147710. */
  147711. constructor(name: string);
  147712. /**
  147713. * Gets the current class name
  147714. * @returns the class name
  147715. */
  147716. getClassName(): string;
  147717. /**
  147718. * Gets the left operand input component
  147719. */
  147720. get left(): NodeMaterialConnectionPoint;
  147721. /**
  147722. * Gets the right operand input component
  147723. */
  147724. get right(): NodeMaterialConnectionPoint;
  147725. /**
  147726. * Gets the output component
  147727. */
  147728. get output(): NodeMaterialConnectionPoint;
  147729. protected _buildBlock(state: NodeMaterialBuildState): this;
  147730. }
  147731. }
  147732. declare module BABYLON {
  147733. /**
  147734. * Configuration for Draco compression
  147735. */
  147736. export interface IDracoCompressionConfiguration {
  147737. /**
  147738. * Configuration for the decoder.
  147739. */
  147740. decoder: {
  147741. /**
  147742. * The url to the WebAssembly module.
  147743. */
  147744. wasmUrl?: string;
  147745. /**
  147746. * The url to the WebAssembly binary.
  147747. */
  147748. wasmBinaryUrl?: string;
  147749. /**
  147750. * The url to the fallback JavaScript module.
  147751. */
  147752. fallbackUrl?: string;
  147753. };
  147754. }
  147755. /**
  147756. * Draco compression (https://google.github.io/draco/)
  147757. *
  147758. * This class wraps the Draco module.
  147759. *
  147760. * **Encoder**
  147761. *
  147762. * The encoder is not currently implemented.
  147763. *
  147764. * **Decoder**
  147765. *
  147766. * 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.
  147767. *
  147768. * To update the configuration, use the following code:
  147769. * ```javascript
  147770. * DracoCompression.Configuration = {
  147771. * decoder: {
  147772. * wasmUrl: "<url to the WebAssembly library>",
  147773. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  147774. * fallbackUrl: "<url to the fallback JavaScript library>",
  147775. * }
  147776. * };
  147777. * ```
  147778. *
  147779. * 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.
  147780. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  147781. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  147782. *
  147783. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  147784. * ```javascript
  147785. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  147786. * ```
  147787. *
  147788. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  147789. */
  147790. export class DracoCompression implements IDisposable {
  147791. private _workerPoolPromise?;
  147792. private _decoderModulePromise?;
  147793. /**
  147794. * The configuration. Defaults to the following urls:
  147795. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  147796. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  147797. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  147798. */
  147799. static Configuration: IDracoCompressionConfiguration;
  147800. /**
  147801. * Returns true if the decoder configuration is available.
  147802. */
  147803. static get DecoderAvailable(): boolean;
  147804. /**
  147805. * Default number of workers to create when creating the draco compression object.
  147806. */
  147807. static DefaultNumWorkers: number;
  147808. private static GetDefaultNumWorkers;
  147809. private static _Default;
  147810. /**
  147811. * Default instance for the draco compression object.
  147812. */
  147813. static get Default(): DracoCompression;
  147814. /**
  147815. * Constructor
  147816. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  147817. */
  147818. constructor(numWorkers?: number);
  147819. /**
  147820. * Stop all async operations and release resources.
  147821. */
  147822. dispose(): void;
  147823. /**
  147824. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  147825. * @returns a promise that resolves when ready
  147826. */
  147827. whenReadyAsync(): Promise<void>;
  147828. /**
  147829. * Decode Draco compressed mesh data to vertex data.
  147830. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  147831. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  147832. * @returns A promise that resolves with the decoded vertex data
  147833. */
  147834. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  147835. [kind: string]: number;
  147836. }): Promise<VertexData>;
  147837. }
  147838. }
  147839. declare module BABYLON {
  147840. /**
  147841. * Class for building Constructive Solid Geometry
  147842. */
  147843. export class CSG {
  147844. private polygons;
  147845. /**
  147846. * The world matrix
  147847. */
  147848. matrix: Matrix;
  147849. /**
  147850. * Stores the position
  147851. */
  147852. position: Vector3;
  147853. /**
  147854. * Stores the rotation
  147855. */
  147856. rotation: Vector3;
  147857. /**
  147858. * Stores the rotation quaternion
  147859. */
  147860. rotationQuaternion: Nullable<Quaternion>;
  147861. /**
  147862. * Stores the scaling vector
  147863. */
  147864. scaling: Vector3;
  147865. /**
  147866. * Convert the Mesh to CSG
  147867. * @param mesh The Mesh to convert to CSG
  147868. * @returns A new CSG from the Mesh
  147869. */
  147870. static FromMesh(mesh: Mesh): CSG;
  147871. /**
  147872. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  147873. * @param polygons Polygons used to construct a CSG solid
  147874. */
  147875. private static FromPolygons;
  147876. /**
  147877. * Clones, or makes a deep copy, of the CSG
  147878. * @returns A new CSG
  147879. */
  147880. clone(): CSG;
  147881. /**
  147882. * Unions this CSG with another CSG
  147883. * @param csg The CSG to union against this CSG
  147884. * @returns The unioned CSG
  147885. */
  147886. union(csg: CSG): CSG;
  147887. /**
  147888. * Unions this CSG with another CSG in place
  147889. * @param csg The CSG to union against this CSG
  147890. */
  147891. unionInPlace(csg: CSG): void;
  147892. /**
  147893. * Subtracts this CSG with another CSG
  147894. * @param csg The CSG to subtract against this CSG
  147895. * @returns A new CSG
  147896. */
  147897. subtract(csg: CSG): CSG;
  147898. /**
  147899. * Subtracts this CSG with another CSG in place
  147900. * @param csg The CSG to subtact against this CSG
  147901. */
  147902. subtractInPlace(csg: CSG): void;
  147903. /**
  147904. * Intersect this CSG with another CSG
  147905. * @param csg The CSG to intersect against this CSG
  147906. * @returns A new CSG
  147907. */
  147908. intersect(csg: CSG): CSG;
  147909. /**
  147910. * Intersects this CSG with another CSG in place
  147911. * @param csg The CSG to intersect against this CSG
  147912. */
  147913. intersectInPlace(csg: CSG): void;
  147914. /**
  147915. * Return a new CSG solid with solid and empty space switched. This solid is
  147916. * not modified.
  147917. * @returns A new CSG solid with solid and empty space switched
  147918. */
  147919. inverse(): CSG;
  147920. /**
  147921. * Inverses the CSG in place
  147922. */
  147923. inverseInPlace(): void;
  147924. /**
  147925. * This is used to keep meshes transformations so they can be restored
  147926. * when we build back a Babylon Mesh
  147927. * NB : All CSG operations are performed in world coordinates
  147928. * @param csg The CSG to copy the transform attributes from
  147929. * @returns This CSG
  147930. */
  147931. copyTransformAttributes(csg: CSG): CSG;
  147932. /**
  147933. * Build Raw mesh from CSG
  147934. * Coordinates here are in world space
  147935. * @param name The name of the mesh geometry
  147936. * @param scene The Scene
  147937. * @param keepSubMeshes Specifies if the submeshes should be kept
  147938. * @returns A new Mesh
  147939. */
  147940. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  147941. /**
  147942. * Build Mesh from CSG taking material and transforms into account
  147943. * @param name The name of the Mesh
  147944. * @param material The material of the Mesh
  147945. * @param scene The Scene
  147946. * @param keepSubMeshes Specifies if submeshes should be kept
  147947. * @returns The new Mesh
  147948. */
  147949. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  147950. }
  147951. }
  147952. declare module BABYLON {
  147953. /**
  147954. * Class used to create a trail following a mesh
  147955. */
  147956. export class TrailMesh extends Mesh {
  147957. private _generator;
  147958. private _autoStart;
  147959. private _running;
  147960. private _diameter;
  147961. private _length;
  147962. private _sectionPolygonPointsCount;
  147963. private _sectionVectors;
  147964. private _sectionNormalVectors;
  147965. private _beforeRenderObserver;
  147966. /**
  147967. * @constructor
  147968. * @param name The value used by scene.getMeshByName() to do a lookup.
  147969. * @param generator The mesh or transform node to generate a trail.
  147970. * @param scene The scene to add this mesh to.
  147971. * @param diameter Diameter of trailing mesh. Default is 1.
  147972. * @param length Length of trailing mesh. Default is 60.
  147973. * @param autoStart Automatically start trailing mesh. Default true.
  147974. */
  147975. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  147976. /**
  147977. * "TrailMesh"
  147978. * @returns "TrailMesh"
  147979. */
  147980. getClassName(): string;
  147981. private _createMesh;
  147982. /**
  147983. * Start trailing mesh.
  147984. */
  147985. start(): void;
  147986. /**
  147987. * Stop trailing mesh.
  147988. */
  147989. stop(): void;
  147990. /**
  147991. * Update trailing mesh geometry.
  147992. */
  147993. update(): void;
  147994. /**
  147995. * Returns a new TrailMesh object.
  147996. * @param name is a string, the name given to the new mesh
  147997. * @param newGenerator use new generator object for cloned trail mesh
  147998. * @returns a new mesh
  147999. */
  148000. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  148001. /**
  148002. * Serializes this trail mesh
  148003. * @param serializationObject object to write serialization to
  148004. */
  148005. serialize(serializationObject: any): void;
  148006. /**
  148007. * Parses a serialized trail mesh
  148008. * @param parsedMesh the serialized mesh
  148009. * @param scene the scene to create the trail mesh in
  148010. * @returns the created trail mesh
  148011. */
  148012. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  148013. }
  148014. }
  148015. declare module BABYLON {
  148016. /**
  148017. * Class containing static functions to help procedurally build meshes
  148018. */
  148019. export class TiledBoxBuilder {
  148020. /**
  148021. * Creates a box mesh
  148022. * 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)
  148023. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  148024. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148025. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148027. * @param name defines the name of the mesh
  148028. * @param options defines the options used to create the mesh
  148029. * @param scene defines the hosting scene
  148030. * @returns the box mesh
  148031. */
  148032. static CreateTiledBox(name: string, options: {
  148033. pattern?: number;
  148034. width?: number;
  148035. height?: number;
  148036. depth?: number;
  148037. tileSize?: number;
  148038. tileWidth?: number;
  148039. tileHeight?: number;
  148040. alignHorizontal?: number;
  148041. alignVertical?: number;
  148042. faceUV?: Vector4[];
  148043. faceColors?: Color4[];
  148044. sideOrientation?: number;
  148045. updatable?: boolean;
  148046. }, scene?: Nullable<Scene>): Mesh;
  148047. }
  148048. }
  148049. declare module BABYLON {
  148050. /**
  148051. * Class containing static functions to help procedurally build meshes
  148052. */
  148053. export class TorusKnotBuilder {
  148054. /**
  148055. * Creates a torus knot mesh
  148056. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  148057. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  148058. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  148059. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  148060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148061. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148063. * @param name defines the name of the mesh
  148064. * @param options defines the options used to create the mesh
  148065. * @param scene defines the hosting scene
  148066. * @returns the torus knot mesh
  148067. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  148068. */
  148069. static CreateTorusKnot(name: string, options: {
  148070. radius?: number;
  148071. tube?: number;
  148072. radialSegments?: number;
  148073. tubularSegments?: number;
  148074. p?: number;
  148075. q?: number;
  148076. updatable?: boolean;
  148077. sideOrientation?: number;
  148078. frontUVs?: Vector4;
  148079. backUVs?: Vector4;
  148080. }, scene: any): Mesh;
  148081. }
  148082. }
  148083. declare module BABYLON {
  148084. /**
  148085. * Polygon
  148086. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  148087. */
  148088. export class Polygon {
  148089. /**
  148090. * Creates a rectangle
  148091. * @param xmin bottom X coord
  148092. * @param ymin bottom Y coord
  148093. * @param xmax top X coord
  148094. * @param ymax top Y coord
  148095. * @returns points that make the resulting rectation
  148096. */
  148097. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  148098. /**
  148099. * Creates a circle
  148100. * @param radius radius of circle
  148101. * @param cx scale in x
  148102. * @param cy scale in y
  148103. * @param numberOfSides number of sides that make up the circle
  148104. * @returns points that make the resulting circle
  148105. */
  148106. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  148107. /**
  148108. * Creates a polygon from input string
  148109. * @param input Input polygon data
  148110. * @returns the parsed points
  148111. */
  148112. static Parse(input: string): Vector2[];
  148113. /**
  148114. * Starts building a polygon from x and y coordinates
  148115. * @param x x coordinate
  148116. * @param y y coordinate
  148117. * @returns the started path2
  148118. */
  148119. static StartingAt(x: number, y: number): Path2;
  148120. }
  148121. /**
  148122. * Builds a polygon
  148123. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  148124. */
  148125. export class PolygonMeshBuilder {
  148126. private _points;
  148127. private _outlinepoints;
  148128. private _holes;
  148129. private _name;
  148130. private _scene;
  148131. private _epoints;
  148132. private _eholes;
  148133. private _addToepoint;
  148134. /**
  148135. * Babylon reference to the earcut plugin.
  148136. */
  148137. bjsEarcut: any;
  148138. /**
  148139. * Creates a PolygonMeshBuilder
  148140. * @param name name of the builder
  148141. * @param contours Path of the polygon
  148142. * @param scene scene to add to when creating the mesh
  148143. * @param earcutInjection can be used to inject your own earcut reference
  148144. */
  148145. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  148146. /**
  148147. * Adds a whole within the polygon
  148148. * @param hole Array of points defining the hole
  148149. * @returns this
  148150. */
  148151. addHole(hole: Vector2[]): PolygonMeshBuilder;
  148152. /**
  148153. * Creates the polygon
  148154. * @param updatable If the mesh should be updatable
  148155. * @param depth The depth of the mesh created
  148156. * @returns the created mesh
  148157. */
  148158. build(updatable?: boolean, depth?: number): Mesh;
  148159. /**
  148160. * Creates the polygon
  148161. * @param depth The depth of the mesh created
  148162. * @returns the created VertexData
  148163. */
  148164. buildVertexData(depth?: number): VertexData;
  148165. /**
  148166. * Adds a side to the polygon
  148167. * @param positions points that make the polygon
  148168. * @param normals normals of the polygon
  148169. * @param uvs uvs of the polygon
  148170. * @param indices indices of the polygon
  148171. * @param bounds bounds of the polygon
  148172. * @param points points of the polygon
  148173. * @param depth depth of the polygon
  148174. * @param flip flip of the polygon
  148175. */
  148176. private addSide;
  148177. }
  148178. }
  148179. declare module BABYLON {
  148180. /**
  148181. * Class containing static functions to help procedurally build meshes
  148182. */
  148183. export class PolygonBuilder {
  148184. /**
  148185. * Creates a polygon mesh
  148186. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  148187. * * 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
  148188. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  148189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  148191. * * Remember you can only change the shape positions, not their number when updating a polygon
  148192. * @param name defines the name of the mesh
  148193. * @param options defines the options used to create the mesh
  148194. * @param scene defines the hosting scene
  148195. * @param earcutInjection can be used to inject your own earcut reference
  148196. * @returns the polygon mesh
  148197. */
  148198. static CreatePolygon(name: string, options: {
  148199. shape: Vector3[];
  148200. holes?: Vector3[][];
  148201. depth?: number;
  148202. faceUV?: Vector4[];
  148203. faceColors?: Color4[];
  148204. updatable?: boolean;
  148205. sideOrientation?: number;
  148206. frontUVs?: Vector4;
  148207. backUVs?: Vector4;
  148208. wrap?: boolean;
  148209. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  148210. /**
  148211. * Creates an extruded polygon mesh, with depth in the Y direction.
  148212. * * 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)
  148213. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  148214. * @param name defines the name of the mesh
  148215. * @param options defines the options used to create the mesh
  148216. * @param scene defines the hosting scene
  148217. * @param earcutInjection can be used to inject your own earcut reference
  148218. * @returns the polygon mesh
  148219. */
  148220. static ExtrudePolygon(name: string, options: {
  148221. shape: Vector3[];
  148222. holes?: Vector3[][];
  148223. depth?: number;
  148224. faceUV?: Vector4[];
  148225. faceColors?: Color4[];
  148226. updatable?: boolean;
  148227. sideOrientation?: number;
  148228. frontUVs?: Vector4;
  148229. backUVs?: Vector4;
  148230. wrap?: boolean;
  148231. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  148232. }
  148233. }
  148234. declare module BABYLON {
  148235. /**
  148236. * Class containing static functions to help procedurally build meshes
  148237. */
  148238. export class LatheBuilder {
  148239. /**
  148240. * Creates lathe mesh.
  148241. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  148242. * * 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
  148243. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  148244. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  148245. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  148246. * * 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
  148247. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  148248. * * 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
  148249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148250. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148251. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148253. * @param name defines the name of the mesh
  148254. * @param options defines the options used to create the mesh
  148255. * @param scene defines the hosting scene
  148256. * @returns the lathe mesh
  148257. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  148258. */
  148259. static CreateLathe(name: string, options: {
  148260. shape: Vector3[];
  148261. radius?: number;
  148262. tessellation?: number;
  148263. clip?: number;
  148264. arc?: number;
  148265. closed?: boolean;
  148266. updatable?: boolean;
  148267. sideOrientation?: number;
  148268. frontUVs?: Vector4;
  148269. backUVs?: Vector4;
  148270. cap?: number;
  148271. invertUV?: boolean;
  148272. }, scene?: Nullable<Scene>): Mesh;
  148273. }
  148274. }
  148275. declare module BABYLON {
  148276. /**
  148277. * Class containing static functions to help procedurally build meshes
  148278. */
  148279. export class TiledPlaneBuilder {
  148280. /**
  148281. * Creates a tiled plane mesh
  148282. * * The parameter `pattern` will, depending on value, do nothing or
  148283. * * * flip (reflect about central vertical) alternate tiles across and up
  148284. * * * flip every tile on alternate rows
  148285. * * * rotate (180 degs) alternate tiles across and up
  148286. * * * rotate every tile on alternate rows
  148287. * * * flip and rotate alternate tiles across and up
  148288. * * * flip and rotate every tile on alternate rows
  148289. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  148290. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  148291. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148292. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  148293. * * 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)
  148294. * * 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)
  148295. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  148296. * @param name defines the name of the mesh
  148297. * @param options defines the options used to create the mesh
  148298. * @param scene defines the hosting scene
  148299. * @returns the box mesh
  148300. */
  148301. static CreateTiledPlane(name: string, options: {
  148302. pattern?: number;
  148303. tileSize?: number;
  148304. tileWidth?: number;
  148305. tileHeight?: number;
  148306. size?: number;
  148307. width?: number;
  148308. height?: number;
  148309. alignHorizontal?: number;
  148310. alignVertical?: number;
  148311. sideOrientation?: number;
  148312. frontUVs?: Vector4;
  148313. backUVs?: Vector4;
  148314. updatable?: boolean;
  148315. }, scene?: Nullable<Scene>): Mesh;
  148316. }
  148317. }
  148318. declare module BABYLON {
  148319. /**
  148320. * Class containing static functions to help procedurally build meshes
  148321. */
  148322. export class TubeBuilder {
  148323. /**
  148324. * Creates a tube mesh.
  148325. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  148326. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  148327. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  148328. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  148329. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  148330. * * 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)
  148331. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  148332. * * 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
  148333. * * 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
  148334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148335. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148336. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148338. * @param name defines the name of the mesh
  148339. * @param options defines the options used to create the mesh
  148340. * @param scene defines the hosting scene
  148341. * @returns the tube mesh
  148342. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148343. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  148344. */
  148345. static CreateTube(name: string, options: {
  148346. path: Vector3[];
  148347. radius?: number;
  148348. tessellation?: number;
  148349. radiusFunction?: {
  148350. (i: number, distance: number): number;
  148351. };
  148352. cap?: number;
  148353. arc?: number;
  148354. updatable?: boolean;
  148355. sideOrientation?: number;
  148356. frontUVs?: Vector4;
  148357. backUVs?: Vector4;
  148358. instance?: Mesh;
  148359. invertUV?: boolean;
  148360. }, scene?: Nullable<Scene>): Mesh;
  148361. }
  148362. }
  148363. declare module BABYLON {
  148364. /**
  148365. * Class containing static functions to help procedurally build meshes
  148366. */
  148367. export class IcoSphereBuilder {
  148368. /**
  148369. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  148370. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  148371. * * 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`)
  148372. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  148373. * * 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
  148374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148377. * @param name defines the name of the mesh
  148378. * @param options defines the options used to create the mesh
  148379. * @param scene defines the hosting scene
  148380. * @returns the icosahedron mesh
  148381. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  148382. */
  148383. static CreateIcoSphere(name: string, options: {
  148384. radius?: number;
  148385. radiusX?: number;
  148386. radiusY?: number;
  148387. radiusZ?: number;
  148388. flat?: boolean;
  148389. subdivisions?: number;
  148390. sideOrientation?: number;
  148391. frontUVs?: Vector4;
  148392. backUVs?: Vector4;
  148393. updatable?: boolean;
  148394. }, scene?: Nullable<Scene>): Mesh;
  148395. }
  148396. }
  148397. declare module BABYLON {
  148398. /**
  148399. * Class containing static functions to help procedurally build meshes
  148400. */
  148401. export class DecalBuilder {
  148402. /**
  148403. * Creates a decal mesh.
  148404. * 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
  148405. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  148406. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  148407. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  148408. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  148409. * @param name defines the name of the mesh
  148410. * @param sourceMesh defines the mesh where the decal must be applied
  148411. * @param options defines the options used to create the mesh
  148412. * @param scene defines the hosting scene
  148413. * @returns the decal mesh
  148414. * @see https://doc.babylonjs.com/how_to/decals
  148415. */
  148416. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  148417. position?: Vector3;
  148418. normal?: Vector3;
  148419. size?: Vector3;
  148420. angle?: number;
  148421. }): Mesh;
  148422. }
  148423. }
  148424. declare module BABYLON {
  148425. /**
  148426. * Class containing static functions to help procedurally build meshes
  148427. */
  148428. export class MeshBuilder {
  148429. /**
  148430. * Creates a box mesh
  148431. * * The parameter `size` sets the size (float) of each box side (default 1)
  148432. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  148433. * * 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)
  148434. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  148435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148436. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148438. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  148439. * @param name defines the name of the mesh
  148440. * @param options defines the options used to create the mesh
  148441. * @param scene defines the hosting scene
  148442. * @returns the box mesh
  148443. */
  148444. static CreateBox(name: string, options: {
  148445. size?: number;
  148446. width?: number;
  148447. height?: number;
  148448. depth?: number;
  148449. faceUV?: Vector4[];
  148450. faceColors?: Color4[];
  148451. sideOrientation?: number;
  148452. frontUVs?: Vector4;
  148453. backUVs?: Vector4;
  148454. wrap?: boolean;
  148455. topBaseAt?: number;
  148456. bottomBaseAt?: number;
  148457. updatable?: boolean;
  148458. }, scene?: Nullable<Scene>): Mesh;
  148459. /**
  148460. * Creates a tiled box mesh
  148461. * * faceTiles sets the pattern, tile size and number of tiles for a face
  148462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148463. * @param name defines the name of the mesh
  148464. * @param options defines the options used to create the mesh
  148465. * @param scene defines the hosting scene
  148466. * @returns the tiled box mesh
  148467. */
  148468. static CreateTiledBox(name: string, options: {
  148469. pattern?: number;
  148470. size?: number;
  148471. width?: number;
  148472. height?: number;
  148473. depth: number;
  148474. tileSize?: number;
  148475. tileWidth?: number;
  148476. tileHeight?: number;
  148477. faceUV?: Vector4[];
  148478. faceColors?: Color4[];
  148479. alignHorizontal?: number;
  148480. alignVertical?: number;
  148481. sideOrientation?: number;
  148482. updatable?: boolean;
  148483. }, scene?: Nullable<Scene>): Mesh;
  148484. /**
  148485. * Creates a sphere mesh
  148486. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  148487. * * 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`)
  148488. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  148489. * * 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
  148490. * * 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)
  148491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148492. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148494. * @param name defines the name of the mesh
  148495. * @param options defines the options used to create the mesh
  148496. * @param scene defines the hosting scene
  148497. * @returns the sphere mesh
  148498. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  148499. */
  148500. static CreateSphere(name: string, options: {
  148501. segments?: number;
  148502. diameter?: number;
  148503. diameterX?: number;
  148504. diameterY?: number;
  148505. diameterZ?: number;
  148506. arc?: number;
  148507. slice?: number;
  148508. sideOrientation?: number;
  148509. frontUVs?: Vector4;
  148510. backUVs?: Vector4;
  148511. updatable?: boolean;
  148512. }, scene?: Nullable<Scene>): Mesh;
  148513. /**
  148514. * Creates a plane polygonal mesh. By default, this is a disc
  148515. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  148516. * * 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
  148517. * * 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
  148518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148519. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148521. * @param name defines the name of the mesh
  148522. * @param options defines the options used to create the mesh
  148523. * @param scene defines the hosting scene
  148524. * @returns the plane polygonal mesh
  148525. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  148526. */
  148527. static CreateDisc(name: string, options: {
  148528. radius?: number;
  148529. tessellation?: number;
  148530. arc?: number;
  148531. updatable?: boolean;
  148532. sideOrientation?: number;
  148533. frontUVs?: Vector4;
  148534. backUVs?: Vector4;
  148535. }, scene?: Nullable<Scene>): Mesh;
  148536. /**
  148537. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  148538. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  148539. * * 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`)
  148540. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  148541. * * 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
  148542. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148543. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148545. * @param name defines the name of the mesh
  148546. * @param options defines the options used to create the mesh
  148547. * @param scene defines the hosting scene
  148548. * @returns the icosahedron mesh
  148549. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  148550. */
  148551. static CreateIcoSphere(name: string, options: {
  148552. radius?: number;
  148553. radiusX?: number;
  148554. radiusY?: number;
  148555. radiusZ?: number;
  148556. flat?: boolean;
  148557. subdivisions?: number;
  148558. sideOrientation?: number;
  148559. frontUVs?: Vector4;
  148560. backUVs?: Vector4;
  148561. updatable?: boolean;
  148562. }, scene?: Nullable<Scene>): Mesh;
  148563. /**
  148564. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  148565. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  148566. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  148567. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  148568. * * 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
  148569. * * 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
  148570. * * 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
  148571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148572. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148573. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148574. * * 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
  148575. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  148576. * * 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
  148577. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  148578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148579. * @param name defines the name of the mesh
  148580. * @param options defines the options used to create the mesh
  148581. * @param scene defines the hosting scene
  148582. * @returns the ribbon mesh
  148583. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  148584. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148585. */
  148586. static CreateRibbon(name: string, options: {
  148587. pathArray: Vector3[][];
  148588. closeArray?: boolean;
  148589. closePath?: boolean;
  148590. offset?: number;
  148591. updatable?: boolean;
  148592. sideOrientation?: number;
  148593. frontUVs?: Vector4;
  148594. backUVs?: Vector4;
  148595. instance?: Mesh;
  148596. invertUV?: boolean;
  148597. uvs?: Vector2[];
  148598. colors?: Color4[];
  148599. }, scene?: Nullable<Scene>): Mesh;
  148600. /**
  148601. * Creates a cylinder or a cone mesh
  148602. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  148603. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  148604. * * 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.
  148605. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  148606. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  148607. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  148608. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  148609. * * 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).
  148610. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  148611. * * 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).
  148612. * * 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
  148613. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  148614. * * 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
  148615. * * 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.
  148616. * * If `enclose` is false, a ring surface is one element.
  148617. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  148618. * * 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
  148619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148620. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148622. * @param name defines the name of the mesh
  148623. * @param options defines the options used to create the mesh
  148624. * @param scene defines the hosting scene
  148625. * @returns the cylinder mesh
  148626. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  148627. */
  148628. static CreateCylinder(name: string, options: {
  148629. height?: number;
  148630. diameterTop?: number;
  148631. diameterBottom?: number;
  148632. diameter?: number;
  148633. tessellation?: number;
  148634. subdivisions?: number;
  148635. arc?: number;
  148636. faceColors?: Color4[];
  148637. faceUV?: Vector4[];
  148638. updatable?: boolean;
  148639. hasRings?: boolean;
  148640. enclose?: boolean;
  148641. cap?: number;
  148642. sideOrientation?: number;
  148643. frontUVs?: Vector4;
  148644. backUVs?: Vector4;
  148645. }, scene?: Nullable<Scene>): Mesh;
  148646. /**
  148647. * Creates a torus mesh
  148648. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  148649. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  148650. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  148651. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148652. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148654. * @param name defines the name of the mesh
  148655. * @param options defines the options used to create the mesh
  148656. * @param scene defines the hosting scene
  148657. * @returns the torus mesh
  148658. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  148659. */
  148660. static CreateTorus(name: string, options: {
  148661. diameter?: number;
  148662. thickness?: number;
  148663. tessellation?: number;
  148664. updatable?: boolean;
  148665. sideOrientation?: number;
  148666. frontUVs?: Vector4;
  148667. backUVs?: Vector4;
  148668. }, scene?: Nullable<Scene>): Mesh;
  148669. /**
  148670. * Creates a torus knot mesh
  148671. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  148672. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  148673. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  148674. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  148675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148676. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148678. * @param name defines the name of the mesh
  148679. * @param options defines the options used to create the mesh
  148680. * @param scene defines the hosting scene
  148681. * @returns the torus knot mesh
  148682. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  148683. */
  148684. static CreateTorusKnot(name: string, options: {
  148685. radius?: number;
  148686. tube?: number;
  148687. radialSegments?: number;
  148688. tubularSegments?: number;
  148689. p?: number;
  148690. q?: number;
  148691. updatable?: boolean;
  148692. sideOrientation?: number;
  148693. frontUVs?: Vector4;
  148694. backUVs?: Vector4;
  148695. }, scene?: Nullable<Scene>): Mesh;
  148696. /**
  148697. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  148698. * * 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
  148699. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  148700. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  148701. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  148702. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  148703. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  148704. * * 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
  148705. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  148706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148707. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  148708. * @param name defines the name of the new line system
  148709. * @param options defines the options used to create the line system
  148710. * @param scene defines the hosting scene
  148711. * @returns a new line system mesh
  148712. */
  148713. static CreateLineSystem(name: string, options: {
  148714. lines: Vector3[][];
  148715. updatable?: boolean;
  148716. instance?: Nullable<LinesMesh>;
  148717. colors?: Nullable<Color4[][]>;
  148718. useVertexAlpha?: boolean;
  148719. }, scene: Nullable<Scene>): LinesMesh;
  148720. /**
  148721. * Creates a line mesh
  148722. * 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
  148723. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  148724. * * The parameter `points` is an array successive Vector3
  148725. * * 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
  148726. * * The optional parameter `colors` is an array of successive Color4, one per line point
  148727. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  148728. * * When updating an instance, remember that only point positions can change, not the number of points
  148729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148730. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  148731. * @param name defines the name of the new line system
  148732. * @param options defines the options used to create the line system
  148733. * @param scene defines the hosting scene
  148734. * @returns a new line mesh
  148735. */
  148736. static CreateLines(name: string, options: {
  148737. points: Vector3[];
  148738. updatable?: boolean;
  148739. instance?: Nullable<LinesMesh>;
  148740. colors?: Color4[];
  148741. useVertexAlpha?: boolean;
  148742. }, scene?: Nullable<Scene>): LinesMesh;
  148743. /**
  148744. * Creates a dashed line mesh
  148745. * * 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
  148746. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  148747. * * The parameter `points` is an array successive Vector3
  148748. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  148749. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  148750. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  148751. * * 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
  148752. * * When updating an instance, remember that only point positions can change, not the number of points
  148753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148754. * @param name defines the name of the mesh
  148755. * @param options defines the options used to create the mesh
  148756. * @param scene defines the hosting scene
  148757. * @returns the dashed line mesh
  148758. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  148759. */
  148760. static CreateDashedLines(name: string, options: {
  148761. points: Vector3[];
  148762. dashSize?: number;
  148763. gapSize?: number;
  148764. dashNb?: number;
  148765. updatable?: boolean;
  148766. instance?: LinesMesh;
  148767. }, scene?: Nullable<Scene>): LinesMesh;
  148768. /**
  148769. * 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.
  148770. * * 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.
  148771. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  148772. * * 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.
  148773. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  148774. * * 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
  148775. * * 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
  148776. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  148777. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148778. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148779. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  148780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148781. * @param name defines the name of the mesh
  148782. * @param options defines the options used to create the mesh
  148783. * @param scene defines the hosting scene
  148784. * @returns the extruded shape mesh
  148785. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148786. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  148787. */
  148788. static ExtrudeShape(name: string, options: {
  148789. shape: Vector3[];
  148790. path: Vector3[];
  148791. scale?: number;
  148792. rotation?: number;
  148793. cap?: number;
  148794. updatable?: boolean;
  148795. sideOrientation?: number;
  148796. frontUVs?: Vector4;
  148797. backUVs?: Vector4;
  148798. instance?: Mesh;
  148799. invertUV?: boolean;
  148800. }, scene?: Nullable<Scene>): Mesh;
  148801. /**
  148802. * Creates an custom extruded shape mesh.
  148803. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  148804. * * 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.
  148805. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  148806. * * 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
  148807. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  148808. * * 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
  148809. * * It must returns a float value that will be the scale value applied to the shape on each path point
  148810. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  148811. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  148812. * * 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
  148813. * * 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
  148814. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  148815. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148816. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148817. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148819. * @param name defines the name of the mesh
  148820. * @param options defines the options used to create the mesh
  148821. * @param scene defines the hosting scene
  148822. * @returns the custom extruded shape mesh
  148823. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  148824. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148825. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  148826. */
  148827. static ExtrudeShapeCustom(name: string, options: {
  148828. shape: Vector3[];
  148829. path: Vector3[];
  148830. scaleFunction?: any;
  148831. rotationFunction?: any;
  148832. ribbonCloseArray?: boolean;
  148833. ribbonClosePath?: boolean;
  148834. cap?: number;
  148835. updatable?: boolean;
  148836. sideOrientation?: number;
  148837. frontUVs?: Vector4;
  148838. backUVs?: Vector4;
  148839. instance?: Mesh;
  148840. invertUV?: boolean;
  148841. }, scene?: Nullable<Scene>): Mesh;
  148842. /**
  148843. * Creates lathe mesh.
  148844. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  148845. * * 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
  148846. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  148847. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  148848. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  148849. * * 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
  148850. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  148851. * * 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
  148852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148853. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148854. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148856. * @param name defines the name of the mesh
  148857. * @param options defines the options used to create the mesh
  148858. * @param scene defines the hosting scene
  148859. * @returns the lathe mesh
  148860. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  148861. */
  148862. static CreateLathe(name: string, options: {
  148863. shape: Vector3[];
  148864. radius?: number;
  148865. tessellation?: number;
  148866. clip?: number;
  148867. arc?: number;
  148868. closed?: boolean;
  148869. updatable?: boolean;
  148870. sideOrientation?: number;
  148871. frontUVs?: Vector4;
  148872. backUVs?: Vector4;
  148873. cap?: number;
  148874. invertUV?: boolean;
  148875. }, scene?: Nullable<Scene>): Mesh;
  148876. /**
  148877. * Creates a tiled plane mesh
  148878. * * You can set a limited pattern arrangement with the tiles
  148879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148880. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148882. * @param name defines the name of the mesh
  148883. * @param options defines the options used to create the mesh
  148884. * @param scene defines the hosting scene
  148885. * @returns the plane mesh
  148886. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  148887. */
  148888. static CreateTiledPlane(name: string, options: {
  148889. pattern?: number;
  148890. tileSize?: number;
  148891. tileWidth?: number;
  148892. tileHeight?: number;
  148893. size?: number;
  148894. width?: number;
  148895. height?: number;
  148896. alignHorizontal?: number;
  148897. alignVertical?: number;
  148898. sideOrientation?: number;
  148899. frontUVs?: Vector4;
  148900. backUVs?: Vector4;
  148901. updatable?: boolean;
  148902. }, scene?: Nullable<Scene>): Mesh;
  148903. /**
  148904. * Creates a plane mesh
  148905. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  148906. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  148907. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  148908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148909. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148911. * @param name defines the name of the mesh
  148912. * @param options defines the options used to create the mesh
  148913. * @param scene defines the hosting scene
  148914. * @returns the plane mesh
  148915. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  148916. */
  148917. static CreatePlane(name: string, options: {
  148918. size?: number;
  148919. width?: number;
  148920. height?: number;
  148921. sideOrientation?: number;
  148922. frontUVs?: Vector4;
  148923. backUVs?: Vector4;
  148924. updatable?: boolean;
  148925. sourcePlane?: Plane;
  148926. }, scene?: Nullable<Scene>): Mesh;
  148927. /**
  148928. * Creates a ground mesh
  148929. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  148930. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  148931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148932. * @param name defines the name of the mesh
  148933. * @param options defines the options used to create the mesh
  148934. * @param scene defines the hosting scene
  148935. * @returns the ground mesh
  148936. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  148937. */
  148938. static CreateGround(name: string, options: {
  148939. width?: number;
  148940. height?: number;
  148941. subdivisions?: number;
  148942. subdivisionsX?: number;
  148943. subdivisionsY?: number;
  148944. updatable?: boolean;
  148945. }, scene?: Nullable<Scene>): Mesh;
  148946. /**
  148947. * Creates a tiled ground mesh
  148948. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  148949. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  148950. * * 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
  148951. * * 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
  148952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148953. * @param name defines the name of the mesh
  148954. * @param options defines the options used to create the mesh
  148955. * @param scene defines the hosting scene
  148956. * @returns the tiled ground mesh
  148957. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  148958. */
  148959. static CreateTiledGround(name: string, options: {
  148960. xmin: number;
  148961. zmin: number;
  148962. xmax: number;
  148963. zmax: number;
  148964. subdivisions?: {
  148965. w: number;
  148966. h: number;
  148967. };
  148968. precision?: {
  148969. w: number;
  148970. h: number;
  148971. };
  148972. updatable?: boolean;
  148973. }, scene?: Nullable<Scene>): Mesh;
  148974. /**
  148975. * Creates a ground mesh from a height map
  148976. * * The parameter `url` sets the URL of the height map image resource.
  148977. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  148978. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  148979. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  148980. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  148981. * * 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.
  148982. * * 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).
  148983. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  148984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148985. * @param name defines the name of the mesh
  148986. * @param url defines the url to the height map
  148987. * @param options defines the options used to create the mesh
  148988. * @param scene defines the hosting scene
  148989. * @returns the ground mesh
  148990. * @see https://doc.babylonjs.com/babylon101/height_map
  148991. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  148992. */
  148993. static CreateGroundFromHeightMap(name: string, url: string, options: {
  148994. width?: number;
  148995. height?: number;
  148996. subdivisions?: number;
  148997. minHeight?: number;
  148998. maxHeight?: number;
  148999. colorFilter?: Color3;
  149000. alphaFilter?: number;
  149001. updatable?: boolean;
  149002. onReady?: (mesh: GroundMesh) => void;
  149003. }, scene?: Nullable<Scene>): GroundMesh;
  149004. /**
  149005. * Creates a polygon mesh
  149006. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  149007. * * 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
  149008. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  149009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  149011. * * Remember you can only change the shape positions, not their number when updating a polygon
  149012. * @param name defines the name of the mesh
  149013. * @param options defines the options used to create the mesh
  149014. * @param scene defines the hosting scene
  149015. * @param earcutInjection can be used to inject your own earcut reference
  149016. * @returns the polygon mesh
  149017. */
  149018. static CreatePolygon(name: string, options: {
  149019. shape: Vector3[];
  149020. holes?: Vector3[][];
  149021. depth?: number;
  149022. faceUV?: Vector4[];
  149023. faceColors?: Color4[];
  149024. updatable?: boolean;
  149025. sideOrientation?: number;
  149026. frontUVs?: Vector4;
  149027. backUVs?: Vector4;
  149028. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  149029. /**
  149030. * Creates an extruded polygon mesh, with depth in the Y direction.
  149031. * * 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)
  149032. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  149033. * @param name defines the name of the mesh
  149034. * @param options defines the options used to create the mesh
  149035. * @param scene defines the hosting scene
  149036. * @param earcutInjection can be used to inject your own earcut reference
  149037. * @returns the polygon mesh
  149038. */
  149039. static ExtrudePolygon(name: string, options: {
  149040. shape: Vector3[];
  149041. holes?: Vector3[][];
  149042. depth?: number;
  149043. faceUV?: Vector4[];
  149044. faceColors?: Color4[];
  149045. updatable?: boolean;
  149046. sideOrientation?: number;
  149047. frontUVs?: Vector4;
  149048. backUVs?: Vector4;
  149049. wrap?: boolean;
  149050. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  149051. /**
  149052. * Creates a tube mesh.
  149053. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  149054. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  149055. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  149056. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  149057. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  149058. * * 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)
  149059. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  149060. * * 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
  149061. * * 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
  149062. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149063. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149064. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  149065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149066. * @param name defines the name of the mesh
  149067. * @param options defines the options used to create the mesh
  149068. * @param scene defines the hosting scene
  149069. * @returns the tube mesh
  149070. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  149071. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  149072. */
  149073. static CreateTube(name: string, options: {
  149074. path: Vector3[];
  149075. radius?: number;
  149076. tessellation?: number;
  149077. radiusFunction?: {
  149078. (i: number, distance: number): number;
  149079. };
  149080. cap?: number;
  149081. arc?: number;
  149082. updatable?: boolean;
  149083. sideOrientation?: number;
  149084. frontUVs?: Vector4;
  149085. backUVs?: Vector4;
  149086. instance?: Mesh;
  149087. invertUV?: boolean;
  149088. }, scene?: Nullable<Scene>): Mesh;
  149089. /**
  149090. * Creates a polyhedron mesh
  149091. * * 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
  149092. * * The parameter `size` (positive float, default 1) sets the polygon size
  149093. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  149094. * * 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`
  149095. * * 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
  149096. * * 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)`)
  149097. * * 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
  149098. * * 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
  149099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149100. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149102. * @param name defines the name of the mesh
  149103. * @param options defines the options used to create the mesh
  149104. * @param scene defines the hosting scene
  149105. * @returns the polyhedron mesh
  149106. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  149107. */
  149108. static CreatePolyhedron(name: string, options: {
  149109. type?: number;
  149110. size?: number;
  149111. sizeX?: number;
  149112. sizeY?: number;
  149113. sizeZ?: number;
  149114. custom?: any;
  149115. faceUV?: Vector4[];
  149116. faceColors?: Color4[];
  149117. flat?: boolean;
  149118. updatable?: boolean;
  149119. sideOrientation?: number;
  149120. frontUVs?: Vector4;
  149121. backUVs?: Vector4;
  149122. }, scene?: Nullable<Scene>): Mesh;
  149123. /**
  149124. * Creates a decal mesh.
  149125. * 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
  149126. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  149127. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  149128. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  149129. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  149130. * @param name defines the name of the mesh
  149131. * @param sourceMesh defines the mesh where the decal must be applied
  149132. * @param options defines the options used to create the mesh
  149133. * @param scene defines the hosting scene
  149134. * @returns the decal mesh
  149135. * @see https://doc.babylonjs.com/how_to/decals
  149136. */
  149137. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  149138. position?: Vector3;
  149139. normal?: Vector3;
  149140. size?: Vector3;
  149141. angle?: number;
  149142. }): Mesh;
  149143. /**
  149144. * Creates a Capsule Mesh
  149145. * @param name defines the name of the mesh.
  149146. * @param options the constructors options used to shape the mesh.
  149147. * @param scene defines the scene the mesh is scoped to.
  149148. * @returns the capsule mesh
  149149. * @see https://doc.babylonjs.com/how_to/capsule_shape
  149150. */
  149151. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  149152. }
  149153. }
  149154. declare module BABYLON {
  149155. /**
  149156. * A simplifier interface for future simplification implementations
  149157. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149158. */
  149159. export interface ISimplifier {
  149160. /**
  149161. * Simplification of a given mesh according to the given settings.
  149162. * Since this requires computation, it is assumed that the function runs async.
  149163. * @param settings The settings of the simplification, including quality and distance
  149164. * @param successCallback A callback that will be called after the mesh was simplified.
  149165. * @param errorCallback in case of an error, this callback will be called. optional.
  149166. */
  149167. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  149168. }
  149169. /**
  149170. * Expected simplification settings.
  149171. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  149172. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149173. */
  149174. export interface ISimplificationSettings {
  149175. /**
  149176. * Gets or sets the expected quality
  149177. */
  149178. quality: number;
  149179. /**
  149180. * Gets or sets the distance when this optimized version should be used
  149181. */
  149182. distance: number;
  149183. /**
  149184. * Gets an already optimized mesh
  149185. */
  149186. optimizeMesh?: boolean;
  149187. }
  149188. /**
  149189. * Class used to specify simplification options
  149190. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149191. */
  149192. export class SimplificationSettings implements ISimplificationSettings {
  149193. /** expected quality */
  149194. quality: number;
  149195. /** distance when this optimized version should be used */
  149196. distance: number;
  149197. /** already optimized mesh */
  149198. optimizeMesh?: boolean | undefined;
  149199. /**
  149200. * Creates a SimplificationSettings
  149201. * @param quality expected quality
  149202. * @param distance distance when this optimized version should be used
  149203. * @param optimizeMesh already optimized mesh
  149204. */
  149205. constructor(
  149206. /** expected quality */
  149207. quality: number,
  149208. /** distance when this optimized version should be used */
  149209. distance: number,
  149210. /** already optimized mesh */
  149211. optimizeMesh?: boolean | undefined);
  149212. }
  149213. /**
  149214. * Interface used to define a simplification task
  149215. */
  149216. export interface ISimplificationTask {
  149217. /**
  149218. * Array of settings
  149219. */
  149220. settings: Array<ISimplificationSettings>;
  149221. /**
  149222. * Simplification type
  149223. */
  149224. simplificationType: SimplificationType;
  149225. /**
  149226. * Mesh to simplify
  149227. */
  149228. mesh: Mesh;
  149229. /**
  149230. * Callback called on success
  149231. */
  149232. successCallback?: () => void;
  149233. /**
  149234. * Defines if parallel processing can be used
  149235. */
  149236. parallelProcessing: boolean;
  149237. }
  149238. /**
  149239. * Queue used to order the simplification tasks
  149240. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149241. */
  149242. export class SimplificationQueue {
  149243. private _simplificationArray;
  149244. /**
  149245. * Gets a boolean indicating that the process is still running
  149246. */
  149247. running: boolean;
  149248. /**
  149249. * Creates a new queue
  149250. */
  149251. constructor();
  149252. /**
  149253. * Adds a new simplification task
  149254. * @param task defines a task to add
  149255. */
  149256. addTask(task: ISimplificationTask): void;
  149257. /**
  149258. * Execute next task
  149259. */
  149260. executeNext(): void;
  149261. /**
  149262. * Execute a simplification task
  149263. * @param task defines the task to run
  149264. */
  149265. runSimplification(task: ISimplificationTask): void;
  149266. private getSimplifier;
  149267. }
  149268. /**
  149269. * The implemented types of simplification
  149270. * At the moment only Quadratic Error Decimation is implemented
  149271. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149272. */
  149273. export enum SimplificationType {
  149274. /** Quadratic error decimation */
  149275. QUADRATIC = 0
  149276. }
  149277. /**
  149278. * An implementation of the Quadratic Error simplification algorithm.
  149279. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  149280. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  149281. * @author RaananW
  149282. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149283. */
  149284. export class QuadraticErrorSimplification implements ISimplifier {
  149285. private _mesh;
  149286. private triangles;
  149287. private vertices;
  149288. private references;
  149289. private _reconstructedMesh;
  149290. /** Gets or sets the number pf sync interations */
  149291. syncIterations: number;
  149292. /** Gets or sets the aggressiveness of the simplifier */
  149293. aggressiveness: number;
  149294. /** Gets or sets the number of allowed iterations for decimation */
  149295. decimationIterations: number;
  149296. /** Gets or sets the espilon to use for bounding box computation */
  149297. boundingBoxEpsilon: number;
  149298. /**
  149299. * Creates a new QuadraticErrorSimplification
  149300. * @param _mesh defines the target mesh
  149301. */
  149302. constructor(_mesh: Mesh);
  149303. /**
  149304. * Simplification of a given mesh according to the given settings.
  149305. * Since this requires computation, it is assumed that the function runs async.
  149306. * @param settings The settings of the simplification, including quality and distance
  149307. * @param successCallback A callback that will be called after the mesh was simplified.
  149308. */
  149309. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  149310. private runDecimation;
  149311. private initWithMesh;
  149312. private init;
  149313. private reconstructMesh;
  149314. private initDecimatedMesh;
  149315. private isFlipped;
  149316. private updateTriangles;
  149317. private identifyBorder;
  149318. private updateMesh;
  149319. private vertexError;
  149320. private calculateError;
  149321. }
  149322. }
  149323. declare module BABYLON {
  149324. interface Scene {
  149325. /** @hidden (Backing field) */
  149326. _simplificationQueue: SimplificationQueue;
  149327. /**
  149328. * Gets or sets the simplification queue attached to the scene
  149329. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149330. */
  149331. simplificationQueue: SimplificationQueue;
  149332. }
  149333. interface Mesh {
  149334. /**
  149335. * Simplify the mesh according to the given array of settings.
  149336. * Function will return immediately and will simplify async
  149337. * @param settings a collection of simplification settings
  149338. * @param parallelProcessing should all levels calculate parallel or one after the other
  149339. * @param simplificationType the type of simplification to run
  149340. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  149341. * @returns the current mesh
  149342. */
  149343. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  149344. }
  149345. /**
  149346. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  149347. * created in a scene
  149348. */
  149349. export class SimplicationQueueSceneComponent implements ISceneComponent {
  149350. /**
  149351. * The component name helpfull to identify the component in the list of scene components.
  149352. */
  149353. readonly name: string;
  149354. /**
  149355. * The scene the component belongs to.
  149356. */
  149357. scene: Scene;
  149358. /**
  149359. * Creates a new instance of the component for the given scene
  149360. * @param scene Defines the scene to register the component in
  149361. */
  149362. constructor(scene: Scene);
  149363. /**
  149364. * Registers the component in a given scene
  149365. */
  149366. register(): void;
  149367. /**
  149368. * Rebuilds the elements related to this component in case of
  149369. * context lost for instance.
  149370. */
  149371. rebuild(): void;
  149372. /**
  149373. * Disposes the component and the associated ressources
  149374. */
  149375. dispose(): void;
  149376. private _beforeCameraUpdate;
  149377. }
  149378. }
  149379. declare module BABYLON {
  149380. interface Mesh {
  149381. /**
  149382. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  149383. */
  149384. thinInstanceEnablePicking: boolean;
  149385. /**
  149386. * Creates a new thin instance
  149387. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  149388. * @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
  149389. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  149390. */
  149391. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  149392. /**
  149393. * Adds the transformation (matrix) of the current mesh as a thin instance
  149394. * @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
  149395. * @returns the thin instance index number
  149396. */
  149397. thinInstanceAddSelf(refresh: boolean): number;
  149398. /**
  149399. * Registers a custom attribute to be used with thin instances
  149400. * @param kind name of the attribute
  149401. * @param stride size in floats of the attribute
  149402. */
  149403. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  149404. /**
  149405. * Sets the matrix of a thin instance
  149406. * @param index index of the thin instance
  149407. * @param matrix matrix to set
  149408. * @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
  149409. */
  149410. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  149411. /**
  149412. * Sets the value of a custom attribute for a thin instance
  149413. * @param kind name of the attribute
  149414. * @param index index of the thin instance
  149415. * @param value value to set
  149416. * @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
  149417. */
  149418. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  149419. /**
  149420. * 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.
  149421. */
  149422. thinInstanceCount: number;
  149423. /**
  149424. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  149425. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  149426. * @param buffer buffer to set
  149427. * @param stride size in floats of each value of the buffer
  149428. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  149429. */
  149430. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  149431. /**
  149432. * Gets the list of world matrices
  149433. * @return an array containing all the world matrices from the thin instances
  149434. */
  149435. thinInstanceGetWorldMatrices(): Matrix[];
  149436. /**
  149437. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  149438. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  149439. */
  149440. thinInstanceBufferUpdated(kind: string): void;
  149441. /**
  149442. * Applies a partial update to a buffer directly on the GPU
  149443. * 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
  149444. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  149445. * @param data the data to set in the GPU buffer
  149446. * @param offset the offset in the GPU buffer where to update the data
  149447. */
  149448. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  149449. /**
  149450. * Refreshes the bounding info, taking into account all the thin instances defined
  149451. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  149452. */
  149453. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  149454. /** @hidden */
  149455. _thinInstanceInitializeUserStorage(): void;
  149456. /** @hidden */
  149457. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  149458. /** @hidden */
  149459. _userThinInstanceBuffersStorage: {
  149460. data: {
  149461. [key: string]: Float32Array;
  149462. };
  149463. sizes: {
  149464. [key: string]: number;
  149465. };
  149466. vertexBuffers: {
  149467. [key: string]: Nullable<VertexBuffer>;
  149468. };
  149469. strides: {
  149470. [key: string]: number;
  149471. };
  149472. };
  149473. }
  149474. }
  149475. declare module BABYLON {
  149476. /**
  149477. * Navigation plugin interface to add navigation constrained by a navigation mesh
  149478. */
  149479. export interface INavigationEnginePlugin {
  149480. /**
  149481. * plugin name
  149482. */
  149483. name: string;
  149484. /**
  149485. * Creates a navigation mesh
  149486. * @param meshes array of all the geometry used to compute the navigatio mesh
  149487. * @param parameters bunch of parameters used to filter geometry
  149488. */
  149489. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  149490. /**
  149491. * Create a navigation mesh debug mesh
  149492. * @param scene is where the mesh will be added
  149493. * @returns debug display mesh
  149494. */
  149495. createDebugNavMesh(scene: Scene): Mesh;
  149496. /**
  149497. * Get a navigation mesh constrained position, closest to the parameter position
  149498. * @param position world position
  149499. * @returns the closest point to position constrained by the navigation mesh
  149500. */
  149501. getClosestPoint(position: Vector3): Vector3;
  149502. /**
  149503. * Get a navigation mesh constrained position, closest to the parameter position
  149504. * @param position world position
  149505. * @param result output the closest point to position constrained by the navigation mesh
  149506. */
  149507. getClosestPointToRef(position: Vector3, result: Vector3): void;
  149508. /**
  149509. * Get a navigation mesh constrained position, within a particular radius
  149510. * @param position world position
  149511. * @param maxRadius the maximum distance to the constrained world position
  149512. * @returns the closest point to position constrained by the navigation mesh
  149513. */
  149514. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  149515. /**
  149516. * Get a navigation mesh constrained position, within a particular radius
  149517. * @param position world position
  149518. * @param maxRadius the maximum distance to the constrained world position
  149519. * @param result output the closest point to position constrained by the navigation mesh
  149520. */
  149521. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  149522. /**
  149523. * Compute the final position from a segment made of destination-position
  149524. * @param position world position
  149525. * @param destination world position
  149526. * @returns the resulting point along the navmesh
  149527. */
  149528. moveAlong(position: Vector3, destination: Vector3): Vector3;
  149529. /**
  149530. * Compute the final position from a segment made of destination-position
  149531. * @param position world position
  149532. * @param destination world position
  149533. * @param result output the resulting point along the navmesh
  149534. */
  149535. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  149536. /**
  149537. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  149538. * @param start world position
  149539. * @param end world position
  149540. * @returns array containing world position composing the path
  149541. */
  149542. computePath(start: Vector3, end: Vector3): Vector3[];
  149543. /**
  149544. * If this plugin is supported
  149545. * @returns true if plugin is supported
  149546. */
  149547. isSupported(): boolean;
  149548. /**
  149549. * Create a new Crowd so you can add agents
  149550. * @param maxAgents the maximum agent count in the crowd
  149551. * @param maxAgentRadius the maximum radius an agent can have
  149552. * @param scene to attach the crowd to
  149553. * @returns the crowd you can add agents to
  149554. */
  149555. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  149556. /**
  149557. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149558. * The queries will try to find a solution within those bounds
  149559. * default is (1,1,1)
  149560. * @param extent x,y,z value that define the extent around the queries point of reference
  149561. */
  149562. setDefaultQueryExtent(extent: Vector3): void;
  149563. /**
  149564. * Get the Bounding box extent specified by setDefaultQueryExtent
  149565. * @returns the box extent values
  149566. */
  149567. getDefaultQueryExtent(): Vector3;
  149568. /**
  149569. * build the navmesh from a previously saved state using getNavmeshData
  149570. * @param data the Uint8Array returned by getNavmeshData
  149571. */
  149572. buildFromNavmeshData(data: Uint8Array): void;
  149573. /**
  149574. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  149575. * @returns data the Uint8Array that can be saved and reused
  149576. */
  149577. getNavmeshData(): Uint8Array;
  149578. /**
  149579. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149580. * @param result output the box extent values
  149581. */
  149582. getDefaultQueryExtentToRef(result: Vector3): void;
  149583. /**
  149584. * Release all resources
  149585. */
  149586. dispose(): void;
  149587. }
  149588. /**
  149589. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  149590. */
  149591. export interface ICrowd {
  149592. /**
  149593. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  149594. * You can attach anything to that node. The node position is updated in the scene update tick.
  149595. * @param pos world position that will be constrained by the navigation mesh
  149596. * @param parameters agent parameters
  149597. * @param transform hooked to the agent that will be update by the scene
  149598. * @returns agent index
  149599. */
  149600. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  149601. /**
  149602. * Returns the agent position in world space
  149603. * @param index agent index returned by addAgent
  149604. * @returns world space position
  149605. */
  149606. getAgentPosition(index: number): Vector3;
  149607. /**
  149608. * Gets the agent position result in world space
  149609. * @param index agent index returned by addAgent
  149610. * @param result output world space position
  149611. */
  149612. getAgentPositionToRef(index: number, result: Vector3): void;
  149613. /**
  149614. * Gets the agent velocity in world space
  149615. * @param index agent index returned by addAgent
  149616. * @returns world space velocity
  149617. */
  149618. getAgentVelocity(index: number): Vector3;
  149619. /**
  149620. * Gets the agent velocity result in world space
  149621. * @param index agent index returned by addAgent
  149622. * @param result output world space velocity
  149623. */
  149624. getAgentVelocityToRef(index: number, result: Vector3): void;
  149625. /**
  149626. * Gets the agent next target point on the path
  149627. * @param index agent index returned by addAgent
  149628. * @returns world space position
  149629. */
  149630. getAgentNextTargetPath(index: number): Vector3;
  149631. /**
  149632. * Gets the agent state
  149633. * @param index agent index returned by addAgent
  149634. * @returns agent state
  149635. */
  149636. getAgentState(index: number): number;
  149637. /**
  149638. * returns true if the agent in over an off mesh link connection
  149639. * @param index agent index returned by addAgent
  149640. * @returns true if over an off mesh link connection
  149641. */
  149642. overOffmeshConnection(index: number): boolean;
  149643. /**
  149644. * Gets the agent next target point on the path
  149645. * @param index agent index returned by addAgent
  149646. * @param result output world space position
  149647. */
  149648. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  149649. /**
  149650. * remove a particular agent previously created
  149651. * @param index agent index returned by addAgent
  149652. */
  149653. removeAgent(index: number): void;
  149654. /**
  149655. * get the list of all agents attached to this crowd
  149656. * @returns list of agent indices
  149657. */
  149658. getAgents(): number[];
  149659. /**
  149660. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  149661. * @param deltaTime in seconds
  149662. */
  149663. update(deltaTime: number): void;
  149664. /**
  149665. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  149666. * @param index agent index returned by addAgent
  149667. * @param destination targeted world position
  149668. */
  149669. agentGoto(index: number, destination: Vector3): void;
  149670. /**
  149671. * Teleport the agent to a new position
  149672. * @param index agent index returned by addAgent
  149673. * @param destination targeted world position
  149674. */
  149675. agentTeleport(index: number, destination: Vector3): void;
  149676. /**
  149677. * Update agent parameters
  149678. * @param index agent index returned by addAgent
  149679. * @param parameters agent parameters
  149680. */
  149681. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  149682. /**
  149683. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149684. * The queries will try to find a solution within those bounds
  149685. * default is (1,1,1)
  149686. * @param extent x,y,z value that define the extent around the queries point of reference
  149687. */
  149688. setDefaultQueryExtent(extent: Vector3): void;
  149689. /**
  149690. * Get the Bounding box extent specified by setDefaultQueryExtent
  149691. * @returns the box extent values
  149692. */
  149693. getDefaultQueryExtent(): Vector3;
  149694. /**
  149695. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149696. * @param result output the box extent values
  149697. */
  149698. getDefaultQueryExtentToRef(result: Vector3): void;
  149699. /**
  149700. * Release all resources
  149701. */
  149702. dispose(): void;
  149703. }
  149704. /**
  149705. * Configures an agent
  149706. */
  149707. export interface IAgentParameters {
  149708. /**
  149709. * Agent radius. [Limit: >= 0]
  149710. */
  149711. radius: number;
  149712. /**
  149713. * Agent height. [Limit: > 0]
  149714. */
  149715. height: number;
  149716. /**
  149717. * Maximum allowed acceleration. [Limit: >= 0]
  149718. */
  149719. maxAcceleration: number;
  149720. /**
  149721. * Maximum allowed speed. [Limit: >= 0]
  149722. */
  149723. maxSpeed: number;
  149724. /**
  149725. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  149726. */
  149727. collisionQueryRange: number;
  149728. /**
  149729. * The path visibility optimization range. [Limit: > 0]
  149730. */
  149731. pathOptimizationRange: number;
  149732. /**
  149733. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  149734. */
  149735. separationWeight: number;
  149736. }
  149737. /**
  149738. * Configures the navigation mesh creation
  149739. */
  149740. export interface INavMeshParameters {
  149741. /**
  149742. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  149743. */
  149744. cs: number;
  149745. /**
  149746. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  149747. */
  149748. ch: number;
  149749. /**
  149750. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  149751. */
  149752. walkableSlopeAngle: number;
  149753. /**
  149754. * Minimum floor to 'ceiling' height that will still allow the floor area to
  149755. * be considered walkable. [Limit: >= 3] [Units: vx]
  149756. */
  149757. walkableHeight: number;
  149758. /**
  149759. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  149760. */
  149761. walkableClimb: number;
  149762. /**
  149763. * The distance to erode/shrink the walkable area of the heightfield away from
  149764. * obstructions. [Limit: >=0] [Units: vx]
  149765. */
  149766. walkableRadius: number;
  149767. /**
  149768. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  149769. */
  149770. maxEdgeLen: number;
  149771. /**
  149772. * The maximum distance a simplfied contour's border edges should deviate
  149773. * the original raw contour. [Limit: >=0] [Units: vx]
  149774. */
  149775. maxSimplificationError: number;
  149776. /**
  149777. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  149778. */
  149779. minRegionArea: number;
  149780. /**
  149781. * Any regions with a span count smaller than this value will, if possible,
  149782. * be merged with larger regions. [Limit: >=0] [Units: vx]
  149783. */
  149784. mergeRegionArea: number;
  149785. /**
  149786. * The maximum number of vertices allowed for polygons generated during the
  149787. * contour to polygon conversion process. [Limit: >= 3]
  149788. */
  149789. maxVertsPerPoly: number;
  149790. /**
  149791. * Sets the sampling distance to use when generating the detail mesh.
  149792. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  149793. */
  149794. detailSampleDist: number;
  149795. /**
  149796. * The maximum distance the detail mesh surface should deviate from heightfield
  149797. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  149798. */
  149799. detailSampleMaxError: number;
  149800. }
  149801. }
  149802. declare module BABYLON {
  149803. /**
  149804. * RecastJS navigation plugin
  149805. */
  149806. export class RecastJSPlugin implements INavigationEnginePlugin {
  149807. /**
  149808. * Reference to the Recast library
  149809. */
  149810. bjsRECAST: any;
  149811. /**
  149812. * plugin name
  149813. */
  149814. name: string;
  149815. /**
  149816. * the first navmesh created. We might extend this to support multiple navmeshes
  149817. */
  149818. navMesh: any;
  149819. /**
  149820. * Initializes the recastJS plugin
  149821. * @param recastInjection can be used to inject your own recast reference
  149822. */
  149823. constructor(recastInjection?: any);
  149824. /**
  149825. * Creates a navigation mesh
  149826. * @param meshes array of all the geometry used to compute the navigatio mesh
  149827. * @param parameters bunch of parameters used to filter geometry
  149828. */
  149829. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  149830. /**
  149831. * Create a navigation mesh debug mesh
  149832. * @param scene is where the mesh will be added
  149833. * @returns debug display mesh
  149834. */
  149835. createDebugNavMesh(scene: Scene): Mesh;
  149836. /**
  149837. * Get a navigation mesh constrained position, closest to the parameter position
  149838. * @param position world position
  149839. * @returns the closest point to position constrained by the navigation mesh
  149840. */
  149841. getClosestPoint(position: Vector3): Vector3;
  149842. /**
  149843. * Get a navigation mesh constrained position, closest to the parameter position
  149844. * @param position world position
  149845. * @param result output the closest point to position constrained by the navigation mesh
  149846. */
  149847. getClosestPointToRef(position: Vector3, result: Vector3): void;
  149848. /**
  149849. * Get a navigation mesh constrained position, within a particular radius
  149850. * @param position world position
  149851. * @param maxRadius the maximum distance to the constrained world position
  149852. * @returns the closest point to position constrained by the navigation mesh
  149853. */
  149854. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  149855. /**
  149856. * Get a navigation mesh constrained position, within a particular radius
  149857. * @param position world position
  149858. * @param maxRadius the maximum distance to the constrained world position
  149859. * @param result output the closest point to position constrained by the navigation mesh
  149860. */
  149861. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  149862. /**
  149863. * Compute the final position from a segment made of destination-position
  149864. * @param position world position
  149865. * @param destination world position
  149866. * @returns the resulting point along the navmesh
  149867. */
  149868. moveAlong(position: Vector3, destination: Vector3): Vector3;
  149869. /**
  149870. * Compute the final position from a segment made of destination-position
  149871. * @param position world position
  149872. * @param destination world position
  149873. * @param result output the resulting point along the navmesh
  149874. */
  149875. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  149876. /**
  149877. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  149878. * @param start world position
  149879. * @param end world position
  149880. * @returns array containing world position composing the path
  149881. */
  149882. computePath(start: Vector3, end: Vector3): Vector3[];
  149883. /**
  149884. * Create a new Crowd so you can add agents
  149885. * @param maxAgents the maximum agent count in the crowd
  149886. * @param maxAgentRadius the maximum radius an agent can have
  149887. * @param scene to attach the crowd to
  149888. * @returns the crowd you can add agents to
  149889. */
  149890. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  149891. /**
  149892. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149893. * The queries will try to find a solution within those bounds
  149894. * default is (1,1,1)
  149895. * @param extent x,y,z value that define the extent around the queries point of reference
  149896. */
  149897. setDefaultQueryExtent(extent: Vector3): void;
  149898. /**
  149899. * Get the Bounding box extent specified by setDefaultQueryExtent
  149900. * @returns the box extent values
  149901. */
  149902. getDefaultQueryExtent(): Vector3;
  149903. /**
  149904. * build the navmesh from a previously saved state using getNavmeshData
  149905. * @param data the Uint8Array returned by getNavmeshData
  149906. */
  149907. buildFromNavmeshData(data: Uint8Array): void;
  149908. /**
  149909. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  149910. * @returns data the Uint8Array that can be saved and reused
  149911. */
  149912. getNavmeshData(): Uint8Array;
  149913. /**
  149914. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149915. * @param result output the box extent values
  149916. */
  149917. getDefaultQueryExtentToRef(result: Vector3): void;
  149918. /**
  149919. * Disposes
  149920. */
  149921. dispose(): void;
  149922. /**
  149923. * If this plugin is supported
  149924. * @returns true if plugin is supported
  149925. */
  149926. isSupported(): boolean;
  149927. }
  149928. /**
  149929. * Recast detour crowd implementation
  149930. */
  149931. export class RecastJSCrowd implements ICrowd {
  149932. /**
  149933. * Recast/detour plugin
  149934. */
  149935. bjsRECASTPlugin: RecastJSPlugin;
  149936. /**
  149937. * Link to the detour crowd
  149938. */
  149939. recastCrowd: any;
  149940. /**
  149941. * One transform per agent
  149942. */
  149943. transforms: TransformNode[];
  149944. /**
  149945. * All agents created
  149946. */
  149947. agents: number[];
  149948. /**
  149949. * Link to the scene is kept to unregister the crowd from the scene
  149950. */
  149951. private _scene;
  149952. /**
  149953. * Observer for crowd updates
  149954. */
  149955. private _onBeforeAnimationsObserver;
  149956. /**
  149957. * Constructor
  149958. * @param plugin recastJS plugin
  149959. * @param maxAgents the maximum agent count in the crowd
  149960. * @param maxAgentRadius the maximum radius an agent can have
  149961. * @param scene to attach the crowd to
  149962. * @returns the crowd you can add agents to
  149963. */
  149964. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  149965. /**
  149966. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  149967. * You can attach anything to that node. The node position is updated in the scene update tick.
  149968. * @param pos world position that will be constrained by the navigation mesh
  149969. * @param parameters agent parameters
  149970. * @param transform hooked to the agent that will be update by the scene
  149971. * @returns agent index
  149972. */
  149973. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  149974. /**
  149975. * Returns the agent position in world space
  149976. * @param index agent index returned by addAgent
  149977. * @returns world space position
  149978. */
  149979. getAgentPosition(index: number): Vector3;
  149980. /**
  149981. * Returns the agent position result in world space
  149982. * @param index agent index returned by addAgent
  149983. * @param result output world space position
  149984. */
  149985. getAgentPositionToRef(index: number, result: Vector3): void;
  149986. /**
  149987. * Returns the agent velocity in world space
  149988. * @param index agent index returned by addAgent
  149989. * @returns world space velocity
  149990. */
  149991. getAgentVelocity(index: number): Vector3;
  149992. /**
  149993. * Returns the agent velocity result in world space
  149994. * @param index agent index returned by addAgent
  149995. * @param result output world space velocity
  149996. */
  149997. getAgentVelocityToRef(index: number, result: Vector3): void;
  149998. /**
  149999. * Returns the agent next target point on the path
  150000. * @param index agent index returned by addAgent
  150001. * @returns world space position
  150002. */
  150003. getAgentNextTargetPath(index: number): Vector3;
  150004. /**
  150005. * Returns the agent next target point on the path
  150006. * @param index agent index returned by addAgent
  150007. * @param result output world space position
  150008. */
  150009. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  150010. /**
  150011. * Gets the agent state
  150012. * @param index agent index returned by addAgent
  150013. * @returns agent state
  150014. */
  150015. getAgentState(index: number): number;
  150016. /**
  150017. * returns true if the agent in over an off mesh link connection
  150018. * @param index agent index returned by addAgent
  150019. * @returns true if over an off mesh link connection
  150020. */
  150021. overOffmeshConnection(index: number): boolean;
  150022. /**
  150023. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  150024. * @param index agent index returned by addAgent
  150025. * @param destination targeted world position
  150026. */
  150027. agentGoto(index: number, destination: Vector3): void;
  150028. /**
  150029. * Teleport the agent to a new position
  150030. * @param index agent index returned by addAgent
  150031. * @param destination targeted world position
  150032. */
  150033. agentTeleport(index: number, destination: Vector3): void;
  150034. /**
  150035. * Update agent parameters
  150036. * @param index agent index returned by addAgent
  150037. * @param parameters agent parameters
  150038. */
  150039. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  150040. /**
  150041. * remove a particular agent previously created
  150042. * @param index agent index returned by addAgent
  150043. */
  150044. removeAgent(index: number): void;
  150045. /**
  150046. * get the list of all agents attached to this crowd
  150047. * @returns list of agent indices
  150048. */
  150049. getAgents(): number[];
  150050. /**
  150051. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  150052. * @param deltaTime in seconds
  150053. */
  150054. update(deltaTime: number): void;
  150055. /**
  150056. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  150057. * The queries will try to find a solution within those bounds
  150058. * default is (1,1,1)
  150059. * @param extent x,y,z value that define the extent around the queries point of reference
  150060. */
  150061. setDefaultQueryExtent(extent: Vector3): void;
  150062. /**
  150063. * Get the Bounding box extent specified by setDefaultQueryExtent
  150064. * @returns the box extent values
  150065. */
  150066. getDefaultQueryExtent(): Vector3;
  150067. /**
  150068. * Get the Bounding box extent result specified by setDefaultQueryExtent
  150069. * @param result output the box extent values
  150070. */
  150071. getDefaultQueryExtentToRef(result: Vector3): void;
  150072. /**
  150073. * Release all resources
  150074. */
  150075. dispose(): void;
  150076. }
  150077. }
  150078. declare module BABYLON {
  150079. /**
  150080. * Class used to enable access to IndexedDB
  150081. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  150082. */
  150083. export class Database implements IOfflineProvider {
  150084. private _callbackManifestChecked;
  150085. private _currentSceneUrl;
  150086. private _db;
  150087. private _enableSceneOffline;
  150088. private _enableTexturesOffline;
  150089. private _manifestVersionFound;
  150090. private _mustUpdateRessources;
  150091. private _hasReachedQuota;
  150092. private _isSupported;
  150093. private _idbFactory;
  150094. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  150095. private static IsUASupportingBlobStorage;
  150096. /**
  150097. * Gets a boolean indicating if Database storate is enabled (off by default)
  150098. */
  150099. static IDBStorageEnabled: boolean;
  150100. /**
  150101. * Gets a boolean indicating if scene must be saved in the database
  150102. */
  150103. get enableSceneOffline(): boolean;
  150104. /**
  150105. * Gets a boolean indicating if textures must be saved in the database
  150106. */
  150107. get enableTexturesOffline(): boolean;
  150108. /**
  150109. * Creates a new Database
  150110. * @param urlToScene defines the url to load the scene
  150111. * @param callbackManifestChecked defines the callback to use when manifest is checked
  150112. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  150113. */
  150114. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  150115. private static _ParseURL;
  150116. private static _ReturnFullUrlLocation;
  150117. private _checkManifestFile;
  150118. /**
  150119. * Open the database and make it available
  150120. * @param successCallback defines the callback to call on success
  150121. * @param errorCallback defines the callback to call on error
  150122. */
  150123. open(successCallback: () => void, errorCallback: () => void): void;
  150124. /**
  150125. * Loads an image from the database
  150126. * @param url defines the url to load from
  150127. * @param image defines the target DOM image
  150128. */
  150129. loadImage(url: string, image: HTMLImageElement): void;
  150130. private _loadImageFromDBAsync;
  150131. private _saveImageIntoDBAsync;
  150132. private _checkVersionFromDB;
  150133. private _loadVersionFromDBAsync;
  150134. private _saveVersionIntoDBAsync;
  150135. /**
  150136. * Loads a file from database
  150137. * @param url defines the URL to load from
  150138. * @param sceneLoaded defines a callback to call on success
  150139. * @param progressCallBack defines a callback to call when progress changed
  150140. * @param errorCallback defines a callback to call on error
  150141. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  150142. */
  150143. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  150144. private _loadFileAsync;
  150145. private _saveFileAsync;
  150146. /**
  150147. * Validates if xhr data is correct
  150148. * @param xhr defines the request to validate
  150149. * @param dataType defines the expected data type
  150150. * @returns true if data is correct
  150151. */
  150152. private static _ValidateXHRData;
  150153. }
  150154. }
  150155. declare module BABYLON {
  150156. /** @hidden */
  150157. export var gpuUpdateParticlesPixelShader: {
  150158. name: string;
  150159. shader: string;
  150160. };
  150161. }
  150162. declare module BABYLON {
  150163. /** @hidden */
  150164. export var gpuUpdateParticlesVertexShader: {
  150165. name: string;
  150166. shader: string;
  150167. };
  150168. }
  150169. declare module BABYLON {
  150170. /** @hidden */
  150171. export var clipPlaneFragmentDeclaration2: {
  150172. name: string;
  150173. shader: string;
  150174. };
  150175. }
  150176. declare module BABYLON {
  150177. /** @hidden */
  150178. export var gpuRenderParticlesPixelShader: {
  150179. name: string;
  150180. shader: string;
  150181. };
  150182. }
  150183. declare module BABYLON {
  150184. /** @hidden */
  150185. export var clipPlaneVertexDeclaration2: {
  150186. name: string;
  150187. shader: string;
  150188. };
  150189. }
  150190. declare module BABYLON {
  150191. /** @hidden */
  150192. export var gpuRenderParticlesVertexShader: {
  150193. name: string;
  150194. shader: string;
  150195. };
  150196. }
  150197. declare module BABYLON {
  150198. /**
  150199. * This represents a GPU particle system in Babylon
  150200. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  150201. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  150202. */
  150203. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  150204. /**
  150205. * The layer mask we are rendering the particles through.
  150206. */
  150207. layerMask: number;
  150208. private _capacity;
  150209. private _activeCount;
  150210. private _currentActiveCount;
  150211. private _accumulatedCount;
  150212. private _renderEffect;
  150213. private _updateEffect;
  150214. private _buffer0;
  150215. private _buffer1;
  150216. private _spriteBuffer;
  150217. private _updateVAO;
  150218. private _renderVAO;
  150219. private _targetIndex;
  150220. private _sourceBuffer;
  150221. private _targetBuffer;
  150222. private _currentRenderId;
  150223. private _started;
  150224. private _stopped;
  150225. private _timeDelta;
  150226. private _randomTexture;
  150227. private _randomTexture2;
  150228. private _attributesStrideSize;
  150229. private _updateEffectOptions;
  150230. private _randomTextureSize;
  150231. private _actualFrame;
  150232. private _customEffect;
  150233. private readonly _rawTextureWidth;
  150234. /**
  150235. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  150236. */
  150237. static get IsSupported(): boolean;
  150238. /**
  150239. * An event triggered when the system is disposed.
  150240. */
  150241. onDisposeObservable: Observable<IParticleSystem>;
  150242. /**
  150243. * An event triggered when the system is stopped
  150244. */
  150245. onStoppedObservable: Observable<IParticleSystem>;
  150246. /**
  150247. * Gets the maximum number of particles active at the same time.
  150248. * @returns The max number of active particles.
  150249. */
  150250. getCapacity(): number;
  150251. /**
  150252. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  150253. * to override the particles.
  150254. */
  150255. forceDepthWrite: boolean;
  150256. /**
  150257. * Gets or set the number of active particles
  150258. */
  150259. get activeParticleCount(): number;
  150260. set activeParticleCount(value: number);
  150261. private _preWarmDone;
  150262. /**
  150263. * Specifies if the particles are updated in emitter local space or world space.
  150264. */
  150265. isLocal: boolean;
  150266. /** Gets or sets a matrix to use to compute projection */
  150267. defaultProjectionMatrix: Matrix;
  150268. /**
  150269. * Is this system ready to be used/rendered
  150270. * @return true if the system is ready
  150271. */
  150272. isReady(): boolean;
  150273. /**
  150274. * Gets if the system has been started. (Note: this will still be true after stop is called)
  150275. * @returns True if it has been started, otherwise false.
  150276. */
  150277. isStarted(): boolean;
  150278. /**
  150279. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  150280. * @returns True if it has been stopped, otherwise false.
  150281. */
  150282. isStopped(): boolean;
  150283. /**
  150284. * Gets a boolean indicating that the system is stopping
  150285. * @returns true if the system is currently stopping
  150286. */
  150287. isStopping(): boolean;
  150288. /**
  150289. * Gets the number of particles active at the same time.
  150290. * @returns The number of active particles.
  150291. */
  150292. getActiveCount(): number;
  150293. /**
  150294. * Starts the particle system and begins to emit
  150295. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  150296. */
  150297. start(delay?: number): void;
  150298. /**
  150299. * Stops the particle system.
  150300. */
  150301. stop(): void;
  150302. /**
  150303. * Remove all active particles
  150304. */
  150305. reset(): void;
  150306. /**
  150307. * Returns the string "GPUParticleSystem"
  150308. * @returns a string containing the class name
  150309. */
  150310. getClassName(): string;
  150311. /**
  150312. * Gets the custom effect used to render the particles
  150313. * @param blendMode Blend mode for which the effect should be retrieved
  150314. * @returns The effect
  150315. */
  150316. getCustomEffect(blendMode?: number): Nullable<Effect>;
  150317. /**
  150318. * Sets the custom effect used to render the particles
  150319. * @param effect The effect to set
  150320. * @param blendMode Blend mode for which the effect should be set
  150321. */
  150322. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  150323. /** @hidden */
  150324. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  150325. /**
  150326. * Observable that will be called just before the particles are drawn
  150327. */
  150328. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  150329. /**
  150330. * Gets the name of the particle vertex shader
  150331. */
  150332. get vertexShaderName(): string;
  150333. private _colorGradientsTexture;
  150334. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  150335. /**
  150336. * Adds a new color gradient
  150337. * @param gradient defines the gradient to use (between 0 and 1)
  150338. * @param color1 defines the color to affect to the specified gradient
  150339. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  150340. * @returns the current particle system
  150341. */
  150342. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  150343. private _refreshColorGradient;
  150344. /** Force the system to rebuild all gradients that need to be resync */
  150345. forceRefreshGradients(): void;
  150346. /**
  150347. * Remove a specific color gradient
  150348. * @param gradient defines the gradient to remove
  150349. * @returns the current particle system
  150350. */
  150351. removeColorGradient(gradient: number): GPUParticleSystem;
  150352. private _angularSpeedGradientsTexture;
  150353. private _sizeGradientsTexture;
  150354. private _velocityGradientsTexture;
  150355. private _limitVelocityGradientsTexture;
  150356. private _dragGradientsTexture;
  150357. private _addFactorGradient;
  150358. /**
  150359. * Adds a new size gradient
  150360. * @param gradient defines the gradient to use (between 0 and 1)
  150361. * @param factor defines the size factor to affect to the specified gradient
  150362. * @returns the current particle system
  150363. */
  150364. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  150365. /**
  150366. * Remove a specific size gradient
  150367. * @param gradient defines the gradient to remove
  150368. * @returns the current particle system
  150369. */
  150370. removeSizeGradient(gradient: number): GPUParticleSystem;
  150371. private _refreshFactorGradient;
  150372. /**
  150373. * Adds a new angular speed gradient
  150374. * @param gradient defines the gradient to use (between 0 and 1)
  150375. * @param factor defines the angular speed to affect to the specified gradient
  150376. * @returns the current particle system
  150377. */
  150378. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  150379. /**
  150380. * Remove a specific angular speed gradient
  150381. * @param gradient defines the gradient to remove
  150382. * @returns the current particle system
  150383. */
  150384. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  150385. /**
  150386. * Adds a new velocity gradient
  150387. * @param gradient defines the gradient to use (between 0 and 1)
  150388. * @param factor defines the velocity to affect to the specified gradient
  150389. * @returns the current particle system
  150390. */
  150391. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  150392. /**
  150393. * Remove a specific velocity gradient
  150394. * @param gradient defines the gradient to remove
  150395. * @returns the current particle system
  150396. */
  150397. removeVelocityGradient(gradient: number): GPUParticleSystem;
  150398. /**
  150399. * Adds a new limit velocity gradient
  150400. * @param gradient defines the gradient to use (between 0 and 1)
  150401. * @param factor defines the limit velocity value to affect to the specified gradient
  150402. * @returns the current particle system
  150403. */
  150404. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  150405. /**
  150406. * Remove a specific limit velocity gradient
  150407. * @param gradient defines the gradient to remove
  150408. * @returns the current particle system
  150409. */
  150410. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  150411. /**
  150412. * Adds a new drag gradient
  150413. * @param gradient defines the gradient to use (between 0 and 1)
  150414. * @param factor defines the drag value to affect to the specified gradient
  150415. * @returns the current particle system
  150416. */
  150417. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  150418. /**
  150419. * Remove a specific drag gradient
  150420. * @param gradient defines the gradient to remove
  150421. * @returns the current particle system
  150422. */
  150423. removeDragGradient(gradient: number): GPUParticleSystem;
  150424. /**
  150425. * Not supported by GPUParticleSystem
  150426. * @param gradient defines the gradient to use (between 0 and 1)
  150427. * @param factor defines the emit rate value to affect to the specified gradient
  150428. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150429. * @returns the current particle system
  150430. */
  150431. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150432. /**
  150433. * Not supported by GPUParticleSystem
  150434. * @param gradient defines the gradient to remove
  150435. * @returns the current particle system
  150436. */
  150437. removeEmitRateGradient(gradient: number): IParticleSystem;
  150438. /**
  150439. * Not supported by GPUParticleSystem
  150440. * @param gradient defines the gradient to use (between 0 and 1)
  150441. * @param factor defines the start size value to affect to the specified gradient
  150442. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150443. * @returns the current particle system
  150444. */
  150445. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150446. /**
  150447. * Not supported by GPUParticleSystem
  150448. * @param gradient defines the gradient to remove
  150449. * @returns the current particle system
  150450. */
  150451. removeStartSizeGradient(gradient: number): IParticleSystem;
  150452. /**
  150453. * Not supported by GPUParticleSystem
  150454. * @param gradient defines the gradient to use (between 0 and 1)
  150455. * @param min defines the color remap minimal range
  150456. * @param max defines the color remap maximal range
  150457. * @returns the current particle system
  150458. */
  150459. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  150460. /**
  150461. * Not supported by GPUParticleSystem
  150462. * @param gradient defines the gradient to remove
  150463. * @returns the current particle system
  150464. */
  150465. removeColorRemapGradient(): IParticleSystem;
  150466. /**
  150467. * Not supported by GPUParticleSystem
  150468. * @param gradient defines the gradient to use (between 0 and 1)
  150469. * @param min defines the alpha remap minimal range
  150470. * @param max defines the alpha remap maximal range
  150471. * @returns the current particle system
  150472. */
  150473. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  150474. /**
  150475. * Not supported by GPUParticleSystem
  150476. * @param gradient defines the gradient to remove
  150477. * @returns the current particle system
  150478. */
  150479. removeAlphaRemapGradient(): IParticleSystem;
  150480. /**
  150481. * Not supported by GPUParticleSystem
  150482. * @param gradient defines the gradient to use (between 0 and 1)
  150483. * @param color defines the color to affect to the specified gradient
  150484. * @returns the current particle system
  150485. */
  150486. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  150487. /**
  150488. * Not supported by GPUParticleSystem
  150489. * @param gradient defines the gradient to remove
  150490. * @returns the current particle system
  150491. */
  150492. removeRampGradient(): IParticleSystem;
  150493. /**
  150494. * Not supported by GPUParticleSystem
  150495. * @returns the list of ramp gradients
  150496. */
  150497. getRampGradients(): Nullable<Array<Color3Gradient>>;
  150498. /**
  150499. * Not supported by GPUParticleSystem
  150500. * Gets or sets a boolean indicating that ramp gradients must be used
  150501. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  150502. */
  150503. get useRampGradients(): boolean;
  150504. set useRampGradients(value: boolean);
  150505. /**
  150506. * Not supported by GPUParticleSystem
  150507. * @param gradient defines the gradient to use (between 0 and 1)
  150508. * @param factor defines the life time factor to affect to the specified gradient
  150509. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150510. * @returns the current particle system
  150511. */
  150512. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150513. /**
  150514. * Not supported by GPUParticleSystem
  150515. * @param gradient defines the gradient to remove
  150516. * @returns the current particle system
  150517. */
  150518. removeLifeTimeGradient(gradient: number): IParticleSystem;
  150519. /**
  150520. * Instantiates a GPU particle system.
  150521. * 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.
  150522. * @param name The name of the particle system
  150523. * @param options The options used to create the system
  150524. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  150525. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  150526. * @param customEffect a custom effect used to change the way particles are rendered by default
  150527. */
  150528. constructor(name: string, options: Partial<{
  150529. capacity: number;
  150530. randomTextureSize: number;
  150531. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  150532. protected _reset(): void;
  150533. private _createUpdateVAO;
  150534. private _createRenderVAO;
  150535. private _initialize;
  150536. /** @hidden */
  150537. _recreateUpdateEffect(): void;
  150538. private _getEffect;
  150539. /**
  150540. * Fill the defines array according to the current settings of the particle system
  150541. * @param defines Array to be updated
  150542. * @param blendMode blend mode to take into account when updating the array
  150543. */
  150544. fillDefines(defines: Array<string>, blendMode?: number): void;
  150545. /**
  150546. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  150547. * @param uniforms Uniforms array to fill
  150548. * @param attributes Attributes array to fill
  150549. * @param samplers Samplers array to fill
  150550. */
  150551. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  150552. /** @hidden */
  150553. _recreateRenderEffect(): Effect;
  150554. /**
  150555. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  150556. * @param preWarm defines if we are in the pre-warmimg phase
  150557. */
  150558. animate(preWarm?: boolean): void;
  150559. private _createFactorGradientTexture;
  150560. private _createSizeGradientTexture;
  150561. private _createAngularSpeedGradientTexture;
  150562. private _createVelocityGradientTexture;
  150563. private _createLimitVelocityGradientTexture;
  150564. private _createDragGradientTexture;
  150565. private _createColorGradientTexture;
  150566. /**
  150567. * Renders the particle system in its current state
  150568. * @param preWarm defines if the system should only update the particles but not render them
  150569. * @returns the current number of particles
  150570. */
  150571. render(preWarm?: boolean): number;
  150572. /**
  150573. * Rebuilds the particle system
  150574. */
  150575. rebuild(): void;
  150576. private _releaseBuffers;
  150577. private _releaseVAOs;
  150578. /**
  150579. * Disposes the particle system and free the associated resources
  150580. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  150581. */
  150582. dispose(disposeTexture?: boolean): void;
  150583. /**
  150584. * Clones the particle system.
  150585. * @param name The name of the cloned object
  150586. * @param newEmitter The new emitter to use
  150587. * @returns the cloned particle system
  150588. */
  150589. clone(name: string, newEmitter: any): GPUParticleSystem;
  150590. /**
  150591. * Serializes the particle system to a JSON object
  150592. * @param serializeTexture defines if the texture must be serialized as well
  150593. * @returns the JSON object
  150594. */
  150595. serialize(serializeTexture?: boolean): any;
  150596. /**
  150597. * Parses a JSON object to create a GPU particle system.
  150598. * @param parsedParticleSystem The JSON object to parse
  150599. * @param sceneOrEngine The scene or the engine to create the particle system in
  150600. * @param rootUrl The root url to use to load external dependencies like texture
  150601. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  150602. * @returns the parsed GPU particle system
  150603. */
  150604. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  150605. }
  150606. }
  150607. declare module BABYLON {
  150608. /**
  150609. * Represents a set of particle systems working together to create a specific effect
  150610. */
  150611. export class ParticleSystemSet implements IDisposable {
  150612. /**
  150613. * Gets or sets base Assets URL
  150614. */
  150615. static BaseAssetsUrl: string;
  150616. private _emitterCreationOptions;
  150617. private _emitterNode;
  150618. /**
  150619. * Gets the particle system list
  150620. */
  150621. systems: IParticleSystem[];
  150622. /**
  150623. * Gets the emitter node used with this set
  150624. */
  150625. get emitterNode(): Nullable<TransformNode>;
  150626. /**
  150627. * Creates a new emitter mesh as a sphere
  150628. * @param options defines the options used to create the sphere
  150629. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  150630. * @param scene defines the hosting scene
  150631. */
  150632. setEmitterAsSphere(options: {
  150633. diameter: number;
  150634. segments: number;
  150635. color: Color3;
  150636. }, renderingGroupId: number, scene: Scene): void;
  150637. /**
  150638. * Starts all particle systems of the set
  150639. * @param emitter defines an optional mesh to use as emitter for the particle systems
  150640. */
  150641. start(emitter?: AbstractMesh): void;
  150642. /**
  150643. * Release all associated resources
  150644. */
  150645. dispose(): void;
  150646. /**
  150647. * Serialize the set into a JSON compatible object
  150648. * @param serializeTexture defines if the texture must be serialized as well
  150649. * @returns a JSON compatible representation of the set
  150650. */
  150651. serialize(serializeTexture?: boolean): any;
  150652. /**
  150653. * Parse a new ParticleSystemSet from a serialized source
  150654. * @param data defines a JSON compatible representation of the set
  150655. * @param scene defines the hosting scene
  150656. * @param gpu defines if we want GPU particles or CPU particles
  150657. * @returns a new ParticleSystemSet
  150658. */
  150659. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  150660. }
  150661. }
  150662. declare module BABYLON {
  150663. /**
  150664. * This class is made for on one-liner static method to help creating particle system set.
  150665. */
  150666. export class ParticleHelper {
  150667. /**
  150668. * Gets or sets base Assets URL
  150669. */
  150670. static BaseAssetsUrl: string;
  150671. /** Define the Url to load snippets */
  150672. static SnippetUrl: string;
  150673. /**
  150674. * Create a default particle system that you can tweak
  150675. * @param emitter defines the emitter to use
  150676. * @param capacity defines the system capacity (default is 500 particles)
  150677. * @param scene defines the hosting scene
  150678. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  150679. * @returns the new Particle system
  150680. */
  150681. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  150682. /**
  150683. * This is the main static method (one-liner) of this helper to create different particle systems
  150684. * @param type This string represents the type to the particle system to create
  150685. * @param scene The scene where the particle system should live
  150686. * @param gpu If the system will use gpu
  150687. * @returns the ParticleSystemSet created
  150688. */
  150689. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  150690. /**
  150691. * Static function used to export a particle system to a ParticleSystemSet variable.
  150692. * Please note that the emitter shape is not exported
  150693. * @param systems defines the particle systems to export
  150694. * @returns the created particle system set
  150695. */
  150696. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  150697. /**
  150698. * Creates a particle system from a snippet saved in a remote file
  150699. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  150700. * @param url defines the url to load from
  150701. * @param scene defines the hosting scene
  150702. * @param gpu If the system will use gpu
  150703. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  150704. * @returns a promise that will resolve to the new particle system
  150705. */
  150706. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  150707. /**
  150708. * Creates a particle system from a snippet saved by the particle system editor
  150709. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  150710. * @param scene defines the hosting scene
  150711. * @param gpu If the system will use gpu
  150712. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  150713. * @returns a promise that will resolve to the new particle system
  150714. */
  150715. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  150716. }
  150717. }
  150718. declare module BABYLON {
  150719. interface Engine {
  150720. /**
  150721. * Create an effect to use with particle systems.
  150722. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  150723. * the particle system for which you want to create a custom effect in the last parameter
  150724. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  150725. * @param uniformsNames defines a list of attribute names
  150726. * @param samplers defines an array of string used to represent textures
  150727. * @param defines defines the string containing the defines to use to compile the shaders
  150728. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  150729. * @param onCompiled defines a function to call when the effect creation is successful
  150730. * @param onError defines a function to call when the effect creation has failed
  150731. * @param particleSystem the particle system you want to create the effect for
  150732. * @returns the new Effect
  150733. */
  150734. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  150735. }
  150736. interface Mesh {
  150737. /**
  150738. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  150739. * @returns an array of IParticleSystem
  150740. */
  150741. getEmittedParticleSystems(): IParticleSystem[];
  150742. /**
  150743. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  150744. * @returns an array of IParticleSystem
  150745. */
  150746. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  150747. }
  150748. }
  150749. declare module BABYLON {
  150750. /** Defines the 4 color options */
  150751. export enum PointColor {
  150752. /** color value */
  150753. Color = 2,
  150754. /** uv value */
  150755. UV = 1,
  150756. /** random value */
  150757. Random = 0,
  150758. /** stated value */
  150759. Stated = 3
  150760. }
  150761. /**
  150762. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  150763. * 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.
  150764. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  150765. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  150766. *
  150767. * Full documentation here : TO BE ENTERED
  150768. */
  150769. export class PointsCloudSystem implements IDisposable {
  150770. /**
  150771. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  150772. * Example : var p = SPS.particles[i];
  150773. */
  150774. particles: CloudPoint[];
  150775. /**
  150776. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  150777. */
  150778. nbParticles: number;
  150779. /**
  150780. * This a counter for your own usage. It's not set by any SPS functions.
  150781. */
  150782. counter: number;
  150783. /**
  150784. * The PCS name. This name is also given to the underlying mesh.
  150785. */
  150786. name: string;
  150787. /**
  150788. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  150789. */
  150790. mesh: Mesh;
  150791. /**
  150792. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  150793. * Please read :
  150794. */
  150795. vars: any;
  150796. /**
  150797. * @hidden
  150798. */
  150799. _size: number;
  150800. private _scene;
  150801. private _promises;
  150802. private _positions;
  150803. private _indices;
  150804. private _normals;
  150805. private _colors;
  150806. private _uvs;
  150807. private _indices32;
  150808. private _positions32;
  150809. private _colors32;
  150810. private _uvs32;
  150811. private _updatable;
  150812. private _isVisibilityBoxLocked;
  150813. private _alwaysVisible;
  150814. private _groups;
  150815. private _groupCounter;
  150816. private _computeParticleColor;
  150817. private _computeParticleTexture;
  150818. private _computeParticleRotation;
  150819. private _computeBoundingBox;
  150820. private _isReady;
  150821. /**
  150822. * Creates a PCS (Points Cloud System) object
  150823. * @param name (String) is the PCS name, this will be the underlying mesh name
  150824. * @param pointSize (number) is the size for each point
  150825. * @param scene (Scene) is the scene in which the PCS is added
  150826. * @param options defines the options of the PCS e.g.
  150827. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  150828. */
  150829. constructor(name: string, pointSize: number, scene: Scene, options?: {
  150830. updatable?: boolean;
  150831. });
  150832. /**
  150833. * Builds the PCS underlying mesh. Returns a standard Mesh.
  150834. * If no points were added to the PCS, the returned mesh is just a single point.
  150835. * @returns a promise for the created mesh
  150836. */
  150837. buildMeshAsync(): Promise<Mesh>;
  150838. /**
  150839. * @hidden
  150840. */
  150841. private _buildMesh;
  150842. private _addParticle;
  150843. private _randomUnitVector;
  150844. private _getColorIndicesForCoord;
  150845. private _setPointsColorOrUV;
  150846. private _colorFromTexture;
  150847. private _calculateDensity;
  150848. /**
  150849. * Adds points to the PCS in random positions within a unit sphere
  150850. * @param nb (positive integer) the number of particles to be created from this model
  150851. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  150852. * @returns the number of groups in the system
  150853. */
  150854. addPoints(nb: number, pointFunction?: any): number;
  150855. /**
  150856. * Adds points to the PCS from the surface of the model shape
  150857. * @param mesh is any Mesh object that will be used as a surface model for the points
  150858. * @param nb (positive integer) the number of particles to be created from this model
  150859. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  150860. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  150861. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  150862. * @returns the number of groups in the system
  150863. */
  150864. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  150865. /**
  150866. * Adds points to the PCS inside the model shape
  150867. * @param mesh is any Mesh object that will be used as a surface model for the points
  150868. * @param nb (positive integer) the number of particles to be created from this model
  150869. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  150870. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  150871. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  150872. * @returns the number of groups in the system
  150873. */
  150874. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  150875. /**
  150876. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  150877. * This method calls `updateParticle()` for each particle of the SPS.
  150878. * For an animated SPS, it is usually called within the render loop.
  150879. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  150880. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  150881. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  150882. * @returns the PCS.
  150883. */
  150884. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  150885. /**
  150886. * Disposes the PCS.
  150887. */
  150888. dispose(): void;
  150889. /**
  150890. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  150891. * doc :
  150892. * @returns the PCS.
  150893. */
  150894. refreshVisibleSize(): PointsCloudSystem;
  150895. /**
  150896. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  150897. * @param size the size (float) of the visibility box
  150898. * note : this doesn't lock the PCS mesh bounding box.
  150899. * doc :
  150900. */
  150901. setVisibilityBox(size: number): void;
  150902. /**
  150903. * Gets whether the PCS is always visible or not
  150904. * doc :
  150905. */
  150906. get isAlwaysVisible(): boolean;
  150907. /**
  150908. * Sets the PCS as always visible or not
  150909. * doc :
  150910. */
  150911. set isAlwaysVisible(val: boolean);
  150912. /**
  150913. * Tells to `setParticles()` to compute the particle rotations or not
  150914. * Default value : false. The PCS is faster when it's set to false
  150915. * Note : particle rotations are only applied to parent particles
  150916. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  150917. */
  150918. set computeParticleRotation(val: boolean);
  150919. /**
  150920. * Tells to `setParticles()` to compute the particle colors or not.
  150921. * Default value : true. The PCS is faster when it's set to false.
  150922. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  150923. */
  150924. set computeParticleColor(val: boolean);
  150925. set computeParticleTexture(val: boolean);
  150926. /**
  150927. * Gets if `setParticles()` computes the particle colors or not.
  150928. * Default value : false. The PCS is faster when it's set to false.
  150929. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  150930. */
  150931. get computeParticleColor(): boolean;
  150932. /**
  150933. * Gets if `setParticles()` computes the particle textures or not.
  150934. * Default value : false. The PCS is faster when it's set to false.
  150935. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  150936. */
  150937. get computeParticleTexture(): boolean;
  150938. /**
  150939. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  150940. */
  150941. set computeBoundingBox(val: boolean);
  150942. /**
  150943. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  150944. */
  150945. get computeBoundingBox(): boolean;
  150946. /**
  150947. * This function does nothing. It may be overwritten to set all the particle first values.
  150948. * The PCS doesn't call this function, you may have to call it by your own.
  150949. * doc :
  150950. */
  150951. initParticles(): void;
  150952. /**
  150953. * This function does nothing. It may be overwritten to recycle a particle
  150954. * The PCS doesn't call this function, you can to call it
  150955. * doc :
  150956. * @param particle The particle to recycle
  150957. * @returns the recycled particle
  150958. */
  150959. recycleParticle(particle: CloudPoint): CloudPoint;
  150960. /**
  150961. * Updates a particle : this function should be overwritten by the user.
  150962. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  150963. * doc :
  150964. * @example : just set a particle position or velocity and recycle conditions
  150965. * @param particle The particle to update
  150966. * @returns the updated particle
  150967. */
  150968. updateParticle(particle: CloudPoint): CloudPoint;
  150969. /**
  150970. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  150971. * This does nothing and may be overwritten by the user.
  150972. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  150973. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  150974. * @param update the boolean update value actually passed to setParticles()
  150975. */
  150976. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  150977. /**
  150978. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  150979. * This will be passed three parameters.
  150980. * This does nothing and may be overwritten by the user.
  150981. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  150982. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  150983. * @param update the boolean update value actually passed to setParticles()
  150984. */
  150985. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  150986. }
  150987. }
  150988. declare module BABYLON {
  150989. /**
  150990. * Represents one particle of a points cloud system.
  150991. */
  150992. export class CloudPoint {
  150993. /**
  150994. * particle global index
  150995. */
  150996. idx: number;
  150997. /**
  150998. * The color of the particle
  150999. */
  151000. color: Nullable<Color4>;
  151001. /**
  151002. * The world space position of the particle.
  151003. */
  151004. position: Vector3;
  151005. /**
  151006. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  151007. */
  151008. rotation: Vector3;
  151009. /**
  151010. * The world space rotation quaternion of the particle.
  151011. */
  151012. rotationQuaternion: Nullable<Quaternion>;
  151013. /**
  151014. * The uv of the particle.
  151015. */
  151016. uv: Nullable<Vector2>;
  151017. /**
  151018. * The current speed of the particle.
  151019. */
  151020. velocity: Vector3;
  151021. /**
  151022. * The pivot point in the particle local space.
  151023. */
  151024. pivot: Vector3;
  151025. /**
  151026. * Must the particle be translated from its pivot point in its local space ?
  151027. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  151028. * Default : false
  151029. */
  151030. translateFromPivot: boolean;
  151031. /**
  151032. * Index of this particle in the global "positions" array (Internal use)
  151033. * @hidden
  151034. */
  151035. _pos: number;
  151036. /**
  151037. * @hidden Index of this particle in the global "indices" array (Internal use)
  151038. */
  151039. _ind: number;
  151040. /**
  151041. * Group this particle belongs to
  151042. */
  151043. _group: PointsGroup;
  151044. /**
  151045. * Group id of this particle
  151046. */
  151047. groupId: number;
  151048. /**
  151049. * Index of the particle in its group id (Internal use)
  151050. */
  151051. idxInGroup: number;
  151052. /**
  151053. * @hidden Particle BoundingInfo object (Internal use)
  151054. */
  151055. _boundingInfo: BoundingInfo;
  151056. /**
  151057. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  151058. */
  151059. _pcs: PointsCloudSystem;
  151060. /**
  151061. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  151062. */
  151063. _stillInvisible: boolean;
  151064. /**
  151065. * @hidden Last computed particle rotation matrix
  151066. */
  151067. _rotationMatrix: number[];
  151068. /**
  151069. * Parent particle Id, if any.
  151070. * Default null.
  151071. */
  151072. parentId: Nullable<number>;
  151073. /**
  151074. * @hidden Internal global position in the PCS.
  151075. */
  151076. _globalPosition: Vector3;
  151077. /**
  151078. * Creates a Point Cloud object.
  151079. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  151080. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  151081. * @param group (PointsGroup) is the group the particle belongs to
  151082. * @param groupId (integer) is the group identifier in the PCS.
  151083. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  151084. * @param pcs defines the PCS it is associated to
  151085. */
  151086. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  151087. /**
  151088. * get point size
  151089. */
  151090. get size(): Vector3;
  151091. /**
  151092. * Set point size
  151093. */
  151094. set size(scale: Vector3);
  151095. /**
  151096. * Legacy support, changed quaternion to rotationQuaternion
  151097. */
  151098. get quaternion(): Nullable<Quaternion>;
  151099. /**
  151100. * Legacy support, changed quaternion to rotationQuaternion
  151101. */
  151102. set quaternion(q: Nullable<Quaternion>);
  151103. /**
  151104. * Returns a boolean. True if the particle intersects a mesh, else false
  151105. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  151106. * @param target is the object (point or mesh) what the intersection is computed against
  151107. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  151108. * @returns true if it intersects
  151109. */
  151110. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  151111. /**
  151112. * get the rotation matrix of the particle
  151113. * @hidden
  151114. */
  151115. getRotationMatrix(m: Matrix): void;
  151116. }
  151117. /**
  151118. * Represents a group of points in a points cloud system
  151119. * * PCS internal tool, don't use it manually.
  151120. */
  151121. export class PointsGroup {
  151122. /**
  151123. * The group id
  151124. * @hidden
  151125. */
  151126. groupID: number;
  151127. /**
  151128. * image data for group (internal use)
  151129. * @hidden
  151130. */
  151131. _groupImageData: Nullable<ArrayBufferView>;
  151132. /**
  151133. * Image Width (internal use)
  151134. * @hidden
  151135. */
  151136. _groupImgWidth: number;
  151137. /**
  151138. * Image Height (internal use)
  151139. * @hidden
  151140. */
  151141. _groupImgHeight: number;
  151142. /**
  151143. * Custom position function (internal use)
  151144. * @hidden
  151145. */
  151146. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  151147. /**
  151148. * density per facet for surface points
  151149. * @hidden
  151150. */
  151151. _groupDensity: number[];
  151152. /**
  151153. * Only when points are colored by texture carries pointer to texture list array
  151154. * @hidden
  151155. */
  151156. _textureNb: number;
  151157. /**
  151158. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  151159. * PCS internal tool, don't use it manually.
  151160. * @hidden
  151161. */
  151162. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  151163. }
  151164. }
  151165. declare module BABYLON {
  151166. interface Scene {
  151167. /** @hidden (Backing field) */
  151168. _physicsEngine: Nullable<IPhysicsEngine>;
  151169. /** @hidden */
  151170. _physicsTimeAccumulator: number;
  151171. /**
  151172. * Gets the current physics engine
  151173. * @returns a IPhysicsEngine or null if none attached
  151174. */
  151175. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  151176. /**
  151177. * Enables physics to the current scene
  151178. * @param gravity defines the scene's gravity for the physics engine
  151179. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  151180. * @return a boolean indicating if the physics engine was initialized
  151181. */
  151182. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  151183. /**
  151184. * Disables and disposes the physics engine associated with the scene
  151185. */
  151186. disablePhysicsEngine(): void;
  151187. /**
  151188. * Gets a boolean indicating if there is an active physics engine
  151189. * @returns a boolean indicating if there is an active physics engine
  151190. */
  151191. isPhysicsEnabled(): boolean;
  151192. /**
  151193. * Deletes a physics compound impostor
  151194. * @param compound defines the compound to delete
  151195. */
  151196. deleteCompoundImpostor(compound: any): void;
  151197. /**
  151198. * An event triggered when physic simulation is about to be run
  151199. */
  151200. onBeforePhysicsObservable: Observable<Scene>;
  151201. /**
  151202. * An event triggered when physic simulation has been done
  151203. */
  151204. onAfterPhysicsObservable: Observable<Scene>;
  151205. }
  151206. interface AbstractMesh {
  151207. /** @hidden */
  151208. _physicsImpostor: Nullable<PhysicsImpostor>;
  151209. /**
  151210. * Gets or sets impostor used for physic simulation
  151211. * @see https://doc.babylonjs.com/features/physics_engine
  151212. */
  151213. physicsImpostor: Nullable<PhysicsImpostor>;
  151214. /**
  151215. * Gets the current physics impostor
  151216. * @see https://doc.babylonjs.com/features/physics_engine
  151217. * @returns a physics impostor or null
  151218. */
  151219. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  151220. /** Apply a physic impulse to the mesh
  151221. * @param force defines the force to apply
  151222. * @param contactPoint defines where to apply the force
  151223. * @returns the current mesh
  151224. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  151225. */
  151226. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  151227. /**
  151228. * Creates a physic joint between two meshes
  151229. * @param otherMesh defines the other mesh to use
  151230. * @param pivot1 defines the pivot to use on this mesh
  151231. * @param pivot2 defines the pivot to use on the other mesh
  151232. * @param options defines additional options (can be plugin dependent)
  151233. * @returns the current mesh
  151234. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  151235. */
  151236. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  151237. /** @hidden */
  151238. _disposePhysicsObserver: Nullable<Observer<Node>>;
  151239. }
  151240. /**
  151241. * Defines the physics engine scene component responsible to manage a physics engine
  151242. */
  151243. export class PhysicsEngineSceneComponent implements ISceneComponent {
  151244. /**
  151245. * The component name helpful to identify the component in the list of scene components.
  151246. */
  151247. readonly name: string;
  151248. /**
  151249. * The scene the component belongs to.
  151250. */
  151251. scene: Scene;
  151252. /**
  151253. * Creates a new instance of the component for the given scene
  151254. * @param scene Defines the scene to register the component in
  151255. */
  151256. constructor(scene: Scene);
  151257. /**
  151258. * Registers the component in a given scene
  151259. */
  151260. register(): void;
  151261. /**
  151262. * Rebuilds the elements related to this component in case of
  151263. * context lost for instance.
  151264. */
  151265. rebuild(): void;
  151266. /**
  151267. * Disposes the component and the associated ressources
  151268. */
  151269. dispose(): void;
  151270. }
  151271. }
  151272. declare module BABYLON {
  151273. /**
  151274. * A helper for physics simulations
  151275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151276. */
  151277. export class PhysicsHelper {
  151278. private _scene;
  151279. private _physicsEngine;
  151280. /**
  151281. * Initializes the Physics helper
  151282. * @param scene Babylon.js scene
  151283. */
  151284. constructor(scene: Scene);
  151285. /**
  151286. * Applies a radial explosion impulse
  151287. * @param origin the origin of the explosion
  151288. * @param radiusOrEventOptions the radius or the options of radial explosion
  151289. * @param strength the explosion strength
  151290. * @param falloff possible options: Constant & Linear. Defaults to Constant
  151291. * @returns A physics radial explosion event, or null
  151292. */
  151293. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  151294. /**
  151295. * Applies a radial explosion force
  151296. * @param origin the origin of the explosion
  151297. * @param radiusOrEventOptions the radius or the options of radial explosion
  151298. * @param strength the explosion strength
  151299. * @param falloff possible options: Constant & Linear. Defaults to Constant
  151300. * @returns A physics radial explosion event, or null
  151301. */
  151302. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  151303. /**
  151304. * Creates a gravitational field
  151305. * @param origin the origin of the explosion
  151306. * @param radiusOrEventOptions the radius or the options of radial explosion
  151307. * @param strength the explosion strength
  151308. * @param falloff possible options: Constant & Linear. Defaults to Constant
  151309. * @returns A physics gravitational field event, or null
  151310. */
  151311. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  151312. /**
  151313. * Creates a physics updraft event
  151314. * @param origin the origin of the updraft
  151315. * @param radiusOrEventOptions the radius or the options of the updraft
  151316. * @param strength the strength of the updraft
  151317. * @param height the height of the updraft
  151318. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  151319. * @returns A physics updraft event, or null
  151320. */
  151321. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  151322. /**
  151323. * Creates a physics vortex event
  151324. * @param origin the of the vortex
  151325. * @param radiusOrEventOptions the radius or the options of the vortex
  151326. * @param strength the strength of the vortex
  151327. * @param height the height of the vortex
  151328. * @returns a Physics vortex event, or null
  151329. * A physics vortex event or null
  151330. */
  151331. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  151332. }
  151333. /**
  151334. * Represents a physics radial explosion event
  151335. */
  151336. class PhysicsRadialExplosionEvent {
  151337. private _scene;
  151338. private _options;
  151339. private _sphere;
  151340. private _dataFetched;
  151341. /**
  151342. * Initializes a radial explosioin event
  151343. * @param _scene BabylonJS scene
  151344. * @param _options The options for the vortex event
  151345. */
  151346. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  151347. /**
  151348. * Returns the data related to the radial explosion event (sphere).
  151349. * @returns The radial explosion event data
  151350. */
  151351. getData(): PhysicsRadialExplosionEventData;
  151352. /**
  151353. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  151354. * @param impostor A physics imposter
  151355. * @param origin the origin of the explosion
  151356. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  151357. */
  151358. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  151359. /**
  151360. * Triggers affecterd impostors callbacks
  151361. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  151362. */
  151363. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  151364. /**
  151365. * Disposes the sphere.
  151366. * @param force Specifies if the sphere should be disposed by force
  151367. */
  151368. dispose(force?: boolean): void;
  151369. /*** Helpers ***/
  151370. private _prepareSphere;
  151371. private _intersectsWithSphere;
  151372. }
  151373. /**
  151374. * Represents a gravitational field event
  151375. */
  151376. class PhysicsGravitationalFieldEvent {
  151377. private _physicsHelper;
  151378. private _scene;
  151379. private _origin;
  151380. private _options;
  151381. private _tickCallback;
  151382. private _sphere;
  151383. private _dataFetched;
  151384. /**
  151385. * Initializes the physics gravitational field event
  151386. * @param _physicsHelper A physics helper
  151387. * @param _scene BabylonJS scene
  151388. * @param _origin The origin position of the gravitational field event
  151389. * @param _options The options for the vortex event
  151390. */
  151391. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  151392. /**
  151393. * Returns the data related to the gravitational field event (sphere).
  151394. * @returns A gravitational field event
  151395. */
  151396. getData(): PhysicsGravitationalFieldEventData;
  151397. /**
  151398. * Enables the gravitational field.
  151399. */
  151400. enable(): void;
  151401. /**
  151402. * Disables the gravitational field.
  151403. */
  151404. disable(): void;
  151405. /**
  151406. * Disposes the sphere.
  151407. * @param force The force to dispose from the gravitational field event
  151408. */
  151409. dispose(force?: boolean): void;
  151410. private _tick;
  151411. }
  151412. /**
  151413. * Represents a physics updraft event
  151414. */
  151415. class PhysicsUpdraftEvent {
  151416. private _scene;
  151417. private _origin;
  151418. private _options;
  151419. private _physicsEngine;
  151420. private _originTop;
  151421. private _originDirection;
  151422. private _tickCallback;
  151423. private _cylinder;
  151424. private _cylinderPosition;
  151425. private _dataFetched;
  151426. /**
  151427. * Initializes the physics updraft event
  151428. * @param _scene BabylonJS scene
  151429. * @param _origin The origin position of the updraft
  151430. * @param _options The options for the updraft event
  151431. */
  151432. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  151433. /**
  151434. * Returns the data related to the updraft event (cylinder).
  151435. * @returns A physics updraft event
  151436. */
  151437. getData(): PhysicsUpdraftEventData;
  151438. /**
  151439. * Enables the updraft.
  151440. */
  151441. enable(): void;
  151442. /**
  151443. * Disables the updraft.
  151444. */
  151445. disable(): void;
  151446. /**
  151447. * Disposes the cylinder.
  151448. * @param force Specifies if the updraft should be disposed by force
  151449. */
  151450. dispose(force?: boolean): void;
  151451. private getImpostorHitData;
  151452. private _tick;
  151453. /*** Helpers ***/
  151454. private _prepareCylinder;
  151455. private _intersectsWithCylinder;
  151456. }
  151457. /**
  151458. * Represents a physics vortex event
  151459. */
  151460. class PhysicsVortexEvent {
  151461. private _scene;
  151462. private _origin;
  151463. private _options;
  151464. private _physicsEngine;
  151465. private _originTop;
  151466. private _tickCallback;
  151467. private _cylinder;
  151468. private _cylinderPosition;
  151469. private _dataFetched;
  151470. /**
  151471. * Initializes the physics vortex event
  151472. * @param _scene The BabylonJS scene
  151473. * @param _origin The origin position of the vortex
  151474. * @param _options The options for the vortex event
  151475. */
  151476. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  151477. /**
  151478. * Returns the data related to the vortex event (cylinder).
  151479. * @returns The physics vortex event data
  151480. */
  151481. getData(): PhysicsVortexEventData;
  151482. /**
  151483. * Enables the vortex.
  151484. */
  151485. enable(): void;
  151486. /**
  151487. * Disables the cortex.
  151488. */
  151489. disable(): void;
  151490. /**
  151491. * Disposes the sphere.
  151492. * @param force
  151493. */
  151494. dispose(force?: boolean): void;
  151495. private getImpostorHitData;
  151496. private _tick;
  151497. /*** Helpers ***/
  151498. private _prepareCylinder;
  151499. private _intersectsWithCylinder;
  151500. }
  151501. /**
  151502. * Options fot the radial explosion event
  151503. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151504. */
  151505. export class PhysicsRadialExplosionEventOptions {
  151506. /**
  151507. * The radius of the sphere for the radial explosion.
  151508. */
  151509. radius: number;
  151510. /**
  151511. * The strenth of the explosion.
  151512. */
  151513. strength: number;
  151514. /**
  151515. * The strenght of the force in correspondence to the distance of the affected object
  151516. */
  151517. falloff: PhysicsRadialImpulseFalloff;
  151518. /**
  151519. * Sphere options for the radial explosion.
  151520. */
  151521. sphere: {
  151522. segments: number;
  151523. diameter: number;
  151524. };
  151525. /**
  151526. * Sphere options for the radial explosion.
  151527. */
  151528. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  151529. }
  151530. /**
  151531. * Options fot the updraft event
  151532. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151533. */
  151534. export class PhysicsUpdraftEventOptions {
  151535. /**
  151536. * The radius of the cylinder for the vortex
  151537. */
  151538. radius: number;
  151539. /**
  151540. * The strenth of the updraft.
  151541. */
  151542. strength: number;
  151543. /**
  151544. * The height of the cylinder for the updraft.
  151545. */
  151546. height: number;
  151547. /**
  151548. * The mode for the the updraft.
  151549. */
  151550. updraftMode: PhysicsUpdraftMode;
  151551. }
  151552. /**
  151553. * Options fot the vortex event
  151554. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151555. */
  151556. export class PhysicsVortexEventOptions {
  151557. /**
  151558. * The radius of the cylinder for the vortex
  151559. */
  151560. radius: number;
  151561. /**
  151562. * The strenth of the vortex.
  151563. */
  151564. strength: number;
  151565. /**
  151566. * The height of the cylinder for the vortex.
  151567. */
  151568. height: number;
  151569. /**
  151570. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  151571. */
  151572. centripetalForceThreshold: number;
  151573. /**
  151574. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  151575. */
  151576. centripetalForceMultiplier: number;
  151577. /**
  151578. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  151579. */
  151580. centrifugalForceMultiplier: number;
  151581. /**
  151582. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  151583. */
  151584. updraftForceMultiplier: number;
  151585. }
  151586. /**
  151587. * The strenght of the force in correspondence to the distance of the affected object
  151588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151589. */
  151590. export enum PhysicsRadialImpulseFalloff {
  151591. /** Defines that impulse is constant in strength across it's whole radius */
  151592. Constant = 0,
  151593. /** Defines that impulse gets weaker if it's further from the origin */
  151594. Linear = 1
  151595. }
  151596. /**
  151597. * The strength of the force in correspondence to the distance of the affected object
  151598. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151599. */
  151600. export enum PhysicsUpdraftMode {
  151601. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  151602. Center = 0,
  151603. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  151604. Perpendicular = 1
  151605. }
  151606. /**
  151607. * Interface for a physics hit data
  151608. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151609. */
  151610. export interface PhysicsHitData {
  151611. /**
  151612. * The force applied at the contact point
  151613. */
  151614. force: Vector3;
  151615. /**
  151616. * The contact point
  151617. */
  151618. contactPoint: Vector3;
  151619. /**
  151620. * The distance from the origin to the contact point
  151621. */
  151622. distanceFromOrigin: number;
  151623. }
  151624. /**
  151625. * Interface for radial explosion event data
  151626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151627. */
  151628. export interface PhysicsRadialExplosionEventData {
  151629. /**
  151630. * A sphere used for the radial explosion event
  151631. */
  151632. sphere: Mesh;
  151633. }
  151634. /**
  151635. * Interface for gravitational field event data
  151636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151637. */
  151638. export interface PhysicsGravitationalFieldEventData {
  151639. /**
  151640. * A sphere mesh used for the gravitational field event
  151641. */
  151642. sphere: Mesh;
  151643. }
  151644. /**
  151645. * Interface for updraft event data
  151646. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151647. */
  151648. export interface PhysicsUpdraftEventData {
  151649. /**
  151650. * A cylinder used for the updraft event
  151651. */
  151652. cylinder: Mesh;
  151653. }
  151654. /**
  151655. * Interface for vortex event data
  151656. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151657. */
  151658. export interface PhysicsVortexEventData {
  151659. /**
  151660. * A cylinder used for the vortex event
  151661. */
  151662. cylinder: Mesh;
  151663. }
  151664. /**
  151665. * Interface for an affected physics impostor
  151666. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151667. */
  151668. export interface PhysicsAffectedImpostorWithData {
  151669. /**
  151670. * The impostor affected by the effect
  151671. */
  151672. impostor: PhysicsImpostor;
  151673. /**
  151674. * The data about the hit/horce from the explosion
  151675. */
  151676. hitData: PhysicsHitData;
  151677. }
  151678. }
  151679. declare module BABYLON {
  151680. /** @hidden */
  151681. export var blackAndWhitePixelShader: {
  151682. name: string;
  151683. shader: string;
  151684. };
  151685. }
  151686. declare module BABYLON {
  151687. /**
  151688. * Post process used to render in black and white
  151689. */
  151690. export class BlackAndWhitePostProcess extends PostProcess {
  151691. /**
  151692. * Linear about to convert he result to black and white (default: 1)
  151693. */
  151694. degree: number;
  151695. /**
  151696. * Gets a string identifying the name of the class
  151697. * @returns "BlackAndWhitePostProcess" string
  151698. */
  151699. getClassName(): string;
  151700. /**
  151701. * Creates a black and white post process
  151702. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  151703. * @param name The name of the effect.
  151704. * @param options The required width/height ratio to downsize to before computing the render pass.
  151705. * @param camera The camera to apply the render pass to.
  151706. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151707. * @param engine The engine which the post process will be applied. (default: current engine)
  151708. * @param reusable If the post process can be reused on the same frame. (default: false)
  151709. */
  151710. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151711. /** @hidden */
  151712. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  151713. }
  151714. }
  151715. declare module BABYLON {
  151716. /**
  151717. * This represents a set of one or more post processes in Babylon.
  151718. * A post process can be used to apply a shader to a texture after it is rendered.
  151719. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151720. */
  151721. export class PostProcessRenderEffect {
  151722. private _postProcesses;
  151723. private _getPostProcesses;
  151724. private _singleInstance;
  151725. private _cameras;
  151726. private _indicesForCamera;
  151727. /**
  151728. * Name of the effect
  151729. * @hidden
  151730. */
  151731. _name: string;
  151732. /**
  151733. * Instantiates a post process render effect.
  151734. * A post process can be used to apply a shader to a texture after it is rendered.
  151735. * @param engine The engine the effect is tied to
  151736. * @param name The name of the effect
  151737. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  151738. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  151739. */
  151740. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  151741. /**
  151742. * Checks if all the post processes in the effect are supported.
  151743. */
  151744. get isSupported(): boolean;
  151745. /**
  151746. * Updates the current state of the effect
  151747. * @hidden
  151748. */
  151749. _update(): void;
  151750. /**
  151751. * Attaches the effect on cameras
  151752. * @param cameras The camera to attach to.
  151753. * @hidden
  151754. */
  151755. _attachCameras(cameras: Camera): void;
  151756. /**
  151757. * Attaches the effect on cameras
  151758. * @param cameras The camera to attach to.
  151759. * @hidden
  151760. */
  151761. _attachCameras(cameras: Camera[]): void;
  151762. /**
  151763. * Detaches the effect on cameras
  151764. * @param cameras The camera to detatch from.
  151765. * @hidden
  151766. */
  151767. _detachCameras(cameras: Camera): void;
  151768. /**
  151769. * Detatches the effect on cameras
  151770. * @param cameras The camera to detatch from.
  151771. * @hidden
  151772. */
  151773. _detachCameras(cameras: Camera[]): void;
  151774. /**
  151775. * Enables the effect on given cameras
  151776. * @param cameras The camera to enable.
  151777. * @hidden
  151778. */
  151779. _enable(cameras: Camera): void;
  151780. /**
  151781. * Enables the effect on given cameras
  151782. * @param cameras The camera to enable.
  151783. * @hidden
  151784. */
  151785. _enable(cameras: Nullable<Camera[]>): void;
  151786. /**
  151787. * Disables the effect on the given cameras
  151788. * @param cameras The camera to disable.
  151789. * @hidden
  151790. */
  151791. _disable(cameras: Camera): void;
  151792. /**
  151793. * Disables the effect on the given cameras
  151794. * @param cameras The camera to disable.
  151795. * @hidden
  151796. */
  151797. _disable(cameras: Nullable<Camera[]>): void;
  151798. /**
  151799. * Gets a list of the post processes contained in the effect.
  151800. * @param camera The camera to get the post processes on.
  151801. * @returns The list of the post processes in the effect.
  151802. */
  151803. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  151804. }
  151805. }
  151806. declare module BABYLON {
  151807. /** @hidden */
  151808. export var extractHighlightsPixelShader: {
  151809. name: string;
  151810. shader: string;
  151811. };
  151812. }
  151813. declare module BABYLON {
  151814. /**
  151815. * 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.
  151816. */
  151817. export class ExtractHighlightsPostProcess extends PostProcess {
  151818. /**
  151819. * The luminance threshold, pixels below this value will be set to black.
  151820. */
  151821. threshold: number;
  151822. /** @hidden */
  151823. _exposure: number;
  151824. /**
  151825. * Post process which has the input texture to be used when performing highlight extraction
  151826. * @hidden
  151827. */
  151828. _inputPostProcess: Nullable<PostProcess>;
  151829. /**
  151830. * Gets a string identifying the name of the class
  151831. * @returns "ExtractHighlightsPostProcess" string
  151832. */
  151833. getClassName(): string;
  151834. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151835. }
  151836. }
  151837. declare module BABYLON {
  151838. /** @hidden */
  151839. export var bloomMergePixelShader: {
  151840. name: string;
  151841. shader: string;
  151842. };
  151843. }
  151844. declare module BABYLON {
  151845. /**
  151846. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  151847. */
  151848. export class BloomMergePostProcess extends PostProcess {
  151849. /** Weight of the bloom to be added to the original input. */
  151850. weight: number;
  151851. /**
  151852. * Gets a string identifying the name of the class
  151853. * @returns "BloomMergePostProcess" string
  151854. */
  151855. getClassName(): string;
  151856. /**
  151857. * Creates a new instance of @see BloomMergePostProcess
  151858. * @param name The name of the effect.
  151859. * @param originalFromInput Post process which's input will be used for the merge.
  151860. * @param blurred Blurred highlights post process which's output will be used.
  151861. * @param weight Weight of the bloom to be added to the original input.
  151862. * @param options The required width/height ratio to downsize to before computing the render pass.
  151863. * @param camera The camera to apply the render pass to.
  151864. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151865. * @param engine The engine which the post process will be applied. (default: current engine)
  151866. * @param reusable If the post process can be reused on the same frame. (default: false)
  151867. * @param textureType Type of textures used when performing the post process. (default: 0)
  151868. * @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)
  151869. */
  151870. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  151871. /** Weight of the bloom to be added to the original input. */
  151872. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151873. }
  151874. }
  151875. declare module BABYLON {
  151876. /**
  151877. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  151878. */
  151879. export class BloomEffect extends PostProcessRenderEffect {
  151880. private bloomScale;
  151881. /**
  151882. * @hidden Internal
  151883. */
  151884. _effects: Array<PostProcess>;
  151885. /**
  151886. * @hidden Internal
  151887. */
  151888. _downscale: ExtractHighlightsPostProcess;
  151889. private _blurX;
  151890. private _blurY;
  151891. private _merge;
  151892. /**
  151893. * The luminance threshold to find bright areas of the image to bloom.
  151894. */
  151895. get threshold(): number;
  151896. set threshold(value: number);
  151897. /**
  151898. * The strength of the bloom.
  151899. */
  151900. get weight(): number;
  151901. set weight(value: number);
  151902. /**
  151903. * Specifies the size of the bloom blur kernel, relative to the final output size
  151904. */
  151905. get kernel(): number;
  151906. set kernel(value: number);
  151907. /**
  151908. * Creates a new instance of @see BloomEffect
  151909. * @param scene The scene the effect belongs to.
  151910. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  151911. * @param bloomKernel The size of the kernel to be used when applying the blur.
  151912. * @param bloomWeight The the strength of bloom.
  151913. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  151914. * @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)
  151915. */
  151916. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  151917. /**
  151918. * Disposes each of the internal effects for a given camera.
  151919. * @param camera The camera to dispose the effect on.
  151920. */
  151921. disposeEffects(camera: Camera): void;
  151922. /**
  151923. * @hidden Internal
  151924. */
  151925. _updateEffects(): void;
  151926. /**
  151927. * Internal
  151928. * @returns if all the contained post processes are ready.
  151929. * @hidden
  151930. */
  151931. _isReady(): boolean;
  151932. }
  151933. }
  151934. declare module BABYLON {
  151935. /** @hidden */
  151936. export var chromaticAberrationPixelShader: {
  151937. name: string;
  151938. shader: string;
  151939. };
  151940. }
  151941. declare module BABYLON {
  151942. /**
  151943. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  151944. */
  151945. export class ChromaticAberrationPostProcess extends PostProcess {
  151946. /**
  151947. * The amount of seperation of rgb channels (default: 30)
  151948. */
  151949. aberrationAmount: number;
  151950. /**
  151951. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  151952. */
  151953. radialIntensity: number;
  151954. /**
  151955. * 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))
  151956. */
  151957. direction: Vector2;
  151958. /**
  151959. * 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))
  151960. */
  151961. centerPosition: Vector2;
  151962. /** The width of the screen to apply the effect on */
  151963. screenWidth: number;
  151964. /** The height of the screen to apply the effect on */
  151965. screenHeight: number;
  151966. /**
  151967. * Gets a string identifying the name of the class
  151968. * @returns "ChromaticAberrationPostProcess" string
  151969. */
  151970. getClassName(): string;
  151971. /**
  151972. * Creates a new instance ChromaticAberrationPostProcess
  151973. * @param name The name of the effect.
  151974. * @param screenWidth The width of the screen to apply the effect on.
  151975. * @param screenHeight The height of the screen to apply the effect on.
  151976. * @param options The required width/height ratio to downsize to before computing the render pass.
  151977. * @param camera The camera to apply the render pass to.
  151978. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151979. * @param engine The engine which the post process will be applied. (default: current engine)
  151980. * @param reusable If the post process can be reused on the same frame. (default: false)
  151981. * @param textureType Type of textures used when performing the post process. (default: 0)
  151982. * @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)
  151983. */
  151984. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151985. /** @hidden */
  151986. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  151987. }
  151988. }
  151989. declare module BABYLON {
  151990. /** @hidden */
  151991. export var circleOfConfusionPixelShader: {
  151992. name: string;
  151993. shader: string;
  151994. };
  151995. }
  151996. declare module BABYLON {
  151997. /**
  151998. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  151999. */
  152000. export class CircleOfConfusionPostProcess extends PostProcess {
  152001. /**
  152002. * 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.
  152003. */
  152004. lensSize: number;
  152005. /**
  152006. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  152007. */
  152008. fStop: number;
  152009. /**
  152010. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  152011. */
  152012. focusDistance: number;
  152013. /**
  152014. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  152015. */
  152016. focalLength: number;
  152017. /**
  152018. * Gets a string identifying the name of the class
  152019. * @returns "CircleOfConfusionPostProcess" string
  152020. */
  152021. getClassName(): string;
  152022. private _depthTexture;
  152023. /**
  152024. * Creates a new instance CircleOfConfusionPostProcess
  152025. * @param name The name of the effect.
  152026. * @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.
  152027. * @param options The required width/height ratio to downsize to before computing the render pass.
  152028. * @param camera The camera to apply the render pass to.
  152029. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152030. * @param engine The engine which the post process will be applied. (default: current engine)
  152031. * @param reusable If the post process can be reused on the same frame. (default: false)
  152032. * @param textureType Type of textures used when performing the post process. (default: 0)
  152033. * @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)
  152034. */
  152035. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152036. /**
  152037. * 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.
  152038. */
  152039. set depthTexture(value: RenderTargetTexture);
  152040. }
  152041. }
  152042. declare module BABYLON {
  152043. /** @hidden */
  152044. export var colorCorrectionPixelShader: {
  152045. name: string;
  152046. shader: string;
  152047. };
  152048. }
  152049. declare module BABYLON {
  152050. /**
  152051. *
  152052. * This post-process allows the modification of rendered colors by using
  152053. * a 'look-up table' (LUT). This effect is also called Color Grading.
  152054. *
  152055. * The object needs to be provided an url to a texture containing the color
  152056. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  152057. * Use an image editing software to tweak the LUT to match your needs.
  152058. *
  152059. * For an example of a color LUT, see here:
  152060. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  152061. * For explanations on color grading, see here:
  152062. * @see http://udn.epicgames.com/Three/ColorGrading.html
  152063. *
  152064. */
  152065. export class ColorCorrectionPostProcess extends PostProcess {
  152066. private _colorTableTexture;
  152067. /**
  152068. * Gets the color table url used to create the LUT texture
  152069. */
  152070. colorTableUrl: string;
  152071. /**
  152072. * Gets a string identifying the name of the class
  152073. * @returns "ColorCorrectionPostProcess" string
  152074. */
  152075. getClassName(): string;
  152076. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152077. /** @hidden */
  152078. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  152079. }
  152080. }
  152081. declare module BABYLON {
  152082. /** @hidden */
  152083. export var convolutionPixelShader: {
  152084. name: string;
  152085. shader: string;
  152086. };
  152087. }
  152088. declare module BABYLON {
  152089. /**
  152090. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  152091. * input texture to perform effects such as edge detection or sharpening
  152092. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  152093. */
  152094. export class ConvolutionPostProcess extends PostProcess {
  152095. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  152096. kernel: number[];
  152097. /**
  152098. * Gets a string identifying the name of the class
  152099. * @returns "ConvolutionPostProcess" string
  152100. */
  152101. getClassName(): string;
  152102. /**
  152103. * Creates a new instance ConvolutionPostProcess
  152104. * @param name The name of the effect.
  152105. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  152106. * @param options The required width/height ratio to downsize to before computing the render pass.
  152107. * @param camera The camera to apply the render pass to.
  152108. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152109. * @param engine The engine which the post process will be applied. (default: current engine)
  152110. * @param reusable If the post process can be reused on the same frame. (default: false)
  152111. * @param textureType Type of textures used when performing the post process. (default: 0)
  152112. */
  152113. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152114. /** @hidden */
  152115. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  152116. /**
  152117. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152118. */
  152119. static EdgeDetect0Kernel: number[];
  152120. /**
  152121. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152122. */
  152123. static EdgeDetect1Kernel: number[];
  152124. /**
  152125. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152126. */
  152127. static EdgeDetect2Kernel: number[];
  152128. /**
  152129. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152130. */
  152131. static SharpenKernel: number[];
  152132. /**
  152133. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152134. */
  152135. static EmbossKernel: number[];
  152136. /**
  152137. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152138. */
  152139. static GaussianKernel: number[];
  152140. }
  152141. }
  152142. declare module BABYLON {
  152143. /**
  152144. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  152145. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  152146. * based on samples that have a large difference in distance than the center pixel.
  152147. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  152148. */
  152149. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  152150. /**
  152151. * The direction the blur should be applied
  152152. */
  152153. direction: Vector2;
  152154. /**
  152155. * Gets a string identifying the name of the class
  152156. * @returns "DepthOfFieldBlurPostProcess" string
  152157. */
  152158. getClassName(): string;
  152159. /**
  152160. * Creates a new instance CircleOfConfusionPostProcess
  152161. * @param name The name of the effect.
  152162. * @param scene The scene the effect belongs to.
  152163. * @param direction The direction the blur should be applied.
  152164. * @param kernel The size of the kernel used to blur.
  152165. * @param options The required width/height ratio to downsize to before computing the render pass.
  152166. * @param camera The camera to apply the render pass to.
  152167. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  152168. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  152169. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152170. * @param engine The engine which the post process will be applied. (default: current engine)
  152171. * @param reusable If the post process can be reused on the same frame. (default: false)
  152172. * @param textureType Type of textures used when performing the post process. (default: 0)
  152173. * @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)
  152174. */
  152175. 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);
  152176. }
  152177. }
  152178. declare module BABYLON {
  152179. /** @hidden */
  152180. export var depthOfFieldMergePixelShader: {
  152181. name: string;
  152182. shader: string;
  152183. };
  152184. }
  152185. declare module BABYLON {
  152186. /**
  152187. * Options to be set when merging outputs from the default pipeline.
  152188. */
  152189. export class DepthOfFieldMergePostProcessOptions {
  152190. /**
  152191. * The original image to merge on top of
  152192. */
  152193. originalFromInput: PostProcess;
  152194. /**
  152195. * Parameters to perform the merge of the depth of field effect
  152196. */
  152197. depthOfField?: {
  152198. circleOfConfusion: PostProcess;
  152199. blurSteps: Array<PostProcess>;
  152200. };
  152201. /**
  152202. * Parameters to perform the merge of bloom effect
  152203. */
  152204. bloom?: {
  152205. blurred: PostProcess;
  152206. weight: number;
  152207. };
  152208. }
  152209. /**
  152210. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  152211. */
  152212. export class DepthOfFieldMergePostProcess extends PostProcess {
  152213. private blurSteps;
  152214. /**
  152215. * Gets a string identifying the name of the class
  152216. * @returns "DepthOfFieldMergePostProcess" string
  152217. */
  152218. getClassName(): string;
  152219. /**
  152220. * Creates a new instance of DepthOfFieldMergePostProcess
  152221. * @param name The name of the effect.
  152222. * @param originalFromInput Post process which's input will be used for the merge.
  152223. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  152224. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  152225. * @param options The required width/height ratio to downsize to before computing the render pass.
  152226. * @param camera The camera to apply the render pass to.
  152227. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152228. * @param engine The engine which the post process will be applied. (default: current engine)
  152229. * @param reusable If the post process can be reused on the same frame. (default: false)
  152230. * @param textureType Type of textures used when performing the post process. (default: 0)
  152231. * @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)
  152232. */
  152233. 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);
  152234. /**
  152235. * Updates the effect with the current post process compile time values and recompiles the shader.
  152236. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  152237. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  152238. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  152239. * @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
  152240. * @param onCompiled Called when the shader has been compiled.
  152241. * @param onError Called if there is an error when compiling a shader.
  152242. */
  152243. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  152244. }
  152245. }
  152246. declare module BABYLON {
  152247. /**
  152248. * Specifies the level of max blur that should be applied when using the depth of field effect
  152249. */
  152250. export enum DepthOfFieldEffectBlurLevel {
  152251. /**
  152252. * Subtle blur
  152253. */
  152254. Low = 0,
  152255. /**
  152256. * Medium blur
  152257. */
  152258. Medium = 1,
  152259. /**
  152260. * Large blur
  152261. */
  152262. High = 2
  152263. }
  152264. /**
  152265. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  152266. */
  152267. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  152268. private _circleOfConfusion;
  152269. /**
  152270. * @hidden Internal, blurs from high to low
  152271. */
  152272. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  152273. private _depthOfFieldBlurY;
  152274. private _dofMerge;
  152275. /**
  152276. * @hidden Internal post processes in depth of field effect
  152277. */
  152278. _effects: Array<PostProcess>;
  152279. /**
  152280. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  152281. */
  152282. set focalLength(value: number);
  152283. get focalLength(): number;
  152284. /**
  152285. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  152286. */
  152287. set fStop(value: number);
  152288. get fStop(): number;
  152289. /**
  152290. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  152291. */
  152292. set focusDistance(value: number);
  152293. get focusDistance(): number;
  152294. /**
  152295. * 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.
  152296. */
  152297. set lensSize(value: number);
  152298. get lensSize(): number;
  152299. /**
  152300. * Creates a new instance DepthOfFieldEffect
  152301. * @param scene The scene the effect belongs to.
  152302. * @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.
  152303. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  152304. * @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)
  152305. */
  152306. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  152307. /**
  152308. * Get the current class name of the current effet
  152309. * @returns "DepthOfFieldEffect"
  152310. */
  152311. getClassName(): string;
  152312. /**
  152313. * 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.
  152314. */
  152315. set depthTexture(value: RenderTargetTexture);
  152316. /**
  152317. * Disposes each of the internal effects for a given camera.
  152318. * @param camera The camera to dispose the effect on.
  152319. */
  152320. disposeEffects(camera: Camera): void;
  152321. /**
  152322. * @hidden Internal
  152323. */
  152324. _updateEffects(): void;
  152325. /**
  152326. * Internal
  152327. * @returns if all the contained post processes are ready.
  152328. * @hidden
  152329. */
  152330. _isReady(): boolean;
  152331. }
  152332. }
  152333. declare module BABYLON {
  152334. /** @hidden */
  152335. export var displayPassPixelShader: {
  152336. name: string;
  152337. shader: string;
  152338. };
  152339. }
  152340. declare module BABYLON {
  152341. /**
  152342. * DisplayPassPostProcess which produces an output the same as it's input
  152343. */
  152344. export class DisplayPassPostProcess extends PostProcess {
  152345. /**
  152346. * Gets a string identifying the name of the class
  152347. * @returns "DisplayPassPostProcess" string
  152348. */
  152349. getClassName(): string;
  152350. /**
  152351. * Creates the DisplayPassPostProcess
  152352. * @param name The name of the effect.
  152353. * @param options The required width/height ratio to downsize to before computing the render pass.
  152354. * @param camera The camera to apply the render pass to.
  152355. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152356. * @param engine The engine which the post process will be applied. (default: current engine)
  152357. * @param reusable If the post process can be reused on the same frame. (default: false)
  152358. */
  152359. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152360. /** @hidden */
  152361. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  152362. }
  152363. }
  152364. declare module BABYLON {
  152365. /** @hidden */
  152366. export var filterPixelShader: {
  152367. name: string;
  152368. shader: string;
  152369. };
  152370. }
  152371. declare module BABYLON {
  152372. /**
  152373. * Applies a kernel filter to the image
  152374. */
  152375. export class FilterPostProcess extends PostProcess {
  152376. /** The matrix to be applied to the image */
  152377. kernelMatrix: Matrix;
  152378. /**
  152379. * Gets a string identifying the name of the class
  152380. * @returns "FilterPostProcess" string
  152381. */
  152382. getClassName(): string;
  152383. /**
  152384. *
  152385. * @param name The name of the effect.
  152386. * @param kernelMatrix The matrix to be applied to the image
  152387. * @param options The required width/height ratio to downsize to before computing the render pass.
  152388. * @param camera The camera to apply the render pass to.
  152389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152390. * @param engine The engine which the post process will be applied. (default: current engine)
  152391. * @param reusable If the post process can be reused on the same frame. (default: false)
  152392. */
  152393. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152394. /** @hidden */
  152395. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  152396. }
  152397. }
  152398. declare module BABYLON {
  152399. /** @hidden */
  152400. export var fxaaPixelShader: {
  152401. name: string;
  152402. shader: string;
  152403. };
  152404. }
  152405. declare module BABYLON {
  152406. /** @hidden */
  152407. export var fxaaVertexShader: {
  152408. name: string;
  152409. shader: string;
  152410. };
  152411. }
  152412. declare module BABYLON {
  152413. /**
  152414. * Fxaa post process
  152415. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  152416. */
  152417. export class FxaaPostProcess extends PostProcess {
  152418. /**
  152419. * Gets a string identifying the name of the class
  152420. * @returns "FxaaPostProcess" string
  152421. */
  152422. getClassName(): string;
  152423. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152424. private _getDefines;
  152425. /** @hidden */
  152426. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  152427. }
  152428. }
  152429. declare module BABYLON {
  152430. /** @hidden */
  152431. export var grainPixelShader: {
  152432. name: string;
  152433. shader: string;
  152434. };
  152435. }
  152436. declare module BABYLON {
  152437. /**
  152438. * The GrainPostProcess adds noise to the image at mid luminance levels
  152439. */
  152440. export class GrainPostProcess extends PostProcess {
  152441. /**
  152442. * The intensity of the grain added (default: 30)
  152443. */
  152444. intensity: number;
  152445. /**
  152446. * If the grain should be randomized on every frame
  152447. */
  152448. animated: boolean;
  152449. /**
  152450. * Gets a string identifying the name of the class
  152451. * @returns "GrainPostProcess" string
  152452. */
  152453. getClassName(): string;
  152454. /**
  152455. * Creates a new instance of @see GrainPostProcess
  152456. * @param name The name of the effect.
  152457. * @param options The required width/height ratio to downsize to before computing the render pass.
  152458. * @param camera The camera to apply the render pass to.
  152459. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152460. * @param engine The engine which the post process will be applied. (default: current engine)
  152461. * @param reusable If the post process can be reused on the same frame. (default: false)
  152462. * @param textureType Type of textures used when performing the post process. (default: 0)
  152463. * @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)
  152464. */
  152465. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152466. /** @hidden */
  152467. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  152468. }
  152469. }
  152470. declare module BABYLON {
  152471. /** @hidden */
  152472. export var highlightsPixelShader: {
  152473. name: string;
  152474. shader: string;
  152475. };
  152476. }
  152477. declare module BABYLON {
  152478. /**
  152479. * Extracts highlights from the image
  152480. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  152481. */
  152482. export class HighlightsPostProcess extends PostProcess {
  152483. /**
  152484. * Gets a string identifying the name of the class
  152485. * @returns "HighlightsPostProcess" string
  152486. */
  152487. getClassName(): string;
  152488. /**
  152489. * Extracts highlights from the image
  152490. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  152491. * @param name The name of the effect.
  152492. * @param options The required width/height ratio to downsize to before computing the render pass.
  152493. * @param camera The camera to apply the render pass to.
  152494. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152495. * @param engine The engine which the post process will be applied. (default: current engine)
  152496. * @param reusable If the post process can be reused on the same frame. (default: false)
  152497. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  152498. */
  152499. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152500. }
  152501. }
  152502. declare module BABYLON {
  152503. /**
  152504. * Contains all parameters needed for the prepass to perform
  152505. * motion blur
  152506. */
  152507. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  152508. /**
  152509. * Is motion blur enabled
  152510. */
  152511. enabled: boolean;
  152512. /**
  152513. * Name of the configuration
  152514. */
  152515. name: string;
  152516. /**
  152517. * Textures that should be present in the MRT for this effect to work
  152518. */
  152519. readonly texturesRequired: number[];
  152520. }
  152521. }
  152522. declare module BABYLON {
  152523. interface Scene {
  152524. /** @hidden (Backing field) */
  152525. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  152526. /**
  152527. * Gets or Sets the current geometry buffer associated to the scene.
  152528. */
  152529. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  152530. /**
  152531. * Enables a GeometryBufferRender and associates it with the scene
  152532. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  152533. * @returns the GeometryBufferRenderer
  152534. */
  152535. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  152536. /**
  152537. * Disables the GeometryBufferRender associated with the scene
  152538. */
  152539. disableGeometryBufferRenderer(): void;
  152540. }
  152541. /**
  152542. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152543. * in several rendering techniques.
  152544. */
  152545. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  152546. /**
  152547. * The component name helpful to identify the component in the list of scene components.
  152548. */
  152549. readonly name: string;
  152550. /**
  152551. * The scene the component belongs to.
  152552. */
  152553. scene: Scene;
  152554. /**
  152555. * Creates a new instance of the component for the given scene
  152556. * @param scene Defines the scene to register the component in
  152557. */
  152558. constructor(scene: Scene);
  152559. /**
  152560. * Registers the component in a given scene
  152561. */
  152562. register(): void;
  152563. /**
  152564. * Rebuilds the elements related to this component in case of
  152565. * context lost for instance.
  152566. */
  152567. rebuild(): void;
  152568. /**
  152569. * Disposes the component and the associated ressources
  152570. */
  152571. dispose(): void;
  152572. private _gatherRenderTargets;
  152573. }
  152574. }
  152575. declare module BABYLON {
  152576. /** @hidden */
  152577. export var motionBlurPixelShader: {
  152578. name: string;
  152579. shader: string;
  152580. };
  152581. }
  152582. declare module BABYLON {
  152583. /**
  152584. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  152585. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  152586. * As an example, all you have to do is to create the post-process:
  152587. * var mb = new BABYLON.MotionBlurPostProcess(
  152588. * 'mb', // The name of the effect.
  152589. * scene, // The scene containing the objects to blur according to their velocity.
  152590. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  152591. * camera // The camera to apply the render pass to.
  152592. * );
  152593. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  152594. */
  152595. export class MotionBlurPostProcess extends PostProcess {
  152596. /**
  152597. * Defines how much the image is blurred by the movement. Default value is equal to 1
  152598. */
  152599. motionStrength: number;
  152600. /**
  152601. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  152602. */
  152603. get motionBlurSamples(): number;
  152604. /**
  152605. * Sets the number of iterations to be used for motion blur quality
  152606. */
  152607. set motionBlurSamples(samples: number);
  152608. private _motionBlurSamples;
  152609. private _forceGeometryBuffer;
  152610. private _geometryBufferRenderer;
  152611. private _prePassRenderer;
  152612. /**
  152613. * Gets a string identifying the name of the class
  152614. * @returns "MotionBlurPostProcess" string
  152615. */
  152616. getClassName(): string;
  152617. /**
  152618. * Creates a new instance MotionBlurPostProcess
  152619. * @param name The name of the effect.
  152620. * @param scene The scene containing the objects to blur according to their velocity.
  152621. * @param options The required width/height ratio to downsize to before computing the render pass.
  152622. * @param camera The camera to apply the render pass to.
  152623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152624. * @param engine The engine which the post process will be applied. (default: current engine)
  152625. * @param reusable If the post process can be reused on the same frame. (default: false)
  152626. * @param textureType Type of textures used when performing the post process. (default: 0)
  152627. * @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)
  152628. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  152629. */
  152630. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  152631. /**
  152632. * Excludes the given skinned mesh from computing bones velocities.
  152633. * 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.
  152634. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  152635. */
  152636. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  152637. /**
  152638. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  152639. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  152640. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  152641. */
  152642. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  152643. /**
  152644. * Disposes the post process.
  152645. * @param camera The camera to dispose the post process on.
  152646. */
  152647. dispose(camera?: Camera): void;
  152648. /** @hidden */
  152649. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  152650. }
  152651. }
  152652. declare module BABYLON {
  152653. /** @hidden */
  152654. export var refractionPixelShader: {
  152655. name: string;
  152656. shader: string;
  152657. };
  152658. }
  152659. declare module BABYLON {
  152660. /**
  152661. * Post process which applies a refractin texture
  152662. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  152663. */
  152664. export class RefractionPostProcess extends PostProcess {
  152665. private _refTexture;
  152666. private _ownRefractionTexture;
  152667. /** the base color of the refraction (used to taint the rendering) */
  152668. color: Color3;
  152669. /** simulated refraction depth */
  152670. depth: number;
  152671. /** the coefficient of the base color (0 to remove base color tainting) */
  152672. colorLevel: number;
  152673. /** Gets the url used to load the refraction texture */
  152674. refractionTextureUrl: string;
  152675. /**
  152676. * Gets or sets the refraction texture
  152677. * Please note that you are responsible for disposing the texture if you set it manually
  152678. */
  152679. get refractionTexture(): Texture;
  152680. set refractionTexture(value: Texture);
  152681. /**
  152682. * Gets a string identifying the name of the class
  152683. * @returns "RefractionPostProcess" string
  152684. */
  152685. getClassName(): string;
  152686. /**
  152687. * Initializes the RefractionPostProcess
  152688. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  152689. * @param name The name of the effect.
  152690. * @param refractionTextureUrl Url of the refraction texture to use
  152691. * @param color the base color of the refraction (used to taint the rendering)
  152692. * @param depth simulated refraction depth
  152693. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  152694. * @param camera The camera to apply the render pass to.
  152695. * @param options The required width/height ratio to downsize to before computing the render pass.
  152696. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152697. * @param engine The engine which the post process will be applied. (default: current engine)
  152698. * @param reusable If the post process can be reused on the same frame. (default: false)
  152699. */
  152700. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152701. /**
  152702. * Disposes of the post process
  152703. * @param camera Camera to dispose post process on
  152704. */
  152705. dispose(camera: Camera): void;
  152706. /** @hidden */
  152707. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  152708. }
  152709. }
  152710. declare module BABYLON {
  152711. /** @hidden */
  152712. export var sharpenPixelShader: {
  152713. name: string;
  152714. shader: string;
  152715. };
  152716. }
  152717. declare module BABYLON {
  152718. /**
  152719. * The SharpenPostProcess applies a sharpen kernel to every pixel
  152720. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  152721. */
  152722. export class SharpenPostProcess extends PostProcess {
  152723. /**
  152724. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  152725. */
  152726. colorAmount: number;
  152727. /**
  152728. * How much sharpness should be applied (default: 0.3)
  152729. */
  152730. edgeAmount: number;
  152731. /**
  152732. * Gets a string identifying the name of the class
  152733. * @returns "SharpenPostProcess" string
  152734. */
  152735. getClassName(): string;
  152736. /**
  152737. * Creates a new instance ConvolutionPostProcess
  152738. * @param name The name of the effect.
  152739. * @param options The required width/height ratio to downsize to before computing the render pass.
  152740. * @param camera The camera to apply the render pass to.
  152741. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152742. * @param engine The engine which the post process will be applied. (default: current engine)
  152743. * @param reusable If the post process can be reused on the same frame. (default: false)
  152744. * @param textureType Type of textures used when performing the post process. (default: 0)
  152745. * @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)
  152746. */
  152747. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152748. /** @hidden */
  152749. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  152750. }
  152751. }
  152752. declare module BABYLON {
  152753. /**
  152754. * PostProcessRenderPipeline
  152755. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152756. */
  152757. export class PostProcessRenderPipeline {
  152758. private engine;
  152759. private _renderEffects;
  152760. private _renderEffectsForIsolatedPass;
  152761. /**
  152762. * List of inspectable custom properties (used by the Inspector)
  152763. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  152764. */
  152765. inspectableCustomProperties: IInspectable[];
  152766. /**
  152767. * @hidden
  152768. */
  152769. protected _cameras: Camera[];
  152770. /** @hidden */
  152771. _name: string;
  152772. /**
  152773. * Gets pipeline name
  152774. */
  152775. get name(): string;
  152776. /** Gets the list of attached cameras */
  152777. get cameras(): Camera[];
  152778. /**
  152779. * Initializes a PostProcessRenderPipeline
  152780. * @param engine engine to add the pipeline to
  152781. * @param name name of the pipeline
  152782. */
  152783. constructor(engine: Engine, name: string);
  152784. /**
  152785. * Gets the class name
  152786. * @returns "PostProcessRenderPipeline"
  152787. */
  152788. getClassName(): string;
  152789. /**
  152790. * If all the render effects in the pipeline are supported
  152791. */
  152792. get isSupported(): boolean;
  152793. /**
  152794. * Adds an effect to the pipeline
  152795. * @param renderEffect the effect to add
  152796. */
  152797. addEffect(renderEffect: PostProcessRenderEffect): void;
  152798. /** @hidden */
  152799. _rebuild(): void;
  152800. /** @hidden */
  152801. _enableEffect(renderEffectName: string, cameras: Camera): void;
  152802. /** @hidden */
  152803. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  152804. /** @hidden */
  152805. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  152806. /** @hidden */
  152807. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  152808. /** @hidden */
  152809. _attachCameras(cameras: Camera, unique: boolean): void;
  152810. /** @hidden */
  152811. _attachCameras(cameras: Camera[], unique: boolean): void;
  152812. /** @hidden */
  152813. _detachCameras(cameras: Camera): void;
  152814. /** @hidden */
  152815. _detachCameras(cameras: Nullable<Camera[]>): void;
  152816. /** @hidden */
  152817. _update(): void;
  152818. /** @hidden */
  152819. _reset(): void;
  152820. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  152821. /**
  152822. * Sets the required values to the prepass renderer.
  152823. * @param prePassRenderer defines the prepass renderer to setup.
  152824. * @returns true if the pre pass is needed.
  152825. */
  152826. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  152827. /**
  152828. * Disposes of the pipeline
  152829. */
  152830. dispose(): void;
  152831. }
  152832. }
  152833. declare module BABYLON {
  152834. /**
  152835. * PostProcessRenderPipelineManager class
  152836. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152837. */
  152838. export class PostProcessRenderPipelineManager {
  152839. private _renderPipelines;
  152840. /**
  152841. * Initializes a PostProcessRenderPipelineManager
  152842. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152843. */
  152844. constructor();
  152845. /**
  152846. * Gets the list of supported render pipelines
  152847. */
  152848. get supportedPipelines(): PostProcessRenderPipeline[];
  152849. /**
  152850. * Adds a pipeline to the manager
  152851. * @param renderPipeline The pipeline to add
  152852. */
  152853. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  152854. /**
  152855. * Attaches a camera to the pipeline
  152856. * @param renderPipelineName The name of the pipeline to attach to
  152857. * @param cameras the camera to attach
  152858. * @param unique if the camera can be attached multiple times to the pipeline
  152859. */
  152860. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  152861. /**
  152862. * Detaches a camera from the pipeline
  152863. * @param renderPipelineName The name of the pipeline to detach from
  152864. * @param cameras the camera to detach
  152865. */
  152866. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  152867. /**
  152868. * Enables an effect by name on a pipeline
  152869. * @param renderPipelineName the name of the pipeline to enable the effect in
  152870. * @param renderEffectName the name of the effect to enable
  152871. * @param cameras the cameras that the effect should be enabled on
  152872. */
  152873. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  152874. /**
  152875. * Disables an effect by name on a pipeline
  152876. * @param renderPipelineName the name of the pipeline to disable the effect in
  152877. * @param renderEffectName the name of the effect to disable
  152878. * @param cameras the cameras that the effect should be disabled on
  152879. */
  152880. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  152881. /**
  152882. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  152883. */
  152884. update(): void;
  152885. /** @hidden */
  152886. _rebuild(): void;
  152887. /**
  152888. * Disposes of the manager and pipelines
  152889. */
  152890. dispose(): void;
  152891. }
  152892. }
  152893. declare module BABYLON {
  152894. interface Scene {
  152895. /** @hidden (Backing field) */
  152896. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  152897. /**
  152898. * Gets the postprocess render pipeline manager
  152899. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152900. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  152901. */
  152902. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  152903. }
  152904. /**
  152905. * Defines the Render Pipeline scene component responsible to rendering pipelines
  152906. */
  152907. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  152908. /**
  152909. * The component name helpfull to identify the component in the list of scene components.
  152910. */
  152911. readonly name: string;
  152912. /**
  152913. * The scene the component belongs to.
  152914. */
  152915. scene: Scene;
  152916. /**
  152917. * Creates a new instance of the component for the given scene
  152918. * @param scene Defines the scene to register the component in
  152919. */
  152920. constructor(scene: Scene);
  152921. /**
  152922. * Registers the component in a given scene
  152923. */
  152924. register(): void;
  152925. /**
  152926. * Rebuilds the elements related to this component in case of
  152927. * context lost for instance.
  152928. */
  152929. rebuild(): void;
  152930. /**
  152931. * Disposes the component and the associated ressources
  152932. */
  152933. dispose(): void;
  152934. private _gatherRenderTargets;
  152935. }
  152936. }
  152937. declare module BABYLON {
  152938. /**
  152939. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  152940. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  152941. */
  152942. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  152943. private _scene;
  152944. private _camerasToBeAttached;
  152945. /**
  152946. * ID of the sharpen post process,
  152947. */
  152948. private readonly SharpenPostProcessId;
  152949. /**
  152950. * @ignore
  152951. * ID of the image processing post process;
  152952. */
  152953. readonly ImageProcessingPostProcessId: string;
  152954. /**
  152955. * @ignore
  152956. * ID of the Fast Approximate Anti-Aliasing post process;
  152957. */
  152958. readonly FxaaPostProcessId: string;
  152959. /**
  152960. * ID of the chromatic aberration post process,
  152961. */
  152962. private readonly ChromaticAberrationPostProcessId;
  152963. /**
  152964. * ID of the grain post process
  152965. */
  152966. private readonly GrainPostProcessId;
  152967. /**
  152968. * Sharpen post process which will apply a sharpen convolution to enhance edges
  152969. */
  152970. sharpen: SharpenPostProcess;
  152971. private _sharpenEffect;
  152972. private bloom;
  152973. /**
  152974. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  152975. */
  152976. depthOfField: DepthOfFieldEffect;
  152977. /**
  152978. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  152979. */
  152980. fxaa: FxaaPostProcess;
  152981. /**
  152982. * Image post processing pass used to perform operations such as tone mapping or color grading.
  152983. */
  152984. imageProcessing: ImageProcessingPostProcess;
  152985. /**
  152986. * Chromatic aberration post process which will shift rgb colors in the image
  152987. */
  152988. chromaticAberration: ChromaticAberrationPostProcess;
  152989. private _chromaticAberrationEffect;
  152990. /**
  152991. * Grain post process which add noise to the image
  152992. */
  152993. grain: GrainPostProcess;
  152994. private _grainEffect;
  152995. /**
  152996. * Glow post process which adds a glow to emissive areas of the image
  152997. */
  152998. private _glowLayer;
  152999. /**
  153000. * Animations which can be used to tweak settings over a period of time
  153001. */
  153002. animations: Animation[];
  153003. private _imageProcessingConfigurationObserver;
  153004. private _sharpenEnabled;
  153005. private _bloomEnabled;
  153006. private _depthOfFieldEnabled;
  153007. private _depthOfFieldBlurLevel;
  153008. private _fxaaEnabled;
  153009. private _imageProcessingEnabled;
  153010. private _defaultPipelineTextureType;
  153011. private _bloomScale;
  153012. private _chromaticAberrationEnabled;
  153013. private _grainEnabled;
  153014. private _buildAllowed;
  153015. /**
  153016. * This is triggered each time the pipeline has been built.
  153017. */
  153018. onBuildObservable: Observable<DefaultRenderingPipeline>;
  153019. /**
  153020. * Gets active scene
  153021. */
  153022. get scene(): Scene;
  153023. /**
  153024. * Enable or disable the sharpen process from the pipeline
  153025. */
  153026. set sharpenEnabled(enabled: boolean);
  153027. get sharpenEnabled(): boolean;
  153028. private _resizeObserver;
  153029. private _hardwareScaleLevel;
  153030. private _bloomKernel;
  153031. /**
  153032. * Specifies the size of the bloom blur kernel, relative to the final output size
  153033. */
  153034. get bloomKernel(): number;
  153035. set bloomKernel(value: number);
  153036. /**
  153037. * Specifies the weight of the bloom in the final rendering
  153038. */
  153039. private _bloomWeight;
  153040. /**
  153041. * Specifies the luma threshold for the area that will be blurred by the bloom
  153042. */
  153043. private _bloomThreshold;
  153044. private _hdr;
  153045. /**
  153046. * The strength of the bloom.
  153047. */
  153048. set bloomWeight(value: number);
  153049. get bloomWeight(): number;
  153050. /**
  153051. * The strength of the bloom.
  153052. */
  153053. set bloomThreshold(value: number);
  153054. get bloomThreshold(): number;
  153055. /**
  153056. * The scale of the bloom, lower value will provide better performance.
  153057. */
  153058. set bloomScale(value: number);
  153059. get bloomScale(): number;
  153060. /**
  153061. * Enable or disable the bloom from the pipeline
  153062. */
  153063. set bloomEnabled(enabled: boolean);
  153064. get bloomEnabled(): boolean;
  153065. private _rebuildBloom;
  153066. /**
  153067. * If the depth of field is enabled.
  153068. */
  153069. get depthOfFieldEnabled(): boolean;
  153070. set depthOfFieldEnabled(enabled: boolean);
  153071. /**
  153072. * Blur level of the depth of field effect. (Higher blur will effect performance)
  153073. */
  153074. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  153075. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  153076. /**
  153077. * If the anti aliasing is enabled.
  153078. */
  153079. set fxaaEnabled(enabled: boolean);
  153080. get fxaaEnabled(): boolean;
  153081. private _samples;
  153082. /**
  153083. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  153084. */
  153085. set samples(sampleCount: number);
  153086. get samples(): number;
  153087. /**
  153088. * If image processing is enabled.
  153089. */
  153090. set imageProcessingEnabled(enabled: boolean);
  153091. get imageProcessingEnabled(): boolean;
  153092. /**
  153093. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  153094. */
  153095. set glowLayerEnabled(enabled: boolean);
  153096. get glowLayerEnabled(): boolean;
  153097. /**
  153098. * Gets the glow layer (or null if not defined)
  153099. */
  153100. get glowLayer(): Nullable<GlowLayer>;
  153101. /**
  153102. * Enable or disable the chromaticAberration process from the pipeline
  153103. */
  153104. set chromaticAberrationEnabled(enabled: boolean);
  153105. get chromaticAberrationEnabled(): boolean;
  153106. /**
  153107. * Enable or disable the grain process from the pipeline
  153108. */
  153109. set grainEnabled(enabled: boolean);
  153110. get grainEnabled(): boolean;
  153111. /**
  153112. * @constructor
  153113. * @param name - The rendering pipeline name (default: "")
  153114. * @param hdr - If high dynamic range textures should be used (default: true)
  153115. * @param scene - The scene linked to this pipeline (default: the last created scene)
  153116. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  153117. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  153118. */
  153119. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  153120. /**
  153121. * Get the class name
  153122. * @returns "DefaultRenderingPipeline"
  153123. */
  153124. getClassName(): string;
  153125. /**
  153126. * Force the compilation of the entire pipeline.
  153127. */
  153128. prepare(): void;
  153129. private _hasCleared;
  153130. private _prevPostProcess;
  153131. private _prevPrevPostProcess;
  153132. private _setAutoClearAndTextureSharing;
  153133. private _depthOfFieldSceneObserver;
  153134. private _buildPipeline;
  153135. private _disposePostProcesses;
  153136. /**
  153137. * Adds a camera to the pipeline
  153138. * @param camera the camera to be added
  153139. */
  153140. addCamera(camera: Camera): void;
  153141. /**
  153142. * Removes a camera from the pipeline
  153143. * @param camera the camera to remove
  153144. */
  153145. removeCamera(camera: Camera): void;
  153146. /**
  153147. * Dispose of the pipeline and stop all post processes
  153148. */
  153149. dispose(): void;
  153150. /**
  153151. * Serialize the rendering pipeline (Used when exporting)
  153152. * @returns the serialized object
  153153. */
  153154. serialize(): any;
  153155. /**
  153156. * Parse the serialized pipeline
  153157. * @param source Source pipeline.
  153158. * @param scene The scene to load the pipeline to.
  153159. * @param rootUrl The URL of the serialized pipeline.
  153160. * @returns An instantiated pipeline from the serialized object.
  153161. */
  153162. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  153163. }
  153164. }
  153165. declare module BABYLON {
  153166. /** @hidden */
  153167. export var lensHighlightsPixelShader: {
  153168. name: string;
  153169. shader: string;
  153170. };
  153171. }
  153172. declare module BABYLON {
  153173. /** @hidden */
  153174. export var depthOfFieldPixelShader: {
  153175. name: string;
  153176. shader: string;
  153177. };
  153178. }
  153179. declare module BABYLON {
  153180. /**
  153181. * BABYLON.JS Chromatic Aberration GLSL Shader
  153182. * Author: Olivier Guyot
  153183. * Separates very slightly R, G and B colors on the edges of the screen
  153184. * Inspired by Francois Tarlier & Martins Upitis
  153185. */
  153186. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  153187. /**
  153188. * @ignore
  153189. * The chromatic aberration PostProcess id in the pipeline
  153190. */
  153191. LensChromaticAberrationEffect: string;
  153192. /**
  153193. * @ignore
  153194. * The highlights enhancing PostProcess id in the pipeline
  153195. */
  153196. HighlightsEnhancingEffect: string;
  153197. /**
  153198. * @ignore
  153199. * The depth-of-field PostProcess id in the pipeline
  153200. */
  153201. LensDepthOfFieldEffect: string;
  153202. private _scene;
  153203. private _depthTexture;
  153204. private _grainTexture;
  153205. private _chromaticAberrationPostProcess;
  153206. private _highlightsPostProcess;
  153207. private _depthOfFieldPostProcess;
  153208. private _edgeBlur;
  153209. private _grainAmount;
  153210. private _chromaticAberration;
  153211. private _distortion;
  153212. private _highlightsGain;
  153213. private _highlightsThreshold;
  153214. private _dofDistance;
  153215. private _dofAperture;
  153216. private _dofDarken;
  153217. private _dofPentagon;
  153218. private _blurNoise;
  153219. /**
  153220. * @constructor
  153221. *
  153222. * Effect parameters are as follow:
  153223. * {
  153224. * chromatic_aberration: number; // from 0 to x (1 for realism)
  153225. * edge_blur: number; // from 0 to x (1 for realism)
  153226. * distortion: number; // from 0 to x (1 for realism)
  153227. * grain_amount: number; // from 0 to 1
  153228. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  153229. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  153230. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  153231. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  153232. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  153233. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  153234. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  153235. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  153236. * }
  153237. * Note: if an effect parameter is unset, effect is disabled
  153238. *
  153239. * @param name The rendering pipeline name
  153240. * @param parameters - An object containing all parameters (see above)
  153241. * @param scene The scene linked to this pipeline
  153242. * @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)
  153243. * @param cameras The array of cameras that the rendering pipeline will be attached to
  153244. */
  153245. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  153246. /**
  153247. * Get the class name
  153248. * @returns "LensRenderingPipeline"
  153249. */
  153250. getClassName(): string;
  153251. /**
  153252. * Gets associated scene
  153253. */
  153254. get scene(): Scene;
  153255. /**
  153256. * Gets or sets the edge blur
  153257. */
  153258. get edgeBlur(): number;
  153259. set edgeBlur(value: number);
  153260. /**
  153261. * Gets or sets the grain amount
  153262. */
  153263. get grainAmount(): number;
  153264. set grainAmount(value: number);
  153265. /**
  153266. * Gets or sets the chromatic aberration amount
  153267. */
  153268. get chromaticAberration(): number;
  153269. set chromaticAberration(value: number);
  153270. /**
  153271. * Gets or sets the depth of field aperture
  153272. */
  153273. get dofAperture(): number;
  153274. set dofAperture(value: number);
  153275. /**
  153276. * Gets or sets the edge distortion
  153277. */
  153278. get edgeDistortion(): number;
  153279. set edgeDistortion(value: number);
  153280. /**
  153281. * Gets or sets the depth of field distortion
  153282. */
  153283. get dofDistortion(): number;
  153284. set dofDistortion(value: number);
  153285. /**
  153286. * Gets or sets the darken out of focus amount
  153287. */
  153288. get darkenOutOfFocus(): number;
  153289. set darkenOutOfFocus(value: number);
  153290. /**
  153291. * Gets or sets a boolean indicating if blur noise is enabled
  153292. */
  153293. get blurNoise(): boolean;
  153294. set blurNoise(value: boolean);
  153295. /**
  153296. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  153297. */
  153298. get pentagonBokeh(): boolean;
  153299. set pentagonBokeh(value: boolean);
  153300. /**
  153301. * Gets or sets the highlight grain amount
  153302. */
  153303. get highlightsGain(): number;
  153304. set highlightsGain(value: number);
  153305. /**
  153306. * Gets or sets the highlight threshold
  153307. */
  153308. get highlightsThreshold(): number;
  153309. set highlightsThreshold(value: number);
  153310. /**
  153311. * Sets the amount of blur at the edges
  153312. * @param amount blur amount
  153313. */
  153314. setEdgeBlur(amount: number): void;
  153315. /**
  153316. * Sets edge blur to 0
  153317. */
  153318. disableEdgeBlur(): void;
  153319. /**
  153320. * Sets the amout of grain
  153321. * @param amount Amount of grain
  153322. */
  153323. setGrainAmount(amount: number): void;
  153324. /**
  153325. * Set grain amount to 0
  153326. */
  153327. disableGrain(): void;
  153328. /**
  153329. * Sets the chromatic aberration amount
  153330. * @param amount amount of chromatic aberration
  153331. */
  153332. setChromaticAberration(amount: number): void;
  153333. /**
  153334. * Sets chromatic aberration amount to 0
  153335. */
  153336. disableChromaticAberration(): void;
  153337. /**
  153338. * Sets the EdgeDistortion amount
  153339. * @param amount amount of EdgeDistortion
  153340. */
  153341. setEdgeDistortion(amount: number): void;
  153342. /**
  153343. * Sets edge distortion to 0
  153344. */
  153345. disableEdgeDistortion(): void;
  153346. /**
  153347. * Sets the FocusDistance amount
  153348. * @param amount amount of FocusDistance
  153349. */
  153350. setFocusDistance(amount: number): void;
  153351. /**
  153352. * Disables depth of field
  153353. */
  153354. disableDepthOfField(): void;
  153355. /**
  153356. * Sets the Aperture amount
  153357. * @param amount amount of Aperture
  153358. */
  153359. setAperture(amount: number): void;
  153360. /**
  153361. * Sets the DarkenOutOfFocus amount
  153362. * @param amount amount of DarkenOutOfFocus
  153363. */
  153364. setDarkenOutOfFocus(amount: number): void;
  153365. private _pentagonBokehIsEnabled;
  153366. /**
  153367. * Creates a pentagon bokeh effect
  153368. */
  153369. enablePentagonBokeh(): void;
  153370. /**
  153371. * Disables the pentagon bokeh effect
  153372. */
  153373. disablePentagonBokeh(): void;
  153374. /**
  153375. * Enables noise blur
  153376. */
  153377. enableNoiseBlur(): void;
  153378. /**
  153379. * Disables noise blur
  153380. */
  153381. disableNoiseBlur(): void;
  153382. /**
  153383. * Sets the HighlightsGain amount
  153384. * @param amount amount of HighlightsGain
  153385. */
  153386. setHighlightsGain(amount: number): void;
  153387. /**
  153388. * Sets the HighlightsThreshold amount
  153389. * @param amount amount of HighlightsThreshold
  153390. */
  153391. setHighlightsThreshold(amount: number): void;
  153392. /**
  153393. * Disables highlights
  153394. */
  153395. disableHighlights(): void;
  153396. /**
  153397. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  153398. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  153399. */
  153400. dispose(disableDepthRender?: boolean): void;
  153401. private _createChromaticAberrationPostProcess;
  153402. private _createHighlightsPostProcess;
  153403. private _createDepthOfFieldPostProcess;
  153404. private _createGrainTexture;
  153405. }
  153406. }
  153407. declare module BABYLON {
  153408. /**
  153409. * Contains all parameters needed for the prepass to perform
  153410. * screen space subsurface scattering
  153411. */
  153412. export class SSAO2Configuration implements PrePassEffectConfiguration {
  153413. /**
  153414. * Is subsurface enabled
  153415. */
  153416. enabled: boolean;
  153417. /**
  153418. * Name of the configuration
  153419. */
  153420. name: string;
  153421. /**
  153422. * Textures that should be present in the MRT for this effect to work
  153423. */
  153424. readonly texturesRequired: number[];
  153425. }
  153426. }
  153427. declare module BABYLON {
  153428. /** @hidden */
  153429. export var ssao2PixelShader: {
  153430. name: string;
  153431. shader: string;
  153432. };
  153433. }
  153434. declare module BABYLON {
  153435. /** @hidden */
  153436. export var ssaoCombinePixelShader: {
  153437. name: string;
  153438. shader: string;
  153439. };
  153440. }
  153441. declare module BABYLON {
  153442. /**
  153443. * Render pipeline to produce ssao effect
  153444. */
  153445. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  153446. /**
  153447. * @ignore
  153448. * The PassPostProcess id in the pipeline that contains the original scene color
  153449. */
  153450. SSAOOriginalSceneColorEffect: string;
  153451. /**
  153452. * @ignore
  153453. * The SSAO PostProcess id in the pipeline
  153454. */
  153455. SSAORenderEffect: string;
  153456. /**
  153457. * @ignore
  153458. * The horizontal blur PostProcess id in the pipeline
  153459. */
  153460. SSAOBlurHRenderEffect: string;
  153461. /**
  153462. * @ignore
  153463. * The vertical blur PostProcess id in the pipeline
  153464. */
  153465. SSAOBlurVRenderEffect: string;
  153466. /**
  153467. * @ignore
  153468. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  153469. */
  153470. SSAOCombineRenderEffect: string;
  153471. /**
  153472. * The output strength of the SSAO post-process. Default value is 1.0.
  153473. */
  153474. totalStrength: number;
  153475. /**
  153476. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  153477. */
  153478. maxZ: number;
  153479. /**
  153480. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  153481. */
  153482. minZAspect: number;
  153483. private _samples;
  153484. /**
  153485. * Number of samples used for the SSAO calculations. Default value is 8
  153486. */
  153487. set samples(n: number);
  153488. get samples(): number;
  153489. private _textureSamples;
  153490. /**
  153491. * Number of samples to use for antialiasing
  153492. */
  153493. set textureSamples(n: number);
  153494. get textureSamples(): number;
  153495. /**
  153496. * Force rendering the geometry through geometry buffer
  153497. */
  153498. private _forceGeometryBuffer;
  153499. /**
  153500. * Ratio object used for SSAO ratio and blur ratio
  153501. */
  153502. private _ratio;
  153503. /**
  153504. * Dynamically generated sphere sampler.
  153505. */
  153506. private _sampleSphere;
  153507. /**
  153508. * Blur filter offsets
  153509. */
  153510. private _samplerOffsets;
  153511. private _expensiveBlur;
  153512. /**
  153513. * If bilateral blur should be used
  153514. */
  153515. set expensiveBlur(b: boolean);
  153516. get expensiveBlur(): boolean;
  153517. /**
  153518. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  153519. */
  153520. radius: number;
  153521. /**
  153522. * The base color of the SSAO post-process
  153523. * The final result is "base + ssao" between [0, 1]
  153524. */
  153525. base: number;
  153526. /**
  153527. * Support test.
  153528. */
  153529. static get IsSupported(): boolean;
  153530. private _scene;
  153531. private _randomTexture;
  153532. private _originalColorPostProcess;
  153533. private _ssaoPostProcess;
  153534. private _blurHPostProcess;
  153535. private _blurVPostProcess;
  153536. private _ssaoCombinePostProcess;
  153537. private _prePassRenderer;
  153538. /**
  153539. * Gets active scene
  153540. */
  153541. get scene(): Scene;
  153542. /**
  153543. * @constructor
  153544. * @param name The rendering pipeline name
  153545. * @param scene The scene linked to this pipeline
  153546. * @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 }
  153547. * @param cameras The array of cameras that the rendering pipeline will be attached to
  153548. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  153549. */
  153550. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  153551. /**
  153552. * Get the class name
  153553. * @returns "SSAO2RenderingPipeline"
  153554. */
  153555. getClassName(): string;
  153556. /**
  153557. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  153558. */
  153559. dispose(disableGeometryBufferRenderer?: boolean): void;
  153560. private _createBlurPostProcess;
  153561. /** @hidden */
  153562. _rebuild(): void;
  153563. private _bits;
  153564. private _radicalInverse_VdC;
  153565. private _hammersley;
  153566. private _hemisphereSample_uniform;
  153567. private _generateHemisphere;
  153568. private _getDefinesForSSAO;
  153569. private _createSSAOPostProcess;
  153570. private _createSSAOCombinePostProcess;
  153571. private _createRandomTexture;
  153572. /**
  153573. * Serialize the rendering pipeline (Used when exporting)
  153574. * @returns the serialized object
  153575. */
  153576. serialize(): any;
  153577. /**
  153578. * Parse the serialized pipeline
  153579. * @param source Source pipeline.
  153580. * @param scene The scene to load the pipeline to.
  153581. * @param rootUrl The URL of the serialized pipeline.
  153582. * @returns An instantiated pipeline from the serialized object.
  153583. */
  153584. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  153585. }
  153586. }
  153587. declare module BABYLON {
  153588. /** @hidden */
  153589. export var ssaoPixelShader: {
  153590. name: string;
  153591. shader: string;
  153592. };
  153593. }
  153594. declare module BABYLON {
  153595. /**
  153596. * Render pipeline to produce ssao effect
  153597. */
  153598. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  153599. /**
  153600. * @ignore
  153601. * The PassPostProcess id in the pipeline that contains the original scene color
  153602. */
  153603. SSAOOriginalSceneColorEffect: string;
  153604. /**
  153605. * @ignore
  153606. * The SSAO PostProcess id in the pipeline
  153607. */
  153608. SSAORenderEffect: string;
  153609. /**
  153610. * @ignore
  153611. * The horizontal blur PostProcess id in the pipeline
  153612. */
  153613. SSAOBlurHRenderEffect: string;
  153614. /**
  153615. * @ignore
  153616. * The vertical blur PostProcess id in the pipeline
  153617. */
  153618. SSAOBlurVRenderEffect: string;
  153619. /**
  153620. * @ignore
  153621. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  153622. */
  153623. SSAOCombineRenderEffect: string;
  153624. /**
  153625. * The output strength of the SSAO post-process. Default value is 1.0.
  153626. */
  153627. totalStrength: number;
  153628. /**
  153629. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  153630. */
  153631. radius: number;
  153632. /**
  153633. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  153634. * Must not be equal to fallOff and superior to fallOff.
  153635. * Default value is 0.0075
  153636. */
  153637. area: number;
  153638. /**
  153639. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  153640. * Must not be equal to area and inferior to area.
  153641. * Default value is 0.000001
  153642. */
  153643. fallOff: number;
  153644. /**
  153645. * The base color of the SSAO post-process
  153646. * The final result is "base + ssao" between [0, 1]
  153647. */
  153648. base: number;
  153649. private _scene;
  153650. private _depthTexture;
  153651. private _randomTexture;
  153652. private _originalColorPostProcess;
  153653. private _ssaoPostProcess;
  153654. private _blurHPostProcess;
  153655. private _blurVPostProcess;
  153656. private _ssaoCombinePostProcess;
  153657. private _firstUpdate;
  153658. /**
  153659. * Gets active scene
  153660. */
  153661. get scene(): Scene;
  153662. /**
  153663. * @constructor
  153664. * @param name - The rendering pipeline name
  153665. * @param scene - The scene linked to this pipeline
  153666. * @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 }
  153667. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  153668. */
  153669. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  153670. /**
  153671. * Get the class name
  153672. * @returns "SSAORenderingPipeline"
  153673. */
  153674. getClassName(): string;
  153675. /**
  153676. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  153677. */
  153678. dispose(disableDepthRender?: boolean): void;
  153679. private _createBlurPostProcess;
  153680. /** @hidden */
  153681. _rebuild(): void;
  153682. private _createSSAOPostProcess;
  153683. private _createSSAOCombinePostProcess;
  153684. private _createRandomTexture;
  153685. }
  153686. }
  153687. declare module BABYLON {
  153688. /**
  153689. * Contains all parameters needed for the prepass to perform
  153690. * screen space reflections
  153691. */
  153692. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  153693. /**
  153694. * Is ssr enabled
  153695. */
  153696. enabled: boolean;
  153697. /**
  153698. * Name of the configuration
  153699. */
  153700. name: string;
  153701. /**
  153702. * Textures that should be present in the MRT for this effect to work
  153703. */
  153704. readonly texturesRequired: number[];
  153705. }
  153706. }
  153707. declare module BABYLON {
  153708. /** @hidden */
  153709. export var screenSpaceReflectionPixelShader: {
  153710. name: string;
  153711. shader: string;
  153712. };
  153713. }
  153714. declare module BABYLON {
  153715. /**
  153716. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  153717. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  153718. */
  153719. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  153720. /**
  153721. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  153722. */
  153723. threshold: number;
  153724. /**
  153725. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  153726. */
  153727. strength: number;
  153728. /**
  153729. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  153730. */
  153731. reflectionSpecularFalloffExponent: number;
  153732. /**
  153733. * 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]
  153734. */
  153735. step: number;
  153736. /**
  153737. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  153738. */
  153739. roughnessFactor: number;
  153740. private _forceGeometryBuffer;
  153741. private _geometryBufferRenderer;
  153742. private _prePassRenderer;
  153743. private _enableSmoothReflections;
  153744. private _reflectionSamples;
  153745. private _smoothSteps;
  153746. /**
  153747. * Gets a string identifying the name of the class
  153748. * @returns "ScreenSpaceReflectionPostProcess" string
  153749. */
  153750. getClassName(): string;
  153751. /**
  153752. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  153753. * @param name The name of the effect.
  153754. * @param scene The scene containing the objects to calculate reflections.
  153755. * @param options The required width/height ratio to downsize to before computing the render pass.
  153756. * @param camera The camera to apply the render pass to.
  153757. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153758. * @param engine The engine which the post process will be applied. (default: current engine)
  153759. * @param reusable If the post process can be reused on the same frame. (default: false)
  153760. * @param textureType Type of textures used when performing the post process. (default: 0)
  153761. * @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)
  153762. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  153763. */
  153764. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  153765. /**
  153766. * Gets wether or not smoothing reflections is enabled.
  153767. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  153768. */
  153769. get enableSmoothReflections(): boolean;
  153770. /**
  153771. * Sets wether or not smoothing reflections is enabled.
  153772. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  153773. */
  153774. set enableSmoothReflections(enabled: boolean);
  153775. /**
  153776. * Gets the number of samples taken while computing reflections. More samples count is high,
  153777. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  153778. */
  153779. get reflectionSamples(): number;
  153780. /**
  153781. * Sets the number of samples taken while computing reflections. More samples count is high,
  153782. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  153783. */
  153784. set reflectionSamples(samples: number);
  153785. /**
  153786. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  153787. * more the post-process will require GPU power and can generate a drop in FPS.
  153788. * Default value (5.0) work pretty well in all cases but can be adjusted.
  153789. */
  153790. get smoothSteps(): number;
  153791. set smoothSteps(steps: number);
  153792. private _updateEffectDefines;
  153793. /** @hidden */
  153794. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  153795. }
  153796. }
  153797. declare module BABYLON {
  153798. /** @hidden */
  153799. export var standardPixelShader: {
  153800. name: string;
  153801. shader: string;
  153802. };
  153803. }
  153804. declare module BABYLON {
  153805. /**
  153806. * Standard rendering pipeline
  153807. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  153808. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  153809. */
  153810. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  153811. /**
  153812. * Public members
  153813. */
  153814. /**
  153815. * Post-process which contains the original scene color before the pipeline applies all the effects
  153816. */
  153817. originalPostProcess: Nullable<PostProcess>;
  153818. /**
  153819. * Post-process used to down scale an image x4
  153820. */
  153821. downSampleX4PostProcess: Nullable<PostProcess>;
  153822. /**
  153823. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  153824. */
  153825. brightPassPostProcess: Nullable<PostProcess>;
  153826. /**
  153827. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  153828. */
  153829. blurHPostProcesses: PostProcess[];
  153830. /**
  153831. * Post-process array storing all the vertical blur post-processes used by the pipeline
  153832. */
  153833. blurVPostProcesses: PostProcess[];
  153834. /**
  153835. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  153836. */
  153837. textureAdderPostProcess: Nullable<PostProcess>;
  153838. /**
  153839. * Post-process used to create volumetric lighting effect
  153840. */
  153841. volumetricLightPostProcess: Nullable<PostProcess>;
  153842. /**
  153843. * Post-process used to smooth the previous volumetric light post-process on the X axis
  153844. */
  153845. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  153846. /**
  153847. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  153848. */
  153849. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  153850. /**
  153851. * Post-process used to merge the volumetric light effect and the real scene color
  153852. */
  153853. volumetricLightMergePostProces: Nullable<PostProcess>;
  153854. /**
  153855. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  153856. */
  153857. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  153858. /**
  153859. * Base post-process used to calculate the average luminance of the final image for HDR
  153860. */
  153861. luminancePostProcess: Nullable<PostProcess>;
  153862. /**
  153863. * Post-processes used to create down sample post-processes in order to get
  153864. * the average luminance of the final image for HDR
  153865. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  153866. */
  153867. luminanceDownSamplePostProcesses: PostProcess[];
  153868. /**
  153869. * Post-process used to create a HDR effect (light adaptation)
  153870. */
  153871. hdrPostProcess: Nullable<PostProcess>;
  153872. /**
  153873. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  153874. */
  153875. textureAdderFinalPostProcess: Nullable<PostProcess>;
  153876. /**
  153877. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  153878. */
  153879. lensFlareFinalPostProcess: Nullable<PostProcess>;
  153880. /**
  153881. * Post-process used to merge the final HDR post-process and the real scene color
  153882. */
  153883. hdrFinalPostProcess: Nullable<PostProcess>;
  153884. /**
  153885. * Post-process used to create a lens flare effect
  153886. */
  153887. lensFlarePostProcess: Nullable<PostProcess>;
  153888. /**
  153889. * Post-process that merges the result of the lens flare post-process and the real scene color
  153890. */
  153891. lensFlareComposePostProcess: Nullable<PostProcess>;
  153892. /**
  153893. * Post-process used to create a motion blur effect
  153894. */
  153895. motionBlurPostProcess: Nullable<PostProcess>;
  153896. /**
  153897. * Post-process used to create a depth of field effect
  153898. */
  153899. depthOfFieldPostProcess: Nullable<PostProcess>;
  153900. /**
  153901. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  153902. */
  153903. fxaaPostProcess: Nullable<FxaaPostProcess>;
  153904. /**
  153905. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  153906. */
  153907. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  153908. /**
  153909. * Represents the brightness threshold in order to configure the illuminated surfaces
  153910. */
  153911. brightThreshold: number;
  153912. /**
  153913. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  153914. */
  153915. blurWidth: number;
  153916. /**
  153917. * Sets if the blur for highlighted surfaces must be only horizontal
  153918. */
  153919. horizontalBlur: boolean;
  153920. /**
  153921. * Gets the overall exposure used by the pipeline
  153922. */
  153923. get exposure(): number;
  153924. /**
  153925. * Sets the overall exposure used by the pipeline
  153926. */
  153927. set exposure(value: number);
  153928. /**
  153929. * Texture used typically to simulate "dirty" on camera lens
  153930. */
  153931. lensTexture: Nullable<Texture>;
  153932. /**
  153933. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  153934. */
  153935. volumetricLightCoefficient: number;
  153936. /**
  153937. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  153938. */
  153939. volumetricLightPower: number;
  153940. /**
  153941. * Used the set the blur intensity to smooth the volumetric lights
  153942. */
  153943. volumetricLightBlurScale: number;
  153944. /**
  153945. * Light (spot or directional) used to generate the volumetric lights rays
  153946. * The source light must have a shadow generate so the pipeline can get its
  153947. * depth map
  153948. */
  153949. sourceLight: Nullable<SpotLight | DirectionalLight>;
  153950. /**
  153951. * For eye adaptation, represents the minimum luminance the eye can see
  153952. */
  153953. hdrMinimumLuminance: number;
  153954. /**
  153955. * For eye adaptation, represents the decrease luminance speed
  153956. */
  153957. hdrDecreaseRate: number;
  153958. /**
  153959. * For eye adaptation, represents the increase luminance speed
  153960. */
  153961. hdrIncreaseRate: number;
  153962. /**
  153963. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  153964. */
  153965. get hdrAutoExposure(): boolean;
  153966. /**
  153967. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  153968. */
  153969. set hdrAutoExposure(value: boolean);
  153970. /**
  153971. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  153972. */
  153973. lensColorTexture: Nullable<Texture>;
  153974. /**
  153975. * The overall strengh for the lens flare effect
  153976. */
  153977. lensFlareStrength: number;
  153978. /**
  153979. * Dispersion coefficient for lens flare ghosts
  153980. */
  153981. lensFlareGhostDispersal: number;
  153982. /**
  153983. * Main lens flare halo width
  153984. */
  153985. lensFlareHaloWidth: number;
  153986. /**
  153987. * Based on the lens distortion effect, defines how much the lens flare result
  153988. * is distorted
  153989. */
  153990. lensFlareDistortionStrength: number;
  153991. /**
  153992. * Configures the blur intensity used for for lens flare (halo)
  153993. */
  153994. lensFlareBlurWidth: number;
  153995. /**
  153996. * Lens star texture must be used to simulate rays on the flares and is available
  153997. * in the documentation
  153998. */
  153999. lensStarTexture: Nullable<Texture>;
  154000. /**
  154001. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  154002. * flare effect by taking account of the dirt texture
  154003. */
  154004. lensFlareDirtTexture: Nullable<Texture>;
  154005. /**
  154006. * Represents the focal length for the depth of field effect
  154007. */
  154008. depthOfFieldDistance: number;
  154009. /**
  154010. * Represents the blur intensity for the blurred part of the depth of field effect
  154011. */
  154012. depthOfFieldBlurWidth: number;
  154013. /**
  154014. * Gets how much the image is blurred by the movement while using the motion blur post-process
  154015. */
  154016. get motionStrength(): number;
  154017. /**
  154018. * Sets how much the image is blurred by the movement while using the motion blur post-process
  154019. */
  154020. set motionStrength(strength: number);
  154021. /**
  154022. * Gets wether or not the motion blur post-process is object based or screen based.
  154023. */
  154024. get objectBasedMotionBlur(): boolean;
  154025. /**
  154026. * Sets wether or not the motion blur post-process should be object based or screen based
  154027. */
  154028. set objectBasedMotionBlur(value: boolean);
  154029. /**
  154030. * List of animations for the pipeline (IAnimatable implementation)
  154031. */
  154032. animations: Animation[];
  154033. /**
  154034. * Private members
  154035. */
  154036. private _scene;
  154037. private _currentDepthOfFieldSource;
  154038. private _basePostProcess;
  154039. private _fixedExposure;
  154040. private _currentExposure;
  154041. private _hdrAutoExposure;
  154042. private _hdrCurrentLuminance;
  154043. private _motionStrength;
  154044. private _isObjectBasedMotionBlur;
  154045. private _floatTextureType;
  154046. private _camerasToBeAttached;
  154047. private _ratio;
  154048. private _bloomEnabled;
  154049. private _depthOfFieldEnabled;
  154050. private _vlsEnabled;
  154051. private _lensFlareEnabled;
  154052. private _hdrEnabled;
  154053. private _motionBlurEnabled;
  154054. private _fxaaEnabled;
  154055. private _screenSpaceReflectionsEnabled;
  154056. private _motionBlurSamples;
  154057. private _volumetricLightStepsCount;
  154058. private _samples;
  154059. /**
  154060. * @ignore
  154061. * Specifies if the bloom pipeline is enabled
  154062. */
  154063. get BloomEnabled(): boolean;
  154064. set BloomEnabled(enabled: boolean);
  154065. /**
  154066. * @ignore
  154067. * Specifies if the depth of field pipeline is enabed
  154068. */
  154069. get DepthOfFieldEnabled(): boolean;
  154070. set DepthOfFieldEnabled(enabled: boolean);
  154071. /**
  154072. * @ignore
  154073. * Specifies if the lens flare pipeline is enabed
  154074. */
  154075. get LensFlareEnabled(): boolean;
  154076. set LensFlareEnabled(enabled: boolean);
  154077. /**
  154078. * @ignore
  154079. * Specifies if the HDR pipeline is enabled
  154080. */
  154081. get HDREnabled(): boolean;
  154082. set HDREnabled(enabled: boolean);
  154083. /**
  154084. * @ignore
  154085. * Specifies if the volumetric lights scattering effect is enabled
  154086. */
  154087. get VLSEnabled(): boolean;
  154088. set VLSEnabled(enabled: boolean);
  154089. /**
  154090. * @ignore
  154091. * Specifies if the motion blur effect is enabled
  154092. */
  154093. get MotionBlurEnabled(): boolean;
  154094. set MotionBlurEnabled(enabled: boolean);
  154095. /**
  154096. * Specifies if anti-aliasing is enabled
  154097. */
  154098. get fxaaEnabled(): boolean;
  154099. set fxaaEnabled(enabled: boolean);
  154100. /**
  154101. * Specifies if screen space reflections are enabled.
  154102. */
  154103. get screenSpaceReflectionsEnabled(): boolean;
  154104. set screenSpaceReflectionsEnabled(enabled: boolean);
  154105. /**
  154106. * Specifies the number of steps used to calculate the volumetric lights
  154107. * Typically in interval [50, 200]
  154108. */
  154109. get volumetricLightStepsCount(): number;
  154110. set volumetricLightStepsCount(count: number);
  154111. /**
  154112. * Specifies the number of samples used for the motion blur effect
  154113. * Typically in interval [16, 64]
  154114. */
  154115. get motionBlurSamples(): number;
  154116. set motionBlurSamples(samples: number);
  154117. /**
  154118. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  154119. */
  154120. get samples(): number;
  154121. set samples(sampleCount: number);
  154122. /**
  154123. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  154124. * @constructor
  154125. * @param name The rendering pipeline name
  154126. * @param scene The scene linked to this pipeline
  154127. * @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)
  154128. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  154129. * @param cameras The array of cameras that the rendering pipeline will be attached to
  154130. */
  154131. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  154132. private _buildPipeline;
  154133. private _createDownSampleX4PostProcess;
  154134. private _createBrightPassPostProcess;
  154135. private _createBlurPostProcesses;
  154136. private _createTextureAdderPostProcess;
  154137. private _createVolumetricLightPostProcess;
  154138. private _createLuminancePostProcesses;
  154139. private _createHdrPostProcess;
  154140. private _createLensFlarePostProcess;
  154141. private _createDepthOfFieldPostProcess;
  154142. private _createMotionBlurPostProcess;
  154143. private _getDepthTexture;
  154144. private _disposePostProcesses;
  154145. /**
  154146. * Dispose of the pipeline and stop all post processes
  154147. */
  154148. dispose(): void;
  154149. /**
  154150. * Serialize the rendering pipeline (Used when exporting)
  154151. * @returns the serialized object
  154152. */
  154153. serialize(): any;
  154154. /**
  154155. * Parse the serialized pipeline
  154156. * @param source Source pipeline.
  154157. * @param scene The scene to load the pipeline to.
  154158. * @param rootUrl The URL of the serialized pipeline.
  154159. * @returns An instantiated pipeline from the serialized object.
  154160. */
  154161. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  154162. /**
  154163. * Luminance steps
  154164. */
  154165. static LuminanceSteps: number;
  154166. }
  154167. }
  154168. declare module BABYLON {
  154169. /** @hidden */
  154170. export var stereoscopicInterlacePixelShader: {
  154171. name: string;
  154172. shader: string;
  154173. };
  154174. }
  154175. declare module BABYLON {
  154176. /**
  154177. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  154178. */
  154179. export class StereoscopicInterlacePostProcessI extends PostProcess {
  154180. private _stepSize;
  154181. private _passedProcess;
  154182. /**
  154183. * Gets a string identifying the name of the class
  154184. * @returns "StereoscopicInterlacePostProcessI" string
  154185. */
  154186. getClassName(): string;
  154187. /**
  154188. * Initializes a StereoscopicInterlacePostProcessI
  154189. * @param name The name of the effect.
  154190. * @param rigCameras The rig cameras to be appled to the post process
  154191. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  154192. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  154193. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  154194. * @param engine The engine which the post process will be applied. (default: current engine)
  154195. * @param reusable If the post process can be reused on the same frame. (default: false)
  154196. */
  154197. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  154198. }
  154199. /**
  154200. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  154201. */
  154202. export class StereoscopicInterlacePostProcess extends PostProcess {
  154203. private _stepSize;
  154204. private _passedProcess;
  154205. /**
  154206. * Gets a string identifying the name of the class
  154207. * @returns "StereoscopicInterlacePostProcess" string
  154208. */
  154209. getClassName(): string;
  154210. /**
  154211. * Initializes a StereoscopicInterlacePostProcess
  154212. * @param name The name of the effect.
  154213. * @param rigCameras The rig cameras to be appled to the post process
  154214. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  154215. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  154216. * @param engine The engine which the post process will be applied. (default: current engine)
  154217. * @param reusable If the post process can be reused on the same frame. (default: false)
  154218. */
  154219. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  154220. }
  154221. }
  154222. declare module BABYLON {
  154223. /** @hidden */
  154224. export var tonemapPixelShader: {
  154225. name: string;
  154226. shader: string;
  154227. };
  154228. }
  154229. declare module BABYLON {
  154230. /** Defines operator used for tonemapping */
  154231. export enum TonemappingOperator {
  154232. /** Hable */
  154233. Hable = 0,
  154234. /** Reinhard */
  154235. Reinhard = 1,
  154236. /** HejiDawson */
  154237. HejiDawson = 2,
  154238. /** Photographic */
  154239. Photographic = 3
  154240. }
  154241. /**
  154242. * Defines a post process to apply tone mapping
  154243. */
  154244. export class TonemapPostProcess extends PostProcess {
  154245. private _operator;
  154246. /** Defines the required exposure adjustement */
  154247. exposureAdjustment: number;
  154248. /**
  154249. * Gets a string identifying the name of the class
  154250. * @returns "TonemapPostProcess" string
  154251. */
  154252. getClassName(): string;
  154253. /**
  154254. * Creates a new TonemapPostProcess
  154255. * @param name defines the name of the postprocess
  154256. * @param _operator defines the operator to use
  154257. * @param exposureAdjustment defines the required exposure adjustement
  154258. * @param camera defines the camera to use (can be null)
  154259. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  154260. * @param engine defines the hosting engine (can be ignore if camera is set)
  154261. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  154262. */
  154263. constructor(name: string, _operator: TonemappingOperator,
  154264. /** Defines the required exposure adjustement */
  154265. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  154266. }
  154267. }
  154268. declare module BABYLON {
  154269. /** @hidden */
  154270. export var volumetricLightScatteringPixelShader: {
  154271. name: string;
  154272. shader: string;
  154273. };
  154274. }
  154275. declare module BABYLON {
  154276. /** @hidden */
  154277. export var volumetricLightScatteringPassVertexShader: {
  154278. name: string;
  154279. shader: string;
  154280. };
  154281. }
  154282. declare module BABYLON {
  154283. /** @hidden */
  154284. export var volumetricLightScatteringPassPixelShader: {
  154285. name: string;
  154286. shader: string;
  154287. };
  154288. }
  154289. declare module BABYLON {
  154290. /**
  154291. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  154292. */
  154293. export class VolumetricLightScatteringPostProcess extends PostProcess {
  154294. private _volumetricLightScatteringPass;
  154295. private _volumetricLightScatteringRTT;
  154296. private _viewPort;
  154297. private _screenCoordinates;
  154298. private _cachedDefines;
  154299. /**
  154300. * If not undefined, the mesh position is computed from the attached node position
  154301. */
  154302. attachedNode: {
  154303. position: Vector3;
  154304. };
  154305. /**
  154306. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  154307. */
  154308. customMeshPosition: Vector3;
  154309. /**
  154310. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  154311. */
  154312. useCustomMeshPosition: boolean;
  154313. /**
  154314. * If the post-process should inverse the light scattering direction
  154315. */
  154316. invert: boolean;
  154317. /**
  154318. * The internal mesh used by the post-process
  154319. */
  154320. mesh: Mesh;
  154321. /**
  154322. * @hidden
  154323. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  154324. */
  154325. get useDiffuseColor(): boolean;
  154326. set useDiffuseColor(useDiffuseColor: boolean);
  154327. /**
  154328. * Array containing the excluded meshes not rendered in the internal pass
  154329. */
  154330. excludedMeshes: AbstractMesh[];
  154331. /**
  154332. * Controls the overall intensity of the post-process
  154333. */
  154334. exposure: number;
  154335. /**
  154336. * Dissipates each sample's contribution in range [0, 1]
  154337. */
  154338. decay: number;
  154339. /**
  154340. * Controls the overall intensity of each sample
  154341. */
  154342. weight: number;
  154343. /**
  154344. * Controls the density of each sample
  154345. */
  154346. density: number;
  154347. /**
  154348. * @constructor
  154349. * @param name The post-process name
  154350. * @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)
  154351. * @param camera The camera that the post-process will be attached to
  154352. * @param mesh The mesh used to create the light scattering
  154353. * @param samples The post-process quality, default 100
  154354. * @param samplingModeThe post-process filtering mode
  154355. * @param engine The babylon engine
  154356. * @param reusable If the post-process is reusable
  154357. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  154358. */
  154359. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  154360. /**
  154361. * Returns the string "VolumetricLightScatteringPostProcess"
  154362. * @returns "VolumetricLightScatteringPostProcess"
  154363. */
  154364. getClassName(): string;
  154365. private _isReady;
  154366. /**
  154367. * Sets the new light position for light scattering effect
  154368. * @param position The new custom light position
  154369. */
  154370. setCustomMeshPosition(position: Vector3): void;
  154371. /**
  154372. * Returns the light position for light scattering effect
  154373. * @return Vector3 The custom light position
  154374. */
  154375. getCustomMeshPosition(): Vector3;
  154376. /**
  154377. * Disposes the internal assets and detaches the post-process from the camera
  154378. */
  154379. dispose(camera: Camera): void;
  154380. /**
  154381. * Returns the render target texture used by the post-process
  154382. * @return the render target texture used by the post-process
  154383. */
  154384. getPass(): RenderTargetTexture;
  154385. private _meshExcluded;
  154386. private _createPass;
  154387. private _updateMeshScreenCoordinates;
  154388. /**
  154389. * Creates a default mesh for the Volumeric Light Scattering post-process
  154390. * @param name The mesh name
  154391. * @param scene The scene where to create the mesh
  154392. * @return the default mesh
  154393. */
  154394. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  154395. }
  154396. }
  154397. declare module BABYLON {
  154398. /** @hidden */
  154399. export var screenSpaceCurvaturePixelShader: {
  154400. name: string;
  154401. shader: string;
  154402. };
  154403. }
  154404. declare module BABYLON {
  154405. /**
  154406. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  154407. */
  154408. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  154409. /**
  154410. * Defines how much ridge the curvature effect displays.
  154411. */
  154412. ridge: number;
  154413. /**
  154414. * Defines how much valley the curvature effect displays.
  154415. */
  154416. valley: number;
  154417. private _geometryBufferRenderer;
  154418. /**
  154419. * Gets a string identifying the name of the class
  154420. * @returns "ScreenSpaceCurvaturePostProcess" string
  154421. */
  154422. getClassName(): string;
  154423. /**
  154424. * Creates a new instance ScreenSpaceCurvaturePostProcess
  154425. * @param name The name of the effect.
  154426. * @param scene The scene containing the objects to blur according to their velocity.
  154427. * @param options The required width/height ratio to downsize to before computing the render pass.
  154428. * @param camera The camera to apply the render pass to.
  154429. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  154430. * @param engine The engine which the post process will be applied. (default: current engine)
  154431. * @param reusable If the post process can be reused on the same frame. (default: false)
  154432. * @param textureType Type of textures used when performing the post process. (default: 0)
  154433. * @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)
  154434. */
  154435. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  154436. /**
  154437. * Support test.
  154438. */
  154439. static get IsSupported(): boolean;
  154440. /** @hidden */
  154441. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  154442. }
  154443. }
  154444. declare module BABYLON {
  154445. interface Scene {
  154446. /** @hidden (Backing field) */
  154447. _boundingBoxRenderer: BoundingBoxRenderer;
  154448. /** @hidden (Backing field) */
  154449. _forceShowBoundingBoxes: boolean;
  154450. /**
  154451. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  154452. */
  154453. forceShowBoundingBoxes: boolean;
  154454. /**
  154455. * Gets the bounding box renderer associated with the scene
  154456. * @returns a BoundingBoxRenderer
  154457. */
  154458. getBoundingBoxRenderer(): BoundingBoxRenderer;
  154459. }
  154460. interface AbstractMesh {
  154461. /** @hidden (Backing field) */
  154462. _showBoundingBox: boolean;
  154463. /**
  154464. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  154465. */
  154466. showBoundingBox: boolean;
  154467. }
  154468. /**
  154469. * Component responsible of rendering the bounding box of the meshes in a scene.
  154470. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  154471. */
  154472. export class BoundingBoxRenderer implements ISceneComponent {
  154473. /**
  154474. * The component name helpfull to identify the component in the list of scene components.
  154475. */
  154476. readonly name: string;
  154477. /**
  154478. * The scene the component belongs to.
  154479. */
  154480. scene: Scene;
  154481. /**
  154482. * Color of the bounding box lines placed in front of an object
  154483. */
  154484. frontColor: Color3;
  154485. /**
  154486. * Color of the bounding box lines placed behind an object
  154487. */
  154488. backColor: Color3;
  154489. /**
  154490. * Defines if the renderer should show the back lines or not
  154491. */
  154492. showBackLines: boolean;
  154493. /**
  154494. * Observable raised before rendering a bounding box
  154495. */
  154496. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  154497. /**
  154498. * Observable raised after rendering a bounding box
  154499. */
  154500. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  154501. /**
  154502. * Observable raised after resources are created
  154503. */
  154504. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  154505. /**
  154506. * When false, no bounding boxes will be rendered
  154507. */
  154508. enabled: boolean;
  154509. /**
  154510. * @hidden
  154511. */
  154512. renderList: SmartArray<BoundingBox>;
  154513. private _colorShader;
  154514. private _vertexBuffers;
  154515. private _indexBuffer;
  154516. private _fillIndexBuffer;
  154517. private _fillIndexData;
  154518. /**
  154519. * Instantiates a new bounding box renderer in a scene.
  154520. * @param scene the scene the renderer renders in
  154521. */
  154522. constructor(scene: Scene);
  154523. /**
  154524. * Registers the component in a given scene
  154525. */
  154526. register(): void;
  154527. private _evaluateSubMesh;
  154528. private _preActiveMesh;
  154529. private _prepareResources;
  154530. private _createIndexBuffer;
  154531. /**
  154532. * Rebuilds the elements related to this component in case of
  154533. * context lost for instance.
  154534. */
  154535. rebuild(): void;
  154536. /**
  154537. * @hidden
  154538. */
  154539. reset(): void;
  154540. /**
  154541. * Render the bounding boxes of a specific rendering group
  154542. * @param renderingGroupId defines the rendering group to render
  154543. */
  154544. render(renderingGroupId: number): void;
  154545. /**
  154546. * In case of occlusion queries, we can render the occlusion bounding box through this method
  154547. * @param mesh Define the mesh to render the occlusion bounding box for
  154548. */
  154549. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  154550. /**
  154551. * Dispose and release the resources attached to this renderer.
  154552. */
  154553. dispose(): void;
  154554. }
  154555. }
  154556. declare module BABYLON {
  154557. interface Scene {
  154558. /** @hidden (Backing field) */
  154559. _depthRenderer: {
  154560. [id: string]: DepthRenderer;
  154561. };
  154562. /**
  154563. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  154564. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  154565. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  154566. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  154567. * @returns the created depth renderer
  154568. */
  154569. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  154570. /**
  154571. * Disables a depth renderer for a given camera
  154572. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  154573. */
  154574. disableDepthRenderer(camera?: Nullable<Camera>): void;
  154575. }
  154576. /**
  154577. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  154578. * in several rendering techniques.
  154579. */
  154580. export class DepthRendererSceneComponent implements ISceneComponent {
  154581. /**
  154582. * The component name helpfull to identify the component in the list of scene components.
  154583. */
  154584. readonly name: string;
  154585. /**
  154586. * The scene the component belongs to.
  154587. */
  154588. scene: Scene;
  154589. /**
  154590. * Creates a new instance of the component for the given scene
  154591. * @param scene Defines the scene to register the component in
  154592. */
  154593. constructor(scene: Scene);
  154594. /**
  154595. * Registers the component in a given scene
  154596. */
  154597. register(): void;
  154598. /**
  154599. * Rebuilds the elements related to this component in case of
  154600. * context lost for instance.
  154601. */
  154602. rebuild(): void;
  154603. /**
  154604. * Disposes the component and the associated ressources
  154605. */
  154606. dispose(): void;
  154607. private _gatherRenderTargets;
  154608. private _gatherActiveCameraRenderTargets;
  154609. }
  154610. }
  154611. declare module BABYLON {
  154612. interface AbstractScene {
  154613. /** @hidden (Backing field) */
  154614. _prePassRenderer: Nullable<PrePassRenderer>;
  154615. /**
  154616. * Gets or Sets the current prepass renderer associated to the scene.
  154617. */
  154618. prePassRenderer: Nullable<PrePassRenderer>;
  154619. /**
  154620. * Enables the prepass and associates it with the scene
  154621. * @returns the PrePassRenderer
  154622. */
  154623. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  154624. /**
  154625. * Disables the prepass associated with the scene
  154626. */
  154627. disablePrePassRenderer(): void;
  154628. }
  154629. /**
  154630. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  154631. * in several rendering techniques.
  154632. */
  154633. export class PrePassRendererSceneComponent implements ISceneComponent {
  154634. /**
  154635. * The component name helpful to identify the component in the list of scene components.
  154636. */
  154637. readonly name: string;
  154638. /**
  154639. * The scene the component belongs to.
  154640. */
  154641. scene: Scene;
  154642. /**
  154643. * Creates a new instance of the component for the given scene
  154644. * @param scene Defines the scene to register the component in
  154645. */
  154646. constructor(scene: Scene);
  154647. /**
  154648. * Registers the component in a given scene
  154649. */
  154650. register(): void;
  154651. private _beforeCameraDraw;
  154652. private _afterCameraDraw;
  154653. private _beforeClearStage;
  154654. /**
  154655. * Rebuilds the elements related to this component in case of
  154656. * context lost for instance.
  154657. */
  154658. rebuild(): void;
  154659. /**
  154660. * Disposes the component and the associated ressources
  154661. */
  154662. dispose(): void;
  154663. }
  154664. }
  154665. declare module BABYLON {
  154666. /** @hidden */
  154667. export var fibonacci: {
  154668. name: string;
  154669. shader: string;
  154670. };
  154671. }
  154672. declare module BABYLON {
  154673. /** @hidden */
  154674. export var diffusionProfile: {
  154675. name: string;
  154676. shader: string;
  154677. };
  154678. }
  154679. declare module BABYLON {
  154680. /** @hidden */
  154681. export var subSurfaceScatteringPixelShader: {
  154682. name: string;
  154683. shader: string;
  154684. };
  154685. }
  154686. declare module BABYLON {
  154687. /**
  154688. * Sub surface scattering post process
  154689. */
  154690. export class SubSurfaceScatteringPostProcess extends PostProcess {
  154691. /**
  154692. * Gets a string identifying the name of the class
  154693. * @returns "SubSurfaceScatteringPostProcess" string
  154694. */
  154695. getClassName(): string;
  154696. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  154697. }
  154698. }
  154699. declare module BABYLON {
  154700. /**
  154701. * Contains all parameters needed for the prepass to perform
  154702. * screen space subsurface scattering
  154703. */
  154704. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  154705. /** @hidden */
  154706. static _SceneComponentInitialization: (scene: Scene) => void;
  154707. private _ssDiffusionS;
  154708. private _ssFilterRadii;
  154709. private _ssDiffusionD;
  154710. /**
  154711. * Post process to attach for screen space subsurface scattering
  154712. */
  154713. postProcess: SubSurfaceScatteringPostProcess;
  154714. /**
  154715. * Diffusion profile color for subsurface scattering
  154716. */
  154717. get ssDiffusionS(): number[];
  154718. /**
  154719. * Diffusion profile max color channel value for subsurface scattering
  154720. */
  154721. get ssDiffusionD(): number[];
  154722. /**
  154723. * Diffusion profile filter radius for subsurface scattering
  154724. */
  154725. get ssFilterRadii(): number[];
  154726. /**
  154727. * Is subsurface enabled
  154728. */
  154729. enabled: boolean;
  154730. /**
  154731. * Name of the configuration
  154732. */
  154733. name: string;
  154734. /**
  154735. * Diffusion profile colors for subsurface scattering
  154736. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  154737. * See ...
  154738. * Note that you can only store up to 5 of them
  154739. */
  154740. ssDiffusionProfileColors: Color3[];
  154741. /**
  154742. * Defines the ratio real world => scene units.
  154743. * Used for subsurface scattering
  154744. */
  154745. metersPerUnit: number;
  154746. /**
  154747. * Textures that should be present in the MRT for this effect to work
  154748. */
  154749. readonly texturesRequired: number[];
  154750. private _scene;
  154751. /**
  154752. * Builds a subsurface configuration object
  154753. * @param scene The scene
  154754. */
  154755. constructor(scene: Scene);
  154756. /**
  154757. * Adds a new diffusion profile.
  154758. * Useful for more realistic subsurface scattering on diverse materials.
  154759. * @param color The color of the diffusion profile. Should be the average color of the material.
  154760. * @return The index of the diffusion profile for the material subsurface configuration
  154761. */
  154762. addDiffusionProfile(color: Color3): number;
  154763. /**
  154764. * Creates the sss post process
  154765. * @return The created post process
  154766. */
  154767. createPostProcess(): SubSurfaceScatteringPostProcess;
  154768. /**
  154769. * Deletes all diffusion profiles.
  154770. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  154771. */
  154772. clearAllDiffusionProfiles(): void;
  154773. /**
  154774. * Disposes this object
  154775. */
  154776. dispose(): void;
  154777. /**
  154778. * @hidden
  154779. * https://zero-radiance.github.io/post/sampling-diffusion/
  154780. *
  154781. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  154782. * ------------------------------------------------------------------------------------
  154783. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  154784. * PDF[r, phi, s] = r * R[r, phi, s]
  154785. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  154786. * ------------------------------------------------------------------------------------
  154787. * We importance sample the color channel with the widest scattering distance.
  154788. */
  154789. getDiffusionProfileParameters(color: Color3): number;
  154790. /**
  154791. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  154792. * 'u' is the random number (the value of the CDF): [0, 1).
  154793. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  154794. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  154795. */
  154796. private _sampleBurleyDiffusionProfile;
  154797. }
  154798. }
  154799. declare module BABYLON {
  154800. interface AbstractScene {
  154801. /** @hidden (Backing field) */
  154802. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  154803. /**
  154804. * Gets or Sets the current prepass renderer associated to the scene.
  154805. */
  154806. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  154807. /**
  154808. * Enables the subsurface effect for prepass
  154809. * @returns the SubSurfaceConfiguration
  154810. */
  154811. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  154812. /**
  154813. * Disables the subsurface effect for prepass
  154814. */
  154815. disableSubSurfaceForPrePass(): void;
  154816. }
  154817. /**
  154818. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  154819. * in several rendering techniques.
  154820. */
  154821. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  154822. /**
  154823. * The component name helpful to identify the component in the list of scene components.
  154824. */
  154825. readonly name: string;
  154826. /**
  154827. * The scene the component belongs to.
  154828. */
  154829. scene: Scene;
  154830. /**
  154831. * Creates a new instance of the component for the given scene
  154832. * @param scene Defines the scene to register the component in
  154833. */
  154834. constructor(scene: Scene);
  154835. /**
  154836. * Registers the component in a given scene
  154837. */
  154838. register(): void;
  154839. /**
  154840. * Serializes the component data to the specified json object
  154841. * @param serializationObject The object to serialize to
  154842. */
  154843. serialize(serializationObject: any): void;
  154844. /**
  154845. * Adds all the elements from the container to the scene
  154846. * @param container the container holding the elements
  154847. */
  154848. addFromContainer(container: AbstractScene): void;
  154849. /**
  154850. * Removes all the elements in the container from the scene
  154851. * @param container contains the elements to remove
  154852. * @param dispose if the removed element should be disposed (default: false)
  154853. */
  154854. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  154855. /**
  154856. * Rebuilds the elements related to this component in case of
  154857. * context lost for instance.
  154858. */
  154859. rebuild(): void;
  154860. /**
  154861. * Disposes the component and the associated ressources
  154862. */
  154863. dispose(): void;
  154864. }
  154865. }
  154866. declare module BABYLON {
  154867. /** @hidden */
  154868. export var outlinePixelShader: {
  154869. name: string;
  154870. shader: string;
  154871. };
  154872. }
  154873. declare module BABYLON {
  154874. /** @hidden */
  154875. export var outlineVertexShader: {
  154876. name: string;
  154877. shader: string;
  154878. };
  154879. }
  154880. declare module BABYLON {
  154881. interface Scene {
  154882. /** @hidden */
  154883. _outlineRenderer: OutlineRenderer;
  154884. /**
  154885. * Gets the outline renderer associated with the scene
  154886. * @returns a OutlineRenderer
  154887. */
  154888. getOutlineRenderer(): OutlineRenderer;
  154889. }
  154890. interface AbstractMesh {
  154891. /** @hidden (Backing field) */
  154892. _renderOutline: boolean;
  154893. /**
  154894. * Gets or sets a boolean indicating if the outline must be rendered as well
  154895. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  154896. */
  154897. renderOutline: boolean;
  154898. /** @hidden (Backing field) */
  154899. _renderOverlay: boolean;
  154900. /**
  154901. * Gets or sets a boolean indicating if the overlay must be rendered as well
  154902. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  154903. */
  154904. renderOverlay: boolean;
  154905. }
  154906. /**
  154907. * This class is responsible to draw bothe outline/overlay of meshes.
  154908. * It should not be used directly but through the available method on mesh.
  154909. */
  154910. export class OutlineRenderer implements ISceneComponent {
  154911. /**
  154912. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  154913. */
  154914. private static _StencilReference;
  154915. /**
  154916. * The name of the component. Each component must have a unique name.
  154917. */
  154918. name: string;
  154919. /**
  154920. * The scene the component belongs to.
  154921. */
  154922. scene: Scene;
  154923. /**
  154924. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  154925. */
  154926. zOffset: number;
  154927. private _engine;
  154928. private _effect;
  154929. private _cachedDefines;
  154930. private _savedDepthWrite;
  154931. /**
  154932. * Instantiates a new outline renderer. (There could be only one per scene).
  154933. * @param scene Defines the scene it belongs to
  154934. */
  154935. constructor(scene: Scene);
  154936. /**
  154937. * Register the component to one instance of a scene.
  154938. */
  154939. register(): void;
  154940. /**
  154941. * Rebuilds the elements related to this component in case of
  154942. * context lost for instance.
  154943. */
  154944. rebuild(): void;
  154945. /**
  154946. * Disposes the component and the associated ressources.
  154947. */
  154948. dispose(): void;
  154949. /**
  154950. * Renders the outline in the canvas.
  154951. * @param subMesh Defines the sumesh to render
  154952. * @param batch Defines the batch of meshes in case of instances
  154953. * @param useOverlay Defines if the rendering is for the overlay or the outline
  154954. */
  154955. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  154956. /**
  154957. * Returns whether or not the outline renderer is ready for a given submesh.
  154958. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  154959. * @param subMesh Defines the submesh to check readyness for
  154960. * @param useInstances Defines wheter wee are trying to render instances or not
  154961. * @returns true if ready otherwise false
  154962. */
  154963. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  154964. private _beforeRenderingMesh;
  154965. private _afterRenderingMesh;
  154966. }
  154967. }
  154968. declare module BABYLON {
  154969. /**
  154970. * Defines the basic options interface of a Sprite Frame Source Size.
  154971. */
  154972. export interface ISpriteJSONSpriteSourceSize {
  154973. /**
  154974. * number of the original width of the Frame
  154975. */
  154976. w: number;
  154977. /**
  154978. * number of the original height of the Frame
  154979. */
  154980. h: number;
  154981. }
  154982. /**
  154983. * Defines the basic options interface of a Sprite Frame Data.
  154984. */
  154985. export interface ISpriteJSONSpriteFrameData {
  154986. /**
  154987. * number of the x offset of the Frame
  154988. */
  154989. x: number;
  154990. /**
  154991. * number of the y offset of the Frame
  154992. */
  154993. y: number;
  154994. /**
  154995. * number of the width of the Frame
  154996. */
  154997. w: number;
  154998. /**
  154999. * number of the height of the Frame
  155000. */
  155001. h: number;
  155002. }
  155003. /**
  155004. * Defines the basic options interface of a JSON Sprite.
  155005. */
  155006. export interface ISpriteJSONSprite {
  155007. /**
  155008. * string name of the Frame
  155009. */
  155010. filename: string;
  155011. /**
  155012. * ISpriteJSONSpriteFrame basic object of the frame data
  155013. */
  155014. frame: ISpriteJSONSpriteFrameData;
  155015. /**
  155016. * boolean to flag is the frame was rotated.
  155017. */
  155018. rotated: boolean;
  155019. /**
  155020. * boolean to flag is the frame was trimmed.
  155021. */
  155022. trimmed: boolean;
  155023. /**
  155024. * ISpriteJSONSpriteFrame basic object of the source data
  155025. */
  155026. spriteSourceSize: ISpriteJSONSpriteFrameData;
  155027. /**
  155028. * ISpriteJSONSpriteFrame basic object of the source data
  155029. */
  155030. sourceSize: ISpriteJSONSpriteSourceSize;
  155031. }
  155032. /**
  155033. * Defines the basic options interface of a JSON atlas.
  155034. */
  155035. export interface ISpriteJSONAtlas {
  155036. /**
  155037. * Array of objects that contain the frame data.
  155038. */
  155039. frames: Array<ISpriteJSONSprite>;
  155040. /**
  155041. * object basic object containing the sprite meta data.
  155042. */
  155043. meta?: object;
  155044. }
  155045. }
  155046. declare module BABYLON {
  155047. /** @hidden */
  155048. export var spriteMapPixelShader: {
  155049. name: string;
  155050. shader: string;
  155051. };
  155052. }
  155053. declare module BABYLON {
  155054. /** @hidden */
  155055. export var spriteMapVertexShader: {
  155056. name: string;
  155057. shader: string;
  155058. };
  155059. }
  155060. declare module BABYLON {
  155061. /**
  155062. * Defines the basic options interface of a SpriteMap
  155063. */
  155064. export interface ISpriteMapOptions {
  155065. /**
  155066. * Vector2 of the number of cells in the grid.
  155067. */
  155068. stageSize?: Vector2;
  155069. /**
  155070. * Vector2 of the size of the output plane in World Units.
  155071. */
  155072. outputSize?: Vector2;
  155073. /**
  155074. * Vector3 of the position of the output plane in World Units.
  155075. */
  155076. outputPosition?: Vector3;
  155077. /**
  155078. * Vector3 of the rotation of the output plane.
  155079. */
  155080. outputRotation?: Vector3;
  155081. /**
  155082. * number of layers that the system will reserve in resources.
  155083. */
  155084. layerCount?: number;
  155085. /**
  155086. * number of max animation frames a single cell will reserve in resources.
  155087. */
  155088. maxAnimationFrames?: number;
  155089. /**
  155090. * number cell index of the base tile when the system compiles.
  155091. */
  155092. baseTile?: number;
  155093. /**
  155094. * boolean flip the sprite after its been repositioned by the framing data.
  155095. */
  155096. flipU?: boolean;
  155097. /**
  155098. * Vector3 scalar of the global RGB values of the SpriteMap.
  155099. */
  155100. colorMultiply?: Vector3;
  155101. }
  155102. /**
  155103. * Defines the IDisposable interface in order to be cleanable from resources.
  155104. */
  155105. export interface ISpriteMap extends IDisposable {
  155106. /**
  155107. * String name of the SpriteMap.
  155108. */
  155109. name: string;
  155110. /**
  155111. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  155112. */
  155113. atlasJSON: ISpriteJSONAtlas;
  155114. /**
  155115. * Texture of the SpriteMap.
  155116. */
  155117. spriteSheet: Texture;
  155118. /**
  155119. * The parameters to initialize the SpriteMap with.
  155120. */
  155121. options: ISpriteMapOptions;
  155122. }
  155123. /**
  155124. * Class used to manage a grid restricted sprite deployment on an Output plane.
  155125. */
  155126. export class SpriteMap implements ISpriteMap {
  155127. /** The Name of the spriteMap */
  155128. name: string;
  155129. /** The JSON file with the frame and meta data */
  155130. atlasJSON: ISpriteJSONAtlas;
  155131. /** The systems Sprite Sheet Texture */
  155132. spriteSheet: Texture;
  155133. /** Arguments passed with the Constructor */
  155134. options: ISpriteMapOptions;
  155135. /** Public Sprite Storage array, parsed from atlasJSON */
  155136. sprites: Array<ISpriteJSONSprite>;
  155137. /** Returns the Number of Sprites in the System */
  155138. get spriteCount(): number;
  155139. /** Returns the Position of Output Plane*/
  155140. get position(): Vector3;
  155141. /** Returns the Position of Output Plane*/
  155142. set position(v: Vector3);
  155143. /** Returns the Rotation of Output Plane*/
  155144. get rotation(): Vector3;
  155145. /** Returns the Rotation of Output Plane*/
  155146. set rotation(v: Vector3);
  155147. /** Sets the AnimationMap*/
  155148. get animationMap(): RawTexture;
  155149. /** Sets the AnimationMap*/
  155150. set animationMap(v: RawTexture);
  155151. /** Scene that the SpriteMap was created in */
  155152. private _scene;
  155153. /** Texture Buffer of Float32 that holds tile frame data*/
  155154. private _frameMap;
  155155. /** Texture Buffers of Float32 that holds tileMap data*/
  155156. private _tileMaps;
  155157. /** Texture Buffer of Float32 that holds Animation Data*/
  155158. private _animationMap;
  155159. /** Custom ShaderMaterial Central to the System*/
  155160. private _material;
  155161. /** Custom ShaderMaterial Central to the System*/
  155162. private _output;
  155163. /** Systems Time Ticker*/
  155164. private _time;
  155165. /**
  155166. * Creates a new SpriteMap
  155167. * @param name defines the SpriteMaps Name
  155168. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  155169. * @param spriteSheet is the Texture that the Sprites are on.
  155170. * @param options a basic deployment configuration
  155171. * @param scene The Scene that the map is deployed on
  155172. */
  155173. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  155174. /**
  155175. * Returns tileID location
  155176. * @returns Vector2 the cell position ID
  155177. */
  155178. getTileID(): Vector2;
  155179. /**
  155180. * Gets the UV location of the mouse over the SpriteMap.
  155181. * @returns Vector2 the UV position of the mouse interaction
  155182. */
  155183. getMousePosition(): Vector2;
  155184. /**
  155185. * Creates the "frame" texture Buffer
  155186. * -------------------------------------
  155187. * Structure of frames
  155188. * "filename": "Falling-Water-2.png",
  155189. * "frame": {"x":69,"y":103,"w":24,"h":32},
  155190. * "rotated": true,
  155191. * "trimmed": true,
  155192. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  155193. * "sourceSize": {"w":32,"h":32}
  155194. * @returns RawTexture of the frameMap
  155195. */
  155196. private _createFrameBuffer;
  155197. /**
  155198. * Creates the tileMap texture Buffer
  155199. * @param buffer normally and array of numbers, or a false to generate from scratch
  155200. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  155201. * @returns RawTexture of the tileMap
  155202. */
  155203. private _createTileBuffer;
  155204. /**
  155205. * Modifies the data of the tileMaps
  155206. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  155207. * @param pos is the iVector2 Coordinates of the Tile
  155208. * @param tile The SpriteIndex of the new Tile
  155209. */
  155210. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  155211. /**
  155212. * Creates the animationMap texture Buffer
  155213. * @param buffer normally and array of numbers, or a false to generate from scratch
  155214. * @returns RawTexture of the animationMap
  155215. */
  155216. private _createTileAnimationBuffer;
  155217. /**
  155218. * Modifies the data of the animationMap
  155219. * @param cellID is the Index of the Sprite
  155220. * @param _frame is the target Animation frame
  155221. * @param toCell is the Target Index of the next frame of the animation
  155222. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  155223. * @param speed is a global scalar of the time variable on the map.
  155224. */
  155225. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  155226. /**
  155227. * Exports the .tilemaps file
  155228. */
  155229. saveTileMaps(): void;
  155230. /**
  155231. * Imports the .tilemaps file
  155232. * @param url of the .tilemaps file
  155233. */
  155234. loadTileMaps(url: string): void;
  155235. /**
  155236. * Release associated resources
  155237. */
  155238. dispose(): void;
  155239. }
  155240. }
  155241. declare module BABYLON {
  155242. /**
  155243. * Class used to manage multiple sprites of different sizes on the same spritesheet
  155244. * @see https://doc.babylonjs.com/babylon101/sprites
  155245. */
  155246. export class SpritePackedManager extends SpriteManager {
  155247. /** defines the packed manager's name */
  155248. name: string;
  155249. /**
  155250. * Creates a new sprite manager from a packed sprite sheet
  155251. * @param name defines the manager's name
  155252. * @param imgUrl defines the sprite sheet url
  155253. * @param capacity defines the maximum allowed number of sprites
  155254. * @param scene defines the hosting scene
  155255. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  155256. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  155257. * @param samplingMode defines the smapling mode to use with spritesheet
  155258. * @param fromPacked set to true; do not alter
  155259. */
  155260. constructor(
  155261. /** defines the packed manager's name */
  155262. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  155263. }
  155264. }
  155265. declare module BABYLON {
  155266. /**
  155267. * Defines the list of states available for a task inside a AssetsManager
  155268. */
  155269. export enum AssetTaskState {
  155270. /**
  155271. * Initialization
  155272. */
  155273. INIT = 0,
  155274. /**
  155275. * Running
  155276. */
  155277. RUNNING = 1,
  155278. /**
  155279. * Done
  155280. */
  155281. DONE = 2,
  155282. /**
  155283. * Error
  155284. */
  155285. ERROR = 3
  155286. }
  155287. /**
  155288. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  155289. */
  155290. export abstract class AbstractAssetTask {
  155291. /**
  155292. * Task name
  155293. */ name: string;
  155294. /**
  155295. * Callback called when the task is successful
  155296. */
  155297. onSuccess: (task: any) => void;
  155298. /**
  155299. * Callback called when the task is not successful
  155300. */
  155301. onError: (task: any, message?: string, exception?: any) => void;
  155302. /**
  155303. * Creates a new AssetsManager
  155304. * @param name defines the name of the task
  155305. */
  155306. constructor(
  155307. /**
  155308. * Task name
  155309. */ name: string);
  155310. private _isCompleted;
  155311. private _taskState;
  155312. private _errorObject;
  155313. /**
  155314. * Get if the task is completed
  155315. */
  155316. get isCompleted(): boolean;
  155317. /**
  155318. * Gets the current state of the task
  155319. */
  155320. get taskState(): AssetTaskState;
  155321. /**
  155322. * Gets the current error object (if task is in error)
  155323. */
  155324. get errorObject(): {
  155325. message?: string;
  155326. exception?: any;
  155327. };
  155328. /**
  155329. * Internal only
  155330. * @hidden
  155331. */
  155332. _setErrorObject(message?: string, exception?: any): void;
  155333. /**
  155334. * Execute the current task
  155335. * @param scene defines the scene where you want your assets to be loaded
  155336. * @param onSuccess is a callback called when the task is successfully executed
  155337. * @param onError is a callback called if an error occurs
  155338. */
  155339. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155340. /**
  155341. * Execute the current task
  155342. * @param scene defines the scene where you want your assets to be loaded
  155343. * @param onSuccess is a callback called when the task is successfully executed
  155344. * @param onError is a callback called if an error occurs
  155345. */
  155346. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155347. /**
  155348. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  155349. * This can be used with failed tasks that have the reason for failure fixed.
  155350. */
  155351. reset(): void;
  155352. private onErrorCallback;
  155353. private onDoneCallback;
  155354. }
  155355. /**
  155356. * Define the interface used by progress events raised during assets loading
  155357. */
  155358. export interface IAssetsProgressEvent {
  155359. /**
  155360. * Defines the number of remaining tasks to process
  155361. */
  155362. remainingCount: number;
  155363. /**
  155364. * Defines the total number of tasks
  155365. */
  155366. totalCount: number;
  155367. /**
  155368. * Defines the task that was just processed
  155369. */
  155370. task: AbstractAssetTask;
  155371. }
  155372. /**
  155373. * Class used to share progress information about assets loading
  155374. */
  155375. export class AssetsProgressEvent implements IAssetsProgressEvent {
  155376. /**
  155377. * Defines the number of remaining tasks to process
  155378. */
  155379. remainingCount: number;
  155380. /**
  155381. * Defines the total number of tasks
  155382. */
  155383. totalCount: number;
  155384. /**
  155385. * Defines the task that was just processed
  155386. */
  155387. task: AbstractAssetTask;
  155388. /**
  155389. * Creates a AssetsProgressEvent
  155390. * @param remainingCount defines the number of remaining tasks to process
  155391. * @param totalCount defines the total number of tasks
  155392. * @param task defines the task that was just processed
  155393. */
  155394. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  155395. }
  155396. /**
  155397. * Define a task used by AssetsManager to load assets into a container
  155398. */
  155399. export class ContainerAssetTask extends AbstractAssetTask {
  155400. /**
  155401. * Defines the name of the task
  155402. */
  155403. name: string;
  155404. /**
  155405. * Defines the list of mesh's names you want to load
  155406. */
  155407. meshesNames: any;
  155408. /**
  155409. * Defines the root url to use as a base to load your meshes and associated resources
  155410. */
  155411. rootUrl: string;
  155412. /**
  155413. * Defines the filename or File of the scene to load from
  155414. */
  155415. sceneFilename: string | File;
  155416. /**
  155417. * Get the loaded asset container
  155418. */
  155419. loadedContainer: AssetContainer;
  155420. /**
  155421. * Gets the list of loaded meshes
  155422. */
  155423. loadedMeshes: Array<AbstractMesh>;
  155424. /**
  155425. * Gets the list of loaded particle systems
  155426. */
  155427. loadedParticleSystems: Array<IParticleSystem>;
  155428. /**
  155429. * Gets the list of loaded skeletons
  155430. */
  155431. loadedSkeletons: Array<Skeleton>;
  155432. /**
  155433. * Gets the list of loaded animation groups
  155434. */
  155435. loadedAnimationGroups: Array<AnimationGroup>;
  155436. /**
  155437. * Callback called when the task is successful
  155438. */
  155439. onSuccess: (task: ContainerAssetTask) => void;
  155440. /**
  155441. * Callback called when the task is successful
  155442. */
  155443. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  155444. /**
  155445. * Creates a new ContainerAssetTask
  155446. * @param name defines the name of the task
  155447. * @param meshesNames defines the list of mesh's names you want to load
  155448. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  155449. * @param sceneFilename defines the filename or File of the scene to load from
  155450. */
  155451. constructor(
  155452. /**
  155453. * Defines the name of the task
  155454. */
  155455. name: string,
  155456. /**
  155457. * Defines the list of mesh's names you want to load
  155458. */
  155459. meshesNames: any,
  155460. /**
  155461. * Defines the root url to use as a base to load your meshes and associated resources
  155462. */
  155463. rootUrl: string,
  155464. /**
  155465. * Defines the filename or File of the scene to load from
  155466. */
  155467. sceneFilename: string | File);
  155468. /**
  155469. * Execute the current task
  155470. * @param scene defines the scene where you want your assets to be loaded
  155471. * @param onSuccess is a callback called when the task is successfully executed
  155472. * @param onError is a callback called if an error occurs
  155473. */
  155474. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155475. }
  155476. /**
  155477. * Define a task used by AssetsManager to load meshes
  155478. */
  155479. export class MeshAssetTask extends AbstractAssetTask {
  155480. /**
  155481. * Defines the name of the task
  155482. */
  155483. name: string;
  155484. /**
  155485. * Defines the list of mesh's names you want to load
  155486. */
  155487. meshesNames: any;
  155488. /**
  155489. * Defines the root url to use as a base to load your meshes and associated resources
  155490. */
  155491. rootUrl: string;
  155492. /**
  155493. * Defines the filename or File of the scene to load from
  155494. */
  155495. sceneFilename: string | File;
  155496. /**
  155497. * Gets the list of loaded meshes
  155498. */
  155499. loadedMeshes: Array<AbstractMesh>;
  155500. /**
  155501. * Gets the list of loaded particle systems
  155502. */
  155503. loadedParticleSystems: Array<IParticleSystem>;
  155504. /**
  155505. * Gets the list of loaded skeletons
  155506. */
  155507. loadedSkeletons: Array<Skeleton>;
  155508. /**
  155509. * Gets the list of loaded animation groups
  155510. */
  155511. loadedAnimationGroups: Array<AnimationGroup>;
  155512. /**
  155513. * Callback called when the task is successful
  155514. */
  155515. onSuccess: (task: MeshAssetTask) => void;
  155516. /**
  155517. * Callback called when the task is successful
  155518. */
  155519. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  155520. /**
  155521. * Creates a new MeshAssetTask
  155522. * @param name defines the name of the task
  155523. * @param meshesNames defines the list of mesh's names you want to load
  155524. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  155525. * @param sceneFilename defines the filename or File of the scene to load from
  155526. */
  155527. constructor(
  155528. /**
  155529. * Defines the name of the task
  155530. */
  155531. name: string,
  155532. /**
  155533. * Defines the list of mesh's names you want to load
  155534. */
  155535. meshesNames: any,
  155536. /**
  155537. * Defines the root url to use as a base to load your meshes and associated resources
  155538. */
  155539. rootUrl: string,
  155540. /**
  155541. * Defines the filename or File of the scene to load from
  155542. */
  155543. sceneFilename: string | File);
  155544. /**
  155545. * Execute the current task
  155546. * @param scene defines the scene where you want your assets to be loaded
  155547. * @param onSuccess is a callback called when the task is successfully executed
  155548. * @param onError is a callback called if an error occurs
  155549. */
  155550. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155551. }
  155552. /**
  155553. * Define a task used by AssetsManager to load text content
  155554. */
  155555. export class TextFileAssetTask extends AbstractAssetTask {
  155556. /**
  155557. * Defines the name of the task
  155558. */
  155559. name: string;
  155560. /**
  155561. * Defines the location of the file to load
  155562. */
  155563. url: string;
  155564. /**
  155565. * Gets the loaded text string
  155566. */
  155567. text: string;
  155568. /**
  155569. * Callback called when the task is successful
  155570. */
  155571. onSuccess: (task: TextFileAssetTask) => void;
  155572. /**
  155573. * Callback called when the task is successful
  155574. */
  155575. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  155576. /**
  155577. * Creates a new TextFileAssetTask object
  155578. * @param name defines the name of the task
  155579. * @param url defines the location of the file to load
  155580. */
  155581. constructor(
  155582. /**
  155583. * Defines the name of the task
  155584. */
  155585. name: string,
  155586. /**
  155587. * Defines the location of the file to load
  155588. */
  155589. url: string);
  155590. /**
  155591. * Execute the current task
  155592. * @param scene defines the scene where you want your assets to be loaded
  155593. * @param onSuccess is a callback called when the task is successfully executed
  155594. * @param onError is a callback called if an error occurs
  155595. */
  155596. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155597. }
  155598. /**
  155599. * Define a task used by AssetsManager to load binary data
  155600. */
  155601. export class BinaryFileAssetTask extends AbstractAssetTask {
  155602. /**
  155603. * Defines the name of the task
  155604. */
  155605. name: string;
  155606. /**
  155607. * Defines the location of the file to load
  155608. */
  155609. url: string;
  155610. /**
  155611. * Gets the lodaded data (as an array buffer)
  155612. */
  155613. data: ArrayBuffer;
  155614. /**
  155615. * Callback called when the task is successful
  155616. */
  155617. onSuccess: (task: BinaryFileAssetTask) => void;
  155618. /**
  155619. * Callback called when the task is successful
  155620. */
  155621. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  155622. /**
  155623. * Creates a new BinaryFileAssetTask object
  155624. * @param name defines the name of the new task
  155625. * @param url defines the location of the file to load
  155626. */
  155627. constructor(
  155628. /**
  155629. * Defines the name of the task
  155630. */
  155631. name: string,
  155632. /**
  155633. * Defines the location of the file to load
  155634. */
  155635. url: string);
  155636. /**
  155637. * Execute the current task
  155638. * @param scene defines the scene where you want your assets to be loaded
  155639. * @param onSuccess is a callback called when the task is successfully executed
  155640. * @param onError is a callback called if an error occurs
  155641. */
  155642. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155643. }
  155644. /**
  155645. * Define a task used by AssetsManager to load images
  155646. */
  155647. export class ImageAssetTask extends AbstractAssetTask {
  155648. /**
  155649. * Defines the name of the task
  155650. */
  155651. name: string;
  155652. /**
  155653. * Defines the location of the image to load
  155654. */
  155655. url: string;
  155656. /**
  155657. * Gets the loaded images
  155658. */
  155659. image: HTMLImageElement;
  155660. /**
  155661. * Callback called when the task is successful
  155662. */
  155663. onSuccess: (task: ImageAssetTask) => void;
  155664. /**
  155665. * Callback called when the task is successful
  155666. */
  155667. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  155668. /**
  155669. * Creates a new ImageAssetTask
  155670. * @param name defines the name of the task
  155671. * @param url defines the location of the image to load
  155672. */
  155673. constructor(
  155674. /**
  155675. * Defines the name of the task
  155676. */
  155677. name: string,
  155678. /**
  155679. * Defines the location of the image to load
  155680. */
  155681. url: string);
  155682. /**
  155683. * Execute the current task
  155684. * @param scene defines the scene where you want your assets to be loaded
  155685. * @param onSuccess is a callback called when the task is successfully executed
  155686. * @param onError is a callback called if an error occurs
  155687. */
  155688. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155689. }
  155690. /**
  155691. * Defines the interface used by texture loading tasks
  155692. */
  155693. export interface ITextureAssetTask<TEX extends BaseTexture> {
  155694. /**
  155695. * Gets the loaded texture
  155696. */
  155697. texture: TEX;
  155698. }
  155699. /**
  155700. * Define a task used by AssetsManager to load 2D textures
  155701. */
  155702. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  155703. /**
  155704. * Defines the name of the task
  155705. */
  155706. name: string;
  155707. /**
  155708. * Defines the location of the file to load
  155709. */
  155710. url: string;
  155711. /**
  155712. * Defines if mipmap should not be generated (default is false)
  155713. */
  155714. noMipmap?: boolean | undefined;
  155715. /**
  155716. * Defines if texture must be inverted on Y axis (default is true)
  155717. */
  155718. invertY: boolean;
  155719. /**
  155720. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  155721. */
  155722. samplingMode: number;
  155723. /**
  155724. * Gets the loaded texture
  155725. */
  155726. texture: Texture;
  155727. /**
  155728. * Callback called when the task is successful
  155729. */
  155730. onSuccess: (task: TextureAssetTask) => void;
  155731. /**
  155732. * Callback called when the task is successful
  155733. */
  155734. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  155735. /**
  155736. * Creates a new TextureAssetTask object
  155737. * @param name defines the name of the task
  155738. * @param url defines the location of the file to load
  155739. * @param noMipmap defines if mipmap should not be generated (default is false)
  155740. * @param invertY defines if texture must be inverted on Y axis (default is true)
  155741. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  155742. */
  155743. constructor(
  155744. /**
  155745. * Defines the name of the task
  155746. */
  155747. name: string,
  155748. /**
  155749. * Defines the location of the file to load
  155750. */
  155751. url: string,
  155752. /**
  155753. * Defines if mipmap should not be generated (default is false)
  155754. */
  155755. noMipmap?: boolean | undefined,
  155756. /**
  155757. * Defines if texture must be inverted on Y axis (default is true)
  155758. */
  155759. invertY?: boolean,
  155760. /**
  155761. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  155762. */
  155763. samplingMode?: number);
  155764. /**
  155765. * Execute the current task
  155766. * @param scene defines the scene where you want your assets to be loaded
  155767. * @param onSuccess is a callback called when the task is successfully executed
  155768. * @param onError is a callback called if an error occurs
  155769. */
  155770. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155771. }
  155772. /**
  155773. * Define a task used by AssetsManager to load cube textures
  155774. */
  155775. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  155776. /**
  155777. * Defines the name of the task
  155778. */
  155779. name: string;
  155780. /**
  155781. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  155782. */
  155783. url: string;
  155784. /**
  155785. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  155786. */
  155787. extensions?: string[] | undefined;
  155788. /**
  155789. * Defines if mipmaps should not be generated (default is false)
  155790. */
  155791. noMipmap?: boolean | undefined;
  155792. /**
  155793. * Defines the explicit list of files (undefined by default)
  155794. */
  155795. files?: string[] | undefined;
  155796. /**
  155797. * Gets the loaded texture
  155798. */
  155799. texture: CubeTexture;
  155800. /**
  155801. * Callback called when the task is successful
  155802. */
  155803. onSuccess: (task: CubeTextureAssetTask) => void;
  155804. /**
  155805. * Callback called when the task is successful
  155806. */
  155807. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  155808. /**
  155809. * Creates a new CubeTextureAssetTask
  155810. * @param name defines the name of the task
  155811. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  155812. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  155813. * @param noMipmap defines if mipmaps should not be generated (default is false)
  155814. * @param files defines the explicit list of files (undefined by default)
  155815. */
  155816. constructor(
  155817. /**
  155818. * Defines the name of the task
  155819. */
  155820. name: string,
  155821. /**
  155822. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  155823. */
  155824. url: string,
  155825. /**
  155826. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  155827. */
  155828. extensions?: string[] | undefined,
  155829. /**
  155830. * Defines if mipmaps should not be generated (default is false)
  155831. */
  155832. noMipmap?: boolean | undefined,
  155833. /**
  155834. * Defines the explicit list of files (undefined by default)
  155835. */
  155836. files?: string[] | undefined);
  155837. /**
  155838. * Execute the current task
  155839. * @param scene defines the scene where you want your assets to be loaded
  155840. * @param onSuccess is a callback called when the task is successfully executed
  155841. * @param onError is a callback called if an error occurs
  155842. */
  155843. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155844. }
  155845. /**
  155846. * Define a task used by AssetsManager to load HDR cube textures
  155847. */
  155848. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  155849. /**
  155850. * Defines the name of the task
  155851. */
  155852. name: string;
  155853. /**
  155854. * Defines the location of the file to load
  155855. */
  155856. url: string;
  155857. /**
  155858. * Defines the desired size (the more it increases the longer the generation will be)
  155859. */
  155860. size: number;
  155861. /**
  155862. * Defines if mipmaps should not be generated (default is false)
  155863. */
  155864. noMipmap: boolean;
  155865. /**
  155866. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  155867. */
  155868. generateHarmonics: boolean;
  155869. /**
  155870. * 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)
  155871. */
  155872. gammaSpace: boolean;
  155873. /**
  155874. * Internal Use Only
  155875. */
  155876. reserved: boolean;
  155877. /**
  155878. * Gets the loaded texture
  155879. */
  155880. texture: HDRCubeTexture;
  155881. /**
  155882. * Callback called when the task is successful
  155883. */
  155884. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  155885. /**
  155886. * Callback called when the task is successful
  155887. */
  155888. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  155889. /**
  155890. * Creates a new HDRCubeTextureAssetTask object
  155891. * @param name defines the name of the task
  155892. * @param url defines the location of the file to load
  155893. * @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.
  155894. * @param noMipmap defines if mipmaps should not be generated (default is false)
  155895. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  155896. * @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)
  155897. * @param reserved Internal use only
  155898. */
  155899. constructor(
  155900. /**
  155901. * Defines the name of the task
  155902. */
  155903. name: string,
  155904. /**
  155905. * Defines the location of the file to load
  155906. */
  155907. url: string,
  155908. /**
  155909. * Defines the desired size (the more it increases the longer the generation will be)
  155910. */
  155911. size: number,
  155912. /**
  155913. * Defines if mipmaps should not be generated (default is false)
  155914. */
  155915. noMipmap?: boolean,
  155916. /**
  155917. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  155918. */
  155919. generateHarmonics?: boolean,
  155920. /**
  155921. * 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)
  155922. */
  155923. gammaSpace?: boolean,
  155924. /**
  155925. * Internal Use Only
  155926. */
  155927. reserved?: boolean);
  155928. /**
  155929. * Execute the current task
  155930. * @param scene defines the scene where you want your assets to be loaded
  155931. * @param onSuccess is a callback called when the task is successfully executed
  155932. * @param onError is a callback called if an error occurs
  155933. */
  155934. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155935. }
  155936. /**
  155937. * Define a task used by AssetsManager to load Equirectangular cube textures
  155938. */
  155939. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  155940. /**
  155941. * Defines the name of the task
  155942. */
  155943. name: string;
  155944. /**
  155945. * Defines the location of the file to load
  155946. */
  155947. url: string;
  155948. /**
  155949. * Defines the desired size (the more it increases the longer the generation will be)
  155950. */
  155951. size: number;
  155952. /**
  155953. * Defines if mipmaps should not be generated (default is false)
  155954. */
  155955. noMipmap: boolean;
  155956. /**
  155957. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  155958. * but the standard material would require them in Gamma space) (default is true)
  155959. */
  155960. gammaSpace: boolean;
  155961. /**
  155962. * Gets the loaded texture
  155963. */
  155964. texture: EquiRectangularCubeTexture;
  155965. /**
  155966. * Callback called when the task is successful
  155967. */
  155968. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  155969. /**
  155970. * Callback called when the task is successful
  155971. */
  155972. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  155973. /**
  155974. * Creates a new EquiRectangularCubeTextureAssetTask object
  155975. * @param name defines the name of the task
  155976. * @param url defines the location of the file to load
  155977. * @param size defines the desired size (the more it increases the longer the generation will be)
  155978. * If the size is omitted this implies you are using a preprocessed cubemap.
  155979. * @param noMipmap defines if mipmaps should not be generated (default is false)
  155980. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  155981. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  155982. * (default is true)
  155983. */
  155984. constructor(
  155985. /**
  155986. * Defines the name of the task
  155987. */
  155988. name: string,
  155989. /**
  155990. * Defines the location of the file to load
  155991. */
  155992. url: string,
  155993. /**
  155994. * Defines the desired size (the more it increases the longer the generation will be)
  155995. */
  155996. size: number,
  155997. /**
  155998. * Defines if mipmaps should not be generated (default is false)
  155999. */
  156000. noMipmap?: boolean,
  156001. /**
  156002. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  156003. * but the standard material would require them in Gamma space) (default is true)
  156004. */
  156005. gammaSpace?: boolean);
  156006. /**
  156007. * Execute the current task
  156008. * @param scene defines the scene where you want your assets to be loaded
  156009. * @param onSuccess is a callback called when the task is successfully executed
  156010. * @param onError is a callback called if an error occurs
  156011. */
  156012. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156013. }
  156014. /**
  156015. * This class can be used to easily import assets into a scene
  156016. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  156017. */
  156018. export class AssetsManager {
  156019. private _scene;
  156020. private _isLoading;
  156021. protected _tasks: AbstractAssetTask[];
  156022. protected _waitingTasksCount: number;
  156023. protected _totalTasksCount: number;
  156024. /**
  156025. * Callback called when all tasks are processed
  156026. */
  156027. onFinish: (tasks: AbstractAssetTask[]) => void;
  156028. /**
  156029. * Callback called when a task is successful
  156030. */
  156031. onTaskSuccess: (task: AbstractAssetTask) => void;
  156032. /**
  156033. * Callback called when a task had an error
  156034. */
  156035. onTaskError: (task: AbstractAssetTask) => void;
  156036. /**
  156037. * Callback called when a task is done (whatever the result is)
  156038. */
  156039. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  156040. /**
  156041. * Observable called when all tasks are processed
  156042. */
  156043. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  156044. /**
  156045. * Observable called when a task had an error
  156046. */
  156047. onTaskErrorObservable: Observable<AbstractAssetTask>;
  156048. /**
  156049. * Observable called when all tasks were executed
  156050. */
  156051. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  156052. /**
  156053. * Observable called when a task is done (whatever the result is)
  156054. */
  156055. onProgressObservable: Observable<IAssetsProgressEvent>;
  156056. /**
  156057. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  156058. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  156059. */
  156060. useDefaultLoadingScreen: boolean;
  156061. /**
  156062. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  156063. * when all assets have been downloaded.
  156064. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  156065. */
  156066. autoHideLoadingUI: boolean;
  156067. /**
  156068. * Creates a new AssetsManager
  156069. * @param scene defines the scene to work on
  156070. */
  156071. constructor(scene: Scene);
  156072. /**
  156073. * Add a ContainerAssetTask to the list of active tasks
  156074. * @param taskName defines the name of the new task
  156075. * @param meshesNames defines the name of meshes to load
  156076. * @param rootUrl defines the root url to use to locate files
  156077. * @param sceneFilename defines the filename of the scene file
  156078. * @returns a new ContainerAssetTask object
  156079. */
  156080. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  156081. /**
  156082. * Add a MeshAssetTask to the list of active tasks
  156083. * @param taskName defines the name of the new task
  156084. * @param meshesNames defines the name of meshes to load
  156085. * @param rootUrl defines the root url to use to locate files
  156086. * @param sceneFilename defines the filename of the scene file
  156087. * @returns a new MeshAssetTask object
  156088. */
  156089. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  156090. /**
  156091. * Add a TextFileAssetTask to the list of active tasks
  156092. * @param taskName defines the name of the new task
  156093. * @param url defines the url of the file to load
  156094. * @returns a new TextFileAssetTask object
  156095. */
  156096. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  156097. /**
  156098. * Add a BinaryFileAssetTask to the list of active tasks
  156099. * @param taskName defines the name of the new task
  156100. * @param url defines the url of the file to load
  156101. * @returns a new BinaryFileAssetTask object
  156102. */
  156103. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  156104. /**
  156105. * Add a ImageAssetTask to the list of active tasks
  156106. * @param taskName defines the name of the new task
  156107. * @param url defines the url of the file to load
  156108. * @returns a new ImageAssetTask object
  156109. */
  156110. addImageTask(taskName: string, url: string): ImageAssetTask;
  156111. /**
  156112. * Add a TextureAssetTask to the list of active tasks
  156113. * @param taskName defines the name of the new task
  156114. * @param url defines the url of the file to load
  156115. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  156116. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  156117. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  156118. * @returns a new TextureAssetTask object
  156119. */
  156120. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  156121. /**
  156122. * Add a CubeTextureAssetTask to the list of active tasks
  156123. * @param taskName defines the name of the new task
  156124. * @param url defines the url of the file to load
  156125. * @param extensions defines the extension to use to load the cube map (can be null)
  156126. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  156127. * @param files defines the list of files to load (can be null)
  156128. * @returns a new CubeTextureAssetTask object
  156129. */
  156130. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  156131. /**
  156132. *
  156133. * Add a HDRCubeTextureAssetTask to the list of active tasks
  156134. * @param taskName defines the name of the new task
  156135. * @param url defines the url of the file to load
  156136. * @param size defines the size you want for the cubemap (can be null)
  156137. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  156138. * @param generateHarmonics defines if you want to automatically generate (true by default)
  156139. * @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)
  156140. * @param reserved Internal use only
  156141. * @returns a new HDRCubeTextureAssetTask object
  156142. */
  156143. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  156144. /**
  156145. *
  156146. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  156147. * @param taskName defines the name of the new task
  156148. * @param url defines the url of the file to load
  156149. * @param size defines the size you want for the cubemap (can be null)
  156150. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  156151. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  156152. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  156153. * @returns a new EquiRectangularCubeTextureAssetTask object
  156154. */
  156155. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  156156. /**
  156157. * Remove a task from the assets manager.
  156158. * @param task the task to remove
  156159. */
  156160. removeTask(task: AbstractAssetTask): void;
  156161. private _decreaseWaitingTasksCount;
  156162. private _runTask;
  156163. /**
  156164. * Reset the AssetsManager and remove all tasks
  156165. * @return the current instance of the AssetsManager
  156166. */
  156167. reset(): AssetsManager;
  156168. /**
  156169. * Start the loading process
  156170. * @return the current instance of the AssetsManager
  156171. */
  156172. load(): AssetsManager;
  156173. /**
  156174. * Start the loading process as an async operation
  156175. * @return a promise returning the list of failed tasks
  156176. */
  156177. loadAsync(): Promise<void>;
  156178. }
  156179. }
  156180. declare module BABYLON {
  156181. /**
  156182. * Wrapper class for promise with external resolve and reject.
  156183. */
  156184. export class Deferred<T> {
  156185. /**
  156186. * The promise associated with this deferred object.
  156187. */
  156188. readonly promise: Promise<T>;
  156189. private _resolve;
  156190. private _reject;
  156191. /**
  156192. * The resolve method of the promise associated with this deferred object.
  156193. */
  156194. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  156195. /**
  156196. * The reject method of the promise associated with this deferred object.
  156197. */
  156198. get reject(): (reason?: any) => void;
  156199. /**
  156200. * Constructor for this deferred object.
  156201. */
  156202. constructor();
  156203. }
  156204. }
  156205. declare module BABYLON {
  156206. /**
  156207. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  156208. */
  156209. export class MeshExploder {
  156210. private _centerMesh;
  156211. private _meshes;
  156212. private _meshesOrigins;
  156213. private _toCenterVectors;
  156214. private _scaledDirection;
  156215. private _newPosition;
  156216. private _centerPosition;
  156217. /**
  156218. * Explodes meshes from a center mesh.
  156219. * @param meshes The meshes to explode.
  156220. * @param centerMesh The mesh to be center of explosion.
  156221. */
  156222. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  156223. private _setCenterMesh;
  156224. /**
  156225. * Get class name
  156226. * @returns "MeshExploder"
  156227. */
  156228. getClassName(): string;
  156229. /**
  156230. * "Exploded meshes"
  156231. * @returns Array of meshes with the centerMesh at index 0.
  156232. */
  156233. getMeshes(): Array<Mesh>;
  156234. /**
  156235. * Explodes meshes giving a specific direction
  156236. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  156237. */
  156238. explode(direction?: number): void;
  156239. }
  156240. }
  156241. declare module BABYLON {
  156242. /**
  156243. * Class used to help managing file picking and drag'n'drop
  156244. */
  156245. export class FilesInput {
  156246. /**
  156247. * List of files ready to be loaded
  156248. */
  156249. static get FilesToLoad(): {
  156250. [key: string]: File;
  156251. };
  156252. /**
  156253. * Callback called when a file is processed
  156254. */
  156255. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  156256. private _engine;
  156257. private _currentScene;
  156258. private _sceneLoadedCallback;
  156259. private _progressCallback;
  156260. private _additionalRenderLoopLogicCallback;
  156261. private _textureLoadingCallback;
  156262. private _startingProcessingFilesCallback;
  156263. private _onReloadCallback;
  156264. private _errorCallback;
  156265. private _elementToMonitor;
  156266. private _sceneFileToLoad;
  156267. private _filesToLoad;
  156268. /**
  156269. * Creates a new FilesInput
  156270. * @param engine defines the rendering engine
  156271. * @param scene defines the hosting scene
  156272. * @param sceneLoadedCallback callback called when scene is loaded
  156273. * @param progressCallback callback called to track progress
  156274. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  156275. * @param textureLoadingCallback callback called when a texture is loading
  156276. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  156277. * @param onReloadCallback callback called when a reload is requested
  156278. * @param errorCallback callback call if an error occurs
  156279. */
  156280. 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>);
  156281. private _dragEnterHandler;
  156282. private _dragOverHandler;
  156283. private _dropHandler;
  156284. /**
  156285. * Calls this function to listen to drag'n'drop events on a specific DOM element
  156286. * @param elementToMonitor defines the DOM element to track
  156287. */
  156288. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  156289. /** Gets the current list of files to load */
  156290. get filesToLoad(): File[];
  156291. /**
  156292. * Release all associated resources
  156293. */
  156294. dispose(): void;
  156295. private renderFunction;
  156296. private drag;
  156297. private drop;
  156298. private _traverseFolder;
  156299. private _processFiles;
  156300. /**
  156301. * Load files from a drop event
  156302. * @param event defines the drop event to use as source
  156303. */
  156304. loadFiles(event: any): void;
  156305. private _processReload;
  156306. /**
  156307. * Reload the current scene from the loaded files
  156308. */
  156309. reload(): void;
  156310. }
  156311. }
  156312. declare module BABYLON {
  156313. /**
  156314. * Defines the root class used to create scene optimization to use with SceneOptimizer
  156315. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156316. */
  156317. export class SceneOptimization {
  156318. /**
  156319. * Defines the priority of this optimization (0 by default which means first in the list)
  156320. */
  156321. priority: number;
  156322. /**
  156323. * Gets a string describing the action executed by the current optimization
  156324. * @returns description string
  156325. */
  156326. getDescription(): string;
  156327. /**
  156328. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156329. * @param scene defines the current scene where to apply this optimization
  156330. * @param optimizer defines the current optimizer
  156331. * @returns true if everything that can be done was applied
  156332. */
  156333. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156334. /**
  156335. * Creates the SceneOptimization object
  156336. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156337. * @param desc defines the description associated with the optimization
  156338. */
  156339. constructor(
  156340. /**
  156341. * Defines the priority of this optimization (0 by default which means first in the list)
  156342. */
  156343. priority?: number);
  156344. }
  156345. /**
  156346. * Defines an optimization used to reduce the size of render target textures
  156347. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156348. */
  156349. export class TextureOptimization extends SceneOptimization {
  156350. /**
  156351. * Defines the priority of this optimization (0 by default which means first in the list)
  156352. */
  156353. priority: number;
  156354. /**
  156355. * 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
  156356. */
  156357. maximumSize: number;
  156358. /**
  156359. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  156360. */
  156361. step: number;
  156362. /**
  156363. * Gets a string describing the action executed by the current optimization
  156364. * @returns description string
  156365. */
  156366. getDescription(): string;
  156367. /**
  156368. * Creates the TextureOptimization object
  156369. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156370. * @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
  156371. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  156372. */
  156373. constructor(
  156374. /**
  156375. * Defines the priority of this optimization (0 by default which means first in the list)
  156376. */
  156377. priority?: number,
  156378. /**
  156379. * 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
  156380. */
  156381. maximumSize?: number,
  156382. /**
  156383. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  156384. */
  156385. step?: number);
  156386. /**
  156387. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156388. * @param scene defines the current scene where to apply this optimization
  156389. * @param optimizer defines the current optimizer
  156390. * @returns true if everything that can be done was applied
  156391. */
  156392. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156393. }
  156394. /**
  156395. * Defines an optimization used to increase or decrease the rendering resolution
  156396. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156397. */
  156398. export class HardwareScalingOptimization extends SceneOptimization {
  156399. /**
  156400. * Defines the priority of this optimization (0 by default which means first in the list)
  156401. */
  156402. priority: number;
  156403. /**
  156404. * Defines the maximum scale to use (2 by default)
  156405. */
  156406. maximumScale: number;
  156407. /**
  156408. * Defines the step to use between two passes (0.5 by default)
  156409. */
  156410. step: number;
  156411. private _currentScale;
  156412. private _directionOffset;
  156413. /**
  156414. * Gets a string describing the action executed by the current optimization
  156415. * @return description string
  156416. */
  156417. getDescription(): string;
  156418. /**
  156419. * Creates the HardwareScalingOptimization object
  156420. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156421. * @param maximumScale defines the maximum scale to use (2 by default)
  156422. * @param step defines the step to use between two passes (0.5 by default)
  156423. */
  156424. constructor(
  156425. /**
  156426. * Defines the priority of this optimization (0 by default which means first in the list)
  156427. */
  156428. priority?: number,
  156429. /**
  156430. * Defines the maximum scale to use (2 by default)
  156431. */
  156432. maximumScale?: number,
  156433. /**
  156434. * Defines the step to use between two passes (0.5 by default)
  156435. */
  156436. step?: number);
  156437. /**
  156438. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156439. * @param scene defines the current scene where to apply this optimization
  156440. * @param optimizer defines the current optimizer
  156441. * @returns true if everything that can be done was applied
  156442. */
  156443. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156444. }
  156445. /**
  156446. * Defines an optimization used to remove shadows
  156447. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156448. */
  156449. export class ShadowsOptimization extends SceneOptimization {
  156450. /**
  156451. * Gets a string describing the action executed by the current optimization
  156452. * @return description string
  156453. */
  156454. getDescription(): string;
  156455. /**
  156456. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156457. * @param scene defines the current scene where to apply this optimization
  156458. * @param optimizer defines the current optimizer
  156459. * @returns true if everything that can be done was applied
  156460. */
  156461. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156462. }
  156463. /**
  156464. * Defines an optimization used to turn post-processes off
  156465. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156466. */
  156467. export class PostProcessesOptimization extends SceneOptimization {
  156468. /**
  156469. * Gets a string describing the action executed by the current optimization
  156470. * @return description string
  156471. */
  156472. getDescription(): string;
  156473. /**
  156474. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156475. * @param scene defines the current scene where to apply this optimization
  156476. * @param optimizer defines the current optimizer
  156477. * @returns true if everything that can be done was applied
  156478. */
  156479. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156480. }
  156481. /**
  156482. * Defines an optimization used to turn lens flares off
  156483. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156484. */
  156485. export class LensFlaresOptimization extends SceneOptimization {
  156486. /**
  156487. * Gets a string describing the action executed by the current optimization
  156488. * @return description string
  156489. */
  156490. getDescription(): string;
  156491. /**
  156492. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156493. * @param scene defines the current scene where to apply this optimization
  156494. * @param optimizer defines the current optimizer
  156495. * @returns true if everything that can be done was applied
  156496. */
  156497. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156498. }
  156499. /**
  156500. * Defines an optimization based on user defined callback.
  156501. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156502. */
  156503. export class CustomOptimization extends SceneOptimization {
  156504. /**
  156505. * Callback called to apply the custom optimization.
  156506. */
  156507. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  156508. /**
  156509. * Callback called to get custom description
  156510. */
  156511. onGetDescription: () => string;
  156512. /**
  156513. * Gets a string describing the action executed by the current optimization
  156514. * @returns description string
  156515. */
  156516. getDescription(): string;
  156517. /**
  156518. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156519. * @param scene defines the current scene where to apply this optimization
  156520. * @param optimizer defines the current optimizer
  156521. * @returns true if everything that can be done was applied
  156522. */
  156523. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156524. }
  156525. /**
  156526. * Defines an optimization used to turn particles off
  156527. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156528. */
  156529. export class ParticlesOptimization extends SceneOptimization {
  156530. /**
  156531. * Gets a string describing the action executed by the current optimization
  156532. * @return description string
  156533. */
  156534. getDescription(): string;
  156535. /**
  156536. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156537. * @param scene defines the current scene where to apply this optimization
  156538. * @param optimizer defines the current optimizer
  156539. * @returns true if everything that can be done was applied
  156540. */
  156541. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156542. }
  156543. /**
  156544. * Defines an optimization used to turn render targets off
  156545. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156546. */
  156547. export class RenderTargetsOptimization extends SceneOptimization {
  156548. /**
  156549. * Gets a string describing the action executed by the current optimization
  156550. * @return description string
  156551. */
  156552. getDescription(): string;
  156553. /**
  156554. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156555. * @param scene defines the current scene where to apply this optimization
  156556. * @param optimizer defines the current optimizer
  156557. * @returns true if everything that can be done was applied
  156558. */
  156559. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156560. }
  156561. /**
  156562. * Defines an optimization used to merge meshes with compatible materials
  156563. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156564. */
  156565. export class MergeMeshesOptimization extends SceneOptimization {
  156566. private static _UpdateSelectionTree;
  156567. /**
  156568. * Gets or sets a boolean which defines if optimization octree has to be updated
  156569. */
  156570. static get UpdateSelectionTree(): boolean;
  156571. /**
  156572. * Gets or sets a boolean which defines if optimization octree has to be updated
  156573. */
  156574. static set UpdateSelectionTree(value: boolean);
  156575. /**
  156576. * Gets a string describing the action executed by the current optimization
  156577. * @return description string
  156578. */
  156579. getDescription(): string;
  156580. private _canBeMerged;
  156581. /**
  156582. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156583. * @param scene defines the current scene where to apply this optimization
  156584. * @param optimizer defines the current optimizer
  156585. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  156586. * @returns true if everything that can be done was applied
  156587. */
  156588. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  156589. }
  156590. /**
  156591. * Defines a list of options used by SceneOptimizer
  156592. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156593. */
  156594. export class SceneOptimizerOptions {
  156595. /**
  156596. * Defines the target frame rate to reach (60 by default)
  156597. */
  156598. targetFrameRate: number;
  156599. /**
  156600. * Defines the interval between two checkes (2000ms by default)
  156601. */
  156602. trackerDuration: number;
  156603. /**
  156604. * Gets the list of optimizations to apply
  156605. */
  156606. optimizations: SceneOptimization[];
  156607. /**
  156608. * Creates a new list of options used by SceneOptimizer
  156609. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  156610. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  156611. */
  156612. constructor(
  156613. /**
  156614. * Defines the target frame rate to reach (60 by default)
  156615. */
  156616. targetFrameRate?: number,
  156617. /**
  156618. * Defines the interval between two checkes (2000ms by default)
  156619. */
  156620. trackerDuration?: number);
  156621. /**
  156622. * Add a new optimization
  156623. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  156624. * @returns the current SceneOptimizerOptions
  156625. */
  156626. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  156627. /**
  156628. * Add a new custom optimization
  156629. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  156630. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  156631. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156632. * @returns the current SceneOptimizerOptions
  156633. */
  156634. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  156635. /**
  156636. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  156637. * @param targetFrameRate defines the target frame rate (60 by default)
  156638. * @returns a SceneOptimizerOptions object
  156639. */
  156640. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  156641. /**
  156642. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  156643. * @param targetFrameRate defines the target frame rate (60 by default)
  156644. * @returns a SceneOptimizerOptions object
  156645. */
  156646. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  156647. /**
  156648. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  156649. * @param targetFrameRate defines the target frame rate (60 by default)
  156650. * @returns a SceneOptimizerOptions object
  156651. */
  156652. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  156653. }
  156654. /**
  156655. * Class used to run optimizations in order to reach a target frame rate
  156656. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156657. */
  156658. export class SceneOptimizer implements IDisposable {
  156659. private _isRunning;
  156660. private _options;
  156661. private _scene;
  156662. private _currentPriorityLevel;
  156663. private _targetFrameRate;
  156664. private _trackerDuration;
  156665. private _currentFrameRate;
  156666. private _sceneDisposeObserver;
  156667. private _improvementMode;
  156668. /**
  156669. * Defines an observable called when the optimizer reaches the target frame rate
  156670. */
  156671. onSuccessObservable: Observable<SceneOptimizer>;
  156672. /**
  156673. * Defines an observable called when the optimizer enables an optimization
  156674. */
  156675. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  156676. /**
  156677. * Defines an observable called when the optimizer is not able to reach the target frame rate
  156678. */
  156679. onFailureObservable: Observable<SceneOptimizer>;
  156680. /**
  156681. * Gets a boolean indicating if the optimizer is in improvement mode
  156682. */
  156683. get isInImprovementMode(): boolean;
  156684. /**
  156685. * Gets the current priority level (0 at start)
  156686. */
  156687. get currentPriorityLevel(): number;
  156688. /**
  156689. * Gets the current frame rate checked by the SceneOptimizer
  156690. */
  156691. get currentFrameRate(): number;
  156692. /**
  156693. * Gets or sets the current target frame rate (60 by default)
  156694. */
  156695. get targetFrameRate(): number;
  156696. /**
  156697. * Gets or sets the current target frame rate (60 by default)
  156698. */
  156699. set targetFrameRate(value: number);
  156700. /**
  156701. * Gets or sets the current interval between two checks (every 2000ms by default)
  156702. */
  156703. get trackerDuration(): number;
  156704. /**
  156705. * Gets or sets the current interval between two checks (every 2000ms by default)
  156706. */
  156707. set trackerDuration(value: number);
  156708. /**
  156709. * Gets the list of active optimizations
  156710. */
  156711. get optimizations(): SceneOptimization[];
  156712. /**
  156713. * Creates a new SceneOptimizer
  156714. * @param scene defines the scene to work on
  156715. * @param options defines the options to use with the SceneOptimizer
  156716. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  156717. * @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)
  156718. */
  156719. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  156720. /**
  156721. * Stops the current optimizer
  156722. */
  156723. stop(): void;
  156724. /**
  156725. * Reset the optimizer to initial step (current priority level = 0)
  156726. */
  156727. reset(): void;
  156728. /**
  156729. * Start the optimizer. By default it will try to reach a specific framerate
  156730. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  156731. */
  156732. start(): void;
  156733. private _checkCurrentState;
  156734. /**
  156735. * Release all resources
  156736. */
  156737. dispose(): void;
  156738. /**
  156739. * Helper function to create a SceneOptimizer with one single line of code
  156740. * @param scene defines the scene to work on
  156741. * @param options defines the options to use with the SceneOptimizer
  156742. * @param onSuccess defines a callback to call on success
  156743. * @param onFailure defines a callback to call on failure
  156744. * @returns the new SceneOptimizer object
  156745. */
  156746. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  156747. }
  156748. }
  156749. declare module BABYLON {
  156750. /**
  156751. * Class used to serialize a scene into a string
  156752. */
  156753. export class SceneSerializer {
  156754. /**
  156755. * Clear cache used by a previous serialization
  156756. */
  156757. static ClearCache(): void;
  156758. /**
  156759. * Serialize a scene into a JSON compatible object
  156760. * @param scene defines the scene to serialize
  156761. * @returns a JSON compatible object
  156762. */
  156763. static Serialize(scene: Scene): any;
  156764. /**
  156765. * Serialize a mesh into a JSON compatible object
  156766. * @param toSerialize defines the mesh to serialize
  156767. * @param withParents defines if parents must be serialized as well
  156768. * @param withChildren defines if children must be serialized as well
  156769. * @returns a JSON compatible object
  156770. */
  156771. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  156772. }
  156773. }
  156774. declare module BABYLON {
  156775. /**
  156776. * Class used to host texture specific utilities
  156777. */
  156778. export class TextureTools {
  156779. /**
  156780. * Uses the GPU to create a copy texture rescaled at a given size
  156781. * @param texture Texture to copy from
  156782. * @param width defines the desired width
  156783. * @param height defines the desired height
  156784. * @param useBilinearMode defines if bilinear mode has to be used
  156785. * @return the generated texture
  156786. */
  156787. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  156788. }
  156789. }
  156790. declare module BABYLON {
  156791. /**
  156792. * This represents the different options available for the video capture.
  156793. */
  156794. export interface VideoRecorderOptions {
  156795. /** Defines the mime type of the video. */
  156796. mimeType: string;
  156797. /** Defines the FPS the video should be recorded at. */
  156798. fps: number;
  156799. /** Defines the chunk size for the recording data. */
  156800. recordChunckSize: number;
  156801. /** The audio tracks to attach to the recording. */
  156802. audioTracks?: MediaStreamTrack[];
  156803. }
  156804. /**
  156805. * This can help with recording videos from BabylonJS.
  156806. * This is based on the available WebRTC functionalities of the browser.
  156807. *
  156808. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  156809. */
  156810. export class VideoRecorder {
  156811. private static readonly _defaultOptions;
  156812. /**
  156813. * Returns whether or not the VideoRecorder is available in your browser.
  156814. * @param engine Defines the Babylon Engine.
  156815. * @returns true if supported otherwise false.
  156816. */
  156817. static IsSupported(engine: Engine): boolean;
  156818. private readonly _options;
  156819. private _canvas;
  156820. private _mediaRecorder;
  156821. private _recordedChunks;
  156822. private _fileName;
  156823. private _resolve;
  156824. private _reject;
  156825. /**
  156826. * True when a recording is already in progress.
  156827. */
  156828. get isRecording(): boolean;
  156829. /**
  156830. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  156831. * @param engine Defines the BabylonJS Engine you wish to record.
  156832. * @param options Defines options that can be used to customize the capture.
  156833. */
  156834. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  156835. /**
  156836. * Stops the current recording before the default capture timeout passed in the startRecording function.
  156837. */
  156838. stopRecording(): void;
  156839. /**
  156840. * Starts recording the canvas for a max duration specified in parameters.
  156841. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  156842. * If null no automatic download will start and you can rely on the promise to get the data back.
  156843. * @param maxDuration Defines the maximum recording time in seconds.
  156844. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  156845. * @return A promise callback at the end of the recording with the video data in Blob.
  156846. */
  156847. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  156848. /**
  156849. * Releases internal resources used during the recording.
  156850. */
  156851. dispose(): void;
  156852. private _handleDataAvailable;
  156853. private _handleError;
  156854. private _handleStop;
  156855. }
  156856. }
  156857. declare module BABYLON {
  156858. /**
  156859. * Class containing a set of static utilities functions for screenshots
  156860. */
  156861. export class ScreenshotTools {
  156862. /**
  156863. * Captures a screenshot of the current rendering
  156864. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  156865. * @param engine defines the rendering engine
  156866. * @param camera defines the source camera
  156867. * @param size This parameter can be set to a single number or to an object with the
  156868. * following (optional) properties: precision, width, height. If a single number is passed,
  156869. * it will be used for both width and height. If an object is passed, the screenshot size
  156870. * will be derived from the parameters. The precision property is a multiplier allowing
  156871. * rendering at a higher or lower resolution
  156872. * @param successCallback defines the callback receives a single parameter which contains the
  156873. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  156874. * src parameter of an <img> to display it
  156875. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  156876. * Check your browser for supported MIME types
  156877. */
  156878. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  156879. /**
  156880. * Captures a screenshot of the current rendering
  156881. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  156882. * @param engine defines the rendering engine
  156883. * @param camera defines the source camera
  156884. * @param size This parameter can be set to a single number or to an object with the
  156885. * following (optional) properties: precision, width, height. If a single number is passed,
  156886. * it will be used for both width and height. If an object is passed, the screenshot size
  156887. * will be derived from the parameters. The precision property is a multiplier allowing
  156888. * rendering at a higher or lower resolution
  156889. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  156890. * Check your browser for supported MIME types
  156891. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  156892. * to the src parameter of an <img> to display it
  156893. */
  156894. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  156895. /**
  156896. * Generates an image screenshot from the specified camera.
  156897. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  156898. * @param engine The engine to use for rendering
  156899. * @param camera The camera to use for rendering
  156900. * @param size This parameter can be set to a single number or to an object with the
  156901. * following (optional) properties: precision, width, height. If a single number is passed,
  156902. * it will be used for both width and height. If an object is passed, the screenshot size
  156903. * will be derived from the parameters. The precision property is a multiplier allowing
  156904. * rendering at a higher or lower resolution
  156905. * @param successCallback The callback receives a single parameter which contains the
  156906. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  156907. * src parameter of an <img> to display it
  156908. * @param mimeType The MIME type of the screenshot image (default: image/png).
  156909. * Check your browser for supported MIME types
  156910. * @param samples Texture samples (default: 1)
  156911. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  156912. * @param fileName A name for for the downloaded file.
  156913. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  156914. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  156915. */
  156916. 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;
  156917. /**
  156918. * Generates an image screenshot from the specified camera.
  156919. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  156920. * @param engine The engine to use for rendering
  156921. * @param camera The camera to use for rendering
  156922. * @param size This parameter can be set to a single number or to an object with the
  156923. * following (optional) properties: precision, width, height. If a single number is passed,
  156924. * it will be used for both width and height. If an object is passed, the screenshot size
  156925. * will be derived from the parameters. The precision property is a multiplier allowing
  156926. * rendering at a higher or lower resolution
  156927. * @param mimeType The MIME type of the screenshot image (default: image/png).
  156928. * Check your browser for supported MIME types
  156929. * @param samples Texture samples (default: 1)
  156930. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  156931. * @param fileName A name for for the downloaded file.
  156932. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  156933. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  156934. * to the src parameter of an <img> to display it
  156935. */
  156936. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  156937. /**
  156938. * Gets height and width for screenshot size
  156939. * @private
  156940. */
  156941. private static _getScreenshotSize;
  156942. }
  156943. }
  156944. declare module BABYLON {
  156945. /**
  156946. * Interface for a data buffer
  156947. */
  156948. export interface IDataBuffer {
  156949. /**
  156950. * Reads bytes from the data buffer.
  156951. * @param byteOffset The byte offset to read
  156952. * @param byteLength The byte length to read
  156953. * @returns A promise that resolves when the bytes are read
  156954. */
  156955. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  156956. /**
  156957. * The byte length of the buffer.
  156958. */
  156959. readonly byteLength: number;
  156960. }
  156961. /**
  156962. * Utility class for reading from a data buffer
  156963. */
  156964. export class DataReader {
  156965. /**
  156966. * The data buffer associated with this data reader.
  156967. */
  156968. readonly buffer: IDataBuffer;
  156969. /**
  156970. * The current byte offset from the beginning of the data buffer.
  156971. */
  156972. byteOffset: number;
  156973. private _dataView;
  156974. private _dataByteOffset;
  156975. /**
  156976. * Constructor
  156977. * @param buffer The buffer to read
  156978. */
  156979. constructor(buffer: IDataBuffer);
  156980. /**
  156981. * Loads the given byte length.
  156982. * @param byteLength The byte length to load
  156983. * @returns A promise that resolves when the load is complete
  156984. */
  156985. loadAsync(byteLength: number): Promise<void>;
  156986. /**
  156987. * Read a unsigned 32-bit integer from the currently loaded data range.
  156988. * @returns The 32-bit integer read
  156989. */
  156990. readUint32(): number;
  156991. /**
  156992. * Read a byte array from the currently loaded data range.
  156993. * @param byteLength The byte length to read
  156994. * @returns The byte array read
  156995. */
  156996. readUint8Array(byteLength: number): Uint8Array;
  156997. /**
  156998. * Read a string from the currently loaded data range.
  156999. * @param byteLength The byte length to read
  157000. * @returns The string read
  157001. */
  157002. readString(byteLength: number): string;
  157003. /**
  157004. * Skips the given byte length the currently loaded data range.
  157005. * @param byteLength The byte length to skip
  157006. */
  157007. skipBytes(byteLength: number): void;
  157008. }
  157009. }
  157010. declare module BABYLON {
  157011. /**
  157012. * Class for storing data to local storage if available or in-memory storage otherwise
  157013. */
  157014. export class DataStorage {
  157015. private static _Storage;
  157016. private static _GetStorage;
  157017. /**
  157018. * Reads a string from the data storage
  157019. * @param key The key to read
  157020. * @param defaultValue The value if the key doesn't exist
  157021. * @returns The string value
  157022. */
  157023. static ReadString(key: string, defaultValue: string): string;
  157024. /**
  157025. * Writes a string to the data storage
  157026. * @param key The key to write
  157027. * @param value The value to write
  157028. */
  157029. static WriteString(key: string, value: string): void;
  157030. /**
  157031. * Reads a boolean from the data storage
  157032. * @param key The key to read
  157033. * @param defaultValue The value if the key doesn't exist
  157034. * @returns The boolean value
  157035. */
  157036. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  157037. /**
  157038. * Writes a boolean to the data storage
  157039. * @param key The key to write
  157040. * @param value The value to write
  157041. */
  157042. static WriteBoolean(key: string, value: boolean): void;
  157043. /**
  157044. * Reads a number from the data storage
  157045. * @param key The key to read
  157046. * @param defaultValue The value if the key doesn't exist
  157047. * @returns The number value
  157048. */
  157049. static ReadNumber(key: string, defaultValue: number): number;
  157050. /**
  157051. * Writes a number to the data storage
  157052. * @param key The key to write
  157053. * @param value The value to write
  157054. */
  157055. static WriteNumber(key: string, value: number): void;
  157056. }
  157057. }
  157058. declare module BABYLON {
  157059. /**
  157060. * Class used to record delta files between 2 scene states
  157061. */
  157062. export class SceneRecorder {
  157063. private _trackedScene;
  157064. private _savedJSON;
  157065. /**
  157066. * Track a given scene. This means the current scene state will be considered the original state
  157067. * @param scene defines the scene to track
  157068. */
  157069. track(scene: Scene): void;
  157070. /**
  157071. * Get the delta between current state and original state
  157072. * @returns a string containing the delta
  157073. */
  157074. getDelta(): any;
  157075. private _compareArray;
  157076. private _compareObjects;
  157077. private _compareCollections;
  157078. private static GetShadowGeneratorById;
  157079. /**
  157080. * Apply a given delta to a given scene
  157081. * @param deltaJSON defines the JSON containing the delta
  157082. * @param scene defines the scene to apply the delta to
  157083. */
  157084. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  157085. private static _ApplyPropertiesToEntity;
  157086. private static _ApplyDeltaForEntity;
  157087. }
  157088. }
  157089. declare module BABYLON {
  157090. /**
  157091. * A 3D trajectory consisting of an order list of vectors describing a
  157092. * path of motion through 3D space.
  157093. */
  157094. export class Trajectory {
  157095. private _points;
  157096. private readonly _segmentLength;
  157097. /**
  157098. * Serialize to JSON.
  157099. * @returns serialized JSON string
  157100. */
  157101. serialize(): string;
  157102. /**
  157103. * Deserialize from JSON.
  157104. * @param json serialized JSON string
  157105. * @returns deserialized Trajectory
  157106. */
  157107. static Deserialize(json: string): Trajectory;
  157108. /**
  157109. * Create a new empty Trajectory.
  157110. * @param segmentLength radius of discretization for Trajectory points
  157111. */
  157112. constructor(segmentLength?: number);
  157113. /**
  157114. * Get the length of the Trajectory.
  157115. * @returns length of the Trajectory
  157116. */
  157117. getLength(): number;
  157118. /**
  157119. * Append a new point to the Trajectory.
  157120. * NOTE: This implementation has many allocations.
  157121. * @param point point to append to the Trajectory
  157122. */
  157123. add(point: DeepImmutable<Vector3>): void;
  157124. /**
  157125. * Create a new Trajectory with a segment length chosen to make it
  157126. * probable that the new Trajectory will have a specified number of
  157127. * segments. This operation is imprecise.
  157128. * @param targetResolution number of segments desired
  157129. * @returns new Trajectory with approximately the requested number of segments
  157130. */
  157131. resampleAtTargetResolution(targetResolution: number): Trajectory;
  157132. /**
  157133. * Convert Trajectory segments into tokenized representation. This
  157134. * representation is an array of numbers where each nth number is the
  157135. * index of the token which is most similar to the nth segment of the
  157136. * Trajectory.
  157137. * @param tokens list of vectors which serve as discrete tokens
  157138. * @returns list of indices of most similar token per segment
  157139. */
  157140. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  157141. private static _forwardDir;
  157142. private static _inverseFromVec;
  157143. private static _upDir;
  157144. private static _fromToVec;
  157145. private static _lookMatrix;
  157146. /**
  157147. * Transform the rotation (i.e., direction) of a segment to isolate
  157148. * the relative transformation represented by the segment. This operation
  157149. * may or may not succeed due to singularities in the equations that define
  157150. * motion relativity in this context.
  157151. * @param priorVec the origin of the prior segment
  157152. * @param fromVec the origin of the current segment
  157153. * @param toVec the destination of the current segment
  157154. * @param result reference to output variable
  157155. * @returns whether or not transformation was successful
  157156. */
  157157. private static _transformSegmentDirToRef;
  157158. private static _bestMatch;
  157159. private static _score;
  157160. private static _bestScore;
  157161. /**
  157162. * Determine which token vector is most similar to the
  157163. * segment vector.
  157164. * @param segment segment vector
  157165. * @param tokens token vector list
  157166. * @returns index of the most similar token to the segment
  157167. */
  157168. private static _tokenizeSegment;
  157169. }
  157170. /**
  157171. * Class representing a set of known, named trajectories to which Trajectories can be
  157172. * added and using which Trajectories can be recognized.
  157173. */
  157174. export class TrajectoryClassifier {
  157175. private _maximumAllowableMatchCost;
  157176. private _vector3Alphabet;
  157177. private _levenshteinAlphabet;
  157178. private _nameToDescribedTrajectory;
  157179. /**
  157180. * Serialize to JSON.
  157181. * @returns JSON serialization
  157182. */
  157183. serialize(): string;
  157184. /**
  157185. * Deserialize from JSON.
  157186. * @param json JSON serialization
  157187. * @returns deserialized TrajectorySet
  157188. */
  157189. static Deserialize(json: string): TrajectoryClassifier;
  157190. /**
  157191. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  157192. * VERY naive, need to be generating these things from known
  157193. * sets. Better version later, probably eliminating this one.
  157194. * @returns auto-generated TrajectorySet
  157195. */
  157196. static Generate(): TrajectoryClassifier;
  157197. private constructor();
  157198. /**
  157199. * Add a new Trajectory to the set with a given name.
  157200. * @param trajectory new Trajectory to be added
  157201. * @param classification name to which to add the Trajectory
  157202. */
  157203. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  157204. /**
  157205. * Remove a known named trajectory and all Trajectories associated with it.
  157206. * @param classification name to remove
  157207. * @returns whether anything was removed
  157208. */
  157209. deleteClassification(classification: string): boolean;
  157210. /**
  157211. * Attempt to recognize a Trajectory from among all the classifications
  157212. * already known to the classifier.
  157213. * @param trajectory Trajectory to be recognized
  157214. * @returns classification of Trajectory if recognized, null otherwise
  157215. */
  157216. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  157217. }
  157218. }
  157219. declare module BABYLON {
  157220. /**
  157221. * An interface for all Hit test features
  157222. */
  157223. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  157224. /**
  157225. * Triggered when new babylon (transformed) hit test results are available
  157226. */
  157227. onHitTestResultObservable: Observable<T[]>;
  157228. }
  157229. /**
  157230. * Options used for hit testing
  157231. */
  157232. export interface IWebXRLegacyHitTestOptions {
  157233. /**
  157234. * Only test when user interacted with the scene. Default - hit test every frame
  157235. */
  157236. testOnPointerDownOnly?: boolean;
  157237. /**
  157238. * The node to use to transform the local results to world coordinates
  157239. */
  157240. worldParentNode?: TransformNode;
  157241. }
  157242. /**
  157243. * Interface defining the babylon result of raycasting/hit-test
  157244. */
  157245. export interface IWebXRLegacyHitResult {
  157246. /**
  157247. * Transformation matrix that can be applied to a node that will put it in the hit point location
  157248. */
  157249. transformationMatrix: Matrix;
  157250. /**
  157251. * The native hit test result
  157252. */
  157253. xrHitResult: XRHitResult | XRHitTestResult;
  157254. }
  157255. /**
  157256. * The currently-working hit-test module.
  157257. * Hit test (or Ray-casting) is used to interact with the real world.
  157258. * For further information read here - https://github.com/immersive-web/hit-test
  157259. */
  157260. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  157261. /**
  157262. * options to use when constructing this feature
  157263. */
  157264. readonly options: IWebXRLegacyHitTestOptions;
  157265. private _direction;
  157266. private _mat;
  157267. private _onSelectEnabled;
  157268. private _origin;
  157269. /**
  157270. * The module's name
  157271. */
  157272. static readonly Name: string;
  157273. /**
  157274. * The (Babylon) version of this module.
  157275. * This is an integer representing the implementation version.
  157276. * This number does not correspond to the WebXR specs version
  157277. */
  157278. static readonly Version: number;
  157279. /**
  157280. * Populated with the last native XR Hit Results
  157281. */
  157282. lastNativeXRHitResults: XRHitResult[];
  157283. /**
  157284. * Triggered when new babylon (transformed) hit test results are available
  157285. */
  157286. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  157287. /**
  157288. * Creates a new instance of the (legacy version) hit test feature
  157289. * @param _xrSessionManager an instance of WebXRSessionManager
  157290. * @param options options to use when constructing this feature
  157291. */
  157292. constructor(_xrSessionManager: WebXRSessionManager,
  157293. /**
  157294. * options to use when constructing this feature
  157295. */
  157296. options?: IWebXRLegacyHitTestOptions);
  157297. /**
  157298. * execute a hit test with an XR Ray
  157299. *
  157300. * @param xrSession a native xrSession that will execute this hit test
  157301. * @param xrRay the ray (position and direction) to use for ray-casting
  157302. * @param referenceSpace native XR reference space to use for the hit-test
  157303. * @param filter filter function that will filter the results
  157304. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  157305. */
  157306. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  157307. /**
  157308. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  157309. * @param event the (select) event to use to select with
  157310. * @param referenceSpace the reference space to use for this hit test
  157311. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  157312. */
  157313. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  157314. /**
  157315. * attach this feature
  157316. * Will usually be called by the features manager
  157317. *
  157318. * @returns true if successful.
  157319. */
  157320. attach(): boolean;
  157321. /**
  157322. * detach this feature.
  157323. * Will usually be called by the features manager
  157324. *
  157325. * @returns true if successful.
  157326. */
  157327. detach(): boolean;
  157328. /**
  157329. * Dispose this feature and all of the resources attached
  157330. */
  157331. dispose(): void;
  157332. protected _onXRFrame(frame: XRFrame): void;
  157333. private _onHitTestResults;
  157334. private _onSelect;
  157335. }
  157336. }
  157337. declare module BABYLON {
  157338. /**
  157339. * Options used for hit testing (version 2)
  157340. */
  157341. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  157342. /**
  157343. * Do not create a permanent hit test. Will usually be used when only
  157344. * transient inputs are needed.
  157345. */
  157346. disablePermanentHitTest?: boolean;
  157347. /**
  157348. * Enable transient (for example touch-based) hit test inspections
  157349. */
  157350. enableTransientHitTest?: boolean;
  157351. /**
  157352. * Offset ray for the permanent hit test
  157353. */
  157354. offsetRay?: Vector3;
  157355. /**
  157356. * Offset ray for the transient hit test
  157357. */
  157358. transientOffsetRay?: Vector3;
  157359. /**
  157360. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  157361. */
  157362. useReferenceSpace?: boolean;
  157363. /**
  157364. * Override the default entity type(s) of the hit-test result
  157365. */
  157366. entityTypes?: XRHitTestTrackableType[];
  157367. }
  157368. /**
  157369. * Interface defining the babylon result of hit-test
  157370. */
  157371. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  157372. /**
  157373. * The input source that generated this hit test (if transient)
  157374. */
  157375. inputSource?: XRInputSource;
  157376. /**
  157377. * Is this a transient hit test
  157378. */
  157379. isTransient?: boolean;
  157380. /**
  157381. * Position of the hit test result
  157382. */
  157383. position: Vector3;
  157384. /**
  157385. * Rotation of the hit test result
  157386. */
  157387. rotationQuaternion: Quaternion;
  157388. /**
  157389. * The native hit test result
  157390. */
  157391. xrHitResult: XRHitTestResult;
  157392. }
  157393. /**
  157394. * The currently-working hit-test module.
  157395. * Hit test (or Ray-casting) is used to interact with the real world.
  157396. * For further information read here - https://github.com/immersive-web/hit-test
  157397. *
  157398. * Tested on chrome (mobile) 80.
  157399. */
  157400. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  157401. /**
  157402. * options to use when constructing this feature
  157403. */
  157404. readonly options: IWebXRHitTestOptions;
  157405. private _tmpMat;
  157406. private _tmpPos;
  157407. private _tmpQuat;
  157408. private _transientXrHitTestSource;
  157409. private _xrHitTestSource;
  157410. private initHitTestSource;
  157411. /**
  157412. * The module's name
  157413. */
  157414. static readonly Name: string;
  157415. /**
  157416. * The (Babylon) version of this module.
  157417. * This is an integer representing the implementation version.
  157418. * This number does not correspond to the WebXR specs version
  157419. */
  157420. static readonly Version: number;
  157421. /**
  157422. * When set to true, each hit test will have its own position/rotation objects
  157423. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  157424. * the developers will clone them or copy them as they see fit.
  157425. */
  157426. autoCloneTransformation: boolean;
  157427. /**
  157428. * Triggered when new babylon (transformed) hit test results are available
  157429. * Note - this will be called when results come back from the device. It can be an empty array!!
  157430. */
  157431. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  157432. /**
  157433. * Use this to temporarily pause hit test checks.
  157434. */
  157435. paused: boolean;
  157436. /**
  157437. * Creates a new instance of the hit test feature
  157438. * @param _xrSessionManager an instance of WebXRSessionManager
  157439. * @param options options to use when constructing this feature
  157440. */
  157441. constructor(_xrSessionManager: WebXRSessionManager,
  157442. /**
  157443. * options to use when constructing this feature
  157444. */
  157445. options?: IWebXRHitTestOptions);
  157446. /**
  157447. * attach this feature
  157448. * Will usually be called by the features manager
  157449. *
  157450. * @returns true if successful.
  157451. */
  157452. attach(): boolean;
  157453. /**
  157454. * detach this feature.
  157455. * Will usually be called by the features manager
  157456. *
  157457. * @returns true if successful.
  157458. */
  157459. detach(): boolean;
  157460. /**
  157461. * Dispose this feature and all of the resources attached
  157462. */
  157463. dispose(): void;
  157464. protected _onXRFrame(frame: XRFrame): void;
  157465. private _processWebXRHitTestResult;
  157466. }
  157467. }
  157468. declare module BABYLON {
  157469. /**
  157470. * Configuration options of the anchor system
  157471. */
  157472. export interface IWebXRAnchorSystemOptions {
  157473. /**
  157474. * a node that will be used to convert local to world coordinates
  157475. */
  157476. worldParentNode?: TransformNode;
  157477. /**
  157478. * If set to true a reference of the created anchors will be kept until the next session starts
  157479. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  157480. */
  157481. doNotRemoveAnchorsOnSessionEnded?: boolean;
  157482. }
  157483. /**
  157484. * A babylon container for an XR Anchor
  157485. */
  157486. export interface IWebXRAnchor {
  157487. /**
  157488. * A babylon-assigned ID for this anchor
  157489. */
  157490. id: number;
  157491. /**
  157492. * Transformation matrix to apply to an object attached to this anchor
  157493. */
  157494. transformationMatrix: Matrix;
  157495. /**
  157496. * The native anchor object
  157497. */
  157498. xrAnchor: XRAnchor;
  157499. /**
  157500. * if defined, this object will be constantly updated by the anchor's position and rotation
  157501. */
  157502. attachedNode?: TransformNode;
  157503. }
  157504. /**
  157505. * An implementation of the anchor system for WebXR.
  157506. * For further information see https://github.com/immersive-web/anchors/
  157507. */
  157508. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  157509. private _options;
  157510. private _lastFrameDetected;
  157511. private _trackedAnchors;
  157512. private _referenceSpaceForFrameAnchors;
  157513. private _futureAnchors;
  157514. /**
  157515. * The module's name
  157516. */
  157517. static readonly Name: string;
  157518. /**
  157519. * The (Babylon) version of this module.
  157520. * This is an integer representing the implementation version.
  157521. * This number does not correspond to the WebXR specs version
  157522. */
  157523. static readonly Version: number;
  157524. /**
  157525. * Observers registered here will be executed when a new anchor was added to the session
  157526. */
  157527. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  157528. /**
  157529. * Observers registered here will be executed when an anchor was removed from the session
  157530. */
  157531. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  157532. /**
  157533. * Observers registered here will be executed when an existing anchor updates
  157534. * This can execute N times every frame
  157535. */
  157536. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  157537. /**
  157538. * Set the reference space to use for anchor creation, when not using a hit test.
  157539. * Will default to the session's reference space if not defined
  157540. */
  157541. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  157542. /**
  157543. * constructs a new anchor system
  157544. * @param _xrSessionManager an instance of WebXRSessionManager
  157545. * @param _options configuration object for this feature
  157546. */
  157547. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  157548. private _tmpVector;
  157549. private _tmpQuaternion;
  157550. private _populateTmpTransformation;
  157551. /**
  157552. * Create a new anchor point using a hit test result at a specific point in the scene
  157553. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  157554. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  157555. *
  157556. * @param hitTestResult The hit test result to use for this anchor creation
  157557. * @param position an optional position offset for this anchor
  157558. * @param rotationQuaternion an optional rotation offset for this anchor
  157559. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  157560. */
  157561. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  157562. /**
  157563. * Add a new anchor at a specific position and rotation
  157564. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  157565. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  157566. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  157567. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  157568. *
  157569. * @param position the position in which to add an anchor
  157570. * @param rotationQuaternion an optional rotation for the anchor transformation
  157571. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  157572. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  157573. */
  157574. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  157575. /**
  157576. * detach this feature.
  157577. * Will usually be called by the features manager
  157578. *
  157579. * @returns true if successful.
  157580. */
  157581. detach(): boolean;
  157582. /**
  157583. * Dispose this feature and all of the resources attached
  157584. */
  157585. dispose(): void;
  157586. protected _onXRFrame(frame: XRFrame): void;
  157587. /**
  157588. * avoiding using Array.find for global support.
  157589. * @param xrAnchor the plane to find in the array
  157590. */
  157591. private _findIndexInAnchorArray;
  157592. private _updateAnchorWithXRFrame;
  157593. private _createAnchorAtTransformation;
  157594. }
  157595. }
  157596. declare module BABYLON {
  157597. /**
  157598. * Options used in the plane detector module
  157599. */
  157600. export interface IWebXRPlaneDetectorOptions {
  157601. /**
  157602. * The node to use to transform the local results to world coordinates
  157603. */
  157604. worldParentNode?: TransformNode;
  157605. /**
  157606. * If set to true a reference of the created planes will be kept until the next session starts
  157607. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  157608. */
  157609. doNotRemovePlanesOnSessionEnded?: boolean;
  157610. }
  157611. /**
  157612. * A babylon interface for a WebXR plane.
  157613. * A Plane is actually a polygon, built from N points in space
  157614. *
  157615. * Supported in chrome 79, not supported in canary 81 ATM
  157616. */
  157617. export interface IWebXRPlane {
  157618. /**
  157619. * a babylon-assigned ID for this polygon
  157620. */
  157621. id: number;
  157622. /**
  157623. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  157624. */
  157625. polygonDefinition: Array<Vector3>;
  157626. /**
  157627. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  157628. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  157629. */
  157630. transformationMatrix: Matrix;
  157631. /**
  157632. * the native xr-plane object
  157633. */
  157634. xrPlane: XRPlane;
  157635. }
  157636. /**
  157637. * The plane detector is used to detect planes in the real world when in AR
  157638. * For more information see https://github.com/immersive-web/real-world-geometry/
  157639. */
  157640. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  157641. private _options;
  157642. private _detectedPlanes;
  157643. private _enabled;
  157644. private _lastFrameDetected;
  157645. /**
  157646. * The module's name
  157647. */
  157648. static readonly Name: string;
  157649. /**
  157650. * The (Babylon) version of this module.
  157651. * This is an integer representing the implementation version.
  157652. * This number does not correspond to the WebXR specs version
  157653. */
  157654. static readonly Version: number;
  157655. /**
  157656. * Observers registered here will be executed when a new plane was added to the session
  157657. */
  157658. onPlaneAddedObservable: Observable<IWebXRPlane>;
  157659. /**
  157660. * Observers registered here will be executed when a plane is no longer detected in the session
  157661. */
  157662. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  157663. /**
  157664. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  157665. * This can execute N times every frame
  157666. */
  157667. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  157668. /**
  157669. * construct a new Plane Detector
  157670. * @param _xrSessionManager an instance of xr Session manager
  157671. * @param _options configuration to use when constructing this feature
  157672. */
  157673. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  157674. /**
  157675. * detach this feature.
  157676. * Will usually be called by the features manager
  157677. *
  157678. * @returns true if successful.
  157679. */
  157680. detach(): boolean;
  157681. /**
  157682. * Dispose this feature and all of the resources attached
  157683. */
  157684. dispose(): void;
  157685. /**
  157686. * Check if the needed objects are defined.
  157687. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  157688. */
  157689. isCompatible(): boolean;
  157690. protected _onXRFrame(frame: XRFrame): void;
  157691. private _init;
  157692. private _updatePlaneWithXRPlane;
  157693. /**
  157694. * avoiding using Array.find for global support.
  157695. * @param xrPlane the plane to find in the array
  157696. */
  157697. private findIndexInPlaneArray;
  157698. }
  157699. }
  157700. declare module BABYLON {
  157701. /**
  157702. * Options interface for the background remover plugin
  157703. */
  157704. export interface IWebXRBackgroundRemoverOptions {
  157705. /**
  157706. * Further background meshes to disable when entering AR
  157707. */
  157708. backgroundMeshes?: AbstractMesh[];
  157709. /**
  157710. * flags to configure the removal of the environment helper.
  157711. * If not set, the entire background will be removed. If set, flags should be set as well.
  157712. */
  157713. environmentHelperRemovalFlags?: {
  157714. /**
  157715. * Should the skybox be removed (default false)
  157716. */
  157717. skyBox?: boolean;
  157718. /**
  157719. * Should the ground be removed (default false)
  157720. */
  157721. ground?: boolean;
  157722. };
  157723. /**
  157724. * don't disable the environment helper
  157725. */
  157726. ignoreEnvironmentHelper?: boolean;
  157727. }
  157728. /**
  157729. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  157730. */
  157731. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  157732. /**
  157733. * read-only options to be used in this module
  157734. */
  157735. readonly options: IWebXRBackgroundRemoverOptions;
  157736. /**
  157737. * The module's name
  157738. */
  157739. static readonly Name: string;
  157740. /**
  157741. * The (Babylon) version of this module.
  157742. * This is an integer representing the implementation version.
  157743. * This number does not correspond to the WebXR specs version
  157744. */
  157745. static readonly Version: number;
  157746. /**
  157747. * registered observers will be triggered when the background state changes
  157748. */
  157749. onBackgroundStateChangedObservable: Observable<boolean>;
  157750. /**
  157751. * constructs a new background remover module
  157752. * @param _xrSessionManager the session manager for this module
  157753. * @param options read-only options to be used in this module
  157754. */
  157755. constructor(_xrSessionManager: WebXRSessionManager,
  157756. /**
  157757. * read-only options to be used in this module
  157758. */
  157759. options?: IWebXRBackgroundRemoverOptions);
  157760. /**
  157761. * attach this feature
  157762. * Will usually be called by the features manager
  157763. *
  157764. * @returns true if successful.
  157765. */
  157766. attach(): boolean;
  157767. /**
  157768. * detach this feature.
  157769. * Will usually be called by the features manager
  157770. *
  157771. * @returns true if successful.
  157772. */
  157773. detach(): boolean;
  157774. /**
  157775. * Dispose this feature and all of the resources attached
  157776. */
  157777. dispose(): void;
  157778. protected _onXRFrame(_xrFrame: XRFrame): void;
  157779. private _setBackgroundState;
  157780. }
  157781. }
  157782. declare module BABYLON {
  157783. /**
  157784. * Options for the controller physics feature
  157785. */
  157786. export class IWebXRControllerPhysicsOptions {
  157787. /**
  157788. * Should the headset get its own impostor
  157789. */
  157790. enableHeadsetImpostor?: boolean;
  157791. /**
  157792. * Optional parameters for the headset impostor
  157793. */
  157794. headsetImpostorParams?: {
  157795. /**
  157796. * The type of impostor to create. Default is sphere
  157797. */
  157798. impostorType: number;
  157799. /**
  157800. * the size of the impostor. Defaults to 10cm
  157801. */
  157802. impostorSize?: number | {
  157803. width: number;
  157804. height: number;
  157805. depth: number;
  157806. };
  157807. /**
  157808. * Friction definitions
  157809. */
  157810. friction?: number;
  157811. /**
  157812. * Restitution
  157813. */
  157814. restitution?: number;
  157815. };
  157816. /**
  157817. * The physics properties of the future impostors
  157818. */
  157819. physicsProperties?: {
  157820. /**
  157821. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  157822. * Note that this requires a physics engine that supports mesh impostors!
  157823. */
  157824. useControllerMesh?: boolean;
  157825. /**
  157826. * The type of impostor to create. Default is sphere
  157827. */
  157828. impostorType?: number;
  157829. /**
  157830. * the size of the impostor. Defaults to 10cm
  157831. */
  157832. impostorSize?: number | {
  157833. width: number;
  157834. height: number;
  157835. depth: number;
  157836. };
  157837. /**
  157838. * Friction definitions
  157839. */
  157840. friction?: number;
  157841. /**
  157842. * Restitution
  157843. */
  157844. restitution?: number;
  157845. };
  157846. /**
  157847. * the xr input to use with this pointer selection
  157848. */
  157849. xrInput: WebXRInput;
  157850. }
  157851. /**
  157852. * Add physics impostor to your webxr controllers,
  157853. * including naive calculation of their linear and angular velocity
  157854. */
  157855. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  157856. private readonly _options;
  157857. private _attachController;
  157858. private _controllers;
  157859. private _debugMode;
  157860. private _delta;
  157861. private _headsetImpostor?;
  157862. private _headsetMesh?;
  157863. private _lastTimestamp;
  157864. private _tmpQuaternion;
  157865. private _tmpVector;
  157866. /**
  157867. * The module's name
  157868. */
  157869. static readonly Name: string;
  157870. /**
  157871. * The (Babylon) version of this module.
  157872. * This is an integer representing the implementation version.
  157873. * This number does not correspond to the webxr specs version
  157874. */
  157875. static readonly Version: number;
  157876. /**
  157877. * Construct a new Controller Physics Feature
  157878. * @param _xrSessionManager the corresponding xr session manager
  157879. * @param _options options to create this feature with
  157880. */
  157881. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  157882. /**
  157883. * @hidden
  157884. * enable debugging - will show console outputs and the impostor mesh
  157885. */
  157886. _enablePhysicsDebug(): void;
  157887. /**
  157888. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  157889. * @param xrController the controller to add
  157890. */
  157891. addController(xrController: WebXRInputSource): void;
  157892. /**
  157893. * attach this feature
  157894. * Will usually be called by the features manager
  157895. *
  157896. * @returns true if successful.
  157897. */
  157898. attach(): boolean;
  157899. /**
  157900. * detach this feature.
  157901. * Will usually be called by the features manager
  157902. *
  157903. * @returns true if successful.
  157904. */
  157905. detach(): boolean;
  157906. /**
  157907. * Get the headset impostor, if enabled
  157908. * @returns the impostor
  157909. */
  157910. getHeadsetImpostor(): PhysicsImpostor | undefined;
  157911. /**
  157912. * Get the physics impostor of a specific controller.
  157913. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  157914. * @param controller the controller or the controller id of which to get the impostor
  157915. * @returns the impostor or null
  157916. */
  157917. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  157918. /**
  157919. * Update the physics properties provided in the constructor
  157920. * @param newProperties the new properties object
  157921. */
  157922. setPhysicsProperties(newProperties: {
  157923. impostorType?: number;
  157924. impostorSize?: number | {
  157925. width: number;
  157926. height: number;
  157927. depth: number;
  157928. };
  157929. friction?: number;
  157930. restitution?: number;
  157931. }): void;
  157932. protected _onXRFrame(_xrFrame: any): void;
  157933. private _detachController;
  157934. }
  157935. }
  157936. declare module BABYLON {
  157937. /**
  157938. * A babylon interface for a "WebXR" feature point.
  157939. * Represents the position and confidence value of a given feature point.
  157940. */
  157941. export interface IWebXRFeaturePoint {
  157942. /**
  157943. * Represents the position of the feature point in world space.
  157944. */
  157945. position: Vector3;
  157946. /**
  157947. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  157948. */
  157949. confidenceValue: number;
  157950. }
  157951. /**
  157952. * The feature point system is used to detect feature points from real world geometry.
  157953. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  157954. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  157955. */
  157956. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  157957. private _enabled;
  157958. private _featurePointCloud;
  157959. /**
  157960. * The module's name
  157961. */
  157962. static readonly Name: string;
  157963. /**
  157964. * The (Babylon) version of this module.
  157965. * This is an integer representing the implementation version.
  157966. * This number does not correspond to the WebXR specs version
  157967. */
  157968. static readonly Version: number;
  157969. /**
  157970. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  157971. * Will notify the observers about which feature points have been added.
  157972. */
  157973. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  157974. /**
  157975. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  157976. * Will notify the observers about which feature points have been updated.
  157977. */
  157978. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  157979. /**
  157980. * The current feature point cloud maintained across frames.
  157981. */
  157982. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  157983. /**
  157984. * construct the feature point system
  157985. * @param _xrSessionManager an instance of xr Session manager
  157986. */
  157987. constructor(_xrSessionManager: WebXRSessionManager);
  157988. /**
  157989. * Detach this feature.
  157990. * Will usually be called by the features manager
  157991. *
  157992. * @returns true if successful.
  157993. */
  157994. detach(): boolean;
  157995. /**
  157996. * Dispose this feature and all of the resources attached
  157997. */
  157998. dispose(): void;
  157999. /**
  158000. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  158001. */
  158002. protected _onXRFrame(frame: XRFrame): void;
  158003. /**
  158004. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  158005. */
  158006. private _init;
  158007. }
  158008. }
  158009. declare module BABYLON {
  158010. /**
  158011. * Configuration interface for the hand tracking feature
  158012. */
  158013. export interface IWebXRHandTrackingOptions {
  158014. /**
  158015. * The xrInput that will be used as source for new hands
  158016. */
  158017. xrInput: WebXRInput;
  158018. /**
  158019. * Configuration object for the joint meshes
  158020. */
  158021. jointMeshes?: {
  158022. /**
  158023. * Should the meshes created be invisible (defaults to false)
  158024. */
  158025. invisible?: boolean;
  158026. /**
  158027. * A source mesh to be used to create instances. Defaults to a sphere.
  158028. * This mesh will be the source for all other (25) meshes.
  158029. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  158030. */
  158031. sourceMesh?: Mesh;
  158032. /**
  158033. * This function will be called after a mesh was created for a specific joint.
  158034. * Using this function you can either manipulate the instance or return a new mesh.
  158035. * When returning a new mesh the instance created before will be disposed
  158036. */
  158037. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  158038. /**
  158039. * Should the source mesh stay visible. Defaults to false
  158040. */
  158041. keepOriginalVisible?: boolean;
  158042. /**
  158043. * Scale factor for all instances (defaults to 2)
  158044. */
  158045. scaleFactor?: number;
  158046. /**
  158047. * Should each instance have its own physics impostor
  158048. */
  158049. enablePhysics?: boolean;
  158050. /**
  158051. * If enabled, override default physics properties
  158052. */
  158053. physicsProps?: {
  158054. friction?: number;
  158055. restitution?: number;
  158056. impostorType?: number;
  158057. };
  158058. /**
  158059. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  158060. */
  158061. handMesh?: AbstractMesh;
  158062. };
  158063. }
  158064. /**
  158065. * Parts of the hands divided to writs and finger names
  158066. */
  158067. export const enum HandPart {
  158068. /**
  158069. * HandPart - Wrist
  158070. */
  158071. WRIST = "wrist",
  158072. /**
  158073. * HandPart - The THumb
  158074. */
  158075. THUMB = "thumb",
  158076. /**
  158077. * HandPart - Index finger
  158078. */
  158079. INDEX = "index",
  158080. /**
  158081. * HandPart - Middle finger
  158082. */
  158083. MIDDLE = "middle",
  158084. /**
  158085. * HandPart - Ring finger
  158086. */
  158087. RING = "ring",
  158088. /**
  158089. * HandPart - Little finger
  158090. */
  158091. LITTLE = "little"
  158092. }
  158093. /**
  158094. * Representing a single hand (with its corresponding native XRHand object)
  158095. */
  158096. export class WebXRHand implements IDisposable {
  158097. /** the controller to which the hand correlates */
  158098. readonly xrController: WebXRInputSource;
  158099. /** the meshes to be used to track the hand joints */
  158100. readonly trackedMeshes: AbstractMesh[];
  158101. /**
  158102. * Hand-parts definition (key is HandPart)
  158103. */
  158104. handPartsDefinition: {
  158105. [key: string]: number[];
  158106. };
  158107. /**
  158108. * Populate the HandPartsDefinition object.
  158109. * This is called as a side effect since certain browsers don't have XRHand defined.
  158110. */
  158111. private generateHandPartsDefinition;
  158112. /**
  158113. * Construct a new hand object
  158114. * @param xrController the controller to which the hand correlates
  158115. * @param trackedMeshes the meshes to be used to track the hand joints
  158116. */
  158117. constructor(
  158118. /** the controller to which the hand correlates */
  158119. xrController: WebXRInputSource,
  158120. /** the meshes to be used to track the hand joints */
  158121. trackedMeshes: AbstractMesh[]);
  158122. /**
  158123. * Update this hand from the latest xr frame
  158124. * @param xrFrame xrFrame to update from
  158125. * @param referenceSpace The current viewer reference space
  158126. * @param scaleFactor optional scale factor for the meshes
  158127. */
  158128. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  158129. /**
  158130. * Get meshes of part of the hand
  158131. * @param part the part of hand to get
  158132. * @returns An array of meshes that correlate to the hand part requested
  158133. */
  158134. getHandPartMeshes(part: HandPart): AbstractMesh[];
  158135. /**
  158136. * Dispose this Hand object
  158137. */
  158138. dispose(): void;
  158139. }
  158140. /**
  158141. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  158142. */
  158143. export class WebXRHandTracking extends WebXRAbstractFeature {
  158144. /**
  158145. * options to use when constructing this feature
  158146. */
  158147. readonly options: IWebXRHandTrackingOptions;
  158148. private static _idCounter;
  158149. /**
  158150. * The module's name
  158151. */
  158152. static readonly Name: string;
  158153. /**
  158154. * The (Babylon) version of this module.
  158155. * This is an integer representing the implementation version.
  158156. * This number does not correspond to the WebXR specs version
  158157. */
  158158. static readonly Version: number;
  158159. /**
  158160. * This observable will notify registered observers when a new hand object was added and initialized
  158161. */
  158162. onHandAddedObservable: Observable<WebXRHand>;
  158163. /**
  158164. * This observable will notify its observers right before the hand object is disposed
  158165. */
  158166. onHandRemovedObservable: Observable<WebXRHand>;
  158167. private _hands;
  158168. /**
  158169. * Creates a new instance of the hit test feature
  158170. * @param _xrSessionManager an instance of WebXRSessionManager
  158171. * @param options options to use when constructing this feature
  158172. */
  158173. constructor(_xrSessionManager: WebXRSessionManager,
  158174. /**
  158175. * options to use when constructing this feature
  158176. */
  158177. options: IWebXRHandTrackingOptions);
  158178. /**
  158179. * Check if the needed objects are defined.
  158180. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  158181. */
  158182. isCompatible(): boolean;
  158183. /**
  158184. * attach this feature
  158185. * Will usually be called by the features manager
  158186. *
  158187. * @returns true if successful.
  158188. */
  158189. attach(): boolean;
  158190. /**
  158191. * detach this feature.
  158192. * Will usually be called by the features manager
  158193. *
  158194. * @returns true if successful.
  158195. */
  158196. detach(): boolean;
  158197. /**
  158198. * Dispose this feature and all of the resources attached
  158199. */
  158200. dispose(): void;
  158201. /**
  158202. * Get the hand object according to the controller id
  158203. * @param controllerId the controller id to which we want to get the hand
  158204. * @returns null if not found or the WebXRHand object if found
  158205. */
  158206. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  158207. /**
  158208. * Get a hand object according to the requested handedness
  158209. * @param handedness the handedness to request
  158210. * @returns null if not found or the WebXRHand object if found
  158211. */
  158212. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  158213. protected _onXRFrame(_xrFrame: XRFrame): void;
  158214. private _attachHand;
  158215. private _detachHand;
  158216. }
  158217. }
  158218. declare module BABYLON {
  158219. /**
  158220. * The motion controller class for all microsoft mixed reality controllers
  158221. */
  158222. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  158223. protected readonly _mapping: {
  158224. defaultButton: {
  158225. valueNodeName: string;
  158226. unpressedNodeName: string;
  158227. pressedNodeName: string;
  158228. };
  158229. defaultAxis: {
  158230. valueNodeName: string;
  158231. minNodeName: string;
  158232. maxNodeName: string;
  158233. };
  158234. buttons: {
  158235. "xr-standard-trigger": {
  158236. rootNodeName: string;
  158237. componentProperty: string;
  158238. states: string[];
  158239. };
  158240. "xr-standard-squeeze": {
  158241. rootNodeName: string;
  158242. componentProperty: string;
  158243. states: string[];
  158244. };
  158245. "xr-standard-touchpad": {
  158246. rootNodeName: string;
  158247. labelAnchorNodeName: string;
  158248. touchPointNodeName: string;
  158249. };
  158250. "xr-standard-thumbstick": {
  158251. rootNodeName: string;
  158252. componentProperty: string;
  158253. states: string[];
  158254. };
  158255. };
  158256. axes: {
  158257. "xr-standard-touchpad": {
  158258. "x-axis": {
  158259. rootNodeName: string;
  158260. };
  158261. "y-axis": {
  158262. rootNodeName: string;
  158263. };
  158264. };
  158265. "xr-standard-thumbstick": {
  158266. "x-axis": {
  158267. rootNodeName: string;
  158268. };
  158269. "y-axis": {
  158270. rootNodeName: string;
  158271. };
  158272. };
  158273. };
  158274. };
  158275. /**
  158276. * The base url used to load the left and right controller models
  158277. */
  158278. static MODEL_BASE_URL: string;
  158279. /**
  158280. * The name of the left controller model file
  158281. */
  158282. static MODEL_LEFT_FILENAME: string;
  158283. /**
  158284. * The name of the right controller model file
  158285. */
  158286. static MODEL_RIGHT_FILENAME: string;
  158287. profileId: string;
  158288. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  158289. protected _getFilenameAndPath(): {
  158290. filename: string;
  158291. path: string;
  158292. };
  158293. protected _getModelLoadingConstraints(): boolean;
  158294. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  158295. protected _setRootMesh(meshes: AbstractMesh[]): void;
  158296. protected _updateModel(): void;
  158297. }
  158298. }
  158299. declare module BABYLON {
  158300. /**
  158301. * The motion controller class for oculus touch (quest, rift).
  158302. * This class supports legacy mapping as well the standard xr mapping
  158303. */
  158304. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  158305. private _forceLegacyControllers;
  158306. private _modelRootNode;
  158307. /**
  158308. * The base url used to load the left and right controller models
  158309. */
  158310. static MODEL_BASE_URL: string;
  158311. /**
  158312. * The name of the left controller model file
  158313. */
  158314. static MODEL_LEFT_FILENAME: string;
  158315. /**
  158316. * The name of the right controller model file
  158317. */
  158318. static MODEL_RIGHT_FILENAME: string;
  158319. /**
  158320. * Base Url for the Quest controller model.
  158321. */
  158322. static QUEST_MODEL_BASE_URL: string;
  158323. profileId: string;
  158324. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  158325. protected _getFilenameAndPath(): {
  158326. filename: string;
  158327. path: string;
  158328. };
  158329. protected _getModelLoadingConstraints(): boolean;
  158330. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  158331. protected _setRootMesh(meshes: AbstractMesh[]): void;
  158332. protected _updateModel(): void;
  158333. /**
  158334. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  158335. * between the touch and touch 2.
  158336. */
  158337. private _isQuest;
  158338. }
  158339. }
  158340. declare module BABYLON {
  158341. /**
  158342. * The motion controller class for the standard HTC-Vive controllers
  158343. */
  158344. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  158345. private _modelRootNode;
  158346. /**
  158347. * The base url used to load the left and right controller models
  158348. */
  158349. static MODEL_BASE_URL: string;
  158350. /**
  158351. * File name for the controller model.
  158352. */
  158353. static MODEL_FILENAME: string;
  158354. profileId: string;
  158355. /**
  158356. * Create a new Vive motion controller object
  158357. * @param scene the scene to use to create this controller
  158358. * @param gamepadObject the corresponding gamepad object
  158359. * @param handedness the handedness of the controller
  158360. */
  158361. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  158362. protected _getFilenameAndPath(): {
  158363. filename: string;
  158364. path: string;
  158365. };
  158366. protected _getModelLoadingConstraints(): boolean;
  158367. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  158368. protected _setRootMesh(meshes: AbstractMesh[]): void;
  158369. protected _updateModel(): void;
  158370. }
  158371. }
  158372. declare module BABYLON {
  158373. /**
  158374. * A cursor which tracks a point on a path
  158375. */
  158376. export class PathCursor {
  158377. private path;
  158378. /**
  158379. * Stores path cursor callbacks for when an onchange event is triggered
  158380. */
  158381. private _onchange;
  158382. /**
  158383. * The value of the path cursor
  158384. */
  158385. value: number;
  158386. /**
  158387. * The animation array of the path cursor
  158388. */
  158389. animations: Animation[];
  158390. /**
  158391. * Initializes the path cursor
  158392. * @param path The path to track
  158393. */
  158394. constructor(path: Path2);
  158395. /**
  158396. * Gets the cursor point on the path
  158397. * @returns A point on the path cursor at the cursor location
  158398. */
  158399. getPoint(): Vector3;
  158400. /**
  158401. * Moves the cursor ahead by the step amount
  158402. * @param step The amount to move the cursor forward
  158403. * @returns This path cursor
  158404. */
  158405. moveAhead(step?: number): PathCursor;
  158406. /**
  158407. * Moves the cursor behind by the step amount
  158408. * @param step The amount to move the cursor back
  158409. * @returns This path cursor
  158410. */
  158411. moveBack(step?: number): PathCursor;
  158412. /**
  158413. * Moves the cursor by the step amount
  158414. * If the step amount is greater than one, an exception is thrown
  158415. * @param step The amount to move the cursor
  158416. * @returns This path cursor
  158417. */
  158418. move(step: number): PathCursor;
  158419. /**
  158420. * Ensures that the value is limited between zero and one
  158421. * @returns This path cursor
  158422. */
  158423. private ensureLimits;
  158424. /**
  158425. * Runs onchange callbacks on change (used by the animation engine)
  158426. * @returns This path cursor
  158427. */
  158428. private raiseOnChange;
  158429. /**
  158430. * Executes a function on change
  158431. * @param f A path cursor onchange callback
  158432. * @returns This path cursor
  158433. */
  158434. onchange(f: (cursor: PathCursor) => void): PathCursor;
  158435. }
  158436. }
  158437. declare module BABYLON {
  158438. /** @hidden */
  158439. export var blurPixelShader: {
  158440. name: string;
  158441. shader: string;
  158442. };
  158443. }
  158444. declare module BABYLON {
  158445. /** @hidden */
  158446. export var pointCloudVertexDeclaration: {
  158447. name: string;
  158448. shader: string;
  158449. };
  158450. }
  158451. // Mixins
  158452. interface Window {
  158453. mozIndexedDB: IDBFactory;
  158454. webkitIndexedDB: IDBFactory;
  158455. msIndexedDB: IDBFactory;
  158456. webkitURL: typeof URL;
  158457. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  158458. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  158459. WebGLRenderingContext: WebGLRenderingContext;
  158460. MSGesture: MSGesture;
  158461. CANNON: any;
  158462. AudioContext: AudioContext;
  158463. webkitAudioContext: AudioContext;
  158464. PointerEvent: any;
  158465. Math: Math;
  158466. Uint8Array: Uint8ArrayConstructor;
  158467. Float32Array: Float32ArrayConstructor;
  158468. mozURL: typeof URL;
  158469. msURL: typeof URL;
  158470. VRFrameData: any; // WebVR, from specs 1.1
  158471. DracoDecoderModule: any;
  158472. setImmediate(handler: (...args: any[]) => void): number;
  158473. }
  158474. interface HTMLCanvasElement {
  158475. requestPointerLock(): void;
  158476. msRequestPointerLock?(): void;
  158477. mozRequestPointerLock?(): void;
  158478. webkitRequestPointerLock?(): void;
  158479. /** Track wether a record is in progress */
  158480. isRecording: boolean;
  158481. /** Capture Stream method defined by some browsers */
  158482. captureStream(fps?: number): MediaStream;
  158483. }
  158484. interface CanvasRenderingContext2D {
  158485. msImageSmoothingEnabled: boolean;
  158486. }
  158487. interface MouseEvent {
  158488. mozMovementX: number;
  158489. mozMovementY: number;
  158490. webkitMovementX: number;
  158491. webkitMovementY: number;
  158492. msMovementX: number;
  158493. msMovementY: number;
  158494. }
  158495. interface Navigator {
  158496. mozGetVRDevices: (any: any) => any;
  158497. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  158498. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  158499. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  158500. webkitGetGamepads(): Gamepad[];
  158501. msGetGamepads(): Gamepad[];
  158502. webkitGamepads(): Gamepad[];
  158503. }
  158504. interface HTMLVideoElement {
  158505. mozSrcObject: any;
  158506. }
  158507. interface Math {
  158508. fround(x: number): number;
  158509. imul(a: number, b: number): number;
  158510. }
  158511. interface WebGLRenderingContext {
  158512. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  158513. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  158514. vertexAttribDivisor(index: number, divisor: number): void;
  158515. createVertexArray(): any;
  158516. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  158517. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  158518. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  158519. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  158520. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  158521. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  158522. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  158523. // Queries
  158524. createQuery(): WebGLQuery;
  158525. deleteQuery(query: WebGLQuery): void;
  158526. beginQuery(target: number, query: WebGLQuery): void;
  158527. endQuery(target: number): void;
  158528. getQueryParameter(query: WebGLQuery, pname: number): any;
  158529. getQuery(target: number, pname: number): any;
  158530. MAX_SAMPLES: number;
  158531. RGBA8: number;
  158532. READ_FRAMEBUFFER: number;
  158533. DRAW_FRAMEBUFFER: number;
  158534. UNIFORM_BUFFER: number;
  158535. HALF_FLOAT_OES: number;
  158536. RGBA16F: number;
  158537. RGBA32F: number;
  158538. R32F: number;
  158539. RG32F: number;
  158540. RGB32F: number;
  158541. R16F: number;
  158542. RG16F: number;
  158543. RGB16F: number;
  158544. RED: number;
  158545. RG: number;
  158546. R8: number;
  158547. RG8: number;
  158548. UNSIGNED_INT_24_8: number;
  158549. DEPTH24_STENCIL8: number;
  158550. MIN: number;
  158551. MAX: number;
  158552. /* Multiple Render Targets */
  158553. drawBuffers(buffers: number[]): void;
  158554. readBuffer(src: number): void;
  158555. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  158556. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  158557. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  158558. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  158559. // Occlusion Query
  158560. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  158561. ANY_SAMPLES_PASSED: number;
  158562. QUERY_RESULT_AVAILABLE: number;
  158563. QUERY_RESULT: number;
  158564. }
  158565. interface WebGLProgram {
  158566. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  158567. }
  158568. interface EXT_disjoint_timer_query {
  158569. QUERY_COUNTER_BITS_EXT: number;
  158570. TIME_ELAPSED_EXT: number;
  158571. TIMESTAMP_EXT: number;
  158572. GPU_DISJOINT_EXT: number;
  158573. QUERY_RESULT_EXT: number;
  158574. QUERY_RESULT_AVAILABLE_EXT: number;
  158575. queryCounterEXT(query: WebGLQuery, target: number): void;
  158576. createQueryEXT(): WebGLQuery;
  158577. beginQueryEXT(target: number, query: WebGLQuery): void;
  158578. endQueryEXT(target: number): void;
  158579. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  158580. deleteQueryEXT(query: WebGLQuery): void;
  158581. }
  158582. interface WebGLUniformLocation {
  158583. _currentState: any;
  158584. }
  158585. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  158586. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  158587. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  158588. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  158589. interface WebGLRenderingContext {
  158590. readonly RASTERIZER_DISCARD: number;
  158591. readonly DEPTH_COMPONENT24: number;
  158592. readonly TEXTURE_3D: number;
  158593. readonly TEXTURE_2D_ARRAY: number;
  158594. readonly TEXTURE_COMPARE_FUNC: number;
  158595. readonly TEXTURE_COMPARE_MODE: number;
  158596. readonly COMPARE_REF_TO_TEXTURE: number;
  158597. readonly TEXTURE_WRAP_R: number;
  158598. readonly HALF_FLOAT: number;
  158599. readonly RGB8: number;
  158600. readonly RED_INTEGER: number;
  158601. readonly RG_INTEGER: number;
  158602. readonly RGB_INTEGER: number;
  158603. readonly RGBA_INTEGER: number;
  158604. readonly R8_SNORM: number;
  158605. readonly RG8_SNORM: number;
  158606. readonly RGB8_SNORM: number;
  158607. readonly RGBA8_SNORM: number;
  158608. readonly R8I: number;
  158609. readonly RG8I: number;
  158610. readonly RGB8I: number;
  158611. readonly RGBA8I: number;
  158612. readonly R8UI: number;
  158613. readonly RG8UI: number;
  158614. readonly RGB8UI: number;
  158615. readonly RGBA8UI: number;
  158616. readonly R16I: number;
  158617. readonly RG16I: number;
  158618. readonly RGB16I: number;
  158619. readonly RGBA16I: number;
  158620. readonly R16UI: number;
  158621. readonly RG16UI: number;
  158622. readonly RGB16UI: number;
  158623. readonly RGBA16UI: number;
  158624. readonly R32I: number;
  158625. readonly RG32I: number;
  158626. readonly RGB32I: number;
  158627. readonly RGBA32I: number;
  158628. readonly R32UI: number;
  158629. readonly RG32UI: number;
  158630. readonly RGB32UI: number;
  158631. readonly RGBA32UI: number;
  158632. readonly RGB10_A2UI: number;
  158633. readonly R11F_G11F_B10F: number;
  158634. readonly RGB9_E5: number;
  158635. readonly RGB10_A2: number;
  158636. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  158637. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  158638. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  158639. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  158640. readonly DEPTH_COMPONENT32F: number;
  158641. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  158642. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  158643. 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;
  158644. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  158645. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  158646. readonly TRANSFORM_FEEDBACK: number;
  158647. readonly INTERLEAVED_ATTRIBS: number;
  158648. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  158649. createTransformFeedback(): WebGLTransformFeedback;
  158650. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  158651. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  158652. beginTransformFeedback(primitiveMode: number): void;
  158653. endTransformFeedback(): void;
  158654. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  158655. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  158656. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  158657. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  158658. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  158659. }
  158660. interface ImageBitmap {
  158661. readonly width: number;
  158662. readonly height: number;
  158663. close(): void;
  158664. }
  158665. interface WebGLQuery extends WebGLObject {
  158666. }
  158667. declare var WebGLQuery: {
  158668. prototype: WebGLQuery;
  158669. new(): WebGLQuery;
  158670. };
  158671. interface WebGLSampler extends WebGLObject {
  158672. }
  158673. declare var WebGLSampler: {
  158674. prototype: WebGLSampler;
  158675. new(): WebGLSampler;
  158676. };
  158677. interface WebGLSync extends WebGLObject {
  158678. }
  158679. declare var WebGLSync: {
  158680. prototype: WebGLSync;
  158681. new(): WebGLSync;
  158682. };
  158683. interface WebGLTransformFeedback extends WebGLObject {
  158684. }
  158685. declare var WebGLTransformFeedback: {
  158686. prototype: WebGLTransformFeedback;
  158687. new(): WebGLTransformFeedback;
  158688. };
  158689. interface WebGLVertexArrayObject extends WebGLObject {
  158690. }
  158691. declare var WebGLVertexArrayObject: {
  158692. prototype: WebGLVertexArrayObject;
  158693. new(): WebGLVertexArrayObject;
  158694. };
  158695. // Type definitions for WebVR API
  158696. // Project: https://w3c.github.io/webvr/
  158697. // Definitions by: six a <https://github.com/lostfictions>
  158698. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  158699. interface VRDisplay extends EventTarget {
  158700. /**
  158701. * Dictionary of capabilities describing the VRDisplay.
  158702. */
  158703. readonly capabilities: VRDisplayCapabilities;
  158704. /**
  158705. * z-depth defining the far plane of the eye view frustum
  158706. * enables mapping of values in the render target depth
  158707. * attachment to scene coordinates. Initially set to 10000.0.
  158708. */
  158709. depthFar: number;
  158710. /**
  158711. * z-depth defining the near plane of the eye view frustum
  158712. * enables mapping of values in the render target depth
  158713. * attachment to scene coordinates. Initially set to 0.01.
  158714. */
  158715. depthNear: number;
  158716. /**
  158717. * An identifier for this distinct VRDisplay. Used as an
  158718. * association point in the Gamepad API.
  158719. */
  158720. readonly displayId: number;
  158721. /**
  158722. * A display name, a user-readable name identifying it.
  158723. */
  158724. readonly displayName: string;
  158725. readonly isConnected: boolean;
  158726. readonly isPresenting: boolean;
  158727. /**
  158728. * If this VRDisplay supports room-scale experiences, the optional
  158729. * stage attribute contains details on the room-scale parameters.
  158730. */
  158731. readonly stageParameters: VRStageParameters | null;
  158732. /**
  158733. * Passing the value returned by `requestAnimationFrame` to
  158734. * `cancelAnimationFrame` will unregister the callback.
  158735. * @param handle Define the hanle of the request to cancel
  158736. */
  158737. cancelAnimationFrame(handle: number): void;
  158738. /**
  158739. * Stops presenting to the VRDisplay.
  158740. * @returns a promise to know when it stopped
  158741. */
  158742. exitPresent(): Promise<void>;
  158743. /**
  158744. * Return the current VREyeParameters for the given eye.
  158745. * @param whichEye Define the eye we want the parameter for
  158746. * @returns the eye parameters
  158747. */
  158748. getEyeParameters(whichEye: string): VREyeParameters;
  158749. /**
  158750. * Populates the passed VRFrameData with the information required to render
  158751. * the current frame.
  158752. * @param frameData Define the data structure to populate
  158753. * @returns true if ok otherwise false
  158754. */
  158755. getFrameData(frameData: VRFrameData): boolean;
  158756. /**
  158757. * Get the layers currently being presented.
  158758. * @returns the list of VR layers
  158759. */
  158760. getLayers(): VRLayer[];
  158761. /**
  158762. * Return a VRPose containing the future predicted pose of the VRDisplay
  158763. * when the current frame will be presented. The value returned will not
  158764. * change until JavaScript has returned control to the browser.
  158765. *
  158766. * The VRPose will contain the position, orientation, velocity,
  158767. * and acceleration of each of these properties.
  158768. * @returns the pose object
  158769. */
  158770. getPose(): VRPose;
  158771. /**
  158772. * Return the current instantaneous pose of the VRDisplay, with no
  158773. * prediction applied.
  158774. * @returns the current instantaneous pose
  158775. */
  158776. getImmediatePose(): VRPose;
  158777. /**
  158778. * The callback passed to `requestAnimationFrame` will be called
  158779. * any time a new frame should be rendered. When the VRDisplay is
  158780. * presenting the callback will be called at the native refresh
  158781. * rate of the HMD. When not presenting this function acts
  158782. * identically to how window.requestAnimationFrame acts. Content should
  158783. * make no assumptions of frame rate or vsync behavior as the HMD runs
  158784. * asynchronously from other displays and at differing refresh rates.
  158785. * @param callback Define the eaction to run next frame
  158786. * @returns the request handle it
  158787. */
  158788. requestAnimationFrame(callback: FrameRequestCallback): number;
  158789. /**
  158790. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  158791. * Repeat calls while already presenting will update the VRLayers being displayed.
  158792. * @param layers Define the list of layer to present
  158793. * @returns a promise to know when the request has been fulfilled
  158794. */
  158795. requestPresent(layers: VRLayer[]): Promise<void>;
  158796. /**
  158797. * Reset the pose for this display, treating its current position and
  158798. * orientation as the "origin/zero" values. VRPose.position,
  158799. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  158800. * updated when calling resetPose(). This should be called in only
  158801. * sitting-space experiences.
  158802. */
  158803. resetPose(): void;
  158804. /**
  158805. * The VRLayer provided to the VRDisplay will be captured and presented
  158806. * in the HMD. Calling this function has the same effect on the source
  158807. * canvas as any other operation that uses its source image, and canvases
  158808. * created without preserveDrawingBuffer set to true will be cleared.
  158809. * @param pose Define the pose to submit
  158810. */
  158811. submitFrame(pose?: VRPose): void;
  158812. }
  158813. declare var VRDisplay: {
  158814. prototype: VRDisplay;
  158815. new(): VRDisplay;
  158816. };
  158817. interface VRLayer {
  158818. leftBounds?: number[] | Float32Array | null;
  158819. rightBounds?: number[] | Float32Array | null;
  158820. source?: HTMLCanvasElement | null;
  158821. }
  158822. interface VRDisplayCapabilities {
  158823. readonly canPresent: boolean;
  158824. readonly hasExternalDisplay: boolean;
  158825. readonly hasOrientation: boolean;
  158826. readonly hasPosition: boolean;
  158827. readonly maxLayers: number;
  158828. }
  158829. interface VREyeParameters {
  158830. /** @deprecated */
  158831. readonly fieldOfView: VRFieldOfView;
  158832. readonly offset: Float32Array;
  158833. readonly renderHeight: number;
  158834. readonly renderWidth: number;
  158835. }
  158836. interface VRFieldOfView {
  158837. readonly downDegrees: number;
  158838. readonly leftDegrees: number;
  158839. readonly rightDegrees: number;
  158840. readonly upDegrees: number;
  158841. }
  158842. interface VRFrameData {
  158843. readonly leftProjectionMatrix: Float32Array;
  158844. readonly leftViewMatrix: Float32Array;
  158845. readonly pose: VRPose;
  158846. readonly rightProjectionMatrix: Float32Array;
  158847. readonly rightViewMatrix: Float32Array;
  158848. readonly timestamp: number;
  158849. }
  158850. interface VRPose {
  158851. readonly angularAcceleration: Float32Array | null;
  158852. readonly angularVelocity: Float32Array | null;
  158853. readonly linearAcceleration: Float32Array | null;
  158854. readonly linearVelocity: Float32Array | null;
  158855. readonly orientation: Float32Array | null;
  158856. readonly position: Float32Array | null;
  158857. readonly timestamp: number;
  158858. }
  158859. interface VRStageParameters {
  158860. sittingToStandingTransform?: Float32Array;
  158861. sizeX?: number;
  158862. sizeY?: number;
  158863. }
  158864. interface Navigator {
  158865. getVRDisplays(): Promise<VRDisplay[]>;
  158866. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  158867. }
  158868. interface Window {
  158869. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  158870. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  158871. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  158872. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  158873. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  158874. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  158875. }
  158876. interface Gamepad {
  158877. readonly displayId: number;
  158878. }
  158879. /**
  158880. * Available session modes
  158881. */
  158882. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  158883. /**
  158884. * Reference space types
  158885. */
  158886. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  158887. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  158888. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  158889. /**
  158890. * Handedness types
  158891. */
  158892. type XRHandedness = "none" | "left" | "right";
  158893. /**
  158894. * InputSource target ray modes
  158895. */
  158896. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  158897. /**
  158898. * Eye types
  158899. */
  158900. type XREye = "none" | "left" | "right";
  158901. /**
  158902. * Type of XR events available
  158903. */
  158904. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  158905. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  158906. type XRPlaneSet = Set<XRPlane>;
  158907. type XRAnchorSet = Set<XRAnchor>;
  158908. type XREventHandler = (callback: any) => void;
  158909. interface XRLayer extends EventTarget {}
  158910. interface XRSessionInit {
  158911. optionalFeatures?: string[];
  158912. requiredFeatures?: string[];
  158913. }
  158914. interface XRSessionEvent extends Event {
  158915. readonly session: XRSession;
  158916. }
  158917. interface XRSystem {
  158918. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  158919. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  158920. }
  158921. interface XRViewport {
  158922. readonly x: number;
  158923. readonly y: number;
  158924. readonly width: number;
  158925. readonly height: number;
  158926. }
  158927. interface XRWebGLLayerInit {
  158928. antialias?: boolean;
  158929. depth?: boolean;
  158930. stencil?: boolean;
  158931. alpha?: boolean;
  158932. multiview?: boolean;
  158933. framebufferScaleFactor?: number;
  158934. }
  158935. declare class XRWebGLLayer {
  158936. static getNativeFramebufferScaleFactor(session: XRSession): number;
  158937. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  158938. readonly antialias: boolean;
  158939. readonly framebuffer: WebGLFramebuffer;
  158940. readonly framebufferWidth: number;
  158941. readonly framebufferHeight: number;
  158942. readonly ignoreDepthValues: boolean;
  158943. getViewport: (view: XRView) => XRViewport;
  158944. }
  158945. // tslint:disable-next-line no-empty-interface
  158946. interface XRSpace extends EventTarget {}
  158947. interface XRRenderState {
  158948. readonly baseLayer?: XRWebGLLayer;
  158949. readonly depthFar: number;
  158950. readonly depthNear: number;
  158951. readonly inlineVerticalFieldOfView?: number;
  158952. }
  158953. interface XRRenderStateInit extends XRRenderState {
  158954. baseLayer: XRWebGLLayer;
  158955. depthFar: number;
  158956. depthNear: number;
  158957. inlineVerticalFieldOfView?: number;
  158958. layers?: XRLayer[];
  158959. }
  158960. interface XRReferenceSpace extends XRSpace {
  158961. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  158962. onreset: XREventHandler;
  158963. }
  158964. interface XRBoundedReferenceSpace extends XRSpace {
  158965. readonly boundsGeometry: DOMPointReadOnly[];
  158966. }
  158967. interface XRInputSource {
  158968. readonly handedness: XRHandedness;
  158969. readonly targetRayMode: XRTargetRayMode;
  158970. readonly targetRaySpace: XRSpace;
  158971. readonly gripSpace?: XRSpace;
  158972. readonly gamepad?: Gamepad;
  158973. readonly profiles: Array<string>;
  158974. readonly hand?: XRHand;
  158975. }
  158976. interface XRPose {
  158977. readonly transform: XRRigidTransform;
  158978. readonly emulatedPosition: boolean;
  158979. }
  158980. interface XRFrame {
  158981. readonly session: XRSession;
  158982. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  158983. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  158984. // AR
  158985. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  158986. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  158987. // Anchors
  158988. trackedAnchors?: XRAnchorSet;
  158989. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  158990. // Planes
  158991. worldInformation?: {
  158992. detectedPlanes?: XRPlaneSet;
  158993. };
  158994. // Hand tracking
  158995. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  158996. }
  158997. interface XRInputSourceEvent extends Event {
  158998. readonly frame: XRFrame;
  158999. readonly inputSource: XRInputSource;
  159000. }
  159001. type XRInputSourceArray = XRInputSource[];
  159002. interface XRSession {
  159003. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  159004. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  159005. /**
  159006. * Returns a list of this session's XRInputSources, each representing an input device
  159007. * used to control the camera and/or scene.
  159008. */
  159009. readonly inputSources: Array<XRInputSource>;
  159010. /**
  159011. * object which contains options affecting how the imagery is rendered.
  159012. * This includes things such as the near and far clipping planes
  159013. */
  159014. readonly renderState: XRRenderState;
  159015. readonly visibilityState: XRVisibilityState;
  159016. /**
  159017. * Removes a callback from the animation frame painting callback from
  159018. * XRSession's set of animation frame rendering callbacks, given the
  159019. * identifying handle returned by a previous call to requestAnimationFrame().
  159020. */
  159021. cancelAnimationFrame: (handle: number) => void;
  159022. /**
  159023. * Ends the WebXR session. Returns a promise which resolves when the
  159024. * session has been shut down.
  159025. */
  159026. end(): Promise<void>;
  159027. /**
  159028. * Schedules the specified method to be called the next time the user agent
  159029. * is working on rendering an animation frame for the WebXR device. Returns an
  159030. * integer value which can be used to identify the request for the purposes of
  159031. * canceling the callback using cancelAnimationFrame(). This method is comparable
  159032. * to the Window.requestAnimationFrame() method.
  159033. */
  159034. requestAnimationFrame: XRFrameRequestCallback;
  159035. /**
  159036. * Requests that a new XRReferenceSpace of the specified type be created.
  159037. * Returns a promise which resolves with the XRReferenceSpace or
  159038. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  159039. * the requested space type isn't supported by the device.
  159040. */
  159041. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  159042. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  159043. onend: XREventHandler;
  159044. oninputsourceschange: XREventHandler;
  159045. onselect: XREventHandler;
  159046. onselectstart: XREventHandler;
  159047. onselectend: XREventHandler;
  159048. onsqueeze: XREventHandler;
  159049. onsqueezestart: XREventHandler;
  159050. onsqueezeend: XREventHandler;
  159051. onvisibilitychange: XREventHandler;
  159052. // hit test
  159053. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  159054. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  159055. // legacy AR hit test
  159056. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  159057. // legacy plane detection
  159058. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  159059. }
  159060. interface XRViewerPose extends XRPose {
  159061. readonly views: Array<XRView>;
  159062. }
  159063. declare class XRRigidTransform {
  159064. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  159065. position: DOMPointReadOnly;
  159066. orientation: DOMPointReadOnly;
  159067. matrix: Float32Array;
  159068. inverse: XRRigidTransform;
  159069. }
  159070. interface XRView {
  159071. readonly eye: XREye;
  159072. readonly projectionMatrix: Float32Array;
  159073. readonly transform: XRRigidTransform;
  159074. readonly recommendedViewportScale?: number;
  159075. requestViewportScale(scale: number): void;
  159076. }
  159077. interface XRInputSourceChangeEvent extends Event {
  159078. session: XRSession;
  159079. removed: Array<XRInputSource>;
  159080. added: Array<XRInputSource>;
  159081. }
  159082. // Experimental/Draft features
  159083. declare class XRRay {
  159084. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  159085. origin: DOMPointReadOnly;
  159086. direction: DOMPointReadOnly;
  159087. matrix: Float32Array;
  159088. }
  159089. declare enum XRHitTestTrackableType {
  159090. "point",
  159091. "plane",
  159092. "mesh",
  159093. }
  159094. interface XRHitResult {
  159095. hitMatrix: Float32Array;
  159096. }
  159097. interface XRTransientInputHitTestResult {
  159098. readonly inputSource: XRInputSource;
  159099. readonly results: Array<XRHitTestResult>;
  159100. }
  159101. interface XRHitTestResult {
  159102. getPose(baseSpace: XRSpace): XRPose | undefined;
  159103. // When anchor system is enabled
  159104. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  159105. }
  159106. interface XRHitTestSource {
  159107. cancel(): void;
  159108. }
  159109. interface XRTransientInputHitTestSource {
  159110. cancel(): void;
  159111. }
  159112. interface XRHitTestOptionsInit {
  159113. space: XRSpace;
  159114. entityTypes?: Array<XRHitTestTrackableType>;
  159115. offsetRay?: XRRay;
  159116. }
  159117. interface XRTransientInputHitTestOptionsInit {
  159118. profile: string;
  159119. entityTypes?: Array<XRHitTestTrackableType>;
  159120. offsetRay?: XRRay;
  159121. }
  159122. interface XRAnchor {
  159123. anchorSpace: XRSpace;
  159124. delete(): void;
  159125. }
  159126. interface XRPlane {
  159127. orientation: "Horizontal" | "Vertical";
  159128. planeSpace: XRSpace;
  159129. polygon: Array<DOMPointReadOnly>;
  159130. lastChangedTime: number;
  159131. }
  159132. interface XRJointSpace extends XRSpace {}
  159133. interface XRJointPose extends XRPose {
  159134. radius: number | undefined;
  159135. }
  159136. interface XRHand extends Iterable<XRJointSpace> {
  159137. readonly length: number;
  159138. [index: number]: XRJointSpace;
  159139. readonly WRIST: number;
  159140. readonly THUMB_METACARPAL: number;
  159141. readonly THUMB_PHALANX_PROXIMAL: number;
  159142. readonly THUMB_PHALANX_DISTAL: number;
  159143. readonly THUMB_PHALANX_TIP: number;
  159144. readonly INDEX_METACARPAL: number;
  159145. readonly INDEX_PHALANX_PROXIMAL: number;
  159146. readonly INDEX_PHALANX_INTERMEDIATE: number;
  159147. readonly INDEX_PHALANX_DISTAL: number;
  159148. readonly INDEX_PHALANX_TIP: number;
  159149. readonly MIDDLE_METACARPAL: number;
  159150. readonly MIDDLE_PHALANX_PROXIMAL: number;
  159151. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  159152. readonly MIDDLE_PHALANX_DISTAL: number;
  159153. readonly MIDDLE_PHALANX_TIP: number;
  159154. readonly RING_METACARPAL: number;
  159155. readonly RING_PHALANX_PROXIMAL: number;
  159156. readonly RING_PHALANX_INTERMEDIATE: number;
  159157. readonly RING_PHALANX_DISTAL: number;
  159158. readonly RING_PHALANX_TIP: number;
  159159. readonly LITTLE_METACARPAL: number;
  159160. readonly LITTLE_PHALANX_PROXIMAL: number;
  159161. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  159162. readonly LITTLE_PHALANX_DISTAL: number;
  159163. readonly LITTLE_PHALANX_TIP: number;
  159164. }
  159165. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  159166. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  159167. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  159168. interface XRSession {
  159169. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  159170. }
  159171. interface XRFrame {
  159172. featurePointCloud? : Array<number>;
  159173. }